From 31a1c59ec2aa45400ded83d228af54b433910b8d Mon Sep 17 00:00:00 2001 From: Salvatore Orlando Date: Tue, 7 Dec 2010 14:36:49 +0000 Subject: first test commit --- plugins/xenapi/etc/xapi.d/plugins/objectstore | 1 + 1 file changed, 1 insertion(+) (limited to 'plugins') diff --git a/plugins/xenapi/etc/xapi.d/plugins/objectstore b/plugins/xenapi/etc/xapi.d/plugins/objectstore index 271e7337f..cbae1e552 100644 --- a/plugins/xenapi/etc/xapi.d/plugins/objectstore +++ b/plugins/xenapi/etc/xapi.d/plugins/objectstore @@ -77,6 +77,7 @@ def get_vdi(session, args): def get_vdi_(proto, netloc, url_path, username, password, add_partition, virtual_size, dest): + #Salvatore: vdi should not be partitioned for raw images if add_partition: write_partition(virtual_size, dest) -- cgit From 49a1cadd61b4badff0578ecd26adb57fb284ad9a Mon Sep 17 00:00:00 2001 From: Salvatore Orlando Date: Thu, 9 Dec 2010 16:42:52 +0000 Subject: raw instances can now be launched in xenapi (only as hvm at the moment) --- plugins/xenapi/etc/xapi.d/plugins/objectstore | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'plugins') diff --git a/plugins/xenapi/etc/xapi.d/plugins/objectstore b/plugins/xenapi/etc/xapi.d/plugins/objectstore index cbae1e552..071494160 100644 --- a/plugins/xenapi/etc/xapi.d/plugins/objectstore +++ b/plugins/xenapi/etc/xapi.d/plugins/objectstore @@ -48,6 +48,7 @@ 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') add_partition = validate_bool(args, 'add_partition', 'false') (proto, netloc, url_path, _, _, _) = urlparse.urlparse(src_url) @@ -69,19 +70,19 @@ 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, + 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, +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: + if (add_partition and not raw_image): write_partition(virtual_size, dest) - offset = add_partition and MBR_SIZE_BYTES or 0 + offset = (add_partition and MBR_SIZE_BYTES and not raw_image) or 0 get(proto, netloc, url_path, username, password, dest, offset) -- cgit From 41203e726fd3e43bcce7f800c6bf042e9dd70531 Mon Sep 17 00:00:00 2001 From: Salvatore Orlando Date: Tue, 14 Dec 2010 16:32:28 +0000 Subject: support for pv guests (in progress) --- plugins/xenapi/etc/xapi.d/plugins/objectstore | 30 +++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) (limited to 'plugins') diff --git a/plugins/xenapi/etc/xapi.d/plugins/objectstore b/plugins/xenapi/etc/xapi.d/plugins/objectstore index 071494160..bc9e783cf 100644 --- a/plugins/xenapi/etc/xapi.d/plugins/objectstore +++ b/plugins/xenapi/etc/xapi.d/plugins/objectstore @@ -43,25 +43,42 @@ SECTOR_SIZE = 512 MBR_SIZE_SECTORS = 63 MBR_SIZE_BYTES = MBR_SIZE_SECTORS * SECTOR_SIZE - +def is_vdi_pv(session,args): + logging.debug("Checking wheter VDI has PV kernel") + vdi = exists(args, 'vdi-ref') + pv=False + pv=with_vdi_in_dom0(session, vdi, False, + lambda dev: _is_vdi_pv('/dev/%s' % dev)) + return pv + +def _is_vdi_pv(dest): + logging.debug("Running pygrub against %s",dest) + output=os.popen('pygrub -qn %s' % dest) + pv=False + for line in output.readlines(): + logging.debug("line:",line) + #try to find kernel string + m=re.search('(?<=kernel:)/.*(?:>)',line) + if (m<>None): + 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') add_partition = validate_bool(args, 'add_partition', 'false') - (proto, netloc, url_path, _, _, _) = urlparse.urlparse(src_url) - sr = find_sr(session) if sr is None: raise Exception('Cannot find SR to write VDI to') - virtual_size = \ get_content_length(proto, netloc, url_path, username, password) if virtual_size < 0: raise Exception('Cannot get VDI size') - vdi_size = virtual_size if add_partition: # Make room for MBR. @@ -230,4 +247,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}) -- cgit From 1dfcd8e6cdd58a0737a8667f8d2b18190527657a Mon Sep 17 00:00:00 2001 From: Salvatore Orlando Date: Tue, 14 Dec 2010 17:02:43 +0000 Subject: nothing --- plugins/xenapi/etc/xapi.d/plugins/objectstore | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/xenapi/etc/xapi.d/plugins/objectstore b/plugins/xenapi/etc/xapi.d/plugins/objectstore index bc9e783cf..e748742b1 100644 --- a/plugins/xenapi/etc/xapi.d/plugins/objectstore +++ b/plugins/xenapi/etc/xapi.d/plugins/objectstore @@ -49,20 +49,26 @@ def is_vdi_pv(session,args): pv=False pv=with_vdi_in_dom0(session, vdi, False, lambda dev: _is_vdi_pv('/dev/%s' % dev)) + logging.debug("HERE - bye bye") return pv def _is_vdi_pv(dest): logging.debug("Running pygrub against %s",dest) output=os.popen('pygrub -qn %s' % dest) + logging.debug("HERE - 1") pv=False + logging.debug("HERE - 2") for line in output.readlines(): - logging.debug("line:",line) + #logging.debug("line:",line) + logging.debug("HERE - loop") #try to find kernel string m=re.search('(?<=kernel:)/.*(?:>)',line) if (m<>None): if m.group(0).find('xen')<>-1: pv=True + logging.debug("HERE - 3") logging.debug("PV:%d",pv) + logging.debug("HERE - 4") return pv def get_vdi(session, args): -- cgit From a6e1399dfb7ffc411876b537ad5a9b80122feacc Mon Sep 17 00:00:00 2001 From: Salvatore Orlando Date: Tue, 14 Dec 2010 17:16:58 +0000 Subject: nothing --- plugins/xenapi/etc/xapi.d/plugins/objectstore | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/xenapi/etc/xapi.d/plugins/objectstore b/plugins/xenapi/etc/xapi.d/plugins/objectstore index e748742b1..af653c495 100644 --- a/plugins/xenapi/etc/xapi.d/plugins/objectstore +++ b/plugins/xenapi/etc/xapi.d/plugins/objectstore @@ -50,7 +50,10 @@ def is_vdi_pv(session,args): pv=with_vdi_in_dom0(session, vdi, False, lambda dev: _is_vdi_pv('/dev/%s' % dev)) logging.debug("HERE - bye bye") - return pv + if (pv): + return 'true' + else: + return 'false' def _is_vdi_pv(dest): logging.debug("Running pygrub against %s",dest) -- cgit From eaf463e4cc15820a5a8b91a31266fee02438c2c9 Mon Sep 17 00:00:00 2001 From: Salvatore Orlando Date: Wed, 15 Dec 2010 14:27:07 +0000 Subject: removed temporary comment lines --- plugins/xenapi/etc/xapi.d/plugins/objectstore | 7 ------- 1 file changed, 7 deletions(-) (limited to 'plugins') diff --git a/plugins/xenapi/etc/xapi.d/plugins/objectstore b/plugins/xenapi/etc/xapi.d/plugins/objectstore index af653c495..c78f0b1d8 100644 --- a/plugins/xenapi/etc/xapi.d/plugins/objectstore +++ b/plugins/xenapi/etc/xapi.d/plugins/objectstore @@ -46,10 +46,8 @@ MBR_SIZE_BYTES = MBR_SIZE_SECTORS * SECTOR_SIZE def is_vdi_pv(session,args): logging.debug("Checking wheter VDI has PV kernel") vdi = exists(args, 'vdi-ref') - pv=False pv=with_vdi_in_dom0(session, vdi, False, lambda dev: _is_vdi_pv('/dev/%s' % dev)) - logging.debug("HERE - bye bye") if (pv): return 'true' else: @@ -58,20 +56,15 @@ def is_vdi_pv(session,args): def _is_vdi_pv(dest): logging.debug("Running pygrub against %s",dest) output=os.popen('pygrub -qn %s' % dest) - logging.debug("HERE - 1") pv=False - logging.debug("HERE - 2") for line in output.readlines(): #logging.debug("line:",line) - logging.debug("HERE - loop") #try to find kernel string m=re.search('(?<=kernel:)/.*(?:>)',line) if (m<>None): if m.group(0).find('xen')<>-1: pv=True - logging.debug("HERE - 3") logging.debug("PV:%d",pv) - logging.debug("HERE - 4") return pv def get_vdi(session, args): -- cgit From 9308d57ee06baab7eda304d0456544d1f9e587f0 Mon Sep 17 00:00:00 2001 From: Salvatore Orlando Date: Wed, 15 Dec 2010 17:35:56 +0000 Subject: final cleanup --- plugins/xenapi/etc/xapi.d/plugins/objectstore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/xenapi/etc/xapi.d/plugins/objectstore b/plugins/xenapi/etc/xapi.d/plugins/objectstore index c78f0b1d8..e17f1ba13 100644 --- a/plugins/xenapi/etc/xapi.d/plugins/objectstore +++ b/plugins/xenapi/etc/xapi.d/plugins/objectstore @@ -101,7 +101,7 @@ def get_vdi_(proto, netloc, url_path, username, password, add_partition,raw_imag if (add_partition and not raw_image): write_partition(virtual_size, dest) - offset = (add_partition and MBR_SIZE_BYTES and not raw_image) or 0 + offset = (add_partition and not raw_image and MBR_SIZE_BYTES) or 0 get(proto, netloc, url_path, username, password, dest, offset) -- cgit From 6c9ec94d0c9303316ad8f3347532eabf31ca8316 Mon Sep 17 00:00:00 2001 From: Salvatore Orlando Date: Fri, 17 Dec 2010 11:49:00 +0000 Subject: Code reviewed --- plugins/xenapi/etc/xapi.d/plugins/objectstore | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'plugins') diff --git a/plugins/xenapi/etc/xapi.d/plugins/objectstore b/plugins/xenapi/etc/xapi.d/plugins/objectstore index e17f1ba13..8ee2f748d 100644 --- a/plugins/xenapi/etc/xapi.d/plugins/objectstore +++ b/plugins/xenapi/etc/xapi.d/plugins/objectstore @@ -48,7 +48,7 @@ def is_vdi_pv(session,args): vdi = exists(args, 'vdi-ref') pv=with_vdi_in_dom0(session, vdi, False, lambda dev: _is_vdi_pv('/dev/%s' % dev)) - if (pv): + if pv: return 'true' else: return 'false' @@ -58,11 +58,10 @@ def _is_vdi_pv(dest): output=os.popen('pygrub -qn %s' % dest) pv=False for line in output.readlines(): - #logging.debug("line:",line) #try to find kernel string m=re.search('(?<=kernel:)/.*(?:>)',line) - if (m<>None): - if m.group(0).find('xen')<>-1: + if m: + if m.group(0).find('xen')!=-1: pv=True logging.debug("PV:%d",pv) return pv -- cgit