コード例 #1
0
 def __add_resource_specific_options(self, obj, specific_options, line, key=None):
     obj_coll_type = TypeHelper.getDecoratorType(TypeHelper.to_plural(obj))
     if obj_coll_type:
         if hasattr(brokers, obj_coll_type):
             obj_coll = getattr(brokers, obj_coll_type)
             if obj_coll and hasattr(obj_coll, AddCmdShell.NAME):
                 method_args = MethodHelper.get_documented_arguments(method_ref=getattr(obj_coll, AddCmdShell.NAME),
                                                                     as_params_collection=True,
                                                                     spilt_or=True)
                 if method_args:
                     specific_options[obj if key == None else key] = method_args
コード例 #2
0
    def __add_resource_specific_options(self, obj, specific_options, line, key=None):
        obj_type = TypeHelper.getDecoratorType(TypeHelper.to_singular(obj))
        if obj_type and hasattr(brokers, obj_type):
            obj_typ_ref = getattr(brokers, obj_type)
            if obj_typ_ref and hasattr(obj_typ_ref, RemoveCmdShell.ALIAS):
                method_args = MethodHelper.get_documented_arguments(
                    method_ref=getattr(obj_typ_ref, RemoveCmdShell.ALIAS), as_params_collection=True, spilt_or=True
                )

                if method_args:
                    specific_options[key if key is not None else obj] = method_args
コード例 #3
0
 def __add_resource_specific_options(self, obj, specific_options, line, key=None):
     obj_coll_type = TypeHelper.getDecoratorType(TypeHelper.to_plural(obj))
     if obj_coll_type:
         if hasattr(brokers, obj_coll_type):
             obj_coll = getattr(brokers, obj_coll_type)
             if obj_coll and hasattr(obj_coll, ShowCmdShell.ALIAS):
                 method_args = MethodHelper.get_documented_arguments(method_ref=getattr(obj_coll, ShowCmdShell.ALIAS),
                                                                     as_params_collection=True,
                                                                     spilt_or=True)
                 if method_args:
                     specific_options[obj if key == None else key] = method_args
コード例 #4
0
 def __add_resource_specific_options(self,
                                     obj,
                                     specific_options,
                                     line,
                                     key=None):
     typ = TypeHelper.getDecoratorType(obj)
     if typ:
         plur_obj = TypeHelper.to_plural(typ)
         if hasattr(brokers, plur_obj):
             method_args = MethodHelper.getMethodArgs(
                 brokers, plur_obj, ListCmdShell.NAME, True, True, True)
             if method_args:
                 specific_options[obj if key == None else key] = method_args
コード例 #5
0
 def __add_resource_specific_options(self, obj, specific_options, line, key=None):
     typ = TypeHelper.getDecoratorType(obj)
     if typ:
         plur_obj = TypeHelper.to_plural(typ)
         if hasattr(brokers, plur_obj):
             method_args = MethodHelper.getMethodArgs(brokers,
                                                      plur_obj,
                                                      ListCmdShell.NAME,
                                                      True,
                                                      True,
                                                      True)
             if method_args:
                 specific_options[obj if key == None else key] = method_args
コード例 #6
0
    def __add_resource_specific_options(self,
                                        obj,
                                        specific_options,
                                        line,
                                        key=None):
        obj_type = TypeHelper.getDecoratorType(TypeHelper.to_singular(obj))
        if obj_type and hasattr(brokers, obj_type):
            obj_typ_ref = getattr(brokers, obj_type)
            if obj_typ_ref and hasattr(obj_typ_ref, UpdateCmdShell.NAME):
                method_args = MethodHelper.get_documented_arguments(
                    method_ref=getattr(obj_typ_ref, UpdateCmdShell.NAME),
                    as_params_collection=True,
                    spilt_or=True)

                if method_args:
                    specific_options[
                        key if key is not None else obj] = method_args
コード例 #7
0
    def __expend_nested_type(type_name, module, method, expended_types):
        """Recursive method's args types resolution"""
        getMethodArgs = MethodHelper.getMethodArgs
        expend_nested_type = MethodHelper.__expend_nested_type

        from ovirtcli.utils.typehelper import TypeHelper
        typ = TypeHelper.getDecoratorType(type_name)

        if typ:
            expended_types_tmp = getMethodArgs(module, typ, method, drop_self=True)
            if len(expended_types_tmp) > 1:
                for item in expended_types_tmp:
                    if item != type_name:
                        expend_nested_type(item, module, method, expended_types)
            elif len(expended_types_tmp) > 0:
                expended_types.append(expended_types_tmp[0])
        else:
            expended_types.append(type_name)
        return expended_types
