2012-01-09 14:49:12 -08:00
|
|
|
# Copyright (c) 2011 X.commerce, a business unit of eBay Inc.
|
2013-03-13 18:09:17 -04:00
|
|
|
# Copyright 2011 OpenStack Foundation
|
2011-08-24 22:51:53 -07:00
|
|
|
# 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
|
|
|
|
# a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
# License for the specific language governing permissions and limitations
|
|
|
|
# under the License.
|
|
|
|
|
2011-08-31 09:24:31 -04:00
|
|
|
from novaclient import base
|
2011-08-24 22:51:53 -07:00
|
|
|
|
|
|
|
|
|
|
|
class FloatingIP(base.Resource):
|
|
|
|
def delete(self):
|
2015-12-25 11:55:05 +09:00
|
|
|
"""
|
|
|
|
Delete this floating IP
|
|
|
|
|
|
|
|
:returns: An instance of novaclient.base.TupleWithMeta
|
|
|
|
"""
|
|
|
|
return self.manager.delete(self)
|
2011-08-24 22:51:53 -07:00
|
|
|
|
|
|
|
|
|
|
|
class FloatingIPManager(base.ManagerWithFind):
|
|
|
|
resource_class = FloatingIP
|
|
|
|
|
2015-06-15 15:25:37 -04:00
|
|
|
def list(self):
|
2015-12-07 17:35:19 +09:00
|
|
|
"""List floating IPs"""
|
2015-06-15 15:25:37 -04:00
|
|
|
return self._list("/os-floating-ips", "floating_ips")
|
2011-08-24 22:51:53 -07:00
|
|
|
|
2012-01-09 14:49:12 -08:00
|
|
|
def create(self, pool=None):
|
2015-12-07 17:35:19 +09:00
|
|
|
"""Create (allocate) a floating IP for a tenant"""
|
2012-01-09 14:49:12 -08:00
|
|
|
return self._create("/os-floating-ips", {'pool': pool}, "floating_ip")
|
2011-08-24 22:51:53 -07:00
|
|
|
|
|
|
|
def delete(self, floating_ip):
|
2015-12-07 17:35:19 +09:00
|
|
|
"""Delete (deallocate) a floating IP for a tenant
|
2011-08-24 22:51:53 -07:00
|
|
|
|
2015-01-17 08:51:36 +01:00
|
|
|
:param floating_ip: The floating IP address to delete.
|
2015-12-25 11:55:05 +09:00
|
|
|
:returns: An instance of novaclient.base.TupleWithMeta
|
2011-08-24 22:51:53 -07:00
|
|
|
"""
|
2015-12-25 11:55:05 +09:00
|
|
|
return self._delete("/os-floating-ips/%s" % base.getid(floating_ip))
|
2011-08-24 22:51:53 -07:00
|
|
|
|
|
|
|
def get(self, floating_ip):
|
2015-12-07 17:35:19 +09:00
|
|
|
"""Retrieve a floating IP"""
|
2011-08-24 22:51:53 -07:00
|
|
|
return self._get("/os-floating-ips/%s" % base.getid(floating_ip),
|
|
|
|
"floating_ip")
|