def create_actions(cls): mapping = get_mapping() method_dict = mapping[cls.action_namespace] action_classes = [] for action_name, method_name in method_dict.items(): clazz = cls.create_action_class(method_name) try: client_method = clazz.get_fake_client_method() except Exception as e: LOG.debug("Failed to get fake client method: %s" % e) client_method = None if client_method: arg_list = i_u.get_arg_list_as_str(client_method) description = i_u.get_docstring(client_method) else: arg_list = '' description = None action_classes.append( { 'class': clazz, 'name': "%s.%s" % (cls.action_namespace, action_name), 'description': description, 'arg_list': arg_list, } ) return action_classes
def _extract_actions_from_module(module): action_list = [] for member in inspect.getmembers(module): if inspect.isclass(member[1]) and hasattr( member[1], '__export__') and hasattr(member[1], 'run'): action = {} cls = member[1] module_name = cls.__module__ action['name'] = (ROOT_NAMESPACE + module_name[module_name.index('.'):] + '.' + utils.convert_to_snake_case(cls.__name__)) action['action_class_str'] = cls.__module__ + '.' + cls.__name__ action['attributes'] = i_utils.get_public_fields(cls) action['description'] = i_utils.get_docstring(cls) action['input_str'] = i_utils.get_arg_list_as_str(cls.__init__) action_list.append(action) return action_list
def register_action_classes(): mgr = extension.ExtensionManager(namespace='mistral.actions', invoke_on_load=False) for name in mgr.names(): action_class_str = mgr[name].entry_point_target.replace(':', '.') action_class = mgr[name].plugin description = i_utils.get_docstring(action_class) input_str = i_utils.get_arg_list_as_str(action_class.__init__) attrs = i_utils.get_public_fields(mgr[name].plugin) register_action_class(name, action_class_str, attrs, description=description, input_str=input_str) _register_dynamic_action_classes()
def create_actions(cls): mapping = get_mapping() method_dict = mapping.get(cls.action_namespace, {}) action_classes = [] for action_name, method_name in method_dict.items(): class_ = cls.create_action_class(method_name) try: client_method = class_.get_fake_client_method() except Exception: LOG.exception( "Failed to create action: %s.%s", cls.action_namespace, action_name ) continue arg_list = i_u.get_arg_list_as_str(client_method) # Support specifying region for OpenStack actions. modules = CONF.openstack_actions.modules_support_region if cls.action_namespace in modules: arg_list = cls.prepare_action_inputs( arg_list, added=['action_region=""'] ) description = i_u.get_docstring(client_method) action_classes.append( { 'class': class_, 'name': "%s.%s" % (cls.action_namespace, action_name), 'description': description, 'arg_list': arg_list, } ) return action_classes
def register_action_classes(): mgr = extension.ExtensionManager( namespace='mistral.actions', invoke_on_load=False ) for name in mgr.names(): action_class_str = mgr[name].entry_point_target.replace(':', '.') action_class = mgr[name].plugin description = i_utils.get_docstring(action_class) input_str = i_utils.get_arg_list_as_str(action_class.__init__) attrs = i_utils.get_public_fields(mgr[name].plugin) register_action_class( name, action_class_str, attrs, description=description, input_str=input_str ) _register_dynamic_action_classes()
def create_actions(cls): mapping = get_mapping() method_dict = mapping.get(cls.action_namespace, {}) action_classes = [] for action_name, method_name in method_dict.items(): class_ = cls.create_action_class(method_name) try: client_method = class_.get_fake_client_method() except Exception: LOG.exception("Failed to create action: %s.%s", cls.action_namespace, action_name) continue arg_list = i_u.get_arg_list_as_str(client_method) # Support specifying region for OpenStack actions. modules = CONF.openstack_actions.modules_support_region if cls.action_namespace in modules: arg_list = cls.prepare_action_inputs( arg_list, added=['action_region=""']) description = i_u.get_docstring(client_method) action_classes.append({ 'class': class_, 'name': "%s.%s" % (cls.action_namespace, action_name), 'description': description, 'arg_list': arg_list, }) return action_classes