Skip to content

Commit

Permalink
Fetchable Files attribute:
Browse files Browse the repository at this point in the history
  Provides a new attribute similar in spirit to mgmt_files, but
  with somewhat reversed meaning.

  foo=bar

  means "if the client requests file foo, give them file bar".

The use case is for supporting installing freebsd, where the pxeboot loader
does not do pxelinux.0-like customization of the name requested.  This allows
you to add an attribute like "boot/kernel/kernel=$kernel boot/mfsroot=$initrd"
to the profile, and then a future cobber-aware tftp server could transparently
provide the right file to the pxeboot loader
  • Loading branch information
Douglas Kilpatrick authored and Scott Henson committed Jul 12, 2010
1 parent 3ef45e3 commit 253f7a9
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 1 deletion.
2 changes: 2 additions & 0 deletions cobbler/field_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"mgmt_classes",
"mgmt_parameters",
"template_files"
"fetchable_files"
]

# fields that use a multi select in the web app
Expand Down Expand Up @@ -129,6 +130,7 @@
"mgmt_classes" : "Management",
"mgmt_parameters" : "Management",
"template_files" : "Management",
"fetchable_files" : "Management",
"network_widget_a" : "Networking",
"network_widget_b" : "Networking",
"server" : "Advanced",
Expand Down
20 changes: 20 additions & 0 deletions cobbler/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,26 @@ def set_template_files(self,template_files,inplace=False):
self.template_files = value
return True

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


def sort_key(self,sort_fields=[]):
data = self.to_datastruct()
return [data.get(x,"") for x in sort_fields]
Expand Down
1 change: 1 addition & 0 deletions cobbler/item_distro.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
[ "comment","",0,"Comment",True,"Free form text description",0,"str"],
[ "tree_build_time",0,0,"Tree Build Time",False,"",0,"str"],
[ "mgmt_classes",[],0,"Management Classes",True,"Management classes for external config management",0,"list"],
[ "fetchable_files",{},0,"Fetchable Files",True,"Templates for tftp or wget",0,"list"],
[ "template_files",{},0,"Template Files",True,"File mappings for built-in config management",0,"list"],
[ "redhat_management_key","<<inherit>>",0,"Red Hat Management Key",True,"Registration key for RHN, Spacewalk, or Satellite",0,"str"],
[ "redhat_management_server", "<<inherit>>",0,"Red Hat Management Server",True,"Address of Spacewalk or Satellite Server",0,"str"]
Expand Down
1 change: 1 addition & 0 deletions cobbler/item_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
["name_servers_search","SETTINGS:default_name_servers_search",[],"Name Servers Search Path",True,"space delimited",0,"list"],
["mgmt_classes",[],'<<inherit>>',"Management Classes",True,"For external configuration management",0,"list"],
["mgmt_parameters","<<inherit>>","<<inherit>>","Management Parameters",True,"Parameters which will be handed to your management application (Must be valid YAML dictionary)", 0,"str"],
["fetchable_files",{},'<<inherit>>',"Fetchable Files",True,"Templates for tftp or wget",0,"dict"],
["template_files",{},'<<inherit>>',"Template Files",True,"File mappings for built-in config management",0,"dict"],
["redhat_management_key","<<inherit>>","<<inherit>>","Red Hat Management Key",True,"Registration key for RHN, Spacewalk, or Satellite",0,"str"],
["redhat_management_server","<<inherit>>","<<inherit>>","Red Hat Management Server",True,"Address of Spacewalk or Satellite Server",0,"str"],
Expand Down
1 change: 1 addition & 0 deletions cobbler/item_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
["*ipv6_default_gateway","",0,"IPv6 Default Gateway",True,"",0,"str"],
["mgmt_classes",[],0,"Management Classes",True,"For external config management",0,"list"],
["mgmt_parameters","<<inherit>>",0,"Management Parameters",True,"Parameters which will be handed to your management application (Must be valid YAML dictionary)", 0,"str"],
["fetchable_files",{},0,"Fetchable Files",True,"Templates for tftp or wget",0,"dict"],
["template_files",{},0,"Template Files",True,"File mappings for built-in configuration management",0,"dict"],
["redhat_management_key","<<inherit>>",0,"Red Hat Management Key",True,"Registration key for RHN, Satellite, or Spacewalk",0,"str"],
["redhat_management_server","<<inherit>>",0,"Red Hat Management Server",True,"Address of Satellite or Spacewalk Server",0,"str"],
Expand Down
3 changes: 2 additions & 1 deletion cobbler/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,7 @@ def xapi_object_edit(self,object_type,object_name,edit_type,attributes,token):

# in place modifications allow for adding a key/value pair while keeping other k/v
# pairs intact.
if k in [ "ks_meta", "kernel_options", "kernel_options_post", "template_files"] and attributes.has_key("in_place") and attributes["in_place"]:
if k in [ "ks_meta", "kernel_options", "kernel_options_post", "template_files", "fetchable_files"] and attributes.has_key("in_place") and attributes["in_place"]:
details = self.get_item(object_type,object_name)
v2 = details[k]
(ok, input) = utils.input_string_or_hash(v)
Expand Down Expand Up @@ -2171,6 +2171,7 @@ def test_xmlrpc_rw():
}, token)
server.modify_system(sid, "mgmt_classes", [ "one", "two", "three"], token)
server.modify_system(sid, "template_files", {}, token)
server.modify_system(sid, "fetchable_files", {}, token)
server.modify_system(sid, "comment", "...", token)
server.modify_system(sid, "power_address", "power.example.org", token)
server.modify_system(sid, "power_type", "ipmitool", token)
Expand Down
3 changes: 3 additions & 0 deletions cobbler/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,8 @@ def flatten(data):
data["ks_meta"] = hash_to_string(data["ks_meta"])
if data.has_key("template_files"):
data["template_files"] = hash_to_string(data["template_files"])
if data.has_key("fetchable_files"):
data["fetchable_files"] = hash_to_string(data["fetchable_files"])
if data.has_key("repos") and isinstance(data["repos"], list):
data["repos"] = " ".join(data["repos"])
if data.has_key("rpm_list") and isinstance(data["rpm_list"], list):
Expand Down Expand Up @@ -796,6 +798,7 @@ def __consolidate(node,results):
hash_removals(results,"kernel_options_post")
hash_removals(results,"ks_meta")
hash_removals(results,"template_files")
hash_removals(results,"fetchable_files")

def hash_removals(results,subkey):
if not results.has_key(subkey):
Expand Down
3 changes: 3 additions & 0 deletions web/cobbler_web/templates/paginate.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<option value="owners">owners</option>
<option value="redhat_management_key">red hat management key</option>
<option value="redhat_management_server">red hat management server</option>
<option value="fetchable_files">fetchable files</option>
<option value="template_files">template files</option>{% endifequal %}
{% ifequal what "profile" %}<option value="comment">comment</option>
<option value="dhcp_tag">dhcp tag</option>
Expand All @@ -49,6 +50,7 @@
<option value="redhat_management_key">red hat management key</option>
<option value="redhat_management_server">red hat management server</option>
<option value="repos">repos</option>
<option value="fetchable_files">fetchable files</option>
<option value="template_files">template files</option>
<option value="virt_auto_boot">virt autoboot</option>
<option value="virt_bridge">virt bridge</option>
Expand Down Expand Up @@ -92,6 +94,7 @@
<option value="subnet">subnet</option>
<option value="static">static</option>
<option value="static_routes">static_routes</option>
<option value="fetchable_files">fetchable files</option>
<option value="template_files">template files</option>
<option value="virt_auto_boot">virt autoboot</option>
<option value="virt_bridge">virt bridge</option>
Expand Down

0 comments on commit 253f7a9

Please sign in to comment.