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.7KB

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