コード例 #8
0
    def _resolve_base(self, args):
        """
        Resolves a base object from a set of '--parent-type-identifier'
        or '--parent-type-name' options.
        """
        parent_candidates = [item for item in args
                if OptionHelper.is_parent_id_option(item)]
        parent_candidates_permutations = list(itertools.permutations(parent_candidates))

        if parent_candidates_permutations[0]:
            for combination in parent_candidates_permutations:
                candidates = [OptionHelper.get_parent_id_type(item)
                        for item in combination
                        if OptionHelper.is_parent_id_option(item)]
                candidate = (''.join(candidates) + args[0]).lower()
                dt = TypeHelper.getDecoratorType(candidate)
                if dt: return dt

        return None
コード例 #9
0
 def __add_resource_specific_options(self,
                                     obj,
                                     specific_options,
                                     line,
                                     key=None):
     obj_coll_type = TypeHelper.getDecoratorType(TypeHelper.to_plural(obj))
     if obj_coll_type:
         if hasattr(brokers, obj_coll_type):
             obj_coll = getattr(brokers, obj_coll_type)
             if obj_coll and hasattr(obj_coll, ShowCmdShell.ALIAS):
                 method_args = MethodHelper.get_documented_arguments(
                     method_ref=getattr(obj_coll, ShowCmdShell.ALIAS),
                     as_params_collection=True,
                     spilt_or=True)
                 if method_args:
                     method_args = [
                         x for x in method_args if x not in ['id', 'name']
                     ]
                     specific_options[obj if key ==
                                      None else key] = method_args
コード例 #10
0
    def _resolve_base(self, args):
        """resolves a base object from a set of '--type-identifier value' options."""
        PARENT_IDENTIFIER = '-identifier'
        parnet_candidates = [
            item for item in args if item.endswith(PARENT_IDENTIFIER)
        ]
        parnet_candidates_permutations = list(
            itertools.permutations(parnet_candidates))

        if parnet_candidates_permutations[0]:
            for combination in parnet_candidates_permutations:
                candidates = [
                    item[2:-11] for item in combination
                    if item.endswith(PARENT_IDENTIFIER)
                ]
                candidate = (''.join(candidates) + args[0]).lower()
                dt = TypeHelper.getDecoratorType(candidate)
                if dt: return dt

        return None
コード例 #11
0
    def __add_resource_specific_options(self, obj, specific_options, line, key=None):
        obj_type = TypeHelper.getDecoratorType(TypeHelper.to_singular(obj))
        gda = MethodHelper.get_documented_arguments
        gat = TypeHelper.get_actionable_types
        memeber = key if key is not None else obj
        method_args = []
        action = None

        if obj_type and hasattr(brokers, obj_type):
            action = self.__get_method_name_by_args(obj,
                                                    line.split(' '),
                                                    gat(expendNestedTypes=True),
                                                    line)
            if action:
                obj_typ_ref = getattr(brokers, obj_type)
                if obj_typ_ref and hasattr(obj_typ_ref, action):
                    method_args = gda(method_ref=getattr(obj_typ_ref, action),
                                      as_params_collection=True,
                                      spilt_or=True)
                    if method_args:
                        specific_options[memeber] = method_args
コード例 #12
0
    def __add_resource_specific_options(self,
                                        obj,
                                        specific_options,
                                        line,
                                        key=None):
        obj_type = TypeHelper.getDecoratorType(TypeHelper.to_singular(obj))
        gda = MethodHelper.get_documented_arguments
        gat = TypeHelper.get_actionable_types
        memeber = key if key is not None else obj
        method_args = []
        action = None

        if obj_type and hasattr(brokers, obj_type):
            action = self.__get_method_name_by_args(
                obj, line.split(' '), gat(expendNestedTypes=True), line)
            if action:
                obj_typ_ref = getattr(brokers, obj_type)
                if obj_typ_ref and hasattr(obj_typ_ref, action):
                    method_args = gda(method_ref=getattr(obj_typ_ref, action),
                                      as_params_collection=True,
                                      spilt_or=True)
                    if method_args:
                        specific_options[memeber] = method_args
コード例 #13
0
    def _resolve_base(self, args):
        """
        Resolves a base object from a set of '--parent-type-identifier'
        or '--parent-type-name' options.
        """
        parent_candidates = [
            item for item in args if OptionHelper.is_parent_id_option(item)
        ]
        parent_candidates_permutations = list(
            itertools.permutations(parent_candidates))

        if parent_candidates_permutations[0]:
            for combination in parent_candidates_permutations:
                candidates = [
                    OptionHelper.get_parent_id_type(item)
                    for item in combination
                    if OptionHelper.is_parent_id_option(item)
                ]
                candidate = (''.join(candidates) + args[0]).lower()
                dt = TypeHelper.getDecoratorType(candidate)
                if dt: return dt

        return None