summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorRick Harris <rick.harris@rackspace.com>2011-02-16 02:44:37 +0000
committerRick Harris <rick.harris@rackspace.com>2011-02-16 02:44:37 +0000
commitb89f3826a63440cd6a1008326c65287ba530cb05 (patch)
tree9d8bdffaa11fe19e9d5077e7d980c831bcc675d7 /plugins
parentaf920572f42b07c3ea491015d30eb5001d1f735d (diff)
parent56df9b129526aad29ac1a751153d94cfe7656993 (diff)
Merging trunk part 1
Diffstat (limited to 'plugins')
-rwxr-xr-xplugins/xenserver/xenapi/etc/xapi.d/plugins/agent7
-rw-r--r--plugins/xenserver/xenapi/etc/xapi.d/plugins/glance14
-rw-r--r--plugins/xenserver/xenapi/etc/xapi.d/plugins/objectstore46
3 files changed, 42 insertions, 25 deletions
diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/agent b/plugins/xenserver/xenapi/etc/xapi.d/plugins/agent
index 12c3a19c8..031a49708 100755
--- a/plugins/xenserver/xenapi/etc/xapi.d/plugins/agent
+++ b/plugins/xenserver/xenapi/etc/xapi.d/plugins/agent
@@ -73,8 +73,8 @@ def key_init(self, arg_dict):
@jsonify
def password(self, arg_dict):
"""Writes a request to xenstore that tells the agent to set
- the root password for the given VM. The password should be
- encrypted using the shared secret key that was returned by a
+ the root password for the given VM. The password should be
+ encrypted using the shared secret key that was returned by a
previous call to key_init. The encrypted password value should
be passed as the value for the 'enc_pass' key in arg_dict.
"""
@@ -108,7 +108,8 @@ def _wait_for_agent(self, request_id, arg_dict):
# First, delete the request record
arg_dict["path"] = "data/host/%s" % request_id
xenstore.delete_record(self, arg_dict)
- raise TimeoutError("TIMEOUT: No response from agent within %s seconds." %
+ raise TimeoutError(
+ "TIMEOUT: No response from agent within %s seconds." %
AGENT_TIMEOUT)
ret = xenstore.read_record(self, arg_dict)
# Note: the response for None with be a string that includes
diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance b/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance
index ceb9a2185..47e094f02 100644
--- a/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance
+++ b/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance
@@ -352,7 +352,19 @@ def copy_kernel_vdi(session, 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')
+ if kernel_file:
+ os.remove(kernel_file)
+ if ramdisk_file:
+ os.remove(ramdisk_file)
+ return "ok"
+
+
if __name__ == '__main__':
XenAPIPlugin.dispatch({'upload_image': upload_image,
'download_image': download_image,
- 'copy_kernel_vdi': copy_kernel_vdi})
+ 'copy_kernel_vdi': copy_kernel_vdi,
+ 'remove_kernel_ramdisk': remove_kernel_ramdisk})
diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/objectstore b/plugins/xenserver/xenapi/etc/xapi.d/plugins/objectstore
index 8ee2f748d..d0313b4ed 100644
--- a/plugins/xenserver/xenapi/etc/xapi.d/plugins/objectstore
+++ b/plugins/xenserver/xenapi/etc/xapi.d/plugins/objectstore
@@ -43,34 +43,37 @@ SECTOR_SIZE = 512
MBR_SIZE_SECTORS = 63
MBR_SIZE_BYTES = MBR_SIZE_SECTORS * SECTOR_SIZE
-def is_vdi_pv(session,args):
+
+def is_vdi_pv(session, args):
logging.debug("Checking wheter VDI has PV kernel")
vdi = exists(args, 'vdi-ref')
- pv=with_vdi_in_dom0(session, vdi, False,
+ pv = with_vdi_in_dom0(session, vdi, False,
lambda dev: _is_vdi_pv('/dev/%s' % dev))
if pv:
return 'true'
else:
return 'false'
+
def _is_vdi_pv(dest):
- logging.debug("Running pygrub against %s",dest)
- output=os.popen('pygrub -qn %s' % dest)
- pv=False
+ logging.debug("Running pygrub against %s", dest)
+ output = os.popen('pygrub -qn %s' % dest)
+ pv = False
for line in output.readlines():
#try to find kernel string
- m=re.search('(?<=kernel:)/.*(?:>)',line)
+ m = re.search('(?<=kernel:)/.*(?:>)', line)
if m:
- if m.group(0).find('xen')!=-1:
- pv=True
- logging.debug("PV:%d",pv)
- return pv
-
+ if m.group(0).find('xen') != -1:
+ pv = True
+ logging.debug("PV:%d", pv)
+ return pv
+
+
def get_vdi(session, args):
src_url = exists(args, 'src_url')
username = exists(args, 'username')
password = exists(args, 'password')
- raw_image=validate_bool(args, 'raw', 'false')
+ raw_image = validate_bool(args, 'raw', 'false')
add_partition = validate_bool(args, 'add_partition', 'false')
(proto, netloc, url_path, _, _, _) = urlparse.urlparse(src_url)
sr = find_sr(session)
@@ -88,16 +91,17 @@ def get_vdi(session, args):
vdi = create_vdi(session, sr, src_url, vdi_size, False)
with_vdi_in_dom0(session, vdi, False,
lambda dev: get_vdi_(proto, netloc, url_path,
- username, password, add_partition,raw_image,
+ username, password,
+ add_partition, raw_image,
virtual_size, '/dev/%s' % dev))
return session.xenapi.VDI.get_uuid(vdi)
-def get_vdi_(proto, netloc, url_path, username, password, add_partition,raw_image,
- virtual_size, dest):
+def get_vdi_(proto, netloc, url_path, username, password,
+ add_partition, raw_image, virtual_size, dest):
- #Salvatore: vdi should not be partitioned for raw images
- if (add_partition and not raw_image):
+ #vdi should not be partitioned for raw images
+ if add_partition and not raw_image:
write_partition(virtual_size, dest)
offset = (add_partition and not raw_image and MBR_SIZE_BYTES) or 0
@@ -144,7 +148,7 @@ def get_kernel(session, args):
password = exists(args, 'password')
(proto, netloc, url_path, _, _, _) = urlparse.urlparse(src_url)
-
+
dest = os.path.join(KERNEL_DIR, url_path[1:])
# Paranoid check against people using ../ to do rude things.
@@ -154,8 +158,8 @@ def get_kernel(session, args):
dirname = os.path.dirname(dest)
try:
os.makedirs(dirname)
- except os.error, e:
- if e.errno != errno.EEXIST:
+ except os.error, e:
+ if e.errno != errno.EEXIST:
raise
if not os.path.isdir(dirname):
raise Exception('Cannot make directory %s', dirname)
@@ -248,5 +252,5 @@ def download_all(response, length, dest_file, offset):
if __name__ == '__main__':
XenAPIPlugin.dispatch({'get_vdi': get_vdi,
- 'get_kernel': get_kernel,
+ 'get_kernel': get_kernel,
'is_vdi_pv': is_vdi_pv})