def execute_file_exist(test_file_name): """ Fabric executor: Run method with assertion 'assert_file_exist' on the remote host :param test_file_name: Target file name :return: True if file contains that content (dir: PROVISION_ROOT_PATH) """ print "FABRIC: Checking if file exists" _init_vm_connection() success = fabric_execute(assert_file_exist, test_file_name=test_file_name) return success[FABRIC_RESULT_EXECUTE]
def execute_content_in_file(file_name, expected_content): """ Fabric executor: Run method with assertion 'assert_content_in_file' on the remote host :param file_name: Target file name :param expected_content: String to be found in file :return: True if file contains that content (dir: PROVISION_ROOT_PATH) """ print "FABRIC: Checking if file contains:", expected_content _init_vm_connection() success = fabric_execute(assert_content_in_file, file_name=file_name, expected_content=expected_content) return success[FABRIC_RESULT_EXECUTE]
def execute(action, output, *args, **kwargs): """Exec allows you to execute an action using fabric API, adding pre-hook and post-hook into the pipeline if required.""" if output: def run(*args, **kwargs): mico.output.debug(" ".join(args)) return mico.output.info(action(*args, **kwargs)) else: def run(*args, **kwargs): return action(*args, **kwargs) return fabric_execute( mico.hook.task_add_pre_run_hook(mico.hook.run_pre_hook)( mico.hook.task_add_post_run_hook(mico.hook.run_post_hook)(run)), *args, **kwargs)
def execute(action, output, *args, **kwargs): """Exec allows you to execute an action using fabric API, adding pre-hook and post-hook into the pipeline if required.""" if output: def run(*args, **kwargs): mico.output.debug(" ".join(args)) return mico.output.info(action(*args, **kwargs)) else: def run(*args, **kwargs): return action(*args, **kwargs) return fabric_execute( mico.hook.task_add_pre_run_hook(mico.hook.run_pre_hook)( mico.hook.task_add_post_run_hook(mico.hook.run_post_hook)(run) ), *args, **kwargs )
def execute_content_in_file(file_name, expected_content): print "Checkin if file contains:", expected_content success = fabric_execute(assert_content_in_file, file_name=file_name, expected_content=expected_content) return success[FABRIC_RESULT_EXECUTE]
def execute_file_exist(test_file_name): success = fabric_execute(assert_file_exist, test_file_name=test_file_name) return success[FABRIC_RESULT_EXECUTE]
def execute_assert_download(module_name): success = fabric_execute(assert_module_exist, module_name=module_name) return success[FABRIC_RESULT_EXECUTE]
def execute_generate(node_name, software_name, version, action, group_name): fabric_execute(assert_generate, node_name=node_name, software_name=software_name, version=version, action=action, group_name=group_name)
def execute_import_deleted(group): success = fabric_execute(assert_site_file_not_content_group, group=group) return success[FABRIC_RESULT_EXECUTE]
def execute_delete_node(group, node_name): success = fabric_execute(assert_node_file_not_exist, group=group, node_name=node_name) return success[FABRIC_RESULT_EXECUTE]
def install_hooks(self): #find the location of the template file fabric_execute(self.__install_hooks, host=self.connection_name)
def create(self): fabric_execute(self.__create, host=self.connection_name)