summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorNaveed Massjouni <naveedm9@gmail.com>2011-02-16 11:53:50 -0500
committerNaveed Massjouni <naveedm9@gmail.com>2011-02-16 11:53:50 -0500
commit163e81ac2bc2f9945273b0659ceb473767e5b19f (patch)
tree7084a9e7bff9d993faaf7282c71476487e834df0 /nova/api
parentac7eb23c88437fa30f0ab256f53ba8a2df6e7965 (diff)
This implements the blueprint 'Openstack API support for hostId':
https://blueprints.launchpad.net/nova/+spec/openstack-api-hostid Now instances will have a unique hostId which for now is just a hash of the host. If the instance does not have a host yet, the hostId will be ''.
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/servers.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py
index 17c5519a1..58eda53b9 100644
--- a/nova/api/openstack/servers.py
+++ b/nova/api/openstack/servers.py
@@ -15,6 +15,7 @@
# License for the specific language governing permissions and limitations
# under the License.
+import hashlib
import json
import traceback
@@ -65,7 +66,11 @@ def _translate_detail_keys(inst):
inst_dict['status'] = power_mapping[inst_dict['status']]
inst_dict['addresses'] = dict(public=[], private=[])
inst_dict['metadata'] = {}
- inst_dict['hostId'] = ''
+
+ if inst['host']:
+ inst_dict['hostId'] = hashlib.sha224(inst['host']).hexdigest()
+ else:
+ inst_dict['hostId'] = ''
return dict(server=inst_dict)