From 3d6e5d82e6cf70ae6e11c66d3e8ccadaccf93987 Mon Sep 17 00:00:00 2001 From: Salvatore Orlando Date: Tue, 8 Mar 2011 18:20:20 +0000 Subject: Removes VDIs from XenServer backend if spawn process fails before vm rec is created. Fixed pep8 errors. --- plugins/xenserver/xenapi/etc/xapi.d/plugins/glance | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'plugins') diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance b/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance index aa12d432a..4251461ae 100644 --- a/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance +++ b/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance @@ -351,18 +351,25 @@ def copy_kernel_vdi(session, args): _copy_kernel_vdi('/dev/%s' % dev, copy_args)) return filename - + def remove_kernel_ramdisk(session, args): """Removes kernel and/or ramdisk from dom0's file system""" - kernel_file = exists(args, 'kernel-file') - ramdisk_file = exists(args, 'ramdisk-file') + kernel_file = optional(args, 'kernel-file') + ramdisk_file = optional(args, 'ramdisk-file') if kernel_file: os.remove(kernel_file) + else: + kernel_uuid = optional(args, 'kernel-uuid') + if kernel_uuid: + os.remove(KERNEL_DIR + '/' + kernel_uuid) if ramdisk_file: os.remove(ramdisk_file) + else: + ramdisk_uuid = optional(args, 'ramdisk-uuid') + if ramdisk_uuid: + os.remove(KERNEL_DIR + '/' + ramdisk_uuid) return "ok" - if __name__ == '__main__': XenAPIPlugin.dispatch({'upload_vhd': upload_vhd, 'download_vhd': download_vhd, -- cgit From 748b3102320a9de3444b067aa783e8f3d7bc5f5c Mon Sep 17 00:00:00 2001 From: Salvatore Orlando Date: Wed, 9 Mar 2011 11:17:41 +0000 Subject: Fixed pep8 violation in glance plugin --- plugins/xenserver/xenapi/etc/xapi.d/plugins/glance | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance b/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance index 4251461ae..13f974fb9 100644 --- a/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance +++ b/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance @@ -351,7 +351,7 @@ def copy_kernel_vdi(session, args): _copy_kernel_vdi('/dev/%s' % dev, copy_args)) return filename - + def remove_kernel_ramdisk(session, args): """Removes kernel and/or ramdisk from dom0's file system""" kernel_file = optional(args, 'kernel-file') -- cgit From 381354babab58688458b2a6cdc463eb0a0fee461 Mon Sep 17 00:00:00 2001 From: Salvatore Orlando Date: Mon, 28 Mar 2011 13:11:45 +0100 Subject: addressed reviewers' concerns --- plugins/xenserver/xenapi/etc/xapi.d/plugins/glance | 1 + 1 file changed, 1 insertion(+) (limited to 'plugins') diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance b/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance index b12175845..1eed7e862 100644 --- a/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance +++ b/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance @@ -374,6 +374,7 @@ def remove_kernel_ramdisk(session, args): os.remove(ramdisk_file) return "ok" + if __name__ == '__main__': XenAPIPlugin.dispatch({'upload_vhd': upload_vhd, 'download_vhd': download_vhd, -- cgit From 31e3aed4a25e0525797c7fc6cbdce0fa652b3878 Mon Sep 17 00:00:00 2001 From: Ewan Mellor Date: Mon, 20 Jun 2011 20:33:15 -0700 Subject: Remove the unnecessary insertion of whitespace. This happens to be enough to match this patch apply on recent versions of XenServer / Xen Cloud Platform. --- .../xenserver/networking/etc/xensource/scripts/vif_5.6-fp1.patch | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'plugins') diff --git a/plugins/xenserver/networking/etc/xensource/scripts/vif_5.6-fp1.patch b/plugins/xenserver/networking/etc/xensource/scripts/vif_5.6-fp1.patch index feaf1312d..d42a11eff 100644 --- a/plugins/xenserver/networking/etc/xensource/scripts/vif_5.6-fp1.patch +++ b/plugins/xenserver/networking/etc/xensource/scripts/vif_5.6-fp1.patch @@ -8,7 +8,7 @@ fi ;; -@@ -224,9 +225,11 @@ +@@ -224,6 +225,7 @@ remove) if [ "${TYPE}" = "vif" ] ;then @@ -16,7 +16,3 @@ xenstore-rm "${HOTPLUG}/hotplug" fi logger -t scripts-vif "${dev} has been removed" - remove_from_bridge - ;; - esac -+ -- cgit From 42dabbc86e3af49215ced275d76d241b4daf8bdc Mon Sep 17 00:00:00 2001 From: Ed Leafe Date: Fri, 1 Jul 2011 19:44:10 +0000 Subject: Updated unit tests --- .../xenserver/xenapi/etc/xapi.d/plugins/xenhost | 45 +++++++++++++++++++--- 1 file changed, 39 insertions(+), 6 deletions(-) (limited to 'plugins') diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/xenhost b/plugins/xenserver/xenapi/etc/xapi.d/plugins/xenhost index a8428e841..13e62929a 100644 --- a/plugins/xenserver/xenapi/etc/xapi.d/plugins/xenhost +++ b/plugins/xenserver/xenapi/etc/xapi.d/plugins/xenhost @@ -33,9 +33,10 @@ import tempfile import time import XenAPIPlugin +import pluginlib_nova as pluginlib -from pluginlib_nova import * -configure_logging("xenhost") + +pluginlib.configure_logging("xenhost") host_data_pattern = re.compile(r"\s*(\S+) \([^\)]+\) *: ?(.*)") @@ -65,14 +66,45 @@ def _run_command(cmd): return proc.stdout.read() +def _get_host_uuid(): + cmd = "xe host-list | grep uuid" + resp = _run_command(cmd) + return resp.split(":")[-1].strip() + + +@jsonify +def set_host_enabled(self, arg_dict): + """Sets this host's ability to accept new instances. + It will otherwise continue to operate normally. + """ + enabled = arg_dict.get("enabled") + if enabled is None: + raise pluginlib.PluginError( + _("Missing 'enabled' argument to set_host_enabled")) + if enabled == "true": + result = _run_command("xe host-enable") + elif enabled == "false": + result = _run_command("xe host-disable") + else: + raise pluginlib.PluginError(_("Illegal enabled status: %s") % enabled) + # Should be empty string + if result: + raise pluginlib.PluginError(result) + # Return the current enabled status + host_uuid = _get_host_uuid() + cmd = "xe host-param-list uuid=%s | grep enabled" % host_uuid + resp = _run_command(cmd) + # Response should be in the format: "enabled ( RO): true" + status = resp.strip().split()[-1] + return {"status": status} + + @jsonify def host_data(self, arg_dict): """Runs the commands on the xenstore host to return the current status information. """ - cmd = "xe host-list | grep uuid" - resp = _run_command(cmd) - host_uuid = resp.split(":")[-1].strip() + host_uuid = _get_host_uuid() cmd = "xe host-param-list uuid=%s" % host_uuid resp = _run_command(cmd) parsed_data = parse_response(resp) @@ -180,4 +212,5 @@ def cleanup(dct): if __name__ == "__main__": XenAPIPlugin.dispatch( - {"host_data": host_data}) + {"host_data": host_data, + "set_host_enabled": set_host_enabled}) -- cgit From b02b1d78245634f81a27d0ba0a6e29024495c162 Mon Sep 17 00:00:00 2001 From: Ed Leafe Date: Tue, 5 Jul 2011 14:36:52 +0000 Subject: Updated the plugin to return the actual enabled status instead of just 'true' or 'false' . --- plugins/xenserver/xenapi/etc/xapi.d/plugins/xenhost | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/xenhost b/plugins/xenserver/xenapi/etc/xapi.d/plugins/xenhost index 13e62929a..292bbce12 100644 --- a/plugins/xenserver/xenapi/etc/xapi.d/plugins/xenhost +++ b/plugins/xenserver/xenapi/etc/xapi.d/plugins/xenhost @@ -95,7 +95,11 @@ def set_host_enabled(self, arg_dict): cmd = "xe host-param-list uuid=%s | grep enabled" % host_uuid resp = _run_command(cmd) # Response should be in the format: "enabled ( RO): true" - status = resp.strip().split()[-1] + host_enabled = resp.strip().split()[-1] + if host_enabled == "true": + status = "enabled" + else: + status = "disabled" return {"status": status} -- cgit