summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorvladimir.p <vladimir@zadarastorage.com>2011-08-24 15:51:29 -0700
committervladimir.p <vladimir@zadarastorage.com>2011-08-24 15:51:29 -0700
commit48cd9689de31e408c792052747f714a9dbe1f8f7 (patch)
tree2ca4c06ed95a47ecce683b166baddbd4dcb145b8 /nova/api
parent2bc1e302910d9f66448618ddf140b72e85292d0f (diff)
added virtio flag; associate address for VSA; cosmetic changes. Prior to volume_types merge
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/contrib/drive_types.py1
-rw-r--r--nova/api/openstack/contrib/virtual_storage_arrays.py49
2 files changed, 47 insertions, 3 deletions
diff --git a/nova/api/openstack/contrib/drive_types.py b/nova/api/openstack/contrib/drive_types.py
index f2cbd3715..1aa65374f 100644
--- a/nova/api/openstack/contrib/drive_types.py
+++ b/nova/api/openstack/contrib/drive_types.py
@@ -2,7 +2,6 @@
# Copyright (c) 2011 Zadara Storage Inc.
# Copyright (c) 2011 OpenStack LLC.
-# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
diff --git a/nova/api/openstack/contrib/virtual_storage_arrays.py b/nova/api/openstack/contrib/virtual_storage_arrays.py
index d6c4a5ef4..81dbc9e1f 100644
--- a/nova/api/openstack/contrib/virtual_storage_arrays.py
+++ b/nova/api/openstack/contrib/virtual_storage_arrays.py
@@ -2,7 +2,6 @@
# Copyright (c) 2011 Zadara Storage Inc.
# Copyright (c) 2011 OpenStack LLC.
-# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
@@ -24,6 +23,7 @@ from webob import exc
from nova import vsa
from nova import volume
from nova import compute
+from nova import network
from nova import db
from nova import quota
from nova import exception
@@ -103,6 +103,7 @@ class VsaController(object):
def __init__(self):
self.vsa_api = vsa.API()
self.compute_api = compute.API()
+ self.network_api = network.API()
super(VsaController, self).__init__()
def _items(self, req, details):
@@ -186,6 +187,48 @@ class VsaController(object):
except exception.NotFound:
return faults.Fault(exc.HTTPNotFound())
+ def associate_address(self, req, id, body):
+ """ /zadr-vsa/{vsa_id}/associate_address
+ auto or manually associate an IP to VSA
+ """
+ context = req.environ['nova.context']
+
+ if body is None:
+ ip = 'auto'
+ else:
+ ip = body.get('ipAddress', 'auto')
+
+ LOG.audit(_("Associate address %(ip)s to VSA %(id)s"),
+ locals(), context=context)
+
+ try:
+ instances = self.compute_api.get_all(context,
+ search_opts={'metadata': dict(vsa_id=str(id))})
+
+ if instances is None or len(instances)==0:
+ return faults.Fault(exc.HTTPNotFound())
+
+ for instance in instances:
+ self.network_api.allocate_for_instance(context, instance, vpn=False)
+ return
+
+ except exception.NotFound:
+ return faults.Fault(exc.HTTPNotFound())
+
+ def disassociate_address(self, req, id, body):
+ """ /zadr-vsa/{vsa_id}/disassociate_address
+ auto or manually associate an IP to VSA
+ """
+ context = req.environ['nova.context']
+
+ if body is None:
+ ip = 'auto'
+ else:
+ ip = body.get('ipAddress', 'auto')
+
+ LOG.audit(_("Disassociate address from VSA %(id)s"),
+ locals(), context=context)
+
class VsaVolumeDriveController(volumes.VolumeController):
"""The base class for VSA volumes & drives.
@@ -515,7 +558,9 @@ class Virtual_storage_arrays(extensions.ExtensionDescriptor):
VsaController(),
collection_actions={'detail': 'GET'},
member_actions={'add_capacity': 'POST',
- 'remove_capacity': 'POST'})
+ 'remove_capacity': 'POST',
+ 'associate_address': 'POST',
+ 'disassociate_address': 'POST'})
resources.append(res)
res = extensions.ResourceExtension('volumes',