def _deploy_continue(location: Path, inv: ExtendedInvocation): # get blueprint CSAR_db.get_revision(inv.blueprint_id, location, inv.version_id) # get session data (.opera) InvocationService.get_dot_opera_from_db(inv.deployment_id, location) with xopera_util.cwd(location): try: if inv.user_id and Settings.secure_workdir: xopera_util.setup_user([location], inv.user_id, inv.access_token) opera_storage = Storage.create(".opera") service_template = entry_definitions(location) opera_deploy(service_template, inv.inputs, opera_storage, verbose_mode=False, num_workers=inv.workers, delete_existing_state=inv.clean_state) outputs = opera_outputs(opera_storage) return outputs finally: if inv.user_id and Settings.secure_workdir: xopera_util.cleanup_user()
def _deploy(service_template: str, inputs: typing.Optional[dict], num_workers: int, clean_state: bool): opera_storage = Storage.create() opera_deploy(service_template, inputs, opera_storage, verbose_mode=True, num_workers=num_workers, delete_existing_state=clean_state)
def build_image(inv: Invocation): with tempfile.TemporaryDirectory() as workdir: dir_util.copy_tree(Settings.TOSCA_path, workdir) with image_builder_util.cwd(workdir): opera_storage = Storage.create(".opera") service_template = "docker_image_definition.yaml" build_params = transform_build_params(inv.build_params) logger.info(json.dumps(build_params)) opera_deploy(service_template, build_params, opera_storage, verbose_mode=False, num_workers=1, delete_existing_state=True) return opera_outputs(opera_storage)
def run_test(registry_ip: str, test_name: str): """ Runs yaml test and returns exit_code """ test_path = test_build_params / f'{test_name}.json' inputs = json_to_yaml(test_path, registry_ip) with cwd(tosca_path): opera_storage = Storage.create('.opera') try: opera_deploy('docker_image_definition.yaml', inputs, opera_storage, verbose_mode=False, num_workers=1, delete_existing_state=True) except OperationError: return 1 finally: shutil.rmtree((tosca_path / ".opera"), ignore_errors=True) return 0