diff options
Diffstat (limited to 'functest/core/cloudify.py')
-rw-r--r-- | functest/core/cloudify.py | 44 |
1 files changed, 21 insertions, 23 deletions
diff --git a/functest/core/cloudify.py b/functest/core/cloudify.py index b5bd1b3c2..966d33645 100644 --- a/functest/core/cloudify.py +++ b/functest/core/cloudify.py @@ -29,7 +29,7 @@ class Cloudify(singlevm.SingleVm2): __logger = logging.getLogger(__name__) filename = ('/home/opnfv/functest/images/' - 'ubuntu-16.04-server-cloudimg-amd64-disk1.img') + 'ubuntu-18.04-server-cloudimg-amd64.img') flavor_ram = 4096 flavor_vcpus = 2 flavor_disk = 40 @@ -46,11 +46,11 @@ class Cloudify(singlevm.SingleVm2): """Initialize Cloudify testcase object.""" if "case_name" not in kwargs: kwargs["case_name"] = "cloudify" - super(Cloudify, self).__init__(**kwargs) + super().__init__(**kwargs) self.cfy_client = None def prepare(self): - super(Cloudify, self).prepare() + super().prepare() for port in self.ports: self.cloud.create_security_group_rule( self.sec.id, port_range_min=port, port_range_max=port, @@ -64,20 +64,19 @@ class Cloudify(singlevm.SingleVm2): scpc.put(self.cloudify_archive, remote_path=os.path.basename(self.cloudify_archive)) (_, stdout, stderr) = self.ssh.exec_command( - "sudo wget https://get.docker.com/ -O script.sh && " - "sudo chmod +x script.sh && " - "sudo ./script.sh && " - "sudo docker load -i ~/{} && " + "sudo apt-get update && " + "sudo apt-get install -y docker.io && " + "sudo docker load -i " + f"~/{os.path.basename(self.cloudify_archive)} && " "sudo docker run --name cfy_manager_local -d " "--restart unless-stopped -v /sys/fs/cgroup:/sys/fs/cgroup:ro " "--tmpfs /run --tmpfs /run/lock --security-opt seccomp:unconfined " - "--cap-add SYS_ADMIN --network=host {}".format( - os.path.basename(self.cloudify_archive), - self.cloudify_container)) - self.__logger.debug("output:\n%s", stdout.read()) - self.__logger.debug("error:\n%s", stderr.read()) + f"--cap-add SYS_ADMIN --network=host {self.cloudify_container}") + self.__logger.debug("output:\n%s", stdout.read().decode("utf-8")) + self.__logger.debug("error:\n%s", stderr.read().decode("utf-8")) self.cfy_client = CloudifyClient( - host=self.fip.floating_ip_address, + host=self.fip.floating_ip_address if self.fip else ( + self.sshvm.public_v4), username='admin', password='admin', tenant='default_tenant') self.__logger.info("Attemps running status of the Manager") secret_key = "foo" @@ -124,17 +123,17 @@ class Cloudify(singlevm.SingleVm2): "cfy_manager_local:/etc/cloudify/ && " "sudo docker exec cfy_manager_local " "chmod 444 /etc/cloudify/cloudify_ims.pem") - self.__logger.debug("output:\n%s", stdout.read()) - self.__logger.debug("error:\n%s", stderr.read()) + self.__logger.debug("output:\n%s", stdout.read().decode("utf-8")) + self.__logger.debug("error:\n%s", stderr.read().decode("utf-8")) def upload_cfy_plugins(self, yaml, wgn): """Upload Cloudify plugins""" (_, stdout, stderr) = self.ssh.exec_command( "sudo docker exec cfy_manager_local " - "cfy plugins upload -y {} {} && " - "sudo docker exec cfy_manager_local cfy status".format(yaml, wgn)) - self.__logger.debug("output:\n%s", stdout.read()) - self.__logger.debug("error:\n%s", stderr.read()) + f"cfy plugins upload -y {yaml} {wgn} && " + "sudo docker exec cfy_manager_local cfy status") + self.__logger.debug("output:\n%s", stdout.read().decode("utf-8")) + self.__logger.debug("error:\n%s", stderr.read().decode("utf-8")) def kill_existing_execution(self, dep_name): """kill existing execution""" @@ -188,9 +187,8 @@ def wait_for_execution(client, execution, logger, timeout=3600, ): if timeout is not None: if time.time() > deadline: raise RuntimeError( - 'execution of operation {0} for deployment {1} ' - 'timed out'.format(execution.workflow_id, - execution.deployment_id)) + 'execution of operation {execution.workflow_id} for ' + 'deployment {execution.deployment_id} timed out') # update the remaining timeout timeout = deadline - time.time() @@ -218,4 +216,4 @@ def get_execution_id(client, deployment_id): return execution raise RuntimeError('Failed to get create_deployment_environment ' 'workflow execution.' - 'Available executions: {0}'.format(executions)) + f'Available executions: {executions}') |