Ask Your Question

MarkHSAS's profile - activity

2018-02-07 15:18:23 -0500 received badge  Famous Question (source)
2018-02-02 08:30:27 -0500 received badge  Notable Question (source)
2018-01-31 21:08:52 -0500 received badge  Popular Question (source)
2018-01-30 10:01:11 -0500 asked a question Nova/Cinder - volume attached but inaccesible

I am using Python to create Openstack instances from base images, and I need to attach a volume in order to increase the available hard drive space. I can do this through the OpenStack web UI by selecting a volume size on the same tab that I select my source, and the instance comes up normally - when I teminal into the instance and df the system, I see the attached volume's extra space on /dev/vda as expected.

When I do this using the Nova and Cinder Python APIs, I can see reflected in the UI that my instance was created, and the volume is reporting as attached (eg, 'Attached to nova-test on /dev/vda' in the UI), but when I log on and df, I only see the amount of hard drive space available on the original source image - not the attached volume.

One difference is that when I create the instance in the UI, the image name is blank, presumably because I replaced the base image with a custom volume; the instance created through the Python API still shows the original source image. Ihave tried rebooting the image, and 'promoting' the volume, though neither have worked.

My code:

new_volume = my_cinder_client.volumes.create(this_size)
my_cinder_client.volumes.set_bootable(new_volume, flag=True)
new_server = my_nova_client.servers.create(host_name, base_image_id, flavor, volume=new_volume, key_name=key_pair, block_device_mapping={'vda':new_volume.__dict__['id']})
my_cinder_client.volumes.attach(volume=new_volume.__dict__['id'], instance_uuid=new_server.__dict__['id'], mountpoint='/dev/vda', mode='rw', host_name=host_name)

Any help/advice would be greatly appreciated. Thanks!