mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-08-22 18:00:35 +00:00
Create volume
This commit is contained in:
parent
1240294784
commit
29b52a6a70
3 changed files with 29 additions and 14 deletions
|
@ -12,9 +12,11 @@ class ManifestError(Exception):
|
||||||
return "{2}\n\tFile: {0}\n\tJSON path: {1}".format(self.manifest.path, path, self.message)
|
return "{2}\n\tFile: {0}\n\tJSON path: {1}".format(self.manifest.path, path, self.message)
|
||||||
return "{0}: {1}".format(self.manifest.path, self.message)
|
return "{0}: {1}".format(self.manifest.path, self.message)
|
||||||
|
|
||||||
|
|
||||||
class TaskListError(Exception):
|
class TaskListError(Exception):
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
self.message = message
|
self.message = message
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "Error in tasklist: {0}".format(self.message)
|
return "Error in tasklist: {0}".format(self.message)
|
||||||
|
|
||||||
|
class VolumeError(Exception):
|
||||||
|
pass
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
"volume": {
|
"volume": {
|
||||||
"backing" : "ebs",
|
"backing" : "ebs",
|
||||||
"filesystem": "ext4",
|
"filesystem": "ext4",
|
||||||
"size" : 1
|
"size" : 1024
|
||||||
},
|
},
|
||||||
"plugins": {
|
"plugins": {
|
||||||
"admin_user": {
|
"admin_user": {
|
||||||
|
|
|
@ -8,17 +8,30 @@ class CreateVolume(Task):
|
||||||
after = [Connect]
|
after = [Connect]
|
||||||
|
|
||||||
def run(self, info):
|
def run(self, info):
|
||||||
# info.conn.create_volume(50, "us-west-2")
|
volume_size = int(info.manifest.volume['size']/1024)
|
||||||
# volume_id=`euca-create-volume --size $volume_size --zone "$availability_zone" | awk '{print $2}'`
|
info.volume = info.conn.create_volume(volume_size, info.host['availabilityZone'])
|
||||||
# [ -z "$volume_id" ] && die "Unable to create volume."
|
|
||||||
# log "The EBS volume id is $volume_id"
|
|
||||||
|
|
||||||
# for package in info.host_packages:
|
class AttachVolume(Task):
|
||||||
# try:
|
description = 'Attaching the EBS volume'
|
||||||
# with open(devnull, 'w') as dev_null:
|
phase = phases.volume_creation
|
||||||
# subprocess.check_call(['/usr/bin/dpkg', '-s', package], stdout=dev_null, stderr=dev_null)
|
after = [CreateVolume]
|
||||||
# except subprocess.CalledProcessError:
|
|
||||||
# msg = "The package ``{0}\'\' is not installed".format(package)
|
def run(self, info):
|
||||||
# raise RuntimeError(msg)
|
def char_range(c1, c2):
|
||||||
pass
|
"""Generates the characters from `c1` to `c2`, inclusive."""
|
||||||
|
for c in xrange(ord(c1), ord(c2)+1):
|
||||||
|
yield chr(c)
|
||||||
|
|
||||||
|
import os.path
|
||||||
|
import os.stat
|
||||||
|
from stat import S_ISBLK
|
||||||
|
for letter in char_range('a', 'z'):
|
||||||
|
dev_path = os.path.join('/dev', 'xvd' + letter)
|
||||||
|
mode = os.stat(dev_path).st_mode
|
||||||
|
if S_ISBLK(mode):
|
||||||
|
info.bootstrap_device = {'path': dev_path}
|
||||||
|
break
|
||||||
|
if 'path' not in info.bootstrap_device:
|
||||||
|
raise VolumeError('Unable to find a free block device path for mounting the bootstrap volume')
|
||||||
|
info.conn.volume.attach(info.host['instanceId'], info.bootstrap_device['path'])
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue