zone tests pass
This commit is contained in:
parent
f0c713658f
commit
7dddd46f01
|
@ -20,6 +20,7 @@ from novatools.images import ImageManager, Image
|
|||
from novatools.ipgroups import IPGroupManager, IPGroup
|
||||
from novatools.servers import (ServerManager, Server, REBOOT_HARD,
|
||||
REBOOT_SOFT)
|
||||
from novatools.zones import Zone, ZoneManager
|
||||
|
||||
|
||||
class OpenStack(object):
|
||||
|
@ -48,6 +49,7 @@ class OpenStack(object):
|
|||
self.images = ImageManager(self)
|
||||
self.ipgroups = IPGroupManager(self)
|
||||
self.servers = ServerManager(self)
|
||||
self.zones = ZoneManager(self)
|
||||
|
||||
def authenticate(self):
|
||||
"""
|
||||
|
|
|
@ -11,16 +11,17 @@ class Zone(base.Resource):
|
|||
"""
|
||||
self.manager.delete(self)
|
||||
|
||||
def update(self, name=None):
|
||||
def update(self, name=None, auth_url=None):
|
||||
"""
|
||||
Update the name for this child zone.
|
||||
|
||||
:param name: Update the child zone's name.
|
||||
:param auth_url: Update the child zone's Auth URL.
|
||||
"""
|
||||
self.manager.update(self, name)
|
||||
self.manager.update(self, name, auth_url)
|
||||
|
||||
|
||||
class ServerManager(base.ManagerWithFind):
|
||||
class ZoneManager(base.ManagerWithFind):
|
||||
resource_class = Zone
|
||||
|
||||
def get(self, zone):
|
||||
|
@ -58,3 +59,22 @@ class ServerManager(base.ManagerWithFind):
|
|||
"""
|
||||
self._delete("/zones/%s" % base.getid(zone))
|
||||
|
||||
def update(self, zone, name=None, auth_url=None):
|
||||
"""
|
||||
Update the name or the auth_url for a zone.
|
||||
|
||||
:param zone: The :class:`Zone` (or its ID) to update.
|
||||
:param name: Update the zone's name.
|
||||
:param auth_url: Update the Auth URL.
|
||||
"""
|
||||
|
||||
if name is None and auth_url is None:
|
||||
return
|
||||
body = {"zone": {}}
|
||||
if name:
|
||||
body["zone"]["name"] = name
|
||||
if auth_url:
|
||||
body["zone"]["auth_url"] = auth_url
|
||||
self._update("/zones/%s" % base.getid(zone), body)
|
||||
|
||||
|
||||
|
|
|
@ -368,3 +368,45 @@ class FakeClient(OpenStackClient):
|
|||
|
||||
def delete_shared_ip_groups_1(self, **kw):
|
||||
return (204, None)
|
||||
|
||||
#
|
||||
# Zones
|
||||
#
|
||||
def get_zones(self, **kw):
|
||||
return (200, {'zones': [
|
||||
{'id': 1, 'name': 'zone1'},
|
||||
{'id': 2, 'name': 'zone2'},
|
||||
]})
|
||||
|
||||
|
||||
def get_zones_detail(self, **kw):
|
||||
return (200, {'zones': [
|
||||
{'id': 1, 'name': 'zone1', 'auth_url': 'http://foo.com'},
|
||||
{'id': 2, 'name': 'zone2', 'auth_url': 'http://foo.com'},
|
||||
]})
|
||||
|
||||
def get_zones_1(self, **kw):
|
||||
r = {'zone': self.get_zones_detail()[1]['zones'][0]}
|
||||
return (200, r)
|
||||
|
||||
def get_zones_2(self, **kw):
|
||||
r = {'zone': self.get_zones_detail()[1]['zones'][1]}
|
||||
return (200, r)
|
||||
|
||||
def post_zones(self, body, **kw):
|
||||
assert_equal(body.keys(), ['zone'])
|
||||
assert_has_keys(body['zone'],
|
||||
required=['name', 'auth_url'],
|
||||
optional=[])
|
||||
|
||||
return (202, self.get_zones_1()[1])
|
||||
|
||||
def put_zones_1(self, body, **kw):
|
||||
assert_equal(body.keys(), ['zone'])
|
||||
assert_has_keys(body['zone'], optional=['name', 'auth_url'])
|
||||
return (204, None)
|
||||
|
||||
def delete_zones_1(self, **kw):
|
||||
return (202, None)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue