-
Notifications
You must be signed in to change notification settings - Fork 487
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge "Add XML support for extensions_client"
- Loading branch information
Showing
5 changed files
with
58 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from lxml import etree | ||
from tempest.common.rest_client import RestClientXML | ||
from tempest.services.nova.xml.common import xml_to_json | ||
|
||
|
||
class ExtensionsClientXML(RestClientXML): | ||
|
||
def __init__(self, config, username, password, auth_url, tenant_name=None): | ||
super(ExtensionsClientXML, self).__init__(config, username, password, | ||
auth_url, tenant_name) | ||
self.service = self.config.compute.catalog_type | ||
|
||
def _parse_array(self, node): | ||
array = [] | ||
for child in node: | ||
array.append(xml_to_json(child)) | ||
return array | ||
|
||
def list_extensions(self): | ||
url = 'extensions' | ||
resp, body = self.get(url, self.headers) | ||
body = self._parse_array(etree.fromstring(body)) | ||
return resp, {'extensions': body} | ||
|
||
def is_enabled(self, extension): | ||
_, extensions = self.list_extensions() | ||
exts = extensions['extensions'] | ||
return any([e for e in exts if e['name'] == extension]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters