diff options
author | Michael DeHaan <mdehaan@redhat.com> | 2007-10-09 18:47:51 -0400 |
---|---|---|
committer | Michael DeHaan <mdehaan@redhat.com> | 2007-10-09 18:47:51 -0400 |
commit | 8b063147ff16bb9412e15f841c673fdc12d5abdb (patch) | |
tree | 0d2ea385417da9a3555c9508aa4501804bbe2978 /cobbler | |
parent | 39c585f8c699acf1f4cd8dfaeef8466ef6ead2f0 (diff) | |
download | third_party-cobbler-8b063147ff16bb9412e15f841c673fdc12d5abdb.tar.gz third_party-cobbler-8b063147ff16bb9412e15f841c673fdc12d5abdb.tar.xz third_party-cobbler-8b063147ff16bb9412e15f841c673fdc12d5abdb.zip |
The stringification problem appears to lie in the serializer, so explicitly use strings in the YAML
to pacify the XMLRPC bits. Plus, this is more readable.
Diffstat (limited to 'cobbler')
-rw-r--r-- | cobbler/action_sync.py | 4 | ||||
-rwxr-xr-x | cobbler/cobbler.py | 28 | ||||
-rw-r--r-- | cobbler/item_system.py | 46 | ||||
-rw-r--r-- | cobbler/utils.py | 2 |
4 files changed, 41 insertions, 39 deletions
diff --git a/cobbler/action_sync.py b/cobbler/action_sync.py index 67af0df..1403a36 100644 --- a/cobbler/action_sync.py +++ b/cobbler/action_sync.py @@ -628,7 +628,7 @@ class BootSync: ip = interface["ip_address"] - f1 = utils.get_config_filename(system,interface=counter) + f1 = utils.get_config_filename(system,interface=name) # for tftp only ... if distro.arch in [ "x86", "x86_64", "standard"]: @@ -640,7 +640,7 @@ class BootSync: if ip is not None and ip != "": print _("Warning: Itanium system object (%s) needs an IP address to PXE") % system.name - filename = "%s.conf" % utils.get_config_filename(system,interface=counter) + filename = "%s.conf" % utils.get_config_filename(system,interface=name) f2 = os.path.join(self.settings.tftpboot, filename) f3 = os.path.join(self.settings.webdir, "systems", f1) diff --git a/cobbler/cobbler.py b/cobbler/cobbler.py index 06c98a8..e1d36a3 100755 --- a/cobbler/cobbler.py +++ b/cobbler/cobbler.py @@ -502,29 +502,29 @@ class BootCLI: '--profile' : lambda(a) : sys.set_profile(a), '--kopts' : lambda(a) : sys.set_kernel_options(a), '--ksmeta' : lambda(a) : sys.set_ksmeta(a), - '--hostname' : lambda(a) : sys.set_hostname(a), - '--ip' : lambda(a) : sys.set_ip_address(a,interface=0), - '--mac' : lambda(a) : sys.set_mac_address(a,interface=0), - '--gateway' : lambda(a) : sys.set_gateway(a,interface=0), - '--subnet' : lambda(a) : sys.set_subnet(a,interface=0), - '--virt-bridge' : lambda(a) : sys.set_virt_bridge(a,interface=0), + '--hostname' : lambda(a) : sys.set_hostname(a,interface="intf0"), + '--ip' : lambda(a) : sys.set_ip_address(a,interface="intf0"), + '--mac' : lambda(a) : sys.set_mac_address(a,interface="intf0"), + '--gateway' : lambda(a) : sys.set_gateway(a,interface="intf0"), + '--subnet' : lambda(a) : sys.set_subnet(a,interface="intf0"), + '--virt-bridge' : lambda(a) : sys.set_virt_bridge(a,interface="intf0"), '--kickstart' : lambda(a) : sys.set_kickstart(a), '--netboot-enabled' : lambda(a) : sys.set_netboot_enabled(a), '--virt-path' : lambda(a) : sys.set_virt_path(a), '--virt-type' : lambda(a) : sys.set_virt_type(a), - '--dhcp-tag' : lambda(a) : sys.set_dhcp_tag(a) + '--dhcp-tag' : lambda(a) : sys.set_dhcp_tag(a,interface="intf0") } # add some command aliases for additional interfaces. The default commands # only operate on the first, which are all many folks will need. for count in range(0,7): - commands["--hostname%d" % count] = lambda(a) : sys.set_hostname(a,interface=count) - commands["--ip%d" % count] = lambda(a) : sys.set_ip_address(a,interface=count) - commands["--mac%d" % count] = lambda(a) : sys.set_mac_address(a,interface=count) - commands["--gateway%d" % count] = lambda(a) : sys.set_gateway(a,interface=count) - commands["--subnet%d" % count] = lambda(a) : sys.set_subnet(a,interface=count) - commands["--virt-bridge%d" % count] = lambda(a) : sys.set_virt_bridge(a,interface=count) - commands["--dhcp-tag%d" % count] = lambda(a) : sys.set_dhcp_tag(a,interface=count) + commands["--hostname%d" % count] = lambda(a) : sys.set_hostname(a,interface="intf%s" % count) + commands["--ip%d" % count] = lambda(a) : sys.set_ip_address(a,interface="intf%s" % count) + commands["--mac%d" % count] = lambda(a) : sys.set_mac_address(a,interface="intf%s" % count) + commands["--gateway%d" % count] = lambda(a) : sys.set_gateway(a,interface="intf%s" % count) + commands["--subnet%d" % count] = lambda(a) : sys.set_subnet(a,interface="intf%s" % count) + commands["--virt-bridge%d" % count] = lambda(a) : sys.set_virt_bridge(a,interface="intf%s" % count) + commands["--dhcp-tag%d" % count] = lambda(a) : sys.set_dhcp_tag(a,interface="intf%s" % count) def on_ok(): diff --git a/cobbler/item_system.py b/cobbler/item_system.py index 1a77e89..d8412b3 100644 --- a/cobbler/item_system.py +++ b/cobbler/item_system.py @@ -42,9 +42,12 @@ class System(item.Item): self.virt_type = "<<inherit>>" # use value in profile def __get_interface(self,name): - n = "%s" % name - if not self.interfaces.has_key(n): - self.interfaces[n] = { + + if name not in [ "intf0", "intf1", "intf2", "intf3", "intf4", "intf5", "intf6", "intf7" ]: + raise CX(_("internal error: invalid key for interface lookup or storage, must be 'intfX' where x is 0..7")) + + if not self.interfaces.has_key(name): + self.interfaces[name] = { "mac_address" : "", "ip_address" : "", "dhcp_tag" : "", @@ -53,7 +56,7 @@ class System(item.Item): "hostname" : "", "virt_bridge" : "" } - return self.interfaces[n] + return self.interfaces[name] def from_datastruct(self,seed_data): @@ -88,13 +91,13 @@ class System(item.Item): # before the upgrade if __hostname != "": - self.set_hostname(__hostname, "0") + self.set_hostname(__hostname, "intf0") if __mac_address != "": - self.set_mac_address(__mac_address, "0") + self.set_mac_address(__mac_address, "intf0") if __ip_address != "": - self.set_ip_address(__ip_address, "0") + self.set_ip_address(__ip_address, "intf0") if __dhcp_tag != "": - self.set_dhcp_tag(__dhcp_tag, "0") + self.set_dhcp_tag(__dhcp_tag, "intf0") # backwards compatibility -- convert string entries to dicts for storage # this allows for better usage from the API. @@ -123,7 +126,7 @@ class System(item.Item): Set the name. If the name is a MAC or IP, and the first MAC and/or IP is not defined, go ahead and fill that value in. """ - intf = self.__get_interface("0") + intf = self.__get_interface("intf0") if utils.is_mac(name): if intf["mac_address"] == "": @@ -135,7 +138,7 @@ class System(item.Item): return True - def get_mac_address(self,interface="0"): + def get_mac_address(self,interface="intf0"): """ Get the mac address, which may be implicit in the object name or explicit with --mac-address. Use the explicit location first. @@ -145,12 +148,12 @@ class System(item.Item): intf = self.__get_interface(interface) if intf["mac_address"] != "": return intf["mac_address"] - elif utils.is_mac(self.name) and interface == "0": + elif utils.is_mac(self.name) and interface == "intf0": return self.name else: return None - def get_ip_address(self,interface="0"): + def get_ip_address(self,interface="intf0"): """ Get the IP address, which may be implicit in the object name or explict with --ip-address. Use the explicit location first. @@ -159,12 +162,12 @@ class System(item.Item): intf = self.__get_interface(interface) if intf["ip_address"] != "": return intf["ip_address"] - elif utils.is_ip(self.name) and interface == "0": + elif utils.is_ip(self.name) and interface == "intf0": return self.name else: return None - def is_pxe_supported(self,interface="0"): + def is_pxe_supported(self,interface="intf0"): """ Can only add system PXE records if a MAC or IP address is available, else it's a koan only record. Actually Itanium goes beyond all this and needs the IP all of the time @@ -178,17 +181,17 @@ class System(item.Item): return False return True - def set_dhcp_tag(self,dhcp_tag,interface="0"): + def set_dhcp_tag(self,dhcp_tag,interface="intf0"): intf = self.__get_interface(interface) intf["dhcp_tag"] = dhcp_tag return True - def set_hostname(self,hostname,interface="0"): + def set_hostname(self,hostname,interface="intf0"): intf = self.__get_interface(interface) intf["hostname"] = hostname return True - def set_ip_address(self,address,interface="0"): + def set_ip_address(self,address,interface="intf0"): """ Assign a IP or hostname in DHCP when this MAC boots. Only works if manage_dhcp is set in /var/lib/cobbler/settings @@ -199,24 +202,24 @@ class System(item.Item): return True raise CX(_("invalid format for IP address (%s)") % address) - def set_mac_address(self,address,interface="0"): + def set_mac_address(self,address,interface="intf0"): intf = self.__get_interface(interface) if utils.is_mac(address): intf["mac_address"] = address return True raise CX(_("invalid format for MAC address (%s)" % address)) - def set_gateway(self,gateway,interface="0"): + def set_gateway(self,gateway,interface="intf0"): intf = self.__get_interface(interface) intf["gateway"] = gateway return True - def set_subnet(self,subnet,interface="0"): + def set_subnet(self,subnet,interface="intf0"): intf = self.__get_interface(interface) intf["subnet"] = subnet return True - def set_virt_bridge(self,bridge,interface="0"): + def set_virt_bridge(self,bridge,interface="intf0"): # FIXME: validate intf = self.__get_interface(interface) intf["virt_bridge"] = bridge @@ -343,7 +346,6 @@ class System(item.Item): buf = buf + _(" subnet : %s\n") % x.get("subnet","") buf = buf + _(" virt bridge : %s\n") % x.get("virt_bridge","") buf = buf + _(" dhcp tag : %s\n") % x.get("dhcp_tag","") - # buf = buf + _(" config id : %s\n") % utils.get_config_filename(self,counter) counter = counter + 1 diff --git a/cobbler/utils.py b/cobbler/utils.py index e85932d..b84140c 100644 --- a/cobbler/utils.py +++ b/cobbler/utils.py @@ -55,7 +55,7 @@ def get_host_ip(ip): results = out.read() return results.split(" ")[-1][0:8] -def get_config_filename(sys,interface=0): +def get_config_filename(sys,interface): """ The configuration file for each system pxe uses is either a form of the MAC address of the hex version of the IP. If none |