summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael DeHaan <mdehaan@redhat.com>2007-10-10 17:41:48 -0400
committerMichael DeHaan <mdehaan@redhat.com>2007-10-10 17:41:48 -0400
commit01f22256f79191fd5d0f0e26e762a1c16afd8bc5 (patch)
treec3f4a2f5b0b9ebe3e1aea3b86cf07f1c46bd866d
parent45915cbb38b81eca62f3d3183ac990b1a91bcfd3 (diff)
downloadthird_party-cobbler-01f22256f79191fd5d0f0e26e762a1c16afd8bc5.tar.gz
third_party-cobbler-01f22256f79191fd5d0f0e26e762a1c16afd8bc5.tar.xz
third_party-cobbler-01f22256f79191fd5d0f0e26e762a1c16afd8bc5.zip
Support for setting virt-cpu number in cobbler + tests.
-rwxr-xr-xcobbler/cobbler.py1
-rw-r--r--cobbler/item_profile.py30
-rw-r--r--docs/cobbler.pod6
-rw-r--r--tests/tests.py10
4 files changed, 38 insertions, 9 deletions
diff --git a/cobbler/cobbler.py b/cobbler/cobbler.py
index b0e5886..e9c1a5f 100755
--- a/cobbler/cobbler.py
+++ b/cobbler/cobbler.py
@@ -440,6 +440,7 @@ class BootCLI:
'--virt-file-size' : lambda(a) : profile.set_virt_file_size(a),
'--virt-ram' : lambda(a) : profile.set_virt_ram(a),
'--virt-bridge' : lambda(a) : profile.set_virt_bridge(a),
+ '--virt-cpus' : lambda(a) : profile.set_virt_cpus(a),
'--ksmeta' : lambda(a) : profile.set_ksmeta(a),
'--repos' : lambda(a) : profile.set_repos(a),
'--virt-path' : lambda(a) : profile.set_virt_path(a),
diff --git a/cobbler/item_profile.py b/cobbler/item_profile.py
index 91e43e0..363f0de 100644
--- a/cobbler/item_profile.py
+++ b/cobbler/item_profile.py
@@ -38,6 +38,7 @@ class Profile(item.Item):
self.kickstart = (self.settings.default_kickstart , '<<inherit>>')[is_subobject]
self.kernel_options = ({}, '<<inherit>>')[is_subobject]
self.ks_meta = ({}, '<<inherit>>')[is_subobject]
+ self.virt_cpus = (1, '<<inherit>>')[is_subobject]
self.virt_file_size = (5, '<<inherit>>')[is_subobject]
self.virt_ram = (512, '<<inherit>>')[is_subobject]
self.repos = ([], '<<inherit>>')[is_subobject]
@@ -67,11 +68,13 @@ class Profile(item.Item):
self.set_repos(self.repos)
# virt specific
- self.virt_ram = self.load_item(seed_data,'virt_ram',512)
+ self.virt_ram = self.load_item(seed_data,'virt_ram',512)
self.virt_file_size = self.load_item(seed_data,'virt_file_size',5)
- self.virt_path = self.load_item(seed_data,'virt_path')
- self.virt_type = self.load_item(seed_data,'virt_type', self.settings.default_virt_type)
- self.virt_bridge = self.load_item(seed_data,'virt_bridge', self.settings.default_virt_bridge)
+ self.virt_path = self.load_item(seed_data,'virt_path')
+ self.virt_type = self.load_item(seed_data,'virt_type', self.settings.default_virt_type)
+ self.virt_bridge = self.load_item(seed_data,'virt_bridge', self.settings.default_virt_bridge)
+ self.virt_cpus = self.load_item(seed_data,'virt_cpus',1)
+
# backwards compatibility -- convert string entries to dicts for storage
if self.kernel_options != "<<inherit>>" and type(self.kernel_options) != dict:
self.set_kernel_options(self.kernel_options)
@@ -164,6 +167,22 @@ class Profile(item.Item):
return True
raise CX(_("kickstart not found"))
+ def set_virt_cpus(self,num):
+ """
+ For Virt only. Set the number of virtual CPUs to give to the
+ virtual machine. This is fed to virtinst RAW, so cobbler
+ will not yelp if you try to feed it 9999 CPUs. No formatting
+ like 9,999 please :)
+ """
+
+ try:
+ num = int(str(num))
+ except:
+ raise CX(_("invalid number of virtual CPUs"))
+
+ self.virt_cpus = num
+ return True
+
def set_virt_file_size(self,num):
"""
For Virt only.
@@ -280,6 +299,7 @@ class Profile(item.Item):
'virt_file_size' : self.virt_file_size,
'virt_ram' : self.virt_ram,
'virt_bridge' : self.virt_bridge,
+ 'virt_cpus' : self.virt_cpus,
'ks_meta' : self.ks_meta,
'repos' : self.repos,
'parent' : self.parent,
@@ -303,6 +323,7 @@ class Profile(item.Item):
buf = buf + _("virt type : %s\n") % self.virt_type
buf = buf + _("virt path : %s\n") % self.virt_path
buf = buf + _("virt bridge : %s\n") % self.virt_bridge
+ buf = buf + _("virt cpus : %s\n") % self.virt_cpus
buf = buf + _("repos : %s\n") % self.repos
buf = buf + _("dhcp tag : %s\n") % self.dhcp_tag
return buf
@@ -323,6 +344,7 @@ class Profile(item.Item):
'virt-type' : self.set_virt_type,
# FIXME: need to add to WUI
'virt-bridge' : self.set_virt_bridge,
+ 'virt-cpus' : self.set_virt_cpus,
'dhcp-tag' : self.set_dhcp_tag
}
diff --git a/docs/cobbler.pod b/docs/cobbler.pod
index 7c4165f..f399b0a 100644
--- a/docs/cobbler.pod
+++ b/docs/cobbler.pod
@@ -108,7 +108,7 @@ The file used for the answer file, regardless of the breed setting, is the value
A profile associates a distribution to additional specialized options, such as a kickstart automation file. Profiles are the core unit of provisioning and at least one profile must exist for every distribution to be provisioned. A profile might represent, for instance, a web server or desktop configuration. In this way, profiles define a role to be performed.
-B<cobbler profile add --name=string --distro=string [--kickstart=url] [--kopts=string] [--ksmeta=string] [--virt-file-size=gigabytes] [--virt-ram=megabytes] [--virt-type=string] [--virt-path=string] [--virt-bridge=string]>
+B<cobbler profile add --name=string --distro=string [--kickstart=url] [--kopts=string] [--ksmeta=string] [--virt-file-size=gigabytes] [--virt-ram=megabytes] [--virt-type=string] [--virt-cpus=integer] [--virt-path=string] [--virt-bridge=string]>
Arguments are as listed for distributions, save for the removal of "arch" and "breed", and with the additions listed below:
@@ -145,6 +145,10 @@ depending on what is given to --virt-path.
(Virt-only) Koan can install images using either Xen paravirt ("xenpv") or QEMU/KVM ("qemu"). Choose one or the other strings to specify, or values will default to attempting to find a compatible installation type on the client system ("auto"). See the "koan" manpage for more documentation. The default virt-type can be configured in the cobbler settings file such that this parameter does not have to be provided.
+=item virt-cpus
+
+(Virt-only) How many virtual CPUs should koan give the virtual machine? The default is 1.
+
=item virt-path
(Virt-only) Where to store the virtual image on the host system. Except for advanced cases, this parameter can usually be omitted. For disk images, the value is usually an absolute path to an existing directory with an optional file name component. There is support for specifying partitions "/dev/sda4" or volume groups "VolGroup00", etc.
diff --git a/tests/tests.py b/tests/tests.py
index b8870ae..d92905a 100644
--- a/tests/tests.py
+++ b/tests/tests.py
@@ -246,12 +246,14 @@ class Utilities(BootTest):
self.assertTrue(profile.set_distro("testdistro0"))
self.assertTrue(profile.set_kickstart("http://127.0.0.1/foo"))
self.assertTrue(profile.set_virt_bridge("xenbr1"))
- # no slashes or wildcards in name
# sizes must be integers
self.assertTrue(profile.set_virt_file_size("54321"))
- # temporarily commenting out failing test
- # self.failUnlessRaises(CobblerException, profile.set_virt_file_size, "huge")
- # self.failUnlessRaises(CobblerException, profile.set_virt_file_size, "54321.23")
+ self.failUnlessRaises(Exception, profile.set_virt_file_size, "huge")
+ self.failUnlessRaises(Exception, profile.set_virt_file_size, "54.321")
+ # cpus must be integers
+ self.assertTrue(profile.set_virt_cpus("2"))
+ self.failUnlessRaises(Exception, profile.set_virt_cpus, "3.14")
+ self.failUnlessRaises(Exception, profile.set_virt_cpus, "6.02*10^23")
self.assertTrue(self.api.profiles().add(profile))
def test_inheritance_and_variable_propogation(self):