本文整理汇总了Python中utils.input_string_or_list函数的典型用法代码示例。如果您正苦于以下问题:Python input_string_or_list函数的具体用法?Python input_string_or_list怎么用?Python input_string_or_list使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了input_string_or_list函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: set_mgmt_classes
def set_mgmt_classes(self,mgmt_classes):
"""
Assigns a list of configuration management classes that can be assigned
to any object, such as those used by Puppet's external_nodes feature.
"""
mgmt_classes_split = utils.input_string_or_list(mgmt_classes)
self.mgmt_classes = utils.input_string_or_list(mgmt_classes_split)
return True
示例2: __setattr__
def __setattr__(self,name,value):
if DEFAULTS.has_key(name):
try:
if DEFAULTS[name][1] == "str":
value = str(value)
elif DEFAULTS[name][1] == "int":
value = int(value)
elif DEFAULTS[name][1] == "bool":
if utils.input_boolean(value):
value = 1
else:
value = 0
elif DEFAULTS[name][1] == "float":
value = float(value)
elif DEFAULTS[name][1] == "list":
value = utils.input_string_or_list(value)
elif DEFAULTS[name][1] == "dict":
value = utils.input_string_or_hash(value)[1]
except:
raise AttributeError, "failed to set %s to %s" % (name,str(value))
self.__dict__[name] = value
if not utils.update_settings_file(self.to_datastruct()):
raise AttributeError, "failed to save the settings file!"
return 0
else:
raise AttributeError, name
示例3: __setattr__
def __setattr__(self, name, value):
if name in DEFAULTS:
try:
if DEFAULTS[name][1] == "str":
value = str(value)
elif DEFAULTS[name][1] == "int":
value = int(value)
elif DEFAULTS[name][1] == "bool":
if utils.input_boolean(value):
value = 1
else:
value = 0
elif DEFAULTS[name][1] == "float":
value = float(value)
elif DEFAULTS[name][1] == "list":
value = utils.input_string_or_list(value)
elif DEFAULTS[name][1] == "dict":
value = utils.input_string_or_hash(value)[1]
except:
raise AttributeError
self.__dict__[name] = value
if not utils.update_settings_file(self.to_datastruct()):
raise AttributeError
return 0
else:
raise AttributeError
示例4: set_name_servers
def set_name_servers(self,data):
# FIXME: move to utils since shared with system
if data == "<<inherit>>":
data = []
data = utils.input_string_or_list(data)
self.name_servers = data
return True
示例5: filter_systems_or_profiles
def filter_systems_or_profiles(self, selected_items, list_type):
"""
Return a list of valid profile or system objects selected from all profiles
or systems by name, or everything if selected_items is empty
"""
if list_type == 'profile':
all_objs = [profile for profile in self.api.profiles()]
elif list_type == 'system':
all_objs = [system for system in self.api.systems()]
else:
utils.die(self.logger, "Invalid list_type argument: " + list_type)
all_objs.sort(self.sort_name)
# no profiles/systems selection is made, let's process everything
if not selected_items:
return all_objs
which_objs = []
selected_list = utils.input_string_or_list(selected_items)
for obj in all_objs:
if obj.name in selected_list:
which_objs.append(obj)
if not which_objs:
utils.die(self.logger, "No valid systems or profiles were specified.")
return which_objs
示例6: set_rpm_list
def set_rpm_list(self,rpms):
"""
Rather than mirroring the entire contents of a repository (Fedora Extras, for instance,
contains games, and we probably don't want those), make it possible to list the packages
one wants out of those repos, so only those packages + deps can be mirrored.
"""
self.rpm_list = utils.input_string_or_list(rpms,delim=" ")
return True
示例7: set_owners
def set_owners(self,data):
"""
The owners field is a comment unless using an authz module that pays attention to it,
like authz_ownership, which ships with Cobbler but is off by default. Consult the Wiki
docs for more info on CustomizableAuthorization.
"""
owners = utils.input_string_or_list(data)
self.owners = owners
return True
示例8: set_ipv6_secondaries
def set_ipv6_secondaries(self,addresses,interface):
intf = self.__get_interface(interface)
data = utils.input_string_or_list(addresses)
secondaries = []
for address in data:
if address == "" or utils.is_ip(address):
secondaries.append(address)
else:
raise CX(_("invalid format for IPv6 IP address (%s)") % address)
intf["ipv6_secondaries"] = secondaries
return True
示例9: __find_compare
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 type(from_obj) == type([]):
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 type(from_obj) == type({}):
(junk, from_search) = utils.input_string_or_hash(from_search,allow_multiples=True)
for x in from_search.keys():
y = from_search[x]
if not from_obj.has_key(x):
return False
if not (y == from_obj[x]):
return False
return True
if type(from_obj) == type(True):
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))
示例10: set_name_servers_search
def set_name_servers_search(self,data):
if data == "<<inherit>>":
data = []
data = utils.input_string_or_list(data)
self.name_servers_search = data
return True
示例11: set_files
def set_files(self, files):
self.files = utils.input_string_or_list(files)
return True
示例12: set_packages
def set_packages(self, packages):
self.packages = utils.input_string_or_list(packages)
return True
示例13: generate_netboot_iso
def generate_netboot_iso(self,imagesdir,isolinuxdir,profiles=None,systems=None,exclude_dns=None):
"""
Create bootable CD image to be used for network installations
"""
# setup all profiles/systems lists
all_profiles = [profile for profile in self.api.profiles()]
all_profiles.sort(self.sort_name)
all_systems = [system for system in self.api.systems()]
all_systems.sort(self.sort_name)
# convert input to lists
which_profiles = utils.input_string_or_list(profiles)
which_systems = utils.input_string_or_list(systems)
# no profiles/systems selection is made, let's process everything
do_all_systems = False
do_all_profiles = False
if len(which_profiles) == 0 and len(which_systems) == 0:
do_all_systems = True
do_all_profiles = True
# setup isolinux.cfg
isolinuxcfg = os.path.join(isolinuxdir, "isolinux.cfg")
cfg = open(isolinuxcfg, "w+")
cfg.write(self.iso_template)
# iterate through selected profiles
for profile in all_profiles:
if profile.name in which_profiles or do_all_profiles is True:
self.logger.info("processing profile: %s" % profile.name)
dist = profile.get_conceptual_parent()
distname = self.make_shorter(dist.name)
self.copy_boot_files(dist,isolinuxdir,distname)
cfg.write("\n")
cfg.write("LABEL %s\n" % profile.name)
cfg.write(" MENU LABEL %s\n" % profile.name)
cfg.write(" kernel %s.krn\n" % distname)
data = utils.blender(self.api, False, profile)
if data["kickstart"].startswith("/"):
data["kickstart"] = "http://%s:%s/cblr/svc/op/ks/profile/%s" % (
data["server"], self.api.settings().http_port, profile.name
)
append_line = " append initrd=%s.img" % distname
if dist.breed == "suse":
if data.has_key("proxy") and data["proxy"] != "":
append_line += " proxy=%s" % data["proxy"]
if data["kernel_options"].has_key("install") and data["kernel_options"]["install"] != "":
append_line += " install=%s" % data["kernel_options"]["install"]
del data["kernel_options"]["install"]
else:
append_line += " install=http://%s:%s/cblr/links/%s" % (
data["server"], self.api.settings().http_port, dist.name
)
if data["kernel_options"].has_key("autoyast") and data["kernel_options"]["autoyast"] != "":
append_line += " autoyast=%s" % data["kernel_options"]["autoyast"]
del data["kernel_options"]["autoyast"]
else:
append_line += " autoyast=%s" % data["kickstart"]
if dist.breed == "redhat":
if data.has_key("proxy") and data["proxy"] != "":
append_line += " proxy=%s http_proxy=%s" % (data["proxy"], data["proxy"])
append_line += " ks=%s" % data["kickstart"]
if dist.breed in ["ubuntu","debian"]:
append_line += " auto-install/enable=true url=%s" % data["kickstart"]
if data.has_key("proxy") and data["proxy"] != "":
append_line += " mirror/http/proxy=%s" % data["proxy"]
append_line += self.add_remaining_kopts(data["kernel_options"])
cfg.write(append_line)
cfg.write("\nMENU SEPARATOR\n")
# iterate through all selected systems
for system in all_systems:
if system.name in which_systems or do_all_systems is True:
self.logger.info("processing system: %s" % system.name)
profile = system.get_conceptual_parent()
dist = profile.get_conceptual_parent()
distname = self.make_shorter(dist.name)
self.copy_boot_files(dist,isolinuxdir,distname)
cfg.write("\n")
cfg.write("LABEL %s\n" % system.name)
cfg.write(" MENU LABEL %s\n" % system.name)
cfg.write(" kernel %s.krn\n" % distname)
data = utils.blender(self.api, False, system)
if data["kickstart"].startswith("/"):
data["kickstart"] = "http://%s:%s/cblr/svc/op/ks/system/%s" % (
data["server"], self.api.settings().http_port, system.name
)
append_line = " append initrd=%s.img" % distname
if dist.breed == "suse":
if data.has_key("proxy") and data["proxy"] != "":
append_line += " proxy=%s" % data["proxy"]
if data["kernel_options"].has_key("install") and data["kernel_options"]["install"] != "":
#.........这里部分代码省略.........
示例14: set_cnames
def set_cnames(self,cnames,interface):
intf = self.__get_interface(interface)
data = utils.input_string_or_list(cnames)
intf["cnames"] = data
return True
示例15: set_apt_dists
def set_apt_dists(self, value):
self.apt_dists = utils.input_string_or_list(value)
return True