mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Merge branch '4.18'
This commit is contained in:
commit
5559668f12
@ -148,7 +148,7 @@ import com.vmware.vim25.VirtualDeviceBackingInfo;
|
|||||||
import com.vmware.vim25.VirtualDeviceConnectInfo;
|
import com.vmware.vim25.VirtualDeviceConnectInfo;
|
||||||
import com.vmware.vim25.VirtualDisk;
|
import com.vmware.vim25.VirtualDisk;
|
||||||
import com.vmware.vim25.VirtualDiskFlatVer2BackingInfo;
|
import com.vmware.vim25.VirtualDiskFlatVer2BackingInfo;
|
||||||
import com.vmware.vim25.VirtualE1000;
|
import com.vmware.vim25.VirtualEthernetCard;
|
||||||
import com.vmware.vim25.VirtualEthernetCardNetworkBackingInfo;
|
import com.vmware.vim25.VirtualEthernetCardNetworkBackingInfo;
|
||||||
import com.vmware.vim25.VirtualMachineConfigSummary;
|
import com.vmware.vim25.VirtualMachineConfigSummary;
|
||||||
import com.vmware.vim25.VirtualMachineRuntimeInfo;
|
import com.vmware.vim25.VirtualMachineRuntimeInfo;
|
||||||
@ -905,7 +905,7 @@ public class VMwareGuru extends HypervisorGuruBase implements HypervisorGuru, Co
|
|||||||
/**
|
/**
|
||||||
* Get network MO from VM NIC
|
* Get network MO from VM NIC
|
||||||
*/
|
*/
|
||||||
private NetworkMO getNetworkMO(VirtualE1000 nic, VmwareContext context) {
|
private NetworkMO getNetworkMO(VirtualEthernetCard nic, VmwareContext context) {
|
||||||
VirtualDeviceConnectInfo connectable = nic.getConnectable();
|
VirtualDeviceConnectInfo connectable = nic.getConnectable();
|
||||||
VirtualEthernetCardNetworkBackingInfo info = (VirtualEthernetCardNetworkBackingInfo)nic.getBacking();
|
VirtualEthernetCardNetworkBackingInfo info = (VirtualEthernetCardNetworkBackingInfo)nic.getBacking();
|
||||||
ManagedObjectReference networkMor = info.getNetwork();
|
ManagedObjectReference networkMor = info.getNetwork();
|
||||||
@ -916,7 +916,7 @@ public class VMwareGuru extends HypervisorGuruBase implements HypervisorGuru, Co
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Pair<String, String> getNicMacAddressAndNetworkName(VirtualDevice nicDevice, VmwareContext context) throws Exception {
|
private Pair<String, String> getNicMacAddressAndNetworkName(VirtualDevice nicDevice, VmwareContext context) throws Exception {
|
||||||
VirtualE1000 nic = (VirtualE1000)nicDevice;
|
VirtualEthernetCard nic = (VirtualEthernetCard)nicDevice;
|
||||||
String macAddress = nic.getMacAddress();
|
String macAddress = nic.getMacAddress();
|
||||||
NetworkMO networkMO = getNetworkMO(nic, context);
|
NetworkMO networkMO = getNetworkMO(nic, context);
|
||||||
String networkName = networkMO.getName();
|
String networkName = networkMO.getName();
|
||||||
|
|||||||
@ -1485,6 +1485,8 @@ public class KubernetesClusterManagerImpl extends ManagerBase implements Kuberne
|
|||||||
if (kubernetesCluster == null) {
|
if (kubernetesCluster == null) {
|
||||||
throw new InvalidParameterValueException("Invalid Kubernetes cluster ID specified");
|
throw new InvalidParameterValueException("Invalid Kubernetes cluster ID specified");
|
||||||
}
|
}
|
||||||
|
Account caller = CallContext.current().getCallingAccount();
|
||||||
|
accountManager.checkAccess(caller, SecurityChecker.AccessType.OperateEntry, false, kubernetesCluster);
|
||||||
KubernetesClusterConfigResponse response = new KubernetesClusterConfigResponse();
|
KubernetesClusterConfigResponse response = new KubernetesClusterConfigResponse();
|
||||||
response.setId(kubernetesCluster.getUuid());
|
response.setId(kubernetesCluster.getUuid());
|
||||||
response.setName(kubernetesCluster.getName());
|
response.setName(kubernetesCluster.getName());
|
||||||
|
|||||||
@ -991,7 +991,8 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage
|
|||||||
Account owner = _accountMgr.getAccount(addr.getAllocatedToAccountId());
|
Account owner = _accountMgr.getAccount(addr.getAllocatedToAccountId());
|
||||||
if (_ipAddressDao.lockRow(addr.getId(), true) != null) {
|
if (_ipAddressDao.lockRow(addr.getId(), true) != null) {
|
||||||
final IPAddressVO userIp = _ipAddressDao.findById(addr.getId());
|
final IPAddressVO userIp = _ipAddressDao.findById(addr.getId());
|
||||||
if (userIp.getState() == IpAddress.State.Allocating || addr.getState() == IpAddress.State.Free) {
|
if (userIp.getState() == IpAddress.State.Allocating || addr.getState() == IpAddress.State.Free || addr.getState() == IpAddress.State.Reserved) {
|
||||||
|
boolean shouldUpdateIpResourceCount = checkIfIpResourceCountShouldBeUpdated(addr);
|
||||||
addr.setState(IpAddress.State.Allocated);
|
addr.setState(IpAddress.State.Allocated);
|
||||||
if (_ipAddressDao.update(addr.getId(), addr)) {
|
if (_ipAddressDao.update(addr.getId(), addr)) {
|
||||||
// Save usage event
|
// Save usage event
|
||||||
@ -1004,7 +1005,7 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage
|
|||||||
addr.getAddress().toString(), addr.isSourceNat(), guestType, addr.getSystem(), usageHidden,
|
addr.getAddress().toString(), addr.isSourceNat(), guestType, addr.getSystem(), usageHidden,
|
||||||
addr.getClass().getName(), addr.getUuid());
|
addr.getClass().getName(), addr.getUuid());
|
||||||
}
|
}
|
||||||
if (updateIpResourceCount(addr)) {
|
if (shouldUpdateIpResourceCount) {
|
||||||
_resourceLimitMgr.incrementResourceCount(owner.getId(), ResourceType.public_ip);
|
_resourceLimitMgr.incrementResourceCount(owner.getId(), ResourceType.public_ip);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1020,7 +1021,7 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isIpDedicated(IPAddressVO addr) {
|
protected boolean isIpDedicated(IPAddressVO addr) {
|
||||||
List<AccountVlanMapVO> maps = _accountVlanMapDao.listAccountVlanMapsByVlan(addr.getVlanId());
|
List<AccountVlanMapVO> maps = _accountVlanMapDao.listAccountVlanMapsByVlan(addr.getVlanId());
|
||||||
if (maps != null && !maps.isEmpty())
|
if (maps != null && !maps.isEmpty())
|
||||||
return true;
|
return true;
|
||||||
@ -1113,7 +1114,7 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage
|
|||||||
// rule is applied. Similarly when last rule on the acquired IP is revoked, IP is not associated with any provider
|
// rule is applied. Similarly when last rule on the acquired IP is revoked, IP is not associated with any provider
|
||||||
// but still be associated with the account. At this point just mark IP as allocated or released.
|
// but still be associated with the account. At this point just mark IP as allocated or released.
|
||||||
for (IPAddressVO addr : userIps) {
|
for (IPAddressVO addr : userIps) {
|
||||||
if (addr.getState() == IpAddress.State.Allocating) {
|
if (addr.getState() == IpAddress.State.Allocating || addr.getState() == IpAddress.State.Reserved) {
|
||||||
addr.setAssociatedWithNetworkId(network.getId());
|
addr.setAssociatedWithNetworkId(network.getId());
|
||||||
markPublicIpAsAllocated(addr);
|
markPublicIpAsAllocated(addr);
|
||||||
} else if (addr.getState() == IpAddress.State.Releasing) {
|
} else if (addr.getState() == IpAddress.State.Releasing) {
|
||||||
@ -1502,7 +1503,6 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage
|
|||||||
|
|
||||||
IPAddressVO ip = _ipAddressDao.findById(ipId);
|
IPAddressVO ip = _ipAddressDao.findById(ipId);
|
||||||
//update ip address with networkId
|
//update ip address with networkId
|
||||||
ip.setState(State.Allocated);
|
|
||||||
ip.setAssociatedWithNetworkId(networkId);
|
ip.setAssociatedWithNetworkId(networkId);
|
||||||
ip.setSourceNat(isSourceNat);
|
ip.setSourceNat(isSourceNat);
|
||||||
_ipAddressDao.update(ipId, ip);
|
_ipAddressDao.update(ipId, ip);
|
||||||
@ -1515,7 +1515,7 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage
|
|||||||
} else {
|
} else {
|
||||||
s_logger.warn("Failed to associate ip address " + ip.getAddress().addr() + " to network " + network);
|
s_logger.warn("Failed to associate ip address " + ip.getAddress().addr() + " to network " + network);
|
||||||
}
|
}
|
||||||
return ip;
|
return _ipAddressDao.findById(ipId);
|
||||||
} finally {
|
} finally {
|
||||||
if (!success && releaseOnFailure) {
|
if (!success && releaseOnFailure) {
|
||||||
if (ip != null) {
|
if (ip != null) {
|
||||||
@ -1918,7 +1918,7 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage
|
|||||||
return Transaction.execute(new TransactionCallback<IPAddressVO>() {
|
return Transaction.execute(new TransactionCallback<IPAddressVO>() {
|
||||||
@Override
|
@Override
|
||||||
public IPAddressVO doInTransaction(TransactionStatus status) {
|
public IPAddressVO doInTransaction(TransactionStatus status) {
|
||||||
if (updateIpResourceCount(ip)) {
|
if (checkIfIpResourceCountShouldBeUpdated(ip)) {
|
||||||
_resourceLimitMgr.decrementResourceCount(_ipAddressDao.findById(addrId).getAllocatedToAccountId(), ResourceType.public_ip);
|
_resourceLimitMgr.decrementResourceCount(_ipAddressDao.findById(addrId).getAllocatedToAccountId(), ResourceType.public_ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1943,9 +1943,26 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage
|
|||||||
return ip;
|
return ip;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean updateIpResourceCount(IPAddressVO ip) {
|
protected boolean checkIfIpResourceCountShouldBeUpdated(IPAddressVO ip) {
|
||||||
// don't increment resource count for direct and dedicated ip addresses
|
boolean isDirectIp = ip.getAssociatedWithNetworkId() == null && ip.getVpcId() == null;
|
||||||
return (ip.getAssociatedWithNetworkId() != null || ip.getVpcId() != null) && !isIpDedicated(ip);
|
if (isDirectIp) {
|
||||||
|
s_logger.debug(String.format("IP address [%s] is direct; therefore, the resource count should not be updated.", ip));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isIpDedicated(ip)) {
|
||||||
|
s_logger.debug(String.format("IP address [%s] is dedicated; therefore, the resource count should not be updated.", ip));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean isReservedIp = ip.getState() == IpAddress.State.Reserved;
|
||||||
|
if (isReservedIp) {
|
||||||
|
s_logger.debug(String.format("IP address [%s] is reserved; therefore, the resource count should not be updated.", ip));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
s_logger.debug(String.format("IP address [%s] is not direct, dedicated or reserved; therefore, the resource count should be updated.", ip));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -67,6 +67,9 @@ public class IpAddressManagerTest {
|
|||||||
@Mock
|
@Mock
|
||||||
NetworkOfferingDao networkOfferingDao;
|
NetworkOfferingDao networkOfferingDao;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
IPAddressVO ipAddressVoMock;
|
||||||
|
|
||||||
@Spy
|
@Spy
|
||||||
@InjectMocks
|
@InjectMocks
|
||||||
IpAddressManagerImpl ipAddressManager;
|
IpAddressManagerImpl ipAddressManager;
|
||||||
@ -242,4 +245,61 @@ public class IpAddressManagerTest {
|
|||||||
verify(requestedIp).setSourceNat(true);
|
verify(requestedIp).setSourceNat(true);
|
||||||
verify(oldIp).setSourceNat(false);
|
verify(oldIp).setSourceNat(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void prepareForCheckIfIpResourceCountShouldBeUpdatedTests() {
|
||||||
|
Mockito.when(ipAddressVoMock.getAssociatedWithNetworkId()).thenReturn(1L);
|
||||||
|
Mockito.when(ipAddressVoMock.getVpcId()).thenReturn(1L);
|
||||||
|
doReturn(false).when(ipAddressManager).isIpDedicated(Mockito.any());
|
||||||
|
Mockito.when(ipAddressVoMock.getState()).thenReturn(IpAddress.State.Allocating);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void checkIfIpResourceCountShouldBeUpdatedTestIpIsDirectReturnFalse() {
|
||||||
|
prepareForCheckIfIpResourceCountShouldBeUpdatedTests();
|
||||||
|
Mockito.when(ipAddressVoMock.getAssociatedWithNetworkId()).thenReturn(null);
|
||||||
|
Mockito.when(ipAddressVoMock.getVpcId()).thenReturn(null);
|
||||||
|
|
||||||
|
boolean result = ipAddressManager.checkIfIpResourceCountShouldBeUpdated(ipAddressVoMock);
|
||||||
|
|
||||||
|
Assert.assertFalse(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void checkIfIpResourceCountShouldBeUpdatedTestIpIsDedicatedReturnFalse() {
|
||||||
|
prepareForCheckIfIpResourceCountShouldBeUpdatedTests();
|
||||||
|
doReturn(true).when(ipAddressManager).isIpDedicated(Mockito.any());
|
||||||
|
|
||||||
|
boolean result = ipAddressManager.checkIfIpResourceCountShouldBeUpdated(ipAddressVoMock);
|
||||||
|
|
||||||
|
Assert.assertFalse(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void checkIfIpResourceCountShouldBeUpdatedTestIpIsReservedReturnFalse() {
|
||||||
|
prepareForCheckIfIpResourceCountShouldBeUpdatedTests();
|
||||||
|
Mockito.when(ipAddressVoMock.getState()).thenReturn(IpAddress.State.Reserved);
|
||||||
|
|
||||||
|
boolean result = ipAddressManager.checkIfIpResourceCountShouldBeUpdated(ipAddressVoMock);
|
||||||
|
|
||||||
|
Assert.assertFalse(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void checkIfIpResourceCountShouldBeUpdatedTestIpIsAssociatedToNetworkAndNotDedicatedAndNotReservedReturnTrue() {
|
||||||
|
prepareForCheckIfIpResourceCountShouldBeUpdatedTests();
|
||||||
|
|
||||||
|
boolean result = ipAddressManager.checkIfIpResourceCountShouldBeUpdated(ipAddressVoMock);
|
||||||
|
|
||||||
|
Assert.assertTrue(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void checkIfIpResourceCountShouldBeUpdatedTestIpIsAssociatedToVpcAndNotDedicatedAndNotReservedReturnTrue() {
|
||||||
|
prepareForCheckIfIpResourceCountShouldBeUpdatedTests();
|
||||||
|
Mockito.when(ipAddressVoMock.getAssociatedWithNetworkId()).thenReturn(null);
|
||||||
|
|
||||||
|
boolean result = ipAddressManager.checkIfIpResourceCountShouldBeUpdated(ipAddressVoMock);
|
||||||
|
|
||||||
|
Assert.assertTrue(result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -114,6 +114,11 @@ public class ConsoleProxyNoVncClient implements ConsoleProxyClient {
|
|||||||
updateFrontEndActivityTime();
|
updateFrontEndActivityTime();
|
||||||
}
|
}
|
||||||
connectionAlive = client.isVncOverWebSocketConnectionAlive();
|
connectionAlive = client.isVncOverWebSocketConnectionAlive();
|
||||||
|
try {
|
||||||
|
Thread.sleep(1);
|
||||||
|
} catch (Exception e) {
|
||||||
|
s_logger.warn("Error on sleep for vnc over websocket", e);
|
||||||
|
}
|
||||||
} else if (client.isVncOverNioSocket()) {
|
} else if (client.isVncOverNioSocket()) {
|
||||||
byte[] bytesArr;
|
byte[] bytesArr;
|
||||||
int nextBytes = client.getNextBytes();
|
int nextBytes = client.getNextBytes();
|
||||||
|
|||||||
@ -1556,7 +1556,7 @@ class TestKVMLiveMigration(cloudstackTestCase):
|
|||||||
self.skipTest("Requires at least two hosts for performing migration related tests")
|
self.skipTest("Requires at least two hosts for performing migration related tests")
|
||||||
|
|
||||||
for host in self.hosts:
|
for host in self.hosts:
|
||||||
if host.details['Host.OS'] in ['CentOS']:
|
if host.details['Host.OS'] and host.details['Host.OS'].startswith('CentOS'):
|
||||||
self.skipTest("live migration is not stabily supported on CentOS")
|
self.skipTest("live migration is not stabily supported on CentOS")
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user