tests working again for weight_scale/weight_offset
This commit is contained in:
parent
46855896a8
commit
2069b17f8b
@ -90,6 +90,12 @@ You'll find complete documentation on the shell by running
|
||||
root-password Change the root password for a server.
|
||||
show Show details about the given server.
|
||||
unrescue Unrescue a server.
|
||||
zone Show or edit a Child Zone
|
||||
zone-add Add a Child Zone.
|
||||
zone-boot Boot a server, considering Zones.
|
||||
zone-delete Remove a Child Zone.
|
||||
zone-info Show the capabilities for this Zone.
|
||||
zone-list List all the immediate Child Zones.
|
||||
|
||||
Optional arguments:
|
||||
--username USERNAME Defaults to env[NOVA_USERNAME].
|
||||
|
@ -680,6 +680,10 @@ class OpenStackShell(object):
|
||||
@arg('--zone_username', dest='zone_username', default=None,
|
||||
help='New zone username.')
|
||||
@arg('--password', dest='password', default=None, help='New password.')
|
||||
@arg('--weight_offset', dest='weight_offset', default=None,
|
||||
help='Child Zone weight offset.')
|
||||
@arg('--weight_scale', dest='weight_scale', default=None,
|
||||
help='Child Zone weight scale.')
|
||||
def do_zone(self, args):
|
||||
"""Show or edit a child zone. No zone arg for this zone."""
|
||||
zone = self.cs.zones.get(args.zone)
|
||||
@ -692,6 +696,10 @@ class OpenStackShell(object):
|
||||
zone_delta['username'] = args.zone_username
|
||||
if args.password:
|
||||
zone_delta['password'] = args.password
|
||||
if args.weight_offset:
|
||||
zone_delta['weight_offset'] = args.weight_offset
|
||||
if args.weight_scale:
|
||||
zone_delta['weight_scale'] = args.weight_scale
|
||||
if zone_delta:
|
||||
zone.update(**zone_delta)
|
||||
else:
|
||||
@ -706,10 +714,15 @@ class OpenStackShell(object):
|
||||
@arg('zone_username', metavar='<zone_username>',
|
||||
help='Authentication username.')
|
||||
@arg('password', metavar='<password>', help='Authentication password.')
|
||||
@arg('weight_offset', metavar='<weight_offset>',
|
||||
help='Child Zone weight offset.')
|
||||
@arg('weight_scale', metavar='<weight_scale>',
|
||||
help='Child Zone weight scale.')
|
||||
def do_zone_add(self, args):
|
||||
"""Add a new child zone."""
|
||||
zone = self.cs.zones.create(args.api_url, args.zone_username,
|
||||
args.password)
|
||||
args.password, args.weight_offset,
|
||||
args.weight_scale)
|
||||
print_dict(zone._info)
|
||||
|
||||
@arg('zone', metavar='<zone name>', help='Name or ID of the zone')
|
||||
|
@ -49,15 +49,19 @@ class Zone(base.Resource):
|
||||
"""
|
||||
self.manager.delete(self)
|
||||
|
||||
def update(self, api_url=None, username=None, password=None):
|
||||
def update(self, api_url=None, username=None, password=None,
|
||||
weight_offset=None, weight_scale=None):
|
||||
"""
|
||||
Update the name for this child zone.
|
||||
|
||||
:param api_url: Update the child zone's API URL.
|
||||
:param username: Update the child zone's username.
|
||||
:param password: Update the child zone's password.
|
||||
:param weight_offset: Update the child zone's weight offset.
|
||||
:param weight_scale: Update the child zone's weight scale.
|
||||
"""
|
||||
self.manager.update(self, api_url, username, password)
|
||||
self.manager.update(self, api_url, username, password,
|
||||
weight_offset, weight_scale)
|
||||
|
||||
|
||||
class ZoneManager(base.BootingManagerWithFind):
|
||||
@ -90,18 +94,23 @@ class ZoneManager(base.BootingManagerWithFind):
|
||||
detail = "/detail"
|
||||
return self._list("/zones%s" % detail, "zones")
|
||||
|
||||
def create(self, api_url, username, password):
|
||||
def create(self, api_url, username, password,
|
||||
weight_offset=0.0, weight_scale=1.0):
|
||||
"""
|
||||
Create a new child zone.
|
||||
|
||||
:param api_url: The child zone's API URL.
|
||||
:param username: The child zone's username.
|
||||
:param password: The child zone's password.
|
||||
:param weight_offset: The child zone's weight offset.
|
||||
:param weight_scale: The child zone's weight scale.
|
||||
"""
|
||||
body = {"zone": {
|
||||
"api_url": api_url,
|
||||
"username": username,
|
||||
"password": password,
|
||||
"weight_offset": weight_offset,
|
||||
"weight_scale": weight_scale
|
||||
}}
|
||||
|
||||
return self._create("/zones", body, "zone")
|
||||
@ -128,6 +137,8 @@ class ZoneManager(base.BootingManagerWithFind):
|
||||
by Nova for routing between Zones. Users cannot populate
|
||||
this field.
|
||||
:param reservation_id: a UUID for the set of servers being requested.
|
||||
:param min_count: minimum number of servers to create.
|
||||
:param max_count: maximum number of servers to create.
|
||||
"""
|
||||
if not min_count:
|
||||
min_count = 1
|
||||
@ -156,7 +167,8 @@ class ZoneManager(base.BootingManagerWithFind):
|
||||
"""
|
||||
self._delete("/zones/%s" % base.getid(zone))
|
||||
|
||||
def update(self, zone, api_url=None, username=None, password=None):
|
||||
def update(self, zone, api_url=None, username=None, password=None,
|
||||
weight_offset=None, weight_scale=None):
|
||||
"""
|
||||
Update the name or the api_url for a zone.
|
||||
|
||||
@ -164,6 +176,8 @@ class ZoneManager(base.BootingManagerWithFind):
|
||||
:param api_url: Update the API URL.
|
||||
:param username: Update the username.
|
||||
:param password: Update the password.
|
||||
:param weight_offset: Update the child zone's weight offset.
|
||||
:param weight_scale: Update the child zone's weight scale.
|
||||
"""
|
||||
|
||||
body = {"zone": {}}
|
||||
@ -173,7 +187,10 @@ class ZoneManager(base.BootingManagerWithFind):
|
||||
body["zone"]["username"] = username
|
||||
if password:
|
||||
body["zone"]["password"] = password
|
||||
|
||||
if weight_offset:
|
||||
body["zone"]["weight_offset"] = weight_offset
|
||||
if weight_scale:
|
||||
body["zone"]["weight_scale"] = weight_scale
|
||||
if not len(body["zone"]):
|
||||
return
|
||||
self._update("/zones/%s" % base.getid(zone), body)
|
||||
|
@ -424,14 +424,16 @@ class FakeClient(OpenStackClient):
|
||||
assert_equal(body.keys(), ['zone'])
|
||||
assert_has_keys(body['zone'],
|
||||
required=['api_url', 'username', 'password'],
|
||||
optional=[])
|
||||
optional=['weight_offset', 'weight_scale'])
|
||||
|
||||
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=['api_url', 'username',
|
||||
'password'])
|
||||
'password',
|
||||
'weight_offset',
|
||||
'weight_scale'])
|
||||
return (204, None)
|
||||
|
||||
def delete_zones_1(self, **kw):
|
||||
|
@ -319,11 +319,12 @@ def test_zone():
|
||||
)
|
||||
|
||||
def test_zone_add():
|
||||
shell('zone-add http://zzz frank xxx')
|
||||
shell('zone-add http://zzz frank xxx 0.0 1.0')
|
||||
assert_called(
|
||||
'POST', '/zones',
|
||||
{'zone': {'api_url': 'http://zzz', 'username': 'frank',
|
||||
'password': 'xxx'}}
|
||||
'password': 'xxx',
|
||||
'weight_offset': '0.0', 'weight_scale': '1.0'}}
|
||||
)
|
||||
|
||||
def test_zone_delete():
|
||||
|
Loading…
x
Reference in New Issue
Block a user