nvazquez commented on a change in pull request #3239: [WIP DO NOT MERGE] KVM: 
Fix agents dont reconnect post maintenance
URL: https://github.com/apache/cloudstack/pull/3239#discussion_r278593957
 
 

 ##########
 File path: test/integration/smoke/test_host_maintenance.py
 ##########
 @@ -290,3 +274,325 @@ def 
test_02_cancel_host_maintenace_with_migration_jobs(self):
         return
 
 
+class TestHostMaintenanceAgents(cloudstackTestCase):
+
+    @classmethod
+    def setUpClass(cls):
+        cls.testClient = super(TestHostMaintenanceAgents, 
cls).getClsTestClient()
+        cls.apiclient = cls.testClient.getApiClient()
+        cls.hypervisor = cls.testClient.getHypervisorInfo()
+        cls.dbclient = cls.testClient.getDbConnection()
+        cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
+        cls.pod = get_pod(cls.apiclient, cls.zone.id)
+        cls.services = cls.testClient.getParsedTestDataConfig()
+
+        cls.logger = logging.getLogger('TestHMAgents')
+        cls.stream_handler = logging.StreamHandler()
+        cls.logger.setLevel(logging.DEBUG)
+        cls.logger.addHandler(cls.stream_handler)
+
+        cls._cleanup = []
+        cls.hypervisorNotSupported = False
+        if cls.hypervisor.lower() not in ['kvm', 'lxc']:
+            cls.hypervisorNotSupported = True
+
+        if not cls.hypervisorNotSupported:
+            cls.initialsshvalue = cls.is_ssh_enabled()
+            cls.template = get_template(
+                cls.apiclient,
+                cls.zone.id,
+                cls.hypervisor
+            )
+            cls.services["virtual_machine"]["zoneid"] = cls.zone.id
+            cls.services["virtual_machine"]["template"] = cls.template.id
+            cls.services["virtual_machine"]["hypervisor"] = cls.hypervisor
+            cls.service_offering = ServiceOffering.create(
+                cls.apiclient,
+                cls.services["service_offerings"]["tiny"]
+            )
+            cls._cleanup.append(cls.service_offering)
+            cls.network_offering = NetworkOffering.create(
+                cls.apiclient,
+                cls.services["l2-network_offering"],
+            )
+            cls.network_offering.update(cls.apiclient, state='Enabled')
+            cls.services["network"]["networkoffering"] = 
cls.network_offering.id
+            cls.l2_network = Network.create(
+                cls.apiclient,
+                cls.services["l2-network"],
+                zoneid=cls.zone.id,
+                networkofferingid=cls.network_offering.id
+            )
+            cls._cleanup.append(cls.l2_network)
+            cls._cleanup.append(cls.network_offering)
+
+    @classmethod
+    def tearDownClass(cls):
+        try:
+            if not cls.hypervisorNotSupported:
+                # Revert setting value to the original
+                cls.set_ssh_enabled(cls.initialsshvalue)
+            cleanup_resources(cls.apiclient, cls._cleanup)
+        except Exception as e:
+            raise Exception("Warning: Exception during cleanup : %s" % e)
+
+    def setUp(self):
+        if not self.hypervisorNotSupported:
+            self.host = self.get_enabled_host_connected_agent()
+        self.cleanup = []
+
+    def tearDown(self):
+        try:
+            cleanup_resources(self.apiclient, self.cleanup)
+        except Exception as e:
+            raise Exception("Warning: Exception during cleanup : %s" % e)
+
+
+    @classmethod
+    def is_ssh_enabled(cls):
+        conf = Configurations.list(cls.apiclient, name="kvm.ssh.to.agent")
+        if not conf:
+            return False
+        else:
+            return bool(strtobool(conf[0].value)) if conf[0].value else False
+
+    @classmethod
+    def set_ssh_enabled(cls, on):
+        value = "true" if on else "false"
+        sql = "update configuration set value = '%s' where name = 
'kvm.ssh.to.agent';" % value
 
 Review comment:
   Done, thanks

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to