summaryrefslogtreecommitdiffstats
path: root/nova
diff options
context:
space:
mode:
authorEldar Nugaev <enugaev@griddynamics.com>2011-06-16 17:30:36 +0400
committerEldar Nugaev <enugaev@griddynamics.com>2011-06-16 17:30:36 +0400
commitb10621f5f85cccde3d159afddb78398544d4c32e (patch)
tree9e5cb7c09afbd8046b39178e90bfedbc5edd3d90 /nova
parent57932d53e7cc5389b7d53fd8875a684f70e2eb67 (diff)
First implementation of FloatingIpController
Diffstat (limited to 'nova')
-rw-r--r--nova/db/api.py3
-rw-r--r--nova/db/sqlalchemy/api.py23
-rw-r--r--nova/network/api.py4
3 files changed, 30 insertions, 0 deletions
diff --git a/nova/db/api.py b/nova/db/api.py
index 4e0aa60a2..8348d90ae 100644
--- a/nova/db/api.py
+++ b/nova/db/api.py
@@ -223,6 +223,9 @@ def certificate_update(context, certificate_id, values):
###################
+def floating_ip_get(context, floating_ip_id):
+ return IMPL.floating_ip_get(context, floating_ip_id)
+
def floating_ip_allocate_address(context, host, project_id):
"""Allocate free floating ip and return the address.
diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py
index 73870d2f3..c3b517492 100644
--- a/nova/db/sqlalchemy/api.py
+++ b/nova/db/sqlalchemy/api.py
@@ -428,6 +428,29 @@ def certificate_update(context, certificate_id, values):
###################
+@require_context
+def floating_ip_get(context, ip_id):
+ session = get_session()
+ result = None
+ if is_admin_context(context):
+ result = session.query(models.FloatingIp).\
+ options(joinedload('fixed_ip')).\
+ options(joinedload_all('fixed_ip.instance')).\
+ filter_by(id=ip_id).\
+ filter_by(deleted=can_read_deleted(context)).\
+ first()
+ elif is_user_context(context):
+ result = session.query(models.FloatingIp).\
+ options(joinedload('fixed_ip')).\
+ options(joinedload_all('fixed_ip.instance')).\
+ filter_by(project_id=context.project_id).\
+ filter_by(id=ip_id).\
+ filter_by(deleted=False).\
+ first()
+ if not result:
+ raise exception.FloatingIpNotFound()
+
+ return result
@require_context
diff --git a/nova/network/api.py b/nova/network/api.py
index e2eacdf42..e5c4d6718 100644
--- a/nova/network/api.py
+++ b/nova/network/api.py
@@ -34,6 +34,10 @@ LOG = logging.getLogger('nova.network')
class API(base.Base):
"""API for interacting with the network manager."""
+ def get(self, context, id):
+ rv = self.db.floating_ip_get(context)
+ return dict(rv.iteritems())
+
def allocate_floating_ip(self, context):
if quota.allowed_floating_ips(context, 1) < 1:
LOG.warn(_('Quota exceeeded for %s, tried to allocate '