'Attached' both cobbler and koan patches.
Michael DeHaan wrote:
Adam Rosenwald wrote:
> Reposting with `git-format-patch` output (i.e. `git-format-patch -1`)...
> FYI, Adam.
>
>
>
Having fun with mail agents and word wrap -- not sure if it's on your
end or mine.
Can you /attach/ the patch rather than sending it inline?
Then we'll be set I hope :)
Sorry for all the complicatedness!
--Michael
> From ee8f57a87faa17daa4772befcd1fd26bf3b5a753 Mon Sep 17 00:00:00 2001
> From: ARos <thestrider@gmailcom>
> Date: Mon, 23 Mar 2009 21:52:31 +0000
> Subject: [PATCH] VM AutoBoot feature
>
> ---
> cobbler/collection.py | 1 +
> cobbler/item_image.py | 9 +++++++++
> cobbler/item_profile.py | 9 +++++++++
> cobbler/item_system.py | 9 +++++++++
> cobbler/remote.py | 2 ++
> cobbler/settings.py | 1 +
> cobbler/utils.py | 22 ++++++++++++++++++++++
> contrib/ruby/lib/cobbler/image.rb | 2 +-
> contrib/ruby/lib/cobbler/profile.rb | 1 +
> contrib/ruby/lib/cobbler/system.rb | 1 +
> contrib/ruby/test/test_image.rb | 2 ++
> contrib/ruby/test/test_profile.rb | 2 ++
> contrib/ruby/test/test_system.rb | 2 ++
> installer_templates/settings.template | 5 +++++
> webui_templates/image_edit.tmpl | 15 +++++++++++++++
> webui_templates/profile_edit.tmpl | 13 +++++++++++++
> webui_templates/search.tmpl | 3 +++
> webui_templates/system_edit.tmpl | 12 ++++++++++++
> 18 files changed, 110 insertions(+), 1 deletions(-)
>
_______________________________________________
cobbler-devel mailing list
cobbler-devel(a)lists.fedorahosted.org
https://fedorahosted.org/mailman/listinfo/cobbler-devel
From ee8f57a87faa17daa4772befcd1fd26bf3b5a753 Mon Sep 17 00:00:00 2001
From: ARos <aros(a)linkshare.com>
Date: Mon, 23 Mar 2009 21:52:31 +0000
Subject: [PATCH] VM AutoBoot feature
---
cobbler/collection.py | 1 +
cobbler/item_image.py | 9 +++++++++
cobbler/item_profile.py | 9 +++++++++
cobbler/item_system.py | 9 +++++++++
cobbler/remote.py | 2 ++
cobbler/settings.py | 1 +
cobbler/utils.py | 22 ++++++++++++++++++++++
contrib/ruby/lib/cobbler/image.rb | 2 +-
contrib/ruby/lib/cobbler/profile.rb | 1 +
contrib/ruby/lib/cobbler/system.rb | 1 +
contrib/ruby/test/test_image.rb | 2 ++
contrib/ruby/test/test_profile.rb | 2 ++
contrib/ruby/test/test_system.rb | 2 ++
installer_templates/settings.template | 5 +++++
webui_templates/image_edit.tmpl | 15 +++++++++++++++
webui_templates/profile_edit.tmpl | 13 +++++++++++++
webui_templates/search.tmpl | 3 +++
webui_templates/system_edit.tmpl | 12 ++++++++++++
18 files changed, 110 insertions(+), 1 deletions(-)
diff --git a/cobbler/collection.py b/cobbler/collection.py
index 36c58b0..dec7b76 100644
--- a/cobbler/collection.py
+++ b/cobbler/collection.py
@@ -105,6 +105,7 @@ class Collection(serializable.Serializable):
'inherit' : 'parent',
'ip' : 'ip_address',
'mac' : 'mac_address',
+ 'virt-auto-boot' : 'virt_auto_boot',
'virt-file-size' : 'virt_file_size',
'virt-ram' : 'virt_ram',
'virt-path' : 'virt_path',
diff --git a/cobbler/item_image.py b/cobbler/item_image.py
index 5a4123b..2deb280 100644
--- a/cobbler/item_image.py
+++ b/cobbler/item_image.py
@@ -49,6 +49,7 @@ class Image(item.Item):
self.file = ''
self.parent = ''
self.depth = 0
+ self.virt_auto_boot = self.settings.virt_auto_boot
self.virt_ram = self.settings.default_virt_ram
self.virt_file_size = self.settings.default_virt_file_size
self.virt_path = ''
@@ -75,6 +76,7 @@ class Image(item.Item):
self.depth = self.load_item(seed_data,'depth',0)
self.owners =
self.load_item(seed_data,'owners',self.settings.default_ownership)
+ self.virt_auto_boot = self.load_item(seed_data, 'virt_auto_boot',
self.settings.virt_auto_boot)
self.virt_ram = self.load_item(seed_data, 'virt_ram',
self.settings.default_virt_ram)
self.virt_file_size = self.load_item(seed_data, 'virt_file_size',
self.settings.default_virt_file_size)
self.virt_path = self.load_item(seed_data, 'virt_path')
@@ -189,6 +191,9 @@ class Image(item.Item):
raise CX("invalid network count")
return True
+ def set_virt_auto_boot(self,num):
+ return utils.set_virt_auto_boot(self,num)
+
def set_virt_file_size(self,num):
return utils.set_virt_file_size(self,num)
@@ -231,6 +236,7 @@ class Image(item.Item):
'depth' : 0,
'parent' : '',
'owners' : self.owners,
+ 'virt_auto_boot' : self.virt_auto_boot,
'virt_ram' : self.virt_ram,
'virt_path' : self.virt_path,
'virt_type' : self.virt_type,
@@ -263,6 +269,7 @@ class Image(item.Item):
buf = buf + _("virt bridge : %s\n") % self.virt_bridge
buf = buf + _("virt cpus : %s\n") % self.virt_cpus
buf = buf + _("network count : %s\n") % self.network_count
+ buf = buf + _("virt auto boot : %s\n") % self.virt_auto_boot
buf = buf + _("virt file size : %s\n") % self.virt_file_size
buf = buf + _("virt path : %s\n") % self.virt_path
buf = buf + _("virt ram : %s\n") % self.virt_ram
@@ -285,6 +292,8 @@ class Image(item.Item):
'virt_cpus' : self.set_virt_cpus,
'network-count' : self.set_network_count,
'network_count' : self.set_network_count,
+ 'virt-auto-boot' : self.set_virt_auto_boot,
+ 'virt_auto_boot' : self.set_virt_auto_boot,
'virt-file-size' : self.set_virt_file_size,
'virt_file_size' : self.set_virt_file_size,
'virt-bridge' : self.set_virt_bridge,
diff --git a/cobbler/item_profile.py b/cobbler/item_profile.py
index 3f9e946..7016038 100644
--- a/cobbler/item_profile.py
+++ b/cobbler/item_profile.py
@@ -53,6 +53,7 @@ class Profile(item.Item):
self.kernel_options_post = ({},
'<<inherit>>')[is_subobject]
self.ks_meta = ({},
'<<inherit>>')[is_subobject]
self.template_files = ({},
'<<inherit>>')[is_subobject]
+ self.virt_auto_boot = (self.settings.virt_auto_boot,
'<<inherit>>')[is_subobject]
self.virt_cpus = (1,
'<<inherit>>')[is_subobject]
self.virt_file_size = (self.settings.default_virt_file_size,
'<<inherit>>')[is_subobject]
self.virt_ram = (self.settings.default_virt_ram,
'<<inherit>>')[is_subobject]
@@ -117,6 +118,7 @@ class Profile(item.Item):
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)
+ self.virt_auto_boot =
self.load_item(seed_data,'virt_auto_boot',self.settings.virt_auto_boot)
# backwards compatibility -- convert string entries to dicts for storage
if self.kernel_options != "<<inherit>>" and
type(self.kernel_options) != dict:
@@ -234,6 +236,9 @@ class Profile(item.Item):
return True
raise CX(_("kickstart not found: %s") % kickstart)
+ def set_virt_auto_boot(self,num):
+ return utils.set_virt_auto_boot(self,num)
+
def set_virt_cpus(self,num):
return utils.set_virt_cpus(self,num)
@@ -303,6 +308,7 @@ class Profile(item.Item):
'virt_ram' : self.virt_ram,
'virt_bridge' : self.virt_bridge,
'virt_cpus' : self.virt_cpus,
+ 'virt_auto_boot' : self.virt_auto_boot,
'ks_meta' : self.ks_meta,
'template_files' : self.template_files,
'repos' : self.repos,
@@ -351,6 +357,7 @@ class Profile(item.Item):
buf = buf + _("repos : %s\n") % self.repos
buf = buf + _("server : %s\n") % self.server
buf = buf + _("template_files : %s\n") % self.template_files
+ buf = buf + _("virt auto boot : %s\n") % self.virt_auto_boot
buf = buf + _("virt bridge : %s\n") % self.virt_bridge
buf = buf + _("virt cpus : %s\n") % self.virt_cpus
buf = buf + _("virt file size : %s\n") % self.virt_file_size
@@ -372,6 +379,8 @@ class Profile(item.Item):
'kopts' : self.set_kernel_options,
'kopts-post' : self.set_kernel_options_post,
'kopts_post' : self.set_kernel_options_post,
+ 'virt-auto-boot' : self.set_virt_auto_boot,
+ 'virt_auto_boot' : self.set_virt_auto_boot,
'virt-file-size' : self.set_virt_file_size,
'virt_file_size' : self.set_virt_file_size,
'virt-ram' : self.set_virt_ram,
diff --git a/cobbler/item_system.py b/cobbler/item_system.py
index b7e7744..72ca4c0 100644
--- a/cobbler/item_system.py
+++ b/cobbler/item_system.py
@@ -58,6 +58,7 @@ class System(item.Item):
self.virt_cpus = "<<inherit>>" #
""
self.virt_file_size = "<<inherit>>" #
""
self.virt_ram = "<<inherit>>" #
""
+ self.virt_auto_boot = "<<inherit>>" #
""
self.virt_type = "<<inherit>>" #
""
self.virt_path = "<<inherit>>" #
""
self.virt_bridge = "<<inherit>>" #
""
@@ -186,6 +187,7 @@ class System(item.Item):
self.virt_path = self.load_item(seed_data, 'virt_path',
'<<inherit>>')
self.virt_type = self.load_item(seed_data, 'virt_type',
'<<inherit>>')
self.virt_ram =
self.load_item(seed_data,'virt_ram','<<inherit>>')
+ self.virt_auto_boot =
self.load_item(seed_data,'virt_auto_boot','<<inherit>>')
self.virt_file_size =
self.load_item(seed_data,'virt_file_size','<<inherit>>')
self.virt_path =
self.load_item(seed_data,'virt_path','<<inherit>>')
self.virt_type =
self.load_item(seed_data,'virt_type','<<inherit>>')
@@ -534,6 +536,9 @@ class System(item.Item):
def set_virt_file_size(self,num):
return utils.set_virt_file_size(self,num)
+ def set_virt_auto_boot(self,num):
+ return utils.set_virt_auto_boot(self,num)
+
def set_virt_ram(self,num):
return utils.set_virt_ram(self,num)
@@ -662,6 +667,7 @@ class System(item.Item):
'virt_file_size' : self.virt_file_size,
'virt_path' : self.virt_path,
'virt_ram' : self.virt_ram,
+ 'virt_auto_boot' : self.virt_auto_boot,
'virt_type' : self.virt_type,
'mgmt_classes' : self.mgmt_classes,
'template_files' : self.template_files,
@@ -707,6 +713,7 @@ class System(item.Item):
buf = buf + _("virt file size : %s\n") % self.virt_file_size
buf = buf + _("virt path : %s\n") % self.virt_path
buf = buf + _("virt ram : %s\n") % self.virt_ram
+ buf = buf + _("virt auto boot : %s\n") % self.virt_auto_boot
buf = buf + _("virt type : %s\n") % self.virt_type
buf = buf + _("power type : %s\n") % self.power_type
@@ -781,6 +788,8 @@ class System(item.Item):
'delete_interface' : self.delete_interface,
'virt-path' : self.set_virt_path,
'virt_path' : self.set_virt_path,
+ 'virt-auto-boot' : self.set_virt_auto_boot,
+ 'virt_auto_boot' : self.set_virt_auto_boot,
'virt-ram' : self.set_virt_ram,
'virt_ram' : self.set_virt_ram,
'virt-type' : self.set_virt_type,
diff --git a/cobbler/remote.py b/cobbler/remote.py
index eaf3d41..35f7cbb 100644
--- a/cobbler/remote.py
+++ b/cobbler/remote.py
@@ -1979,6 +1979,7 @@ def test_xmlrpc_rw():
server.modify_profile(pid, "kickstart",
"/var/lib/cobbler/kickstarts/sample.ks", token)
server.modify_profile(pid, "kopts", { "level" : "11" },
token)
server.modify_profile(pid, "kopts-post", "noapic", token)
+ server.modify_profile(pid, "virt-auto-boot", 0, token)
server.modify_profile(pid, "virt-file-size", 20, token)
server.modify_profile(pid, "virt-ram", 2048, token)
server.modify_profile(pid, "repos", [], token)
@@ -2050,6 +2051,7 @@ def test_xmlrpc_rw():
server.modify_image(iid, "arch", "x86_64", token)
server.modify_image(iid, "file", "nfs://server/path/to/x.iso",
token)
server.modify_image(iid, "owners", [ "alex", "michael"
], token)
+ server.modify_image(iid, "virt-auto-boot", 0, token)
server.modify_image(iid, "virt-cpus", 1, token)
server.modify_image(iid, "virt-file-size", 5, token)
server.modify_image(iid, "virt-bridge", "virbr0", token)
diff --git a/cobbler/settings.py b/cobbler/settings.py
index ce49d9c..576af2c 100644
--- a/cobbler/settings.py
+++ b/cobbler/settings.py
@@ -108,6 +108,7 @@ DEFAULTS = {
"tftpd_bin" : "/usr/sbin/in.tftpd",
"tftpd_conf" : "/etc/xinetd.d/tftp",
"tftpd_rules" : "/etc/tftpd.rules",
+ "virt_auto_boot" : 0,
"vsftpd_bin" : "/usr/sbin/vsftpd",
"webdir" : "/var/www/cobbler",
"xmlrpc_port" : 25151,
diff --git a/cobbler/utils.py b/cobbler/utils.py
index 72b438f..badc524 100644
--- a/cobbler/utils.py
+++ b/cobbler/utils.py
@@ -1177,6 +1177,28 @@ def set_virt_file_size(self,num):
raise CX(_("invalid virt file size"))
return True
+def set_virt_auto_boot(self,num):
+ """
+ For Virt only.
+ Specifies whether the VM should automatically boot upon host reboot
+ 0 tells Koan not to auto_boot virtuals
+ """
+
+ if num == "<<inherit>>":
+ self.virt_auto_boot = "<<inherit>>"
+ return True
+
+ # num is a non-negative integer (0 means default)
+ try:
+ inum = int(num)
+ if (inum == 0) or (inum == 1):
+ self.virt_auto_boot = inum
+ return True
+ return CX(_("invalid virt_auto_boot value: value must be either '0'
(disabled) or '1' (enabled)"))
+ except:
+ return CX(_("invalid virt_auto_boot value: value must be either '0'
(disabled) or '1' (enabled)"))
+ return True
+
def set_virt_ram(self,num):
"""
For Virt only.
diff --git a/contrib/ruby/lib/cobbler/image.rb b/contrib/ruby/lib/cobbler/image.rb
index ea9dddc..03493c9 100644
--- a/contrib/ruby/lib/cobbler/image.rb
+++ b/contrib/ruby/lib/cobbler/image.rb
@@ -32,7 +32,7 @@ module Cobbler
ATTRIBUTES = [:name, :owners, :depth, :virt_file_size,
:virt_path, :xml_file, :virt_bridge, :file, :parent,
- :image_type, :virt_ram, :virt_cpus, :virt_type, :network_count]
+ :image_type, :virt_ram, :virt_auto_boot, :virt_cpus, :virt_type, :network_count]
ATTRIBUTES.each do |attr|
cobbler_field attr
diff --git a/contrib/ruby/lib/cobbler/profile.rb b/contrib/ruby/lib/cobbler/profile.rb
index 9ee27df..438ea26 100644
--- a/contrib/ruby/lib/cobbler/profile.rb
+++ b/contrib/ruby/lib/cobbler/profile.rb
@@ -44,6 +44,7 @@ module Cobbler
cobbler_field :server
cobbler_field :virt_bridge
cobbler_field :virt_ram
+ cobbler_field :virt_auto_boot
cobbler_field :kernel_options
cobbler_field :virt_cpus
cobbler_field :ks_meta
diff --git a/contrib/ruby/lib/cobbler/system.rb b/contrib/ruby/lib/cobbler/system.rb
index 5751ede..b6d6cea 100644
--- a/contrib/ruby/lib/cobbler/system.rb
+++ b/contrib/ruby/lib/cobbler/system.rb
@@ -46,6 +46,7 @@ module Cobbler
cobbler_field :virt_file_size
cobbler_field :virt_path
cobbler_field :virt_ram
+ cobbler_field :virt_auto_boot
cobbler_field :virt_type
cobbler_field :virt_bridge
diff --git a/contrib/ruby/test/test_image.rb b/contrib/ruby/test/test_image.rb
index a29218f..53ff95c 100644
--- a/contrib/ruby/test/test_image.rb
+++ b/contrib/ruby/test/test_image.rb
@@ -47,6 +47,7 @@ module Cobbler
'virt_path' => '<<inherit>>',
'virt_bridge' => '<<inherit>>',
'virt_ram' => '<<inherit>>',
+ 'virt_auto_boot' => '<<inherit>>',
'virt_cpus' => '<<inherit>>',
'file' =>
'/var/ftp/pub/Fedora-9-i686-Live-KDE.iso',
'parent' => nil,
@@ -60,6 +61,7 @@ module Cobbler
'virt_path' => '<<inherit>>',
'virt_bridge' => '<<inherit>>',
'virt_ram' => '<<inherit>>',
+ 'virt_auto_boot' => '<<inherit>>',
'virt_cpus' => '<<inherit>>',
'file' => '/var/ftp/pub/Fedora-9-i686-Live.iso',
'parent' => nil,
diff --git a/contrib/ruby/test/test_profile.rb b/contrib/ruby/test/test_profile.rb
index 237f47b..76251a9 100644
--- a/contrib/ruby/test/test_profile.rb
+++ b/contrib/ruby/test/test_profile.rb
@@ -44,6 +44,7 @@ module Cobbler
'owners' => ['admin'],
'repos' => [],
'server' => '<<inherit>>',
+ 'virt auto boot' => 0,
'virt bridge' => 'xenbr0',
'virt cpus' => '1',
'virt file size' => '5',
@@ -62,6 +63,7 @@ module Cobbler
'owners' => ['admin'],
'repos' => [],
'server' => '<<inherit>>',
+ 'virt auto boot' => 0,
'virt bridge' => 'xenbr0',
'virt cpus' => '1',
'virt file size' => '5',
diff --git a/contrib/ruby/test/test_system.rb b/contrib/ruby/test/test_system.rb
index 727ea7e..db13bc3 100644
--- a/contrib/ruby/test/test_system.rb
+++ b/contrib/ruby/test/test_system.rb
@@ -67,6 +67,7 @@ module Cobbler
},
'virt_bridge' => '<<inherit>>',
'virt_ram' => '<<inherit>>',
+ 'virt_auto_boot' => '<<inherit>>',
'ks_meta' => nil,
'netboot_enabled' => 'True',
'kernel_options' => nil,
@@ -89,6 +90,7 @@ module Cobbler
'mac_address' => 'AA:BB:CC:DD:EE:FF'}},
'virt_bridge' => '<<inherit>>',
'virt_ram' => '<<inherit>>',
+ 'virt_auto_boot' => '<<inherit>>',
'ks_meta' => nil,
'netboot_enabled' => 'True',
'kernel_options' => nil,
diff --git a/installer_templates/settings.template
b/installer_templates/settings.template
index 51457a6..81ccdb4 100644
--- a/installer_templates/settings.template
+++ b/installer_templates/settings.template
@@ -346,6 +346,11 @@ anamon_enabled: 0
tftpd_bin: /usr/sbin/in.tftpd
tftpd_conf: /etc/xinetd.d/tftp
+# by default, profiles/systems will not be set to 'auto-boot' virtual systems;
+# i.e. if a physical system reboots, the virtual systems hosted on that
+# physical system will NOT be booted automatically.
+virt_auto_boot: 0
+
# cobbler's web directory. Don't change this setting -- see the
# Wiki on "relocating your cobbler install" if your /var partition
# is not large enough.
diff --git a/webui_templates/image_edit.tmpl b/webui_templates/image_edit.tmpl
index 8c369db..83a2c21 100644
--- a/webui_templates/image_edit.tmpl
+++ b/webui_templates/image_edit.tmpl
@@ -196,6 +196,21 @@ function disablename(value)
</td>
</tr>
+ ## self.virt_auto_boot = self.settings.virt_auto_boot
+
+ <tr>
+ <td>
+ <label for="virtautoboot">Virt AutoBoot</label>
+ </td>
+ <td>
+ <input type="text" size="5" style="width: 150px;"
name="virtautoboot" id="virtautoboot"
+ #if $image
+ value="$image.virt_auto_boot"
+ #end if
+ />
+ <p class="context-tip">For virtual installs only, enable/disable VM
autoboot.</p>
+ </td>
+ </tr>
## self.virt_file_size = self.settings.default_virt_file_size
<tr>
diff --git a/webui_templates/profile_edit.tmpl b/webui_templates/profile_edit.tmpl
index 1091de5..4cbc20a 100644
--- a/webui_templates/profile_edit.tmpl
+++ b/webui_templates/profile_edit.tmpl
@@ -299,6 +299,19 @@ function disablename(value)
<tr>
<td class="virtedit">
+ <label for="virtautoboot">Virt AutoBoot</label>
+ </td>
+ <td class="virtedit">
+ <input type="text" size="5" style="width: 150px;"
name="virtautoboot" id="virtautoboot"
+ #if $profile
+ value="$profile.virt_auto_boot"
+ #end if
+ />
+ <p class="context-tip">For virtual installs only, enable/disable VM
autoboot.</p>
+ </td>
+ </tr>
+ <tr>
+ <td class="virtedit">
<label for="virttype">Virt Type</label>
</td>
<td class="virtedit">
diff --git a/webui_templates/search.tmpl b/webui_templates/search.tmpl
index 44f1eb5..3f0adf0 100644
--- a/webui_templates/search.tmpl
+++ b/webui_templates/search.tmpl
@@ -58,6 +58,7 @@
<option value="redhat_management_server">red hat management
server</option>
<option value="repos">repos</option>
<option value="template_files">template files</option>
+ <option value="virt_auto_boot">virt autoboot</option>
<option value="virt_bridge">virt bridge</option>
<option value="virt_cpus">virt cpus</option>
<option value="virt_file_size">virt file size
(GB)</option>
@@ -104,6 +105,7 @@
<option value="static">static</option>
<option value="static_routes">static_routes</option>
<option value="template_files">template files</option>
+ <option value="virt_auto_boot">virt autoboot</option>
<option value="virt_bridge">virt bridge</option>
<option value="virt_cpus">virt cpus</option>
<option value="virt_file_size">virt file size
(GB)</option>
@@ -135,6 +137,7 @@
<option value="network_count">network count</option>
<option value="os_version">os version</option>
<option value="owners">owners</option>
+ <option value="virt_auto_boot">virt autoboot</option>
<option value="virt_ram">virt ram (MB)</option>
<option value="virt_path">virt path</option>
<option value="virt_type">virt type</option>
diff --git a/webui_templates/system_edit.tmpl b/webui_templates/system_edit.tmpl
index cf04725..b1d6335 100644
--- a/webui_templates/system_edit.tmpl
+++ b/webui_templates/system_edit.tmpl
@@ -646,6 +646,18 @@ redhatmanagementserver"
<tr>
<td class="virtedit">
+ <label for="virtautoboot">Virt AutoBoot</label>
+ </td>
+ <td class="virtedit">
+ <input type="text" size="5" style="width: 150px;"
name="virtautoboot" id="virtautoboot"
+ #if $system
+ value="$system.virt_auto_boot"
+ #end if
+ />
+ <p class="context-tip">For virtual installs only, enable/disable VM
autoboot.</p>
+ </td>
+ <tr>
+ <td class="virtedit">
<label for="virttype">Virt Type</label>
</td>
<td class="virtedit">
--
1.5.5.1
From 2a536e4b4f5e0bbc493728256eeb006d00a91736 Mon Sep 17 00:00:00 2001
From: ARos <aros(a)linkshare.com>
Date: Mon, 23 Mar 2009 22:37:31 +0000
Subject: [PATCH] VM AutoBoot
---
koan/app.py | 38 +++++++++++++++++++++++++-------------
koan/utils.py | 13 +++++++++++++
2 files changed, 38 insertions(+), 13 deletions(-)
diff --git a/koan/app.py b/koan/app.py
index cf49737..b74ca39 100755
--- a/koan/app.py
+++ b/koan/app.py
@@ -59,7 +59,7 @@ DISPLAY_PARAMS = [
"install_tree","kernel","initrd",
"kernel_options",
"repos",
- "virt_ram","virt_disk","virt_type",
"virt_path"
+ "virt_ram","virt_disk","virt_type",
"virt_path", "virt_auto_boot"
]
@@ -138,6 +138,10 @@ def main():
action="store_true",
dest="no_gfx",
help="disable Xen graphics (xenpv,xenfv)")
+ p.add_option("", "--auto-boot",
+ action="store_true",
+ dest="virt_auto_boot",
+ help="set VM for autoboot")
p.add_option("", "--add-reinstall-entry",
dest="add_reinstall_entry",
action="store_true",
@@ -180,6 +184,7 @@ def main():
k.use_kexec = options.use_kexec
k.should_poll = options.should_poll
k.embed_kickstart = options.embed_kickstart
+ k.virt_auto_boot = options.virt_auto_boot
if options.virt_name is not None:
k.virt_name = options.virt_name
@@ -1025,20 +1030,22 @@ class Koan:
path_list = self.calc_virt_path(pd, virtname)
size_list = self.calc_virt_filesize(pd)
disks = self.merge_disk_data(path_list,size_list)
+ virt_auto_boot = self.virt_auto_boot
results = create_func(
- name = virtname,
- ram = ram,
- disks = disks,
- uuid = uuid,
- extra = kextra,
- vcpus = vcpus,
- profile_data = profile_data,
- arch = arch,
- no_gfx = self.no_gfx,
- fullvirt = fullvirt,
- bridge = self.virt_bridge,
- virt_type = self.virt_type
+ name = virtname,
+ ram = ram,
+ disks = disks,
+ uuid = uuid,
+ extra = kextra,
+ vcpus = vcpus,
+ profile_data = profile_data,
+ arch = arch,
+ no_gfx = self.no_gfx,
+ fullvirt = fullvirt,
+ bridge = self.virt_bridge,
+ virt_type = self.virt_type,
+ virt_auto_boot = self.virt_auto_boot
)
print results
@@ -1071,6 +1078,11 @@ class Koan:
else:
raise InfoException("internal error, bad virt state")
+ if self.virt_auto_boot:
+ if self.virt_type in [ "xenpv", "xenfv" ]:
+ utils.create_xendomains_symlink(virtname)
+ # else qemu
+ # else...
return results
#---------------------------------------------------
diff --git a/koan/utils.py b/koan/utils.py
index 77e51fd..50b263a 100644
--- a/koan/utils.py
+++ b/koan/utils.py
@@ -377,6 +377,19 @@ def connect_to_server(server=None,port=None):
return server
raise InfoException ("Could not find Cobbler.")
+def create_xendomains_symlink(name):
+ """
+ Create an /etc/xen/auto/<name> symlink for use with
"xendomains"-style
+ VM boot upon dom0 reboot.
+ """
+ src = "/etc/xen/%s" % name
+ dst = "/etc/xen/auto/%s" % name
+
+ # check that xen config file exists and create symlink
+ if os.path.exists(src) and os.access(os.path.dirname(dst), os.W_OK):
+ os.symlink(src, dst)
+ else:
+ raise InfoException("Could not create /etc/xen/auto/%s symlink. Please
check write permissions and ownership" % name)
class ServerProxy(xmlrpclib.ServerProxy):
--
1.5.5.1