Not a member of Pastebin yet?
                        Sign Up,
                        it unlocks many cool features!                    
                - import time
 - import urllib
 - from lxml import etree
 - from tempest.common.rest_client import RestClientXML
 - from tempest import exceptions
 - from tempest.services.compute.xml.common import Document
 - from tempest.services.compute.xml.common import Element
 - from tempest.services.compute.xml.common import Text
 - from tempest.services.compute.xml.common import xml_to_json
 - from tempest.services.compute.xml.common import XMLNS_11
 - class VolumesClientXML(RestClientXML):
 - """
 - Client class to send CRUD Volume API requests to a Cinder endpoint
 - """
 - def __init__(self, config, username, password, auth_url, tenant_name=None):
 - super(VolumesClientXML, self).__init__(config, username, password,
 - auth_url, tenant_name)
 - self.service = self.config.volume.catalog_type
 - self.build_interval = self.config.compute.build_interval
 - self.build_timeout = self.config.compute.build_timeout
 - def _parse_volume(self, body):
 - vol = dict((attr, body.get(attr)) for attr in body.keys())
 - for child in body.getchildren():
 - else:
 - vol[tag] = xml_to_json(child)
 - return vol
 - def upload_volume(self, volume_id, image_name):
 - """Uploads a volume in Glance."""
 - post_body = Element("volume",
 - image_name=image_name,
 - )
 - resp, body = self.post('os-volume_upload_image',
 - str(Document(post_body)),
 - self.headers)
 - url = 'volumes/%s/action' % (volume_id)
 - resp, body = self.post(url, str(Document(post_body)), self.headers)
 - volume = self.xml_to_json(etree.fromstring(body))
 - return resp, volume
 
Advertisement
 
                    Add Comment                
                
                        Please, Sign In to add comment