mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
volume create & attach method draft
This commit is contained in:
parent
27c0568e78
commit
80ef6e9a2d
@ -235,3 +235,22 @@ def create(vm_):
|
||||
))
|
||||
for key, val in data.__dict__.items():
|
||||
print(' {0}: {1}'.format(key, val))
|
||||
volumes = vm_.get('map_volumes')
|
||||
if volumes != {}:
|
||||
print ('Create and attach volumes to node {0}'.format(data.name))
|
||||
create_attach_volumes(volumes,location, data)
|
||||
|
||||
|
||||
def create_attach_volumes(volumes, location, data):
|
||||
conn = get_conn(location=location)
|
||||
node_avz = data.__dict__.get('extra').get('availability')
|
||||
for avz in conn.list_locations():
|
||||
if avz.availability_zone.name == node_avz:
|
||||
break
|
||||
for volume in volumes:
|
||||
volume_name= volume['device'] + " on " + data.name
|
||||
created_volume = conn.create_volume(volume['size'], volume_name, avz)
|
||||
attach = conn.attach_volume(data, created_volume, volume['device'])
|
||||
if attach:
|
||||
print created_volume.id + " attached to " + data.id + " aka " + data.name + " as device " + volume['device']
|
||||
print ('{0} attached to {1} (aka {2}) as device {3}'.format(created_volume.id, data.id, data.name, volume['device']))
|
||||
|
Loading…
Reference in New Issue
Block a user