OpenStack Compute (Nova) Client
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

fixed_ips.py 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. # Copyright 2012 IBM Corp.
  2. # All Rights Reserved.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License"); you may
  5. # not use this file except in compliance with the License. You may obtain
  6. # a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. # License for the specific language governing permissions and limitations
  14. # under the License.
  15. """
  16. Fixed IPs interface.
  17. """
  18. from novaclient import base
  19. class FixedIP(base.Resource):
  20. def __repr__(self):
  21. return "<FixedIP: %s>" % self.address
  22. class FixedIPsManager(base.Manager):
  23. resource_class = FixedIP
  24. def get(self, fixed_ip):
  25. """
  26. Show information for a Fixed IP
  27. :param fixed_ip: Fixed IP address to get info for
  28. """
  29. return self._get('/os-fixed-ips/%s' % base.getid(fixed_ip),
  30. "fixed_ip")
  31. def reserve(self, fixed_ip):
  32. """Reserve a Fixed IP
  33. :param fixed_ip: Fixed IP address to reserve
  34. """
  35. body = {"reserve": None}
  36. self.api.client.post('/os-fixed-ips/%s/action' % base.getid(fixed_ip),
  37. body=body)
  38. def unreserve(self, fixed_ip):
  39. """Unreserve a Fixed IP
  40. :param fixed_ip: Fixed IP address to unreserve
  41. """
  42. body = {"unreserve": None}
  43. self.api.client.post('/os-fixed-ips/%s/action' % base.getid(fixed_ip),
  44. body=body)