mirror of https://github.com/apache/cloudstack.git
Merge branch '4.16' into main
This commit is contained in:
commit
0c0254d8f5
|
|
@ -561,9 +561,12 @@ public class TemplateJoinDaoImpl extends GenericDaoBaseWithTagInformation<Templa
|
|||
if (ids == null || ids.length == 0) {
|
||||
return new ArrayList<TemplateJoinVO>();
|
||||
}
|
||||
|
||||
Filter searchFilter = new Filter(TemplateJoinVO.class, "sortKey", QueryService.SortKeyAscending.value(), null, null);
|
||||
searchFilter.addOrderBy(TemplateJoinVO.class, "tempZonePair", true);
|
||||
|
||||
SearchCriteria<TemplateJoinVO> sc = tmpltIdsSearch.create();
|
||||
sc.setParameters("idsIN", ids);
|
||||
return searchIncludingRemoved(sc, null, null, false);
|
||||
return searchIncludingRemoved(sc, searchFilter, null, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4921,7 +4921,10 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
public boolean releasePublicIpRange(final long vlanDbId, final long userId, final Account caller) {
|
||||
VlanVO vlan = _vlanDao.findById(vlanDbId);
|
||||
if(vlan == null) {
|
||||
s_logger.warn("VLAN information for Account '" + caller + "', User '" + userId + "' VLAN '" + vlanDbId + "' is null. This is NPE situation.");
|
||||
// Nothing to do if vlan can't be found
|
||||
s_logger.warn(String.format("Skipping the process for releasing public IP range as could not find a VLAN with ID '%s' for Account '%s' and User '%s'."
|
||||
,vlanDbId, caller, userId));
|
||||
return true;
|
||||
}
|
||||
|
||||
// Verify range is dedicated
|
||||
|
|
@ -4988,13 +4991,15 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
}
|
||||
// decrement resource count for dedicated public ip's
|
||||
_resourceLimitMgr.decrementResourceCount(acctVln.get(0).getAccountId(), ResourceType.public_ip, new Long(ips.size()));
|
||||
return true;
|
||||
success = true;
|
||||
} else if (isDomainSpecific && _domainVlanMapDao.remove(domainVlan.get(0).getId())) {
|
||||
s_logger.debug("Remove the vlan from domain_vlan_map successfully.");
|
||||
return true;
|
||||
success = true;
|
||||
} else {
|
||||
return false;
|
||||
success = false;
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
@DB
|
||||
|
|
|
|||
|
|
@ -73,6 +73,7 @@ import com.cloud.vm.VirtualMachineManager;
|
|||
import com.cloud.vm.VirtualMachineProfile;
|
||||
|
||||
import org.apache.cloudstack.network.topology.NetworkTopology;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.cloud.network.router.deployment.RouterDeploymentDefinition;
|
||||
import org.cloud.network.router.deployment.RouterDeploymentDefinitionBuilder;
|
||||
|
|
@ -348,7 +349,7 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements Vpc
|
|||
|
||||
//1st time it runs the domain router of the VM shall be returned
|
||||
List<DomainRouterVO> routers = super.getRouters(network, dest);
|
||||
if (routers.size() > 0) {
|
||||
if (CollectionUtils.isNotEmpty(routers)) {
|
||||
return routers;
|
||||
}
|
||||
|
||||
|
|
@ -712,4 +713,4 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements Vpc
|
|||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -342,6 +342,7 @@ import com.cloud.utils.db.UUIDManager;
|
|||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.utils.exception.ExecutionException;
|
||||
import com.cloud.utils.fsm.NoTransitionException;
|
||||
import com.cloud.utils.net.Ip;
|
||||
import com.cloud.utils.net.NetUtils;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
import com.cloud.vm.dao.DomainRouterDao;
|
||||
|
|
@ -1750,38 +1751,12 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
|||
throw new InvalidParameterValueException("Allocating ip to guest nic " + nicVO.getUuid() + " failed, please choose another ip");
|
||||
}
|
||||
|
||||
if (_networkModel.areServicesSupportedInNetwork(network.getId(), Service.StaticNat)) {
|
||||
IPAddressVO oldIP = _ipAddressDao.findByAssociatedVmId(vm.getId());
|
||||
if (oldIP != null) {
|
||||
oldIP.setVmIp(ipaddr);
|
||||
_ipAddressDao.persist(oldIP);
|
||||
}
|
||||
if (nicVO.getIPv4Address() != null) {
|
||||
updatePublicIpDnatVmIp(vm.getId(), network.getId(), nicVO.getIPv4Address(), ipaddr);
|
||||
updateLoadBalancerRulesVmIp(vm.getId(), network.getId(), nicVO.getIPv4Address(), ipaddr);
|
||||
updatePortForwardingRulesVmIp(vm.getId(), network.getId(), nicVO.getIPv4Address(), ipaddr);
|
||||
}
|
||||
// implementing the network elements and resources as a part of vm nic ip update if network has services and it is in Implemented state
|
||||
if (!_networkModel.listNetworkOfferingServices(offering.getId()).isEmpty() && network.getState() == Network.State.Implemented) {
|
||||
User callerUser = _accountMgr.getActiveUser(CallContext.current().getCallingUserId());
|
||||
ReservationContext context = new ReservationContextImpl(null, null, callerUser, caller);
|
||||
DeployDestination dest = new DeployDestination(_dcDao.findById(network.getDataCenterId()), null, null, null);
|
||||
|
||||
s_logger.debug("Implementing the network " + network + " elements and resources as a part of vm nic ip update");
|
||||
try {
|
||||
// implement the network elements and rules again
|
||||
_networkMgr.implementNetworkElementsAndResources(dest, context, network, offering);
|
||||
} catch (Exception ex) {
|
||||
s_logger.warn("Failed to implement network " + network + " elements and resources as a part of vm nic ip update due to ", ex);
|
||||
CloudRuntimeException e = new CloudRuntimeException("Failed to implement network (with specified id) elements and resources as a part of vm nic ip update");
|
||||
e.addProxyObject(network.getUuid(), "networkId");
|
||||
// restore to old ip address
|
||||
if (_networkModel.areServicesSupportedInNetwork(network.getId(), Service.StaticNat)) {
|
||||
IPAddressVO oldIP = _ipAddressDao.findByAssociatedVmId(vm.getId());
|
||||
if (oldIP != null) {
|
||||
oldIP.setVmIp(nicVO.getIPv4Address());
|
||||
_ipAddressDao.persist(oldIP);
|
||||
}
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
} else if (dc.getNetworkType() == NetworkType.Basic || network.getGuestType() == Network.GuestType.Shared) {
|
||||
//handle the basic networks here
|
||||
//for basic zone, need to provide the podId to ensure proper ip alloation
|
||||
|
|
@ -1829,6 +1804,48 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
|||
return vm;
|
||||
}
|
||||
|
||||
private void updatePublicIpDnatVmIp(long vmId, long networkId, String oldIp, String newIp) {
|
||||
if (!_networkModel.areServicesSupportedInNetwork(networkId, Service.StaticNat)) {
|
||||
return;
|
||||
}
|
||||
List<IPAddressVO> publicIps = _ipAddressDao.listByAssociatedVmId(vmId);
|
||||
for (IPAddressVO publicIp : publicIps) {
|
||||
if (oldIp.equals(publicIp.getVmIp()) && publicIp.getAssociatedWithNetworkId() == networkId) {
|
||||
publicIp.setVmIp(newIp);
|
||||
_ipAddressDao.persist(publicIp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateLoadBalancerRulesVmIp(long vmId, long networkId, String oldIp, String newIp) {
|
||||
if (!_networkModel.areServicesSupportedInNetwork(networkId, Service.Lb)) {
|
||||
return;
|
||||
}
|
||||
List<LoadBalancerVMMapVO> loadBalancerVMMaps = _loadBalancerVMMapDao.listByInstanceId(vmId);
|
||||
for (LoadBalancerVMMapVO map : loadBalancerVMMaps) {
|
||||
long lbId = map.getLoadBalancerId();
|
||||
FirewallRuleVO rule = _rulesDao.findById(lbId);
|
||||
if (oldIp.equals(map.getInstanceIp()) && networkId == rule.getNetworkId()) {
|
||||
map.setInstanceIp(newIp);
|
||||
_loadBalancerVMMapDao.persist(map);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updatePortForwardingRulesVmIp(long vmId, long networkId, String oldIp, String newIp) {
|
||||
if (!_networkModel.areServicesSupportedInNetwork(networkId, Service.PortForwarding)) {
|
||||
return;
|
||||
}
|
||||
List<PortForwardingRuleVO> firewallRules = _portForwardingDao.listByVm(vmId);
|
||||
for (PortForwardingRuleVO firewallRule : firewallRules) {
|
||||
FirewallRuleVO rule = _rulesDao.findById(firewallRule.getId());
|
||||
if (oldIp.equals(firewallRule.getDestinationIpAddress().toString()) && networkId == rule.getNetworkId()) {
|
||||
firewallRule.setDestinationIpAddress(new Ip(newIp));
|
||||
_portForwardingDao.persist(firewallRule);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ActionEvent(eventType = EventTypes.EVENT_VM_UPGRADE, eventDescription = "Upgrading VM", async = true)
|
||||
public UserVm upgradeVirtualMachine(ScaleVMCmd cmd) throws ResourceUnavailableException, ConcurrentOperationException, ManagementServerException,
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ import static org.mockito.Matchers.anyInt;
|
|||
import static org.mockito.Matchers.anyLong;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Mockito.doNothing;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.doThrow;
|
||||
import static org.mockito.Mockito.lenient;
|
||||
|
|
@ -78,7 +77,6 @@ import com.cloud.dc.DataCenterVO;
|
|||
import com.cloud.dc.VlanVO;
|
||||
import com.cloud.dc.dao.DataCenterDao;
|
||||
import com.cloud.dc.dao.VlanDao;
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
import com.cloud.event.dao.UsageEventDao;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.PermissionDeniedException;
|
||||
|
|
@ -575,8 +573,6 @@ public class UserVmManagerTest {
|
|||
when(_dcMock.getNetworkType()).thenReturn(NetworkType.Advanced);
|
||||
|
||||
when(_ipAddrMgr.allocateGuestIP(Mockito.eq(_networkMock), anyString())).thenReturn("10.10.10.10");
|
||||
doNothing().when(_networkMgr).implementNetworkElementsAndResources(Mockito.any(DeployDestination.class), Mockito.any(ReservationContext.class), Mockito.eq(_networkMock),
|
||||
Mockito.eq(_networkOfferingMock));
|
||||
when(_nicDao.persist(any(NicVO.class))).thenReturn(nic);
|
||||
|
||||
Account caller = new AccountVO("testaccount", 1, "networkdomain", (short)0, UUID.randomUUID().toString());
|
||||
|
|
|
|||
|
|
@ -194,6 +194,9 @@ export default {
|
|||
if (['Admin', 'DomainAdmin'].includes(store.getters.userInfo.roletype)) {
|
||||
fields.push('account')
|
||||
}
|
||||
if (['Admin'].includes(store.getters.userInfo.roletype)) {
|
||||
fields.push('order')
|
||||
}
|
||||
return fields
|
||||
},
|
||||
details: ['name', 'id', 'displaytext', 'checksum', 'ostypename', 'size', 'bootable', 'isready', 'directdownload', 'isextractable', 'ispublic', 'isfeatured', 'crosszones', 'account', 'domain', 'created'],
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
import Cookies from 'js-cookie'
|
||||
import Vue from 'vue'
|
||||
import md5 from 'md5'
|
||||
import message from 'ant-design-vue/es/message'
|
||||
import notification from 'ant-design-vue/es/notification'
|
||||
import router from '@/router'
|
||||
|
|
@ -198,11 +197,6 @@ const user = {
|
|||
const result = response.listusersresponse.user[0]
|
||||
commit('SET_INFO', result)
|
||||
commit('SET_NAME', result.firstname + ' ' + result.lastname)
|
||||
if ('email' in result) {
|
||||
commit('SET_AVATAR', 'https://www.gravatar.com/avatar/' + md5(result.email))
|
||||
} else {
|
||||
commit('SET_AVATAR', 'https://www.gravatar.com/avatar/' + md5('dev@cloudstack.apache.org'))
|
||||
}
|
||||
resolve(cachedApis)
|
||||
}).catch(error => {
|
||||
reject(error)
|
||||
|
|
@ -242,11 +236,6 @@ const user = {
|
|||
const result = response.listusersresponse.user[0]
|
||||
commit('SET_INFO', result)
|
||||
commit('SET_NAME', result.firstname + ' ' + result.lastname)
|
||||
if ('email' in result) {
|
||||
commit('SET_AVATAR', 'https://www.gravatar.com/avatar/' + md5(result.email))
|
||||
} else {
|
||||
commit('SET_AVATAR', 'https://www.gravatar.com/avatar/' + md5('dev@cloudstack.apache.org'))
|
||||
}
|
||||
}).catch(error => {
|
||||
reject(error)
|
||||
})
|
||||
|
|
|
|||
|
|
@ -391,6 +391,7 @@
|
|||
</template>
|
||||
</a-step>
|
||||
<a-step
|
||||
v-if="isUserAllowedToListSshKeys"
|
||||
:title="this.$t('label.sshkeypairs')"
|
||||
:status="zoneSelected ? 'process' : 'wait'">
|
||||
<template slot="description">
|
||||
|
|
@ -1059,6 +1060,9 @@ export default {
|
|||
showSecurityGroupSection () {
|
||||
return (this.networks.length > 0 && this.zone.securitygroupsenabled) || (this.zone && this.zone.networktype === 'Basic')
|
||||
},
|
||||
isUserAllowedToListSshKeys () {
|
||||
return Boolean('listSSHKeyPairs' in this.$store.getters.apis)
|
||||
},
|
||||
dynamicScalingVmConfigValue () {
|
||||
return this.options.dynamicScalingVmConfig?.[0]?.value === 'true'
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue