Please contact your support team if you have a question or need assistance for any Rackspace products, services, or articles.
This question is not answered.
Hi,
I have made a script that can spawn an instance with a given flavor human ID (and "debian-testing-jessie-pvhvm" for the image).
It works fine with flavor "2gb-standard-instance" but it does not for "15-gb-compute-v1": In that case, I have the following error message:
Traceback (most recent call last): ....
server = compute_client.servers.create(name=name, image=debian_image, flavor=flavor, nics=nics) File "/home/fabien/.virtualenvs/pyrax/local/lib/python2.7/site-packages/novaclient/v2/servers.py", line 907, in create **boot_kwargs) File "/home/fabien/.virtualenvs/pyrax/local/lib/python2.7/site-packages/novaclient/v2/servers.py", line 531, in _boot return_raw=return_raw, **kwargs) File "/home/fabien/.virtualenvs/pyrax/local/lib/python2.7/site-packages/novaclient/base.py", line 161, in _create _resp, body = self.api.client.post(url, body=body) File "/home/fabien/.virtualenvs/pyrax/local/lib/python2.7/site-packages/novaclient/client.py", line 447, in post return self._cs_request(url, 'POST', **kwargs) File "/home/fabien/.virtualenvs/pyrax/local/lib/python2.7/site-packages/novaclient/client.py", line 422, in _cs_request resp, body = self._time_request(url, method, **kwargs) File "/home/fabien/.virtualenvs/pyrax/local/lib/python2.7/site-packages/novaclient/client.py", line 393, in _time_request resp, body = self.request(url, method, **kwargs) File "/home/fabien/.virtualenvs/pyrax/local/lib/python2.7/site-packages/novaclient/client.py", line 387, in request raise exceptions.from_response(resp, body, url, method)novaclient.exceptions.Forbidden: Policy doesn't allow compute_flavor:create:image_backed to be performed. (HTTP 403) (Request-ID: req-d...)
The source code looks like this:
import pyrax from os import environ username = environ.get('OS_USERNAME') tenant_id = environ.get('OS_TENANTID') api_key = environ.get('OS_APIKEY') ctx = pyrax.create_context(id_type='rackspace', username=username, tenant_id=tenant_id, api_key=api_key) ctx.authenticate() compute = ctx.get_client('compute', 'IAD') debian_image = compute.images.find(human_id='debian-testing-jessie-pvhvm') flavor = compute_client.flavors.find(human_id='15-gb-compute-v1') nics = network.get_server_networks(network.find(label='our-internal-network')) server = compute.servers.create(name='test', image=debian_image, flavor=flv, nics=nics)
While trying to find out why on the Internet, I saw that the same error occurred with people using knife for Chef: https://github.com/chef/knife-rackspace/pull/91
Note: with the user account used here I can create an instance using the Rackspace dashboard. But this is not what I want here.
Best regards,
Fabien
Racker
Fabien,
The problem appears to stem from the fact that you are trying to create a compute flavor which does not come with a boot disk. That error means that you have provided an image to use when building the server, but that the server does not have a boot disk.
You will need to specify the block_device_mapping_v2 charge to the create method when building the server, so that it can also create a block storage device at create time to use as it's boot device. Here is an example that should fit into your use case:
block_device_mapping_v2 = [{ 'boot_index': '0', 'delete_on_termination': True, 'destination_type': 'volume', 'uuid': pyrax.utils.get_id(debian_image), 'source_type': 'image', 'volume_size': '75',}]image = Noneserver = compute.servers.create('test', image, flv, nics=nics, block_device_mapping_v2=block_device_mapping_v2)
You can find more information about booting from volume at http://www.rackspace.com/knowledge_center/article/boot-a-server-from-a-cloud-block-storage-volume
- Matt
EDIT: I just noticed that I originally made block_device_mapping_v2 a dict. It should be a list of dicts.
HI Matt,
I've having the same problem.Supplying a block_device_mapping_v2 doesn't appear to work.This is basically what I have:
block_device_map = [{ 'boot_index': '0', 'source_type': 'image', 'destination_type': 'volume', 'delete_on_termination': True, 'uuid': pyrax.util.get_id(server.image_id), 'volume_size': server.boot_device['size'], 'device_name': 'vda' }] server.image_id = None rs.servers.create(server.name, server.image_id, server.flavor_id, meta=server.meta_data, files=server.files, nics=server.networks, block_device_mapping_v2=block_device_map)
When this code runs, I always get the following error: Invalid imageRef provided. (HTTP 400)I know the image id is good because I can build a volume using that same image id without issues (and I can't use that newly made volume as the boot device either). If I leave the image_id alone and don't clear it, then I'll get the error the OP posted. Simply adding the device map doesn't appear to work.
I've poured over the docs and must be missing something critical, any ideas?
These are the docs I've looked at:
https://developer.rackspace.com/docs/cloud-block-storage/v1/developer-guide/#create-volumehttps://www.rackspace.com/knowledge_center/article/boot-a-server-from-a-cloud-block-storage-volumehttps://developer.rackspace.com/docs/cloud-servers/v2/developer-guide/#document-extensions/ext-boot-from-volume
Ok, I figured out my problem.
This is a case of a typo in a key that causes no exceptions to be thrown, it just silently swallows it.I misspelled block_device_mapping_v2 as block_device_mappping_v2, no matter how many times I read that line, I didn't see the typo (brain autocorrect).Since the key was spelled wrong, it wasn't mapped into the body of the create request. Always leaving out the device mapping always causes the 400 "Invald imageRef" to be returned.
Posted in case someone else has this problem and doesn't see it.