"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "cobbler/item_image.py" between
cobbler-2.8.4.tar.gz and cobbler-3.0.0.tar.gz

About: cobbler is a Linux installation and deployment server that allows for rapid setup of network installation environments. It can help with installation, DNS, DHCP, package updates, power management, configuration management orchestration, and much more.

item_image.py  (cobbler-2.8.4):item_image.py  (cobbler-3.0.0)
""" """
A Cobbler Image. Tracks a virtual or physical image, as opposed to a answer
file (kickstart) led installation.
Copyright 2006-2009, Red Hat, Inc and Others Copyright 2006-2009, Red Hat, Inc and Others
Michael DeHaan <michael.dehaan AT gmail> Michael DeHaan <michael.dehaan AT gmail>
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA 02110-1301 USA
""" """
import string import string
import utils
import item
from cexceptions import CX
from utils import _
# this datastructure is described in great detail in item_distro.py -- read the from cobbler import autoinstall_manager
comments there. from cobbler import item
from cobbler import utils
from cobbler.cexceptions import CX
from cobbler.utils import _
# this data structure is described in item.py
FIELDS = [ FIELDS = [
['name','',0,"Name",True,"",0,"str"], # non-editable in UI (internal)
['arch','i386',0,"Architecture",True,"",["i386","x86_64","ia64","s390","ppc"," ['ctime', 0, 0, "", False, "", 0, "float"],
ppc64","ppc64le", "arm"],"str"], ['depth', 0, 0, "", False, "", 0, "int"],
['breed','redhat',0,"Breed",True,"",utils.get_valid_breeds(),"str"], ['mtime', 0, 0, "", False, "", 0, "float"],
['comment','',0,"Comment",True,"Free form text description",0,"str"], ['parent', '', 0, "", False, "", 0, "str"],
['ctime',0,0,"",False,"",0,"float"], ['uid', "", 0, "", False, "", 0, "str"],
['mtime',0,0,"",False,"",0,"float"],
['file','',0,"File",True,"Path to local file or nfs://user@host:path",0,"str"] # editable in UI
, ['arch', 'x86_64', 0, "Architecture", True, "", utils.get_valid_archs(), "st
['depth',0,0,"",False,"",0,"int"], r"],
['image_type',"iso",0,"Image Type",True,"", ["iso","direct","memdisk","virt-im ['autoinstall', '', 0, "Automatic installation file", True, "Path to autoins
age"],"str"], #FIXME:complete? t/answer file template", 0, "str"],
['network_count',1,0,"Virt NICs",True,"",0,"int"], ['breed', 'redhat', 0, "Breed", True, "", utils.get_valid_breeds(), "str"],
['os_version','',0,"OS Version",True,"ex: rhel4",utils.get_valid_os_versions() ['comment', '', 0, "Comment", True, "Free form text description", 0, "str"],
,"str"], ['file', '', 0, "File", True, "Path to local file or nfs://user@host:path",
['owners',"SETTINGS:default_ownership",0,"Owners",True,"Owners list for authz_ 0, "str"],
ownership (space delimited)",[],"list"], ['image_type', "iso", 0, "Image Type", True, "", ["iso", "direct", "memdisk"
['parent','',0,"",False,"",0,"str"], , "virt-image"], "str"],
['kickstart','',0,"Kickstart",True,"Path to kickstart/answer file template",0, ['name', '', 0, "Name", True, "", 0, "str"],
"str"], ['network_count', 1, 0, "Virt NICs", True, "", 0, "int"],
['virt_auto_boot',"SETTINGS:virt_auto_boot",0,"Virt Auto Boot",True,"Auto boot ['os_version', '', 0, "OS Version", True, "ex: rhel4", utils.get_valid_os_ve
this VM?",0,"bool"], rsions(), "str"],
['virt_bridge',"SETTINGS:default_virt_bridge",0,"Virt Bridge",True,"",0,"str"] ['owners', "SETTINGS:default_ownership", 0, "Owners", True, "Owners list for
, authz_ownership (space delimited)", [], "list"],
['virt_cpus',1,0,"Virt CPUs",True,"",0,"int"], ['virt_auto_boot', "SETTINGS:virt_auto_boot", 0, "Virt Auto Boot", True, "Au
['virt_file_size',"SETTINGS:default_virt_file_size",0,"Virt File Size (GB)",Tr to boot this VM?", 0, "bool"],
ue,"",0,"float"], ['virt_bridge', "SETTINGS:default_virt_bridge", 0, "Virt Bridge", True, "",
["virt_disk_driver","SETTINGS:default_virt_disk_driver",0,"Virt Disk Driver Ty 0, "str"],
pe",True,"The on-disk format for the virtualization disk","raw","str"], ['virt_cpus', 1, 0, "Virt CPUs", True, "", 0, "int"],
['virt_path','',0,"Virt Path",True,"Ex: /directory or VolGroup00",0,"str"], ["virt_disk_driver", "SETTINGS:default_virt_disk_driver", 0, "Virt Disk Driv
['virt_ram',"SETTINGS:default_virt_ram",0,"Virt RAM (MB)",True,"",0,"int"], er Type", True, "The on-disk format for the virtualization disk", "raw", "str"],
['virt_type',"SETTINGS:default_virt_type",0,"Virt Type",True,"",["xenpv","xenf ['virt_file_size', "SETTINGS:default_virt_file_size", 0, "Virt File Size (GB
v","qemu","kvm", "vmware"],"str"], )", True, "", 0, "float"],
['uid',"",0,"",False,"",0,"str"] ['virt_path', '', 0, "Virt Path", True, "Ex: /directory or VolGroup00", 0, "
str"],
['virt_ram', "SETTINGS:default_virt_ram", 0, "Virt RAM (MB)", True, "", 0, "
int"],
['virt_type', "SETTINGS:default_virt_type", 0, "Virt Type", True, "", ["xenp
v", "xenfv", "qemu", "kvm", "vmware"], "str"],
] ]
class Image(item.Item): class Image(item.Item):
"""
A Cobbler Image. Tracks a virtual or physical image, as opposed to a answer
file (autoinst) led installation.
"""
TYPE_NAME = _("image") TYPE_NAME = _("image")
COLLECTION_TYPE = "image" COLLECTION_TYPE = "image"
#
# override some base class methods first (item.Item)
#
def make_clone(self): def make_clone(self):
ds = self.to_datastruct()
cloned = Image(self.config) _dict = self.to_dict()
cloned.from_datastruct(ds) cloned = Image(self.collection_mgr)
cloned.from_dict(_dict)
return cloned return cloned
def get_fields(self): def get_fields(self):
return FIELDS return FIELDS
def set_arch(self,arch): def get_parent(self):
"""
Images have no parent object.
"""
return None
#
# specific methods for item.Image
#
def set_arch(self, arch):
""" """
The field is mainly relevant to PXE provisioning. The field is mainly relevant to PXE provisioning.
see comments for set_arch in item_distro.py, this works the same. see comments for set_arch in item_distro.py, this works the same.
""" """
return utils.set_arch(self,arch) return utils.set_arch(self, arch)
def set_kickstart(self,kickstart): def set_autoinstall(self, autoinstall):
""" """
It may not make sense for images to have kickstarts. It really doesn't. Set the automatic installation file path, this must be a local file.
However if the image type is 'iso' koan can create a virtual floppy
and shove an answer file on it, to script an installation. This may
not be a kickstart per se, it might be a windows answer file (SIF) etc.
"""
if kickstart is None or kickstart == "" or kickstart == "delete":
self.kickstart = ""
return True
kickstart = utils.find_kickstart(kickstart)
if kickstart:
self.kickstart = kickstart
return True
raise CX(_("kickstart not found for image"))
def set_file(self,filename): It may not make sense for images to have automatic installation template
s.
It really doesn't. However if the image type is 'iso' koan can create a
virtual
floppy and shove an answer file on it, to script an installation. This
may
not be a automatic installation template per se, it might be a Windows a
nswer
file (SIF) etc.
@param str local automatic installation template file path
"""
autoinstall_mgr = autoinstall_manager.AutoInstallationManager(self.colle
ction_mgr)
self.autoinstall = autoinstall_mgr.validate_autoinstall_template_file_pa
th(autoinstall)
def set_file(self, filename):
""" """
Stores the image location. This should be accessible on all nodes Stores the image location. This should be accessible on all nodes
that need to access it. Format: can be one of the following: that need to access it. Format: can be one of the following:
* username:password@hostname:/path/to/the/filename.ext * username:password@hostname:/path/to/the/filename.ext
* username@hostname:/path/to/the/filename.ext * username@hostname:/path/to/the/filename.ext
* hostname:/path/to/the/filename.ext * hostname:/path/to/the/filename.ext
* /path/to/the/filename.ext * /path/to/the/filename.ext
""" """
uri = "" uri = ""
scheme = auth = hostname = path = "" auth = hostname = path = ""
# we'll discard the protocol if it's supplied, for legacy support # validate file location format
if filename.find("://") != -1: if filename.find("://") != -1:
scheme, uri = filename.split("://") raise CX("Invalid image file path location, it should not contain a
filename = uri protocol")
else: uri = filename
uri = filename
if filename.find("@") != -1: if filename.find("@") != -1:
auth, filename = filename.split("@") auth, filename = filename.split("@")
# extract the hostname # extract the hostname
# 1. if we have a colon, then everything before it is a hostname # 1. if we have a colon, then everything before it is a hostname
# 2. if we don't have a colon, then check if we had a scheme; if # 2. if we don't have a colon, there is no hostname
# we did, then grab all before the first forward slash as the
# hostname; otherwise, we've got a bad file
if filename.find(":") != -1: if filename.find(":") != -1:
hostname, filename = filename.split(":") hostname, filename = filename.split(":")
elif filename[0] != '/': elif filename[0] != '/':
if len(scheme) > 0: raise CX(_("invalid file: %s" % filename))
index = filename.find("/")
hostname = filename[:index]
filename = filename[index:]
else:
raise CX(_("invalid file: %s" % filename))
# raise an exception if we don't have a valid path # raise an exception if we don't have a valid path
if len(filename) > 0 and filename[0] != '/': if len(filename) > 0 and filename[0] != '/':
raise CX(_("file contains an invalid path: %s" % filename)) raise CX(_("file contains an invalid path: %s" % filename))
if filename.find("/") != -1: if filename.find("/") != -1:
path, filename = filename.rsplit("/", 1) path, filename = filename.rsplit("/", 1)
if len(filename) == 0: if len(filename) == 0:
raise CX(_("missing filename")) raise CX(_("missing filename"))
if len(auth) > 0 and len(hostname) == 0: if len(auth) > 0 and len(hostname) == 0:
raise CX(_("a hostname must be specified with authentication details ")) raise CX(_("a hostname must be specified with authentication details "))
self.file = uri self.file = uri
return True
def set_os_version(self,os_version): def set_os_version(self, os_version):
return utils.set_os_version(self,os_version) return utils.set_os_version(self, os_version)
def set_breed(self,breed): def set_breed(self, breed):
return utils.set_breed(self,breed) return utils.set_breed(self, breed)
def set_image_type(self,image_type): def set_image_type(self, image_type):
""" """
Indicates what type of image this is. Indicates what type of image this is.
direct = something like "memdisk", physical only direct = something like "memdisk", physical only
iso = a bootable ISO that pxe's or can be used for virt installs, virtual only iso = a bootable ISO that pxe's or can be used for virt installs, virtual only
virt-clone = a cloned virtual disk (FIXME: not yet supported), virtual o nly virt-clone = a cloned virtual disk (FIXME: not yet supported), virtual o nly
memdisk = hdd image (physical only) memdisk = hdd image (physical only)
""" """
if not image_type in self.get_valid_image_types(): if image_type not in self.get_valid_image_types():
raise CX(_("image type must be on of the following: %s") % string.joi raise CX(_("image type must be on of the following: %s") % string.jo
n(self.get_valid_image_types(),", ")) in(self.get_valid_image_types(), ", "))
self.image_type = image_type self.image_type = image_type
return True
def set_virt_cpus(self,num): def set_virt_cpus(self, num):
return utils.set_virt_cpus(self,num) return utils.set_virt_cpus(self, num)
def set_network_count(self, num): def set_network_count(self, num):
if num is None or num == "": if num is None or num == "":
num = 1 num = 1
try: try:
self.network_count = int(num) self.network_count = int(num)
except: except:
raise CX("invalid network count (%s)" % num) raise CX("invalid network count (%s)" % num)
return True
def set_virt_auto_boot(self,num): def set_virt_auto_boot(self, num):
return utils.set_virt_auto_boot(self,num) return utils.set_virt_auto_boot(self, num)
def set_virt_file_size(self,num): def set_virt_file_size(self, num):
return utils.set_virt_file_size(self,num) return utils.set_virt_file_size(self, num)
def set_virt_disk_driver(self,driver): def set_virt_disk_driver(self, driver):
return utils.set_virt_disk_driver(self,driver) return utils.set_virt_disk_driver(self, driver)
def set_virt_ram(self,num): def set_virt_ram(self, num):
return utils.set_virt_ram(self,num) return utils.set_virt_ram(self, num)
def set_virt_type(self,vtype): def set_virt_type(self, vtype):
return utils.set_virt_type(self,vtype) return utils.set_virt_type(self, vtype)
def set_virt_bridge(self,vbridge): def set_virt_bridge(self, vbridge):
return utils.set_virt_bridge(self,vbridge) return utils.set_virt_bridge(self, vbridge)
def set_virt_path(self,path): def set_virt_path(self, path):
return utils.set_virt_path(self,path) return utils.set_virt_path(self, path)
def get_valid_image_types(self): def get_valid_image_types(self):
return ["direct","iso","memdisk","virt-clone"] return ["direct", "iso", "memdisk", "virt-clone"]
def get_parent(self): # EOF
"""
Return object next highest up the tree.
"""
return None # no parent
 End of changes. 34 change blocks. 
106 lines changed or deleted 122 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)