diff options
| author | Brian Waldon <brian.waldon@rackspace.com> | 2011-08-02 10:24:23 -0400 |
|---|---|---|
| committer | Brian Waldon <brian.waldon@rackspace.com> | 2011-08-02 10:24:23 -0400 |
| commit | 1fc4c4cb9bdfca2cf6a931cec44fa25ee76c502d (patch) | |
| tree | 684ecf61f4469f34deb860a71e252ca213c04169 | |
| parent | 804bbc7656080597880e9705532ac161d3124aa4 (diff) | |
| download | nova-1fc4c4cb9bdfca2cf6a931cec44fa25ee76c502d.tar.gz nova-1fc4c4cb9bdfca2cf6a931cec44fa25ee76c502d.tar.xz nova-1fc4c4cb9bdfca2cf6a931cec44fa25ee76c502d.zip | |
abstraction of xml deserialization
| -rw-r--r-- | nova/api/openstack/create_instance_helper.py | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/nova/api/openstack/create_instance_helper.py b/nova/api/openstack/create_instance_helper.py index ea5d4af73..b0f422655 100644 --- a/nova/api/openstack/create_instance_helper.py +++ b/nova/api/openstack/create_instance_helper.py @@ -311,18 +311,15 @@ class ServerXMLDeserializer(wsgi.MetadataXMLDeserializer): return {'body': {action_name: action_data}} def _action_create_image(self, node): - data = {} - value = node.getAttribute('name') - if value: - data['name'] = value - metadata_node = self.find_first_child_named(node, 'metadata') - data['metadata'] = self.extract_metadata(metadata_node) - return data + return self._deserialize_image_action(node, ('name',)) def _action_create_backup(self, node): + attributes = ('name', 'backup_type', 'rotation') + return self._deserialize_image_action(node, attributes) + + def _deserialize_image_action(self, node, allowed_attribtues): data = {} - attributes = ['name', 'backup_type', 'rotation'] - for attribute in attributes: + for attribute in allowed_attributes: value = node.getAttribute(attribute) if value: data[attribute] = value |
