Esempio n. 1
0
 def set_params(self, params, inplace=False):
     (success, value) = utils.input_string_or_hash(params, allow_multiples=True)
     if not success:
         raise CX(_("invalid parameters"))
     else:
         if inplace:
             for key in value.keys():
                 if key.startswith("~"):
                     del self.params[key[1:]]
                 else:
                     self.params[key] = value[key]
         else:
             self.params = value
         return True
Esempio n. 2
0
 def set_params(self, params, inplace=False):
     (success, value) = utils.input_string_or_hash(params,
                                                   allow_multiples=True)
     if not success:
         raise CX(_("invalid parameters"))
     else:
         if inplace:
             for key in value.keys():
                 if key.startswith("~"):
                     del self.params[key[1:]]
                 else:
                     self.params[key] = value[key]
         else:
             self.params = value
         return True
Esempio n. 3
0
 def set_environment(self, options, inplace=False):
     """
     Yum can take options from the environment.  This puts them there before
     each reposync.
     """
     (success, value) = utils.input_string_or_hash(options, allow_multiples=False)
     if not success:
         raise CX(_("invalid environment options"))
     else:
         if inplace:
             for key in value.keys():
                 self.environment[key] = value[key]
         else:
             self.environment = value
         return True
Esempio n. 4
0
 def set_yumopts(self, options, inplace=False):
     """
     Kernel options are a space delimited list,
     like 'a=b c=d e=f g h i=j' or a hash.
     """
     (success, value) = utils.input_string_or_hash(options, allow_multiples=False)
     if not success:
         raise CX(_("invalid yum options"))
     else:
         if inplace:
             for key in value.keys():
                 self.yumopts[key] = value[key]
         else:
             self.yumopts = value
         return True
Esempio n. 5
0
 def set_fetchable_files(self, fetchable_files, inplace=False):
     """
     A comma seperated list of virt_name=path_to_template
     that should be fetchable via tftp or a webserver
     """
     (success, value) = utils.input_string_or_hash(fetchable_files, allow_multiples=False)
     if not success:
         return False
     else:
         if inplace:
             for key in value.keys():
                 if key.startswith("~"):
                     del self.fetchable_files[key[1:]]
                 else:
                     self.fetchable_files[key] = value[key]
         else:
             self.fetchable_files = value
         return True
Esempio n. 6
0
 def set_boot_files(self, boot_files, inplace=False):
     """
     A comma seperated list of req_name=source_file_path
     that should be fetchable via tftp
     """
     (success, value) = utils.input_string_or_hash(boot_files, allow_multiples=False)
     if not success:
         return False
     else:
         if inplace:
             for key in value.keys():
                 if key.startswith("~"):
                     del self.boot_files[key[1:]]
                 else:
                     self.boot_files[key] = value[key]
         else:
             self.boot_files = value
         return True
Esempio n. 7
0
 def set_template_files(self, template_files, inplace=False):
     """
     A comma seperated list of source=destination templates
     that should be generated during a sync.
     """
     (success, value) = utils.input_string_or_hash(template_files, allow_multiples=False)
     if not success:
         return False
     else:
         if inplace:
             for key in value.keys():
                 if key.startswith("~"):
                     del self.template_files[key[1:]]
                 else:
                     self.template_files[key] = value[key]
         else:
             self.template_files = value
         return True
Esempio n. 8
0
 def set_kernel_options_post(self, options, inplace=False):
     """
     Post kernel options are a space delimited list,
     like 'a=b c=d e=f g h i=j' or a hash.
     """
     (success, value) = utils.input_string_or_hash(options, allow_multiples=True)
     if not success:
         raise CX(_("invalid post kernel options"))
     else:
         if inplace:
             for key in value.keys():
                 if key.startswith("~"):
                     del self.kernel_options_post[key[1:]]
                 else:
                     self.kernel_options_post[key] = value[key]
         else:
             self.kernel_options_post = value
         return True
Esempio n. 9
0
 def set_fetchable_files(self, fetchable_files, inplace=False):
     """
     A comma seperated list of virt_name=path_to_template
     that should be fetchable via tftp or a webserver
     """
     (success, value) = utils.input_string_or_hash(fetchable_files,
                                                   allow_multiples=False)
     if not success:
         return False
     else:
         if inplace:
             for key in value.keys():
                 if key.startswith("~"):
                     del self.fetchable_files[key[1:]]
                 else:
                     self.fetchable_files[key] = value[key]
         else:
             self.fetchable_files = value
         return True
Esempio n. 10
0
 def set_boot_files(self, boot_files, inplace=False):
     """
     A comma seperated list of req_name=source_file_path
     that should be fetchable via tftp
     """
     (success, value) = utils.input_string_or_hash(boot_files,
                                                   allow_multiples=False)
     if not success:
         return False
     else:
         if inplace:
             for key in value.keys():
                 if key.startswith("~"):
                     del self.boot_files[key[1:]]
                 else:
                     self.boot_files[key] = value[key]
         else:
             self.boot_files = value
         return True
Esempio n. 11
0
 def set_template_files(self, template_files, inplace=False):
     """
     A comma seperated list of source=destination templates
     that should be generated during a sync.
     """
     (success, value) = utils.input_string_or_hash(template_files,
                                                   allow_multiples=False)
     if not success:
         return False
     else:
         if inplace:
             for key in value.keys():
                 if key.startswith("~"):
                     del self.template_files[key[1:]]
                 else:
                     self.template_files[key] = value[key]
         else:
             self.template_files = value
         return True
Esempio n. 12
0
 def set_kernel_options_post(self, options, inplace=False):
     """
     Post kernel options are a space delimited list,
     like 'a=b c=d e=f g h i=j' or a hash.
     """
     (success, value) = utils.input_string_or_hash(options,
                                                   allow_multiples=True)
     if not success:
         raise CX(_("invalid post kernel options"))
     else:
         if inplace:
             for key in value.keys():
                 if key.startswith("~"):
                     del self.kernel_options_post[key[1:]]
                 else:
                     self.kernel_options_post[key] = value[key]
         else:
             self.kernel_options_post = value
         return True
Esempio n. 13
0
 def set_ks_meta(self, options, inplace=False):
     """
     A comma delimited list of key value pairs, like 'a=b,c=d,e=f' or a hash.
     The meta tags are used as input to the templating system
     to preprocess kickstart files
     """
     (success, value) = utils.input_string_or_hash(options, allow_multiples=True)
     if not success:
         return False
     else:
         if inplace:
             for key in value.keys():
                 if key.startswith("~"):
                     del self.ks_meta[key[1:]]
                 else:
                     self.ks_meta[key] = value[key]
         else:
             self.ks_meta = value
         return True
Esempio n. 14
0
 def set_ks_meta(self, options, inplace=False):
     """
     A comma delimited list of key value pairs, like 'a=b,c=d,e=f' or a hash.
     The meta tags are used as input to the templating system
     to preprocess kickstart files
     """
     (success, value) = utils.input_string_or_hash(options,
                                                   allow_multiples=True)
     if not success:
         return False
     else:
         if inplace:
             for key in value.keys():
                 if key.startswith("~"):
                     del self.ks_meta[key[1:]]
                 else:
                     self.ks_meta[key] = value[key]
         else:
             self.ks_meta = value
         return True
Esempio n. 15
0
    def __find_compare(self, from_search, from_obj):

        if isinstance(from_obj, basestring):
            # FIXME: fnmatch is only used for string to string comparisions
            # which should cover most major usage, if not, this deserves fixing
            if fnmatch.fnmatch(from_obj.lower(), from_search.lower()):
                return True
            else:
                return False
        else:
            if isinstance(from_search, basestring):
                if isinstance(from_obj, list):
                    from_search = utils.input_string_or_list(from_search)
                    for x in from_search:
                        if x not in from_obj:
                            return False
                    return True
                if isinstance(from_obj, dict):
                    (junk, from_search) = utils.input_string_or_hash(
                        from_search, allow_multiples=True)
                    for x in from_search.keys():
                        y = from_search[x]
                        if x not in from_obj:
                            return False
                        if not (y == from_obj[x]):
                            return False
                    return True
                if isinstance(from_obj, bool):
                    if from_search.lower() in ["true", "1", "y", "yes"]:
                        inp = True
                    else:
                        inp = False
                    if inp == from_obj:
                        return True
                    return False

            raise CX(_("find cannot compare type: %s") % type(from_obj))
Esempio n. 16
0
    def __find_compare(self, from_search, from_obj):

        if isinstance(from_obj, basestring):
            # FIXME: fnmatch is only used for string to string comparisions
            # which should cover most major usage, if not, this deserves fixing
            if fnmatch.fnmatch(from_obj.lower(), from_search.lower()):
                return True
            else:
                return False
        else:
            if isinstance(from_search, basestring):
                if isinstance(from_obj, list):
                    from_search = utils.input_string_or_list(from_search)
                    for x in from_search:
                        if x not in from_obj:
                            return False
                    return True
                if isinstance(from_obj, dict):
                    (junk, from_search) = utils.input_string_or_hash(from_search, allow_multiples=True)
                    for x in from_search.keys():
                        y = from_search[x]
                        if x not in from_obj:
                            return False
                        if not (y == from_obj[x]):
                            return False
                    return True
                if isinstance(from_obj, bool):
                    if from_search.lower() in ["true", "1", "y", "yes"]:
                        inp = True
                    else:
                        inp = False
                    if inp == from_obj:
                        return True
                    return False

            raise CX(_("find cannot compare type: %s") % type(from_obj))