mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-04 00:02:37 +01:00
Merge remote-tracking branch 'origin/4.12'
This commit is contained in:
commit
5ee7a9c530
@ -96,6 +96,7 @@ class TestDeployVirtioSCSIVM(cloudstackTestCase):
|
||||
cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
|
||||
cls.pod = get_pod(cls.apiclient, cls.zone.id)
|
||||
cls.services['mode'] = cls.zone.networktype
|
||||
cls.cleanup = []
|
||||
if cls.hypervisor.lower() not in ['kvm']:
|
||||
cls.hypervisorNotSupported = True
|
||||
return
|
||||
|
||||
@ -274,9 +274,12 @@ class TestHAKVM(cloudstackTestCase):
|
||||
Tests Enable HA when host is in Maintenance mode, should be Ineligible
|
||||
"""
|
||||
self.logger.debug("Starting test_hostha_enable_ha_when_host_in_maintenance")
|
||||
|
||||
self.logger.debug("Pausing to wait for VMs to have finished starting")
|
||||
time.sleep(300)
|
||||
|
||||
# Enable HA
|
||||
self.configureAndEnableHostHa()
|
||||
|
||||
|
||||
# Prepare for maintenance Host
|
||||
self.setHostToMaintanance(self.host.id)
|
||||
|
||||
@ -940,6 +940,23 @@ class TestSecuredVmMigration(cloudstackTestCase):
|
||||
vm_response = VirtualMachine.list(self.apiclient, id=vm.id)[0]
|
||||
self.assertEqual(vm_response.hostid, dest_host.id, "Check destination host ID of migrated VM")
|
||||
|
||||
def waitUntilHostInState(self, hostId, state="Up", interval=5, retries=20):
|
||||
while retries > -1:
|
||||
print("Waiting for host: %s to be %s. %s retries left." % (hostId, state, retries))
|
||||
time.sleep(interval)
|
||||
host = Host.list(
|
||||
self.apiclient,
|
||||
hostid=hostId,
|
||||
type='Routing'
|
||||
)[0]
|
||||
if host.state != state:
|
||||
if retries >= 0:
|
||||
retries = retries - 1
|
||||
continue
|
||||
else:
|
||||
print("Host %s now showing as %s" % (hostId, state))
|
||||
return
|
||||
|
||||
def unsecure_host(self, host):
|
||||
SshClient(host.ipaddress, port=22, user=self.hostConfig["username"], passwd=self.hostConfig["password"]) \
|
||||
.execute("rm -f /etc/cloudstack/agent/cloud* && \
|
||||
@ -947,9 +964,10 @@ class TestSecuredVmMigration(cloudstackTestCase):
|
||||
sed -i 's/listen_tcp.*/listen_tcp=1/g' /etc/libvirt/libvirtd.conf && \
|
||||
sed -i '/.*_file=.*/d' /etc/libvirt/libvirtd.conf && \
|
||||
service libvirtd restart && \
|
||||
sleep 30 && \
|
||||
service cloudstack-agent restart")
|
||||
|
||||
time.sleep(10)
|
||||
print("Unsecuring Host: %s" % (host.name))
|
||||
self.waitUntilHostInState(hostId=host.id, state="Up")
|
||||
self.check_connection(host=host, secured='false')
|
||||
return host
|
||||
|
||||
@ -961,6 +979,8 @@ class TestSecuredVmMigration(cloudstackTestCase):
|
||||
self.apiclient.provisionCertificate(cmd)
|
||||
|
||||
for host in self.hosts:
|
||||
print("Securing Host %s" % host.name)
|
||||
self.waitUntilHostInState(hostId=host.id, state="Up")
|
||||
self.check_connection(secured='true', host=host)
|
||||
|
||||
def deploy_vm(self, origin_host):
|
||||
@ -1011,6 +1031,7 @@ class TestSecuredVmMigration(cloudstackTestCase):
|
||||
vm = self.deploy_vm(src_host)
|
||||
self.cleanup.append(vm)
|
||||
|
||||
self.debug("Securing Host(s)")
|
||||
dest_host = self.get_target_host(secured='true', virtualmachineid=vm.id)
|
||||
self.migrate_and_check(vm, src_host, dest_host)
|
||||
|
||||
|
||||
@ -623,22 +623,34 @@ class VirtualMachine:
|
||||
return VirtualMachine(virtual_machine.__dict__, services)
|
||||
|
||||
# program ssh access over NAT via PF
|
||||
if mode.lower() == 'advanced':
|
||||
cls.access_ssh_over_nat(
|
||||
apiclient,
|
||||
services,
|
||||
virtual_machine,
|
||||
allow_egress=allow_egress,
|
||||
networkid=cmd.networkids[0] if cmd.networkids else None)
|
||||
elif mode.lower() == 'basic':
|
||||
if virtual_machine.publicip is not None:
|
||||
# EIP/ELB (netscaler) enabled zone
|
||||
vm_ssh_ip = virtual_machine.publicip
|
||||
else:
|
||||
# regular basic zone with security group
|
||||
vm_ssh_ip = virtual_machine.nic[0].ipaddress
|
||||
virtual_machine.ssh_ip = vm_ssh_ip
|
||||
virtual_machine.public_ip = vm_ssh_ip
|
||||
retries = 5
|
||||
interval = 30
|
||||
while retries > 0:
|
||||
time.sleep(interval)
|
||||
try:
|
||||
if mode.lower() == 'advanced':
|
||||
cls.access_ssh_over_nat(
|
||||
apiclient,
|
||||
services,
|
||||
virtual_machine,
|
||||
allow_egress=allow_egress,
|
||||
networkid=cmd.networkids[0] if cmd.networkids else None)
|
||||
elif mode.lower() == 'basic':
|
||||
if virtual_machine.publicip is not None:
|
||||
# EIP/ELB (netscaler) enabled zone
|
||||
vm_ssh_ip = virtual_machine.publicip
|
||||
else:
|
||||
# regular basic zone with security group
|
||||
vm_ssh_ip = virtual_machine.nic[0].ipaddress
|
||||
virtual_machine.ssh_ip = vm_ssh_ip
|
||||
virtual_machine.public_ip = vm_ssh_ip
|
||||
break
|
||||
except Exception as e:
|
||||
if retries >= 0:
|
||||
retries = retries - 1
|
||||
continue
|
||||
raise Exception(
|
||||
"The following exception appeared while programming ssh access - %s" % e)
|
||||
|
||||
return VirtualMachine(virtual_machine.__dict__, services)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user