SHOW:
|
|
- or go back to the newest paste.
| 1 | - | def upload_volume(self, volume_id, image_name): |
| 1 | + | import time |
| 2 | import urllib | |
| 3 | ||
| 4 | from lxml import etree | |
| 5 | ||
| 6 | from tempest.common.rest_client import RestClientXML | |
| 7 | from tempest import exceptions | |
| 8 | from tempest.services.compute.xml.common import Document | |
| 9 | from tempest.services.compute.xml.common import Element | |
| 10 | from tempest.services.compute.xml.common import Text | |
| 11 | - | volume = self.xml_to_json(etree.fromstring(body) |
| 11 | + | from tempest.services.compute.xml.common import xml_to_json |
| 12 | from tempest.services.compute.xml.common import XMLNS_11 | |
| 13 | ||
| 14 | ||
| 15 | class VolumesClientXML(RestClientXML): | |
| 16 | """ | |
| 17 | Client class to send CRUD Volume API requests to a Cinder endpoint | |
| 18 | """ | |
| 19 | ||
| 20 | def __init__(self, config, username, password, auth_url, tenant_name=None): | |
| 21 | super(VolumesClientXML, self).__init__(config, username, password, | |
| 22 | auth_url, tenant_name) | |
| 23 | self.service = self.config.volume.catalog_type | |
| 24 | self.build_interval = self.config.compute.build_interval | |
| 25 | self.build_timeout = self.config.compute.build_timeout | |
| 26 | ||
| 27 | def _parse_volume(self, body): | |
| 28 | vol = dict((attr, body.get(attr)) for attr in body.keys()) | |
| 29 | ||
| 30 | for child in body.getchildren(): | |
| 31 | else: | |
| 32 | vol[tag] = xml_to_json(child) | |
| 33 | return vol | |
| 34 | ||
| 35 | def upload_volume(self, volume_id, image_name): | |
| 36 | """Uploads a volume in Glance.""" | |
| 37 | post_body = Element("volume",
| |
| 38 | image_name=image_name, | |
| 39 | ) | |
| 40 | resp, body = self.post('os-volume_upload_image',
| |
| 41 | str(Document(post_body)), | |
| 42 | self.headers) | |
| 43 | url = 'volumes/%s/action' % (volume_id) | |
| 44 | resp, body = self.post(url, str(Document(post_body)), self.headers) | |
| 45 | volume = self.xml_to_json(etree.fromstring(body)) | |
| 46 | ||
| 47 | return resp, volume |