diff options
| author | Dongdong Zhou <dzhou121@gmail.com> | 2012-09-03 21:44:36 +0100 |
|---|---|---|
| committer | Dongdong Zhou <dzhou121@gmail.com> | 2012-09-04 16:56:43 +0100 |
| commit | c44ce398eacbd95331fb8990390a662cf4ce8f24 (patch) | |
| tree | 504318098d10f47b287a234d947b26dcca48e4f0 | |
| parent | 0318efe625682ee8703b91f363a966200503782f (diff) | |
| download | nova-c44ce398eacbd95331fb8990390a662cf4ce8f24.tar.gz nova-c44ce398eacbd95331fb8990390a662cf4ce8f24.tar.xz nova-c44ce398eacbd95331fb8990390a662cf4ce8f24.zip | |
Allow admins to de-allocate any floating IPs
Fix bug 1045508
Change-Id: Ie5be3748c16a592209934cc85777f534e84842bc
| -rw-r--r-- | nova/network/manager.py | 3 | ||||
| -rw-r--r-- | nova/tests/network/test_manager.py | 13 |
2 files changed, 16 insertions, 0 deletions
diff --git a/nova/network/manager.py b/nova/network/manager.py index f2af017df..d908b7a4c 100644 --- a/nova/network/manager.py +++ b/nova/network/manager.py @@ -388,6 +388,9 @@ class FloatingIP(object): def _floating_ip_owned_by_project(self, context, floating_ip): """Raises if floating ip does not belong to project""" + if context.is_admin: + return + if floating_ip['project_id'] != context.project_id: if floating_ip['project_id'] is None: LOG.warn(_('Address |%(address)s| is not allocated'), diff --git a/nova/tests/network/test_manager.py b/nova/tests/network/test_manager.py index bfe8d7a3b..31b600b16 100644 --- a/nova/tests/network/test_manager.py +++ b/nova/tests/network/test_manager.py @@ -581,6 +581,19 @@ class VlanNetworkTestCase(test.TestCase): 'project_id': ctxt.project_id} self.network._floating_ip_owned_by_project(ctxt, floating_ip) + ctxt = context.RequestContext(None, None, + is_admin=True) + + # does not raise (ctxt is admin) + floating_ip = {'address': '10.0.0.1', + 'project_id': None} + self.network._floating_ip_owned_by_project(ctxt, floating_ip) + + # does not raise (ctxt is admin) + floating_ip = {'address': '10.0.0.1', + 'project_id': 'testproject'} + self.network._floating_ip_owned_by_project(ctxt, floating_ip) + def test_allocate_floating_ip(self): ctxt = context.RequestContext('testuser', 'testproject', is_admin=False) |
