Diff comments:

> === modified file 'cloudinit/config/cc_disk_setup.py'
> --- cloudinit/config/cc_disk_setup.py 2015-07-22 19:14:33 +0000
> +++ cloudinit/config/cc_disk_setup.py 2015-10-19 14:33:26 +0000
> @@ -343,13 +345,16 @@
>  
>  
>  def get_mbr_hdd_size(device):
> -    size_cmd = [SFDISK_CMD, '--show-size', device]
> -    size = None
> +    size_cmd = [SFDISK_CMD, '-l', device]
>      try:
> -        size, _err = util.subp(size_cmd)
> +        output, _ = util.subp(size_cmd)
>      except Exception as e:
>          raise Exception("Failed to get %s size\n%s" % (device, e))
>  
> +    match = re.search(r'(?P<sector_count>\d+) sectors', output)
> +    if match is None:
> +        raise Exception("Failed to get %s size\n%s" % (device, e))
> +    size = match.groupdict()['sector_count']
>      return int(size.strip())

I considered both of those options, but didn't go for them because it isn't 
clear to me that sfdisk expects to use 512-byte sectors.

For example, if we had a disk that sfdisk treats as having 1024 byte sectors, 
all of our partition definitions would be out by a factor of two.

I have opted for parsing the output of sfdisk, because that seems like the best 
way of finding out how sfdisk views the disk in question.

Given all the stuff you do with curtin, you certainly have more knowledge in 
this area than me.  Am I missing something that would make this line of 
reasoning incorrect?

>  
>  


-- 
https://code.launchpad.net/~daniel-thewatkins/cloud-init/lp1460715/+merge/274897
Your team cloud init development team is requested to review the proposed merge 
of lp:~daniel-thewatkins/cloud-init/lp1460715 into lp:cloud-init.

_______________________________________________
Mailing list: https://launchpad.net/~cloud-init-dev
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~cloud-init-dev
More help   : https://help.launchpad.net/ListHelp

Reply via email to