def run(self): mc = self.get_workflow_client() try: env = mc.environments.get('ssh_keys') public_key = env.variables['public_key'] except Exception: ssh_key = password_utils.create_ssh_keypair() public_key = ssh_key['public_key'] workflow_env = { 'name': 'ssh_keys', 'description': 'SSH keys for TripleO validations', 'variables': ssh_key } mc.environments.create(**workflow_env) return public_key
def run(self, context): mc = self.get_workflow_client(context) try: env = mc.environments.get('ssh_keys') p_key = env.variables[self.key_type] except Exception: ssh_key = password_utils.create_ssh_keypair() p_key = ssh_key[self.key_type] workflow_env = { 'name': 'ssh_keys', 'description': 'SSH keys for TripleO validations', 'variables': ssh_key } mc.environments.create(**workflow_env) return p_key
def run(self, context): mc = self.get_workflow_client(context) swift = self.get_object_client(context) identity_file = None inputs_file = None # Make sure the ssh_keys environment exists try: env = mc.environments.get('ssh_keys') except Exception: workflow_env = { 'name': 'ssh_keys', 'description': 'SSH keys for TripleO validations', 'variables': password_utils.create_ssh_keypair() } env = mc.environments.create(**workflow_env) try: private_key = env.variables['private_key'] identity_file = utils.write_identity_file(private_key) inputs_file = utils.write_inputs_file(self.inputs) stdout, stderr = utils.run_validation(swift, self.validation, identity_file, self.plan, inputs_file, context) return_value = {'stdout': stdout, 'stderr': stderr} mistral_result = {"data": return_value} except mistralclient_api.APIException as e: return_value = {'stdout': '', 'stderr': e.error_message} mistral_result = {"error": return_value} except ProcessExecutionError as e: return_value = {'stdout': e.stdout, 'stderr': e.stderr} # Indicates to Mistral there was a failure mistral_result = {"error": return_value} finally: if identity_file: utils.cleanup_identity_file(identity_file) if inputs_file: utils.cleanup_inputs_file(inputs_file) return actions.Result(**mistral_result)
def run(self, context): mc = self.get_workflow_client(context) swift = self.get_object_client(context) identity_file = None inputs_file = None # Make sure the ssh_keys environment exists try: env = mc.environments.get('ssh_keys') except Exception: workflow_env = { 'name': 'ssh_keys', 'description': 'SSH keys for TripleO validations', 'variables': password_utils.create_ssh_keypair() } env = mc.environments.create(**workflow_env) try: private_key = env.variables['private_key'] identity_file = utils.write_identity_file(private_key) inputs_file = utils.write_inputs_file(self.inputs) stdout, stderr = utils.run_validation(swift, self.validation, identity_file, self.plan, inputs_file, context) return_value = {'stdout': stdout, 'stderr': stderr} mistral_result = {"data": return_value} except mistralclient_api.APIException as e: return_value = {'stdout': '', 'stderr': e.error_message} mistral_result = {"error": return_value} except ProcessExecutionError as e: return_value = {'stdout': e.stdout, 'stderr': e.stderr} # Indicates to Mistral there was a failure mistral_result = {"error": return_value} finally: if identity_file: utils.cleanup_identity_file(identity_file) if inputs_file: utils.cleanup_inputs_file(inputs_file) return actions.Result(**mistral_result)
def test_create_ssh_keypair(self): value = password_utils.create_ssh_keypair(comment="Foo") self.assertEqual('ssh-rsa', value['public_key'][:7]) self.assertEqual('Foo', value['public_key'][-3:])
def test_create_ssh_keypair(self): value = password_utils.create_ssh_keypair(comment="Foo") self.assertEqual('ssh-rsa', value['public_key'][:7]) self.assertEqual('Foo', value['public_key'][-3:])