Fix continuation line under/over indented problems
When you are writing a multiple method invocation (or other similar syntax) ``` obj.method(argument1, argument2, ...) ``` If you put argument1 in the first line, the following lines should have the same hanging distance to argument1. If you put argument1 in the second line, the hanging distance should always be four. ``` obj.method( argument1, argument2, ... ) ``` Otherwise PEP8 would complain for continuation line under/over indented problems. See below for more details https://www.python.org/dev/peps/pep-0008/#indentation This patch fixes all the continuation line indentation problems and enables related checks in tox.ini. Closes-bug: #1459514 Change-Id: I80995c2ae71b817ad78a87ab7c567f0d36112710
This commit is contained in:
parent
433403099a
commit
7344fcf2a7
|
@ -116,52 +116,45 @@ class V1(APIBase):
|
|||
'http://docs.openstack.org',
|
||||
'developer/magnum/dev',
|
||||
'api-spec-v1.html',
|
||||
bookmark=True, type='text/html')
|
||||
]
|
||||
bookmark=True, type='text/html')]
|
||||
v1.media_types = [MediaType('application/json',
|
||||
'application/vnd.openstack.magnum.v1+json')]
|
||||
v1.pods = [link.Link.make_link('self', pecan.request.host_url,
|
||||
'pods', ''),
|
||||
link.Link.make_link('bookmark',
|
||||
pecan.request.host_url,
|
||||
'pods', '',
|
||||
bookmark=True)
|
||||
]
|
||||
'pods', ''),
|
||||
link.Link.make_link('bookmark',
|
||||
pecan.request.host_url,
|
||||
'pods', '',
|
||||
bookmark=True)]
|
||||
v1.rcs = [link.Link.make_link('self', pecan.request.host_url,
|
||||
'rcs', ''),
|
||||
link.Link.make_link('bookmark',
|
||||
pecan.request.host_url,
|
||||
'rcs', '',
|
||||
bookmark=True)
|
||||
]
|
||||
link.Link.make_link('bookmark',
|
||||
pecan.request.host_url,
|
||||
'rcs', '',
|
||||
bookmark=True)]
|
||||
v1.baymodels = [link.Link.make_link('self', pecan.request.host_url,
|
||||
'baymodels', ''),
|
||||
link.Link.make_link('bookmark',
|
||||
pecan.request.host_url,
|
||||
'bays', '',
|
||||
bookmark=True)
|
||||
]
|
||||
'baymodels', ''),
|
||||
link.Link.make_link('bookmark',
|
||||
pecan.request.host_url,
|
||||
'bays', '',
|
||||
bookmark=True)]
|
||||
v1.bays = [link.Link.make_link('self', pecan.request.host_url,
|
||||
'bays', ''),
|
||||
link.Link.make_link('bookmark',
|
||||
pecan.request.host_url,
|
||||
'bays', '',
|
||||
bookmark=True)
|
||||
]
|
||||
'bays', ''),
|
||||
link.Link.make_link('bookmark',
|
||||
pecan.request.host_url,
|
||||
'bays', '',
|
||||
bookmark=True)]
|
||||
v1.containers = [link.Link.make_link('self', pecan.request.host_url,
|
||||
'containers', ''),
|
||||
link.Link.make_link('bookmark',
|
||||
pecan.request.host_url,
|
||||
'containers', '',
|
||||
bookmark=True)
|
||||
]
|
||||
'containers', ''),
|
||||
link.Link.make_link('bookmark',
|
||||
pecan.request.host_url,
|
||||
'containers', '',
|
||||
bookmark=True)]
|
||||
v1.services = [link.Link.make_link('self', pecan.request.host_url,
|
||||
'services', ''),
|
||||
link.Link.make_link('bookmark',
|
||||
pecan.request.host_url,
|
||||
'services', '',
|
||||
bookmark=True)
|
||||
]
|
||||
'services', ''),
|
||||
link.Link.make_link('bookmark',
|
||||
pecan.request.host_url,
|
||||
'services', '',
|
||||
bookmark=True)]
|
||||
return v1
|
||||
|
||||
|
||||
|
|
|
@ -113,15 +113,14 @@ class Bay(base.APIBase):
|
|||
def _convert_with_links(bay, url, expand=True):
|
||||
if not expand:
|
||||
bay.unset_fields_except(['uuid', 'name', 'baymodel_id',
|
||||
'node_count', 'status',
|
||||
'bay_create_timeout'])
|
||||
'node_count', 'status',
|
||||
'bay_create_timeout'])
|
||||
|
||||
bay.links = [link.Link.make_link('self', url,
|
||||
'bays', bay.uuid),
|
||||
link.Link.make_link('bookmark', url,
|
||||
'bays', bay.uuid,
|
||||
bookmark=True)
|
||||
]
|
||||
'bays', bay.uuid),
|
||||
link.Link.make_link('bookmark', url,
|
||||
'bays', bay.uuid,
|
||||
bookmark=True)]
|
||||
return bay
|
||||
|
||||
@classmethod
|
||||
|
@ -157,7 +156,7 @@ class BayCollection(collection.Collection):
|
|||
def convert_with_links(rpc_bays, limit, url=None, expand=False, **kwargs):
|
||||
collection = BayCollection()
|
||||
collection.bays = [Bay.convert_with_links(p, expand)
|
||||
for p in rpc_bays]
|
||||
for p in rpc_bays]
|
||||
collection.next = collection.get_next(limit, url=url, **kwargs)
|
||||
return collection
|
||||
|
||||
|
@ -182,8 +181,8 @@ class BaysController(rest.RestController):
|
|||
}
|
||||
|
||||
def _get_bays_collection(self, marker, limit,
|
||||
sort_key, sort_dir, expand=False,
|
||||
resource_url=None):
|
||||
sort_key, sort_dir, expand=False,
|
||||
resource_url=None):
|
||||
|
||||
limit = api_utils.validate_limit(limit)
|
||||
sort_dir = api_utils.validate_sort_dir(sort_dir)
|
||||
|
@ -191,11 +190,12 @@ class BaysController(rest.RestController):
|
|||
marker_obj = None
|
||||
if marker:
|
||||
marker_obj = objects.Bay.get_by_uuid(pecan.request.context,
|
||||
marker)
|
||||
marker)
|
||||
|
||||
bays = pecan.request.rpcapi.bay_list(pecan.request.context, limit,
|
||||
marker_obj, sort_key=sort_key,
|
||||
sort_dir=sort_dir)
|
||||
bays = pecan.request.rpcapi.bay_list(
|
||||
pecan.request.context, limit,
|
||||
marker_obj, sort_key=sort_key,
|
||||
sort_dir=sort_dir)
|
||||
|
||||
return BayCollection.convert_with_links(bays, limit,
|
||||
url=resource_url,
|
||||
|
@ -220,7 +220,7 @@ class BaysController(rest.RestController):
|
|||
@wsme_pecan.wsexpose(BayCollection, types.uuid,
|
||||
types.uuid, int, wtypes.text, wtypes.text)
|
||||
def detail(self, bay_uuid=None, marker=None, limit=None,
|
||||
sort_key='id', sort_dir='asc'):
|
||||
sort_key='id', sort_dir='asc'):
|
||||
"""Retrieve a list of bays with detail.
|
||||
|
||||
:param bay_uuid: UUID of a bay, to get only bays for that bay.
|
||||
|
|
|
@ -116,10 +116,10 @@ class BayModel(base.APIBase):
|
|||
'apiserver_port', 'coe'])
|
||||
|
||||
baymodel.links = [link.Link.make_link('self', url,
|
||||
'baymodels', baymodel.uuid),
|
||||
link.Link.make_link('bookmark', url,
|
||||
'baymodels', baymodel.uuid,
|
||||
bookmark=True)
|
||||
'baymodels', baymodel.uuid),
|
||||
link.Link.make_link('bookmark', url,
|
||||
'baymodels', baymodel.uuid,
|
||||
bookmark=True)
|
||||
]
|
||||
return baymodel
|
||||
|
||||
|
@ -131,22 +131,23 @@ class BayModel(base.APIBase):
|
|||
|
||||
@classmethod
|
||||
def sample(cls, expand=True):
|
||||
sample = cls(uuid='27e3153e-d5bf-4b7e-b517-fb518e17f34c',
|
||||
name='example',
|
||||
image_id='Fedora-k8s',
|
||||
flavor_id='m1.small',
|
||||
master_flavor_id='m1.small',
|
||||
dns_nameserver='8.8.1.1',
|
||||
keypair_id='keypair1',
|
||||
external_network_id='ffc44e4a-2319-4062-bce0-9ae1c38b05ba',
|
||||
fixed_network='private',
|
||||
apiserver_port=8080,
|
||||
docker_volume_size=25,
|
||||
cluster_distro='fedora-atomic',
|
||||
ssh_authorized_key='ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAB',
|
||||
coe='kubernetes',
|
||||
created_at=datetime.datetime.utcnow(),
|
||||
updated_at=datetime.datetime.utcnow())
|
||||
sample = cls(
|
||||
uuid='27e3153e-d5bf-4b7e-b517-fb518e17f34c',
|
||||
name='example',
|
||||
image_id='Fedora-k8s',
|
||||
flavor_id='m1.small',
|
||||
master_flavor_id='m1.small',
|
||||
dns_nameserver='8.8.1.1',
|
||||
keypair_id='keypair1',
|
||||
external_network_id='ffc44e4a-2319-4062-bce0-9ae1c38b05ba',
|
||||
fixed_network='private',
|
||||
apiserver_port=8080,
|
||||
docker_volume_size=25,
|
||||
cluster_distro='fedora-atomic',
|
||||
ssh_authorized_key='ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAB',
|
||||
coe='kubernetes',
|
||||
created_at=datetime.datetime.utcnow(),
|
||||
updated_at=datetime.datetime.utcnow())
|
||||
return cls._convert_with_links(sample, 'http://localhost:9511', expand)
|
||||
|
||||
|
||||
|
@ -164,7 +165,7 @@ class BayModelCollection(collection.Collection):
|
|||
**kwargs):
|
||||
collection = BayModelCollection()
|
||||
collection.baymodels = [BayModel.convert_with_links(p, expand)
|
||||
for p in rpc_baymodels]
|
||||
for p in rpc_baymodels]
|
||||
collection.next = collection.get_next(limit, url=url, **kwargs)
|
||||
return collection
|
||||
|
||||
|
@ -187,8 +188,8 @@ class BayModelsController(rest.RestController):
|
|||
}
|
||||
|
||||
def _get_baymodels_collection(self, marker, limit,
|
||||
sort_key, sort_dir, expand=False,
|
||||
resource_url=None):
|
||||
sort_key, sort_dir, expand=False,
|
||||
resource_url=None):
|
||||
|
||||
limit = api_utils.validate_limit(limit)
|
||||
sort_dir = api_utils.validate_sort_dir(sort_dir)
|
||||
|
@ -196,17 +197,17 @@ class BayModelsController(rest.RestController):
|
|||
marker_obj = None
|
||||
if marker:
|
||||
marker_obj = objects.BayModel.get_by_uuid(pecan.request.context,
|
||||
marker)
|
||||
marker)
|
||||
|
||||
baymodels = objects.BayModel.list(pecan.request.context, limit,
|
||||
marker_obj, sort_key=sort_key,
|
||||
sort_dir=sort_dir)
|
||||
marker_obj, sort_key=sort_key,
|
||||
sort_dir=sort_dir)
|
||||
|
||||
return BayModelCollection.convert_with_links(baymodels, limit,
|
||||
url=resource_url,
|
||||
expand=expand,
|
||||
sort_key=sort_key,
|
||||
sort_dir=sort_dir)
|
||||
url=resource_url,
|
||||
expand=expand,
|
||||
sort_key=sort_key,
|
||||
sort_dir=sort_dir)
|
||||
|
||||
def _get_image_data(self, context, image_ident):
|
||||
"""Retrieves os_distro and other metadata from the Glance image.
|
||||
|
@ -234,12 +235,12 @@ class BayModelsController(rest.RestController):
|
|||
:param sort_dir: direction to sort. "asc" or "desc". Default: asc.
|
||||
"""
|
||||
return self._get_baymodels_collection(marker, limit, sort_key,
|
||||
sort_dir)
|
||||
sort_dir)
|
||||
|
||||
@wsme_pecan.wsexpose(BayModelCollection, types.uuid,
|
||||
types.uuid, int, wtypes.text, wtypes.text)
|
||||
def detail(self, baymodel_uuid=None, marker=None, limit=None,
|
||||
sort_key='id', sort_dir='asc'):
|
||||
sort_key='id', sort_dir='asc'):
|
||||
"""Retrieve a list of baymodels with detail.
|
||||
|
||||
:param baymodel_uuid: UUID of a baymodel, to get only baymodels for
|
||||
|
@ -257,8 +258,8 @@ class BayModelsController(rest.RestController):
|
|||
expand = True
|
||||
resource_url = '/'.join(['baymodels', 'detail'])
|
||||
return self._get_baymodels_collection(marker, limit,
|
||||
sort_key, sort_dir, expand,
|
||||
resource_url)
|
||||
sort_key, sort_dir, expand,
|
||||
resource_url)
|
||||
|
||||
@wsme_pecan.wsexpose(BayModel, types.uuid_or_name)
|
||||
def get_one(self, baymodel_ident):
|
||||
|
@ -296,7 +297,7 @@ class BayModelsController(rest.RestController):
|
|||
new_baymodel.create()
|
||||
# Set the HTTP Location Header
|
||||
pecan.response.location = link.build_url('baymodels',
|
||||
new_baymodel.uuid)
|
||||
new_baymodel.uuid)
|
||||
return BayModel.convert_with_links(new_baymodel)
|
||||
|
||||
@wsme.validate(types.uuid, [BayModelPatchType])
|
||||
|
@ -311,10 +312,11 @@ class BayModelsController(rest.RestController):
|
|||
raise exception.OperationNotPermitted
|
||||
|
||||
rpc_baymodel = objects.BayModel.get_by_uuid(pecan.request.context,
|
||||
baymodel_uuid)
|
||||
baymodel_uuid)
|
||||
try:
|
||||
baymodel_dict = rpc_baymodel.as_dict()
|
||||
baymodel = BayModel(**api_utils.apply_jsonpatch(baymodel_dict,
|
||||
baymodel = BayModel(**api_utils.apply_jsonpatch(
|
||||
baymodel_dict,
|
||||
patch))
|
||||
except api_utils.JSONPATCH_EXCEPTIONS as e:
|
||||
raise exception.PatchError(patch=patch, reason=e)
|
||||
|
|
|
@ -41,8 +41,8 @@ class Collection(base.APIBase):
|
|||
resource_url = url or self._type
|
||||
q_args = ''.join(['%s=%s&' % (key, kwargs[key]) for key in kwargs])
|
||||
next_args = '?%(args)slimit=%(limit)d&marker=%(marker)s' % {
|
||||
'args': q_args, 'limit': limit,
|
||||
'marker': self.collection[-1].uuid}
|
||||
'args': q_args, 'limit': limit,
|
||||
'marker': self.collection[-1].uuid}
|
||||
|
||||
return link.Link.make_link('next', pecan.request.host_url,
|
||||
resource_url, next_args).href
|
||||
|
|
|
@ -103,12 +103,13 @@ class Container(base.APIBase):
|
|||
container.unset_fields_except(['uuid', 'name', 'bay_uuid',
|
||||
'image_id', 'command', 'status'])
|
||||
|
||||
container.links = [link.Link.make_link('self', url,
|
||||
'containers', container.uuid),
|
||||
link.Link.make_link('bookmark', url,
|
||||
'containers', container.uuid,
|
||||
bookmark=True)
|
||||
]
|
||||
container.links = [link.Link.make_link(
|
||||
'self', url,
|
||||
'containers', container.uuid),
|
||||
link.Link.make_link(
|
||||
'bookmark', url,
|
||||
'containers', container.uuid,
|
||||
bookmark=True)]
|
||||
return container
|
||||
|
||||
@classmethod
|
||||
|
@ -144,7 +145,7 @@ class ContainerCollection(collection.Collection):
|
|||
expand=False, **kwargs):
|
||||
collection = ContainerCollection()
|
||||
collection.containers = [Container.convert_with_links(p, expand)
|
||||
for p in rpc_containers]
|
||||
for p in rpc_containers]
|
||||
collection.next = collection.get_next(limit, url=url, **kwargs)
|
||||
return collection
|
||||
|
||||
|
@ -230,7 +231,7 @@ class LogsController(object):
|
|||
container_uuid = api_utils.get_rpc_resource('Container',
|
||||
container_ident).uuid
|
||||
LOG.debug('Calling conductor.container_logs with %s' %
|
||||
container_uuid)
|
||||
container_uuid)
|
||||
return pecan.request.rpcapi.container_logs(container_uuid)
|
||||
|
||||
|
||||
|
@ -270,8 +271,8 @@ class ContainersController(rest.RestController):
|
|||
}
|
||||
|
||||
def _get_containers_collection(self, marker, limit,
|
||||
sort_key, sort_dir, expand=False,
|
||||
resource_url=None):
|
||||
sort_key, sort_dir, expand=False,
|
||||
resource_url=None):
|
||||
|
||||
limit = api_utils.validate_limit(limit)
|
||||
sort_dir = api_utils.validate_sort_dir(sort_dir)
|
||||
|
@ -279,19 +280,19 @@ class ContainersController(rest.RestController):
|
|||
marker_obj = None
|
||||
if marker:
|
||||
marker_obj = objects.Container.get_by_uuid(pecan.request.context,
|
||||
marker)
|
||||
marker)
|
||||
|
||||
containers = objects.Container.list(pecan.request.context, limit,
|
||||
marker_obj, sort_key=sort_key,
|
||||
sort_dir=sort_dir)
|
||||
containers = [pecan.request.rpcapi.container_show(c.uuid)
|
||||
for c in containers]
|
||||
for c in containers]
|
||||
|
||||
return ContainerCollection.convert_with_links(containers, limit,
|
||||
url=resource_url,
|
||||
expand=expand,
|
||||
sort_key=sort_key,
|
||||
sort_dir=sort_dir)
|
||||
url=resource_url,
|
||||
expand=expand,
|
||||
sort_key=sort_key,
|
||||
sort_dir=sort_dir)
|
||||
|
||||
@wsme_pecan.wsexpose(ContainerCollection, types.uuid,
|
||||
types.uuid, int, wtypes.text, wtypes.text)
|
||||
|
@ -310,7 +311,7 @@ class ContainersController(rest.RestController):
|
|||
@wsme_pecan.wsexpose(ContainerCollection, types.uuid,
|
||||
types.uuid, int, wtypes.text, wtypes.text)
|
||||
def detail(self, container_uuid=None, marker=None, limit=None,
|
||||
sort_key='id', sort_dir='asc'):
|
||||
sort_key='id', sort_dir='asc'):
|
||||
"""Retrieve a list of containers with detail.
|
||||
|
||||
:param container_uuid: UUID of a container, to get only containers
|
||||
|
@ -327,8 +328,8 @@ class ContainersController(rest.RestController):
|
|||
expand = True
|
||||
resource_url = '/'.join(['containers', 'detail'])
|
||||
return self._get_containers_collection(marker, limit,
|
||||
sort_key, sort_dir, expand,
|
||||
resource_url)
|
||||
sort_key, sort_dir, expand,
|
||||
resource_url)
|
||||
|
||||
@wsme_pecan.wsexpose(Container, types.uuid_or_name)
|
||||
def get_one(self, container_ident):
|
||||
|
@ -361,8 +362,8 @@ class ContainersController(rest.RestController):
|
|||
new_container = objects.Container(context, **container_dict)
|
||||
new_container.create()
|
||||
res_container = pecan.request.rpcapi.container_create(
|
||||
new_container.name, new_container.uuid,
|
||||
new_container)
|
||||
new_container.name, new_container.uuid,
|
||||
new_container)
|
||||
|
||||
# Set the HTTP Location Header
|
||||
pecan.response.location = link.build_url('containers',
|
||||
|
|
|
@ -185,8 +185,8 @@ class PodsController(rest.RestController):
|
|||
marker)
|
||||
|
||||
pods = pecan.request.rpcapi.pod_list(pecan.request.context, limit,
|
||||
marker_obj, sort_key=sort_key,
|
||||
sort_dir=sort_dir)
|
||||
marker_obj, sort_key=sort_key,
|
||||
sort_dir=sort_dir)
|
||||
|
||||
return PodCollection.convert_with_links(pods, limit,
|
||||
url=resource_url,
|
||||
|
|
|
@ -76,11 +76,10 @@ class ReplicationController(v1_base.K8sResourceBase):
|
|||
'labels', 'replicas'])
|
||||
|
||||
rc.links = [link.Link.make_link('self', url,
|
||||
'rcs', rc.uuid),
|
||||
link.Link.make_link('bookmark', url,
|
||||
'rcs', rc.uuid,
|
||||
bookmark=True)
|
||||
]
|
||||
'rcs', rc.uuid),
|
||||
link.Link.make_link('bookmark', url,
|
||||
'rcs', rc.uuid,
|
||||
bookmark=True)]
|
||||
return rc
|
||||
|
||||
@classmethod
|
||||
|
@ -182,7 +181,7 @@ class ReplicationControllerCollection(collection.Collection):
|
|||
def convert_with_links(rpc_rcs, limit, url=None, expand=False, **kwargs):
|
||||
collection = ReplicationControllerCollection()
|
||||
collection.rcs = [ReplicationController.convert_with_links(p, expand)
|
||||
for p in rpc_rcs]
|
||||
for p in rpc_rcs]
|
||||
collection.next = collection.get_next(limit, url=url, **kwargs)
|
||||
return collection
|
||||
|
||||
|
@ -208,8 +207,8 @@ class ReplicationControllersController(rest.RestController):
|
|||
}
|
||||
|
||||
def _get_rcs_collection(self, marker, limit,
|
||||
sort_key, sort_dir, expand=False,
|
||||
resource_url=None):
|
||||
sort_key, sort_dir, expand=False,
|
||||
resource_url=None):
|
||||
|
||||
limit = api_utils.validate_limit(limit)
|
||||
sort_dir = api_utils.validate_sort_dir(sort_dir)
|
||||
|
@ -217,18 +216,20 @@ class ReplicationControllersController(rest.RestController):
|
|||
marker_obj = None
|
||||
if marker:
|
||||
marker_obj = objects.ReplicationController.get_by_uuid(
|
||||
pecan.request.context,
|
||||
marker)
|
||||
pecan.request.context,
|
||||
marker)
|
||||
|
||||
rcs = pecan.request.rpcapi.rc_list(pecan.request.context, limit,
|
||||
marker_obj, sort_key=sort_key,
|
||||
sort_dir=sort_dir)
|
||||
rcs = pecan.request.rpcapi.rc_list(
|
||||
pecan.request.context, limit,
|
||||
marker_obj, sort_key=sort_key,
|
||||
sort_dir=sort_dir)
|
||||
|
||||
return ReplicationControllerCollection.convert_with_links(rcs, limit,
|
||||
url=resource_url,
|
||||
expand=expand,
|
||||
sort_key=sort_key,
|
||||
sort_dir=sort_dir)
|
||||
return ReplicationControllerCollection.convert_with_links(
|
||||
rcs, limit,
|
||||
url=resource_url,
|
||||
expand=expand,
|
||||
sort_key=sort_key,
|
||||
sort_dir=sort_dir)
|
||||
|
||||
@wsme_pecan.wsexpose(ReplicationControllerCollection, types.uuid,
|
||||
types.uuid, int, wtypes.text, wtypes.text)
|
||||
|
@ -265,8 +266,8 @@ class ReplicationControllersController(rest.RestController):
|
|||
expand = True
|
||||
resource_url = '/'.join(['rcs', 'detail'])
|
||||
return self._get_rcs_collection(marker, limit,
|
||||
sort_key, sort_dir, expand,
|
||||
resource_url)
|
||||
sort_key, sort_dir, expand,
|
||||
resource_url)
|
||||
|
||||
@wsme_pecan.wsexpose(ReplicationController, types.uuid_or_name)
|
||||
def get_one(self, rc_ident):
|
||||
|
|
|
@ -95,13 +95,9 @@ class Service(v1_base.K8sResourceBase):
|
|||
labels={'label1': 'foo'},
|
||||
selector={'label1': 'foo'},
|
||||
ip='172.17.2.2',
|
||||
ports=[
|
||||
{
|
||||
"port": 88,
|
||||
"targetPort": 6379,
|
||||
"protocol": "TCP"
|
||||
}
|
||||
],
|
||||
ports=[{"port": 88,
|
||||
"targetPort": 6379,
|
||||
"protocol": "TCP"}],
|
||||
manifest_url='file:///tmp/rc.yaml',
|
||||
manifest='''{
|
||||
"metadata": {
|
||||
|
@ -201,10 +197,10 @@ class ServicesController(rest.RestController):
|
|||
marker)
|
||||
|
||||
services = pecan.request.rpcapi.service_list(pecan.request.context,
|
||||
limit,
|
||||
marker_obj,
|
||||
sort_key=sort_key,
|
||||
sort_dir=sort_dir)
|
||||
limit,
|
||||
marker_obj,
|
||||
sort_key=sort_key,
|
||||
sort_dir=sort_dir)
|
||||
|
||||
return ServiceCollection.convert_with_links(services, limit,
|
||||
url=resource_url,
|
||||
|
|
|
@ -146,8 +146,8 @@ class MultiType(wtypes.UserType):
|
|||
pass
|
||||
else:
|
||||
raise ValueError(
|
||||
_("Wrong type. Expected '%(type)s', got '%(value)s'")
|
||||
% {'type': self.types, 'value': type(value)})
|
||||
_("Wrong type. Expected '%(type)s', got '%(value)s'")
|
||||
% {'type': self.types, 'value': type(value)})
|
||||
|
||||
|
||||
macaddress = MacAddressType()
|
||||
|
|
|
@ -66,7 +66,7 @@ class ParsableErrorMiddleware(object):
|
|||
if (state['status_code'] // 100) not in (2, 3):
|
||||
req = webob.Request(environ)
|
||||
if (req.accept.best_match(['application/json', 'application/xml'])
|
||||
== 'application/xml'):
|
||||
== 'application/xml'):
|
||||
try:
|
||||
# simple check xml is valid
|
||||
body = [et.ElementTree.tostring(
|
||||
|
|
|
@ -45,7 +45,7 @@ def main():
|
|||
|
||||
if host == '0.0.0.0':
|
||||
LOG.info(_LI('serving on 0.0.0.0:%(port)s, '
|
||||
'view at http://127.0.0.1:%(port)s') %
|
||||
'view at http://127.0.0.1:%(port)s') %
|
||||
dict(port=port))
|
||||
else:
|
||||
LOG.info(_LI('serving on http://%(host)s:%(port)s') %
|
||||
|
|
|
@ -52,7 +52,7 @@ def main():
|
|||
]
|
||||
|
||||
if (not os.path.isfile(cfg.CONF.bay.k8s_atomic_template_path)
|
||||
and not os.path.isfile(cfg.CONF.bay.k8s_coreos_template_path)):
|
||||
and not os.path.isfile(cfg.CONF.bay.k8s_coreos_template_path)):
|
||||
LOG.error(_LE("The Heat template can not be found for either k8s "
|
||||
"atomic %(atomic_template)s or coreos "
|
||||
"(coreos_template)%s. Install template first if you "
|
||||
|
|
|
@ -41,7 +41,7 @@ CONF = cfg.CONF
|
|||
|
||||
try:
|
||||
CONF.import_opt('fatal_exception_format_errors',
|
||||
'oslo_versionedobjects.exception')
|
||||
'oslo_versionedobjects.exception')
|
||||
except cfg.NoSuchOptError as e:
|
||||
# Note:work around for magnum run against master branch
|
||||
# in devstack gate job, as magnum not branched yet
|
||||
|
@ -126,8 +126,8 @@ def wrap_controller_exception(func, func_server_error, func_client_error):
|
|||
# correlation id
|
||||
log_correlation_id = str(uuid.uuid4())
|
||||
LOG.error(_LE("%(correlation_id)s:%(excp)s") %
|
||||
{'correlation_id': log_correlation_id,
|
||||
'excp': str(excp)})
|
||||
{'correlation_id': log_correlation_id,
|
||||
'excp': str(excp)})
|
||||
# raise a client error with an obfuscated message
|
||||
func_server_error(log_correlation_id, http_error_code)
|
||||
else:
|
||||
|
@ -216,7 +216,7 @@ class MagnumException(Exception):
|
|||
LOG.exception(_LE('Exception in string format operation'))
|
||||
for name, value in kwargs.iteritems():
|
||||
LOG.error(_LE("%(name)s: %(value)s") %
|
||||
{'name': name, 'value': value})
|
||||
{'name': name, 'value': value})
|
||||
try:
|
||||
if CONF.fatal_exception_format_errors:
|
||||
raise e
|
||||
|
|
|
@ -123,7 +123,7 @@ class KeystoneClientV3(object):
|
|||
kwargs['project_id'] = self.context.project_id
|
||||
else:
|
||||
LOG.error(_LE("Keystone v3 API connection failed, no password "
|
||||
"trust or auth_token!"))
|
||||
"trust or auth_token!"))
|
||||
raise exception.AuthorizationFailure()
|
||||
client = kc_v3.Client(**kwargs)
|
||||
if 'auth_ref' not in kwargs:
|
||||
|
|
|
@ -253,7 +253,7 @@ def is_valid_cidr(address):
|
|||
ip_segment = address.split('/')
|
||||
|
||||
if (len(ip_segment) <= 1 or
|
||||
ip_segment[1] == ''):
|
||||
ip_segment[1] == ''):
|
||||
return False
|
||||
|
||||
return True
|
||||
|
@ -442,7 +442,7 @@ def unlink_without_raise(path):
|
|||
return
|
||||
else:
|
||||
LOG.warn(_LW("Failed to unlink %(path)s, error: %(e)s"),
|
||||
{'path': path, 'e': e})
|
||||
{'path': path, 'e': e})
|
||||
|
||||
|
||||
def rmtree_without_raise(path):
|
||||
|
@ -451,7 +451,7 @@ def rmtree_without_raise(path):
|
|||
shutil.rmtree(path)
|
||||
except OSError as e:
|
||||
LOG.warn(_LW("Failed to remove dir %(path)s, error: %(e)s"),
|
||||
{'path': path, 'e': e})
|
||||
{'path': path, 'e': e})
|
||||
|
||||
|
||||
def write_to_file(path, contents):
|
||||
|
@ -468,7 +468,7 @@ def create_link_without_raise(source, link):
|
|||
else:
|
||||
LOG.warn(_LW("Failed to create symlink from %(source)s to %(link)s"
|
||||
", error: %(e)s"),
|
||||
{'source': source, 'link': link, 'e': e})
|
||||
{'source': source, 'link': link, 'e': e})
|
||||
|
||||
|
||||
def safe_rstrip(value, chars=None):
|
||||
|
|
|
@ -45,7 +45,7 @@ bay_heat_opts = [
|
|||
cfg.IntOpt('bay_create_timeout',
|
||||
default=None,
|
||||
help=('The length of time to let bay creation continue. This '
|
||||
'interval is in minutes. The default is no timeout.'))
|
||||
'interval is in minutes. The default is no timeout.'))
|
||||
]
|
||||
|
||||
cfg.CONF.register_opts(bay_heat_opts, group='bay_heat')
|
||||
|
@ -148,7 +148,7 @@ class Handler(object):
|
|||
osc = clients.OpenStackClients(context)
|
||||
stack = osc.heat().stacks.get(bay.stack_id)
|
||||
if (stack.stack_status != bay_status.CREATE_COMPLETE and
|
||||
stack.stack_status != bay_status.UPDATE_COMPLETE):
|
||||
stack.stack_status != bay_status.UPDATE_COMPLETE):
|
||||
operation = _('Updating a bay when stack status is '
|
||||
'"%s"') % stack.stack_status
|
||||
raise exception.NotSupported(operation=operation)
|
||||
|
@ -217,7 +217,7 @@ class HeatPoller(object):
|
|||
# so another user/client can call delete bay/stack.
|
||||
if stack.stack_status == bay_status.DELETE_COMPLETE:
|
||||
LOG.info(_LI('Bay has been deleted, stack_id: %s')
|
||||
% self.bay.stack_id)
|
||||
% self.bay.stack_id)
|
||||
self.bay.destroy()
|
||||
raise loopingcall.LoopingCallDone()
|
||||
if (stack.stack_status in [bay_status.CREATE_COMPLETE,
|
||||
|
@ -233,20 +233,20 @@ class HeatPoller(object):
|
|||
if stack.stack_status == bay_status.CREATE_FAILED:
|
||||
LOG.error(_LE('Unable to create bay, stack_id: %(stack_id)s, '
|
||||
'reason: %(reason)s') %
|
||||
{'stack_id': self.bay.stack_id,
|
||||
'reason': stack.stack_status_reason})
|
||||
{'stack_id': self.bay.stack_id,
|
||||
'reason': stack.stack_status_reason})
|
||||
raise loopingcall.LoopingCallDone()
|
||||
if stack.stack_status == bay_status.DELETE_FAILED:
|
||||
LOG.error(_LE('Unable to delete bay, stack_id: %(stack_id)s, '
|
||||
'reason: %(reason)s') %
|
||||
{'stack_id': self.bay.stack_id,
|
||||
'reason': stack.stack_status_reason})
|
||||
{'stack_id': self.bay.stack_id,
|
||||
'reason': stack.stack_status_reason})
|
||||
raise loopingcall.LoopingCallDone()
|
||||
if stack.stack_status == bay_status.UPDATE_FAILED:
|
||||
LOG.error(_LE('Unable to update bay, stack_id: %(stack_id)s, '
|
||||
'reason: %(reason)s') %
|
||||
{'stack_id': self.bay.stack_id,
|
||||
'reason': stack.stack_status_reason})
|
||||
{'stack_id': self.bay.stack_id,
|
||||
'reason': stack.stack_status_reason})
|
||||
raise loopingcall.LoopingCallDone()
|
||||
# only check max attempts when the stack is being created when
|
||||
# the timeout hasn't been set. If the timeout has been set then
|
||||
|
@ -256,15 +256,15 @@ class HeatPoller(object):
|
|||
self.attempts > cfg.CONF.bay_heat.max_attempts):
|
||||
LOG.error(_LE('Bay check exit after %(attempts)s attempts,'
|
||||
'stack_id: %(id)s, stack_status: %(status)s') %
|
||||
{'attempts': cfg.CONF.bay_heat.max_attempts,
|
||||
'id': self.bay.stack_id,
|
||||
'status': stack.stack_status})
|
||||
{'attempts': cfg.CONF.bay_heat.max_attempts,
|
||||
'id': self.bay.stack_id,
|
||||
'status': stack.stack_status})
|
||||
raise loopingcall.LoopingCallDone()
|
||||
else:
|
||||
if self.attempts > cfg.CONF.bay_heat.max_attempts:
|
||||
LOG.error(_LE('Bay check exit after %(attempts)s attempts,'
|
||||
'stack_id: %(id)s, stack_status: %(status)s') %
|
||||
{'attempts': cfg.CONF.bay_heat.max_attempts,
|
||||
'id': self.bay.stack_id,
|
||||
'status': stack.stack_status})
|
||||
{'attempts': cfg.CONF.bay_heat.max_attempts,
|
||||
'id': self.bay.stack_id,
|
||||
'status': stack.stack_status})
|
||||
raise loopingcall.LoopingCallDone()
|
||||
|
|
|
@ -88,7 +88,7 @@ class KubeClient(object):
|
|||
except Exception as e:
|
||||
LOG.error(_LE("Couldn't create service with contents %(content)s "
|
||||
"due to error %(error)s") %
|
||||
{'content': service, 'error': e})
|
||||
{'content': service, 'error': e})
|
||||
return False
|
||||
return True
|
||||
|
||||
|
@ -102,7 +102,7 @@ class KubeClient(object):
|
|||
except Exception as e:
|
||||
LOG.error(_LE("Couldn't update service with contents %(content)s "
|
||||
"due to error %(error)s") %
|
||||
{'content': service, 'error': e})
|
||||
{'content': service, 'error': e})
|
||||
return False
|
||||
return True
|
||||
|
||||
|
@ -130,7 +130,7 @@ class KubeClient(object):
|
|||
except Exception as e:
|
||||
LOG.error(_LE("Couldn't create pod with contents %(content)s "
|
||||
"due to error %(error)s") %
|
||||
{'content': pod, 'error': e})
|
||||
{'content': pod, 'error': e})
|
||||
return False
|
||||
return True
|
||||
|
||||
|
@ -201,6 +201,6 @@ class KubeClient(object):
|
|||
return False
|
||||
except Exception as e:
|
||||
LOG.error(_LE("Couldn't delete rc %(rc)s due to error %(error)s")
|
||||
% {'rc': name, 'error': e})
|
||||
% {'rc': name, 'error': e})
|
||||
return False
|
||||
return True
|
||||
|
|
|
@ -66,7 +66,7 @@ def wrap_container_exception(f):
|
|||
{'name': container_uuid,
|
||||
'error': str(e)})
|
||||
raise exception.ContainerException(
|
||||
"Docker internal Error: %s" % str(e))
|
||||
"Docker internal Error: %s" % str(e))
|
||||
return functools.wraps(f)(wrapped)
|
||||
|
||||
|
||||
|
@ -92,9 +92,11 @@ class Handler(object):
|
|||
@staticmethod
|
||||
def _docker_for_bay(bay):
|
||||
tcp_url = 'tcp://%s:2376' % bay.api_address
|
||||
return docker_client.DockerHTTPClient(tcp_url,
|
||||
CONF.docker.docker_remote_api_version,
|
||||
CONF.docker.default_timeout)
|
||||
return docker_client.DockerHTTPClient(
|
||||
tcp_url,
|
||||
CONF.docker.docker_remote_api_version,
|
||||
CONF.docker.default_timeout
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def _docker_for_container(cls, context, container):
|
||||
|
@ -127,7 +129,7 @@ class Handler(object):
|
|||
except errors.APIError as api_error:
|
||||
container.status = obj_container.ERROR
|
||||
raise exception.ContainerException(
|
||||
"Docker API Error : %s" % str(api_error))
|
||||
"Docker API Error : %s" % str(api_error))
|
||||
finally:
|
||||
container.save()
|
||||
|
||||
|
@ -142,7 +144,7 @@ class Handler(object):
|
|||
return docker.remove_container(docker_id)
|
||||
except errors.APIError as api_error:
|
||||
raise exception.ContainerException(
|
||||
"Docker API Error : %s" % str(api_error))
|
||||
"Docker API Error : %s" % str(api_error))
|
||||
|
||||
@wrap_container_exception
|
||||
def container_show(self, context, container_uuid):
|
||||
|
@ -171,7 +173,7 @@ class Handler(object):
|
|||
container.save()
|
||||
return container
|
||||
raise exception.ContainerException(
|
||||
"Docker API Error : %s" % (error_message))
|
||||
"Docker API Error : %s" % (error_message))
|
||||
|
||||
@wrap_container_exception
|
||||
def _container_action(self, context, container_uuid, status, docker_func):
|
||||
|
@ -186,7 +188,7 @@ class Handler(object):
|
|||
return result
|
||||
except errors.APIError as api_error:
|
||||
raise exception.ContainerException(
|
||||
"Docker API Error : %s" % str(api_error))
|
||||
"Docker API Error : %s" % str(api_error))
|
||||
|
||||
def container_reboot(self, context, container_uuid):
|
||||
return self._container_action(context, container_uuid,
|
||||
|
@ -217,7 +219,7 @@ class Handler(object):
|
|||
return {'output': docker.get_container_logs(docker_id)}
|
||||
except errors.APIError as api_error:
|
||||
raise exception.ContainerException(
|
||||
"Docker API Error : %s" % str(api_error))
|
||||
"Docker API Error : %s" % str(api_error))
|
||||
|
||||
@wrap_container_exception
|
||||
def container_execute(self, context, container_uuid, command):
|
||||
|
@ -227,9 +229,9 @@ class Handler(object):
|
|||
try:
|
||||
docker_id = self._find_container_by_name(docker, container_uuid)
|
||||
create_res = docker.exec_create(docker_id, command, True,
|
||||
True, False)
|
||||
True, False)
|
||||
return {'output': docker.exec_start(create_res, False,
|
||||
False, False)}
|
||||
False, False)}
|
||||
except errors.APIError as api_error:
|
||||
raise exception.ContainerException(
|
||||
"Docker API Error : %s" % str(api_error))
|
||||
"Docker API Error : %s" % str(api_error))
|
||||
|
|
|
@ -32,8 +32,8 @@ LOG = logging.getLogger(__name__)
|
|||
kubernetes_opts = [
|
||||
cfg.StrOpt('k8s_protocol',
|
||||
default='http',
|
||||
help=_('Default protocol of k8s master endpoint'
|
||||
' (http or https).')),
|
||||
help=_('Default protocol of k8s master endpoint '
|
||||
'(http or https).')),
|
||||
cfg.IntOpt('k8s_port',
|
||||
default=8080,
|
||||
help=_('Default port of the k8s master endpoint.')),
|
||||
|
|
|
@ -61,7 +61,7 @@ logging = {
|
|||
'()': 'pecan.log.ColorFormatter',
|
||||
'format': ('%(asctime)s [%(padded_color_levelname)s] [%(name)s]'
|
||||
'[%(threadName)s] %(message)s'),
|
||||
'__force_dict__': True
|
||||
'__force_dict__': True
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -331,7 +331,7 @@ class Connection(object):
|
|||
|
||||
@abc.abstractmethod
|
||||
def get_node_list(self, context, columns=None, filters=None, limit=None,
|
||||
marker=None, sort_key=None, sort_dir=None):
|
||||
marker=None, sort_key=None, sort_dir=None):
|
||||
"""Get specific columns for matching nodes.
|
||||
|
||||
Return a list of the specified columns for all nodes that match the
|
||||
|
@ -495,7 +495,7 @@ class Connection(object):
|
|||
|
||||
@abc.abstractmethod
|
||||
def get_service_list(self, context, columns=None, filters=None, limit=None,
|
||||
marker=None, sort_key=None, sort_dir=None):
|
||||
marker=None, sort_key=None, sort_dir=None):
|
||||
"""Get specific columns for matching services.
|
||||
|
||||
Return a list of the specified columns for all services that match the
|
||||
|
@ -587,7 +587,7 @@ class Connection(object):
|
|||
|
||||
@abc.abstractmethod
|
||||
def get_rc_list(self, context, columns=None, filters=None, limit=None,
|
||||
marker=None, sort_key=None, sort_dir=None):
|
||||
marker=None, sort_key=None, sort_dir=None):
|
||||
"""Get specific columns for matching ReplicationController.
|
||||
|
||||
Return a list of the specified columns for all rcs that match the
|
||||
|
|
|
@ -30,10 +30,10 @@ from magnum.i18n import _
|
|||
|
||||
|
||||
bay_heat_opts = [
|
||||
cfg.StrOpt('cluster_coe',
|
||||
default='kubernetes',
|
||||
help=_('Container Orchestration Environments are '
|
||||
'kubernetes or swarm. ')),
|
||||
cfg.StrOpt('cluster_coe',
|
||||
default='kubernetes',
|
||||
help=_('Container Orchestration Environments are '
|
||||
'kubernetes or swarm.'))
|
||||
]
|
||||
|
||||
cfg.CONF.register_opts(bay_heat_opts, group='bay_heat')
|
||||
|
@ -46,7 +46,6 @@ def upgrade():
|
|||
baymodel = sa.sql.table('baymodel',
|
||||
sa.sql.column('coe', sa.String(length=255)))
|
||||
op.execute(
|
||||
baymodel.update().values({'coe':
|
||||
op.inline_literal(
|
||||
cfg.CONF.bay_heat.cluster_coe)})
|
||||
baymodel.update().values({
|
||||
'coe': op.inline_literal(cfg.CONF.bay_heat.cluster_coe)})
|
||||
)
|
||||
|
|
|
@ -28,5 +28,5 @@ import sqlalchemy as sa
|
|||
|
||||
def upgrade():
|
||||
op.add_column('container',
|
||||
sa.Column('status', sa.String(length=20),
|
||||
nullable=True))
|
||||
sa.Column('status', sa.String(length=20),
|
||||
nullable=True))
|
||||
|
|
|
@ -28,4 +28,4 @@ import sqlalchemy as sa
|
|||
def upgrade():
|
||||
op.add_column('container',
|
||||
sa.Column('command', sa.String(length=255),
|
||||
nullable=True))
|
||||
nullable=True))
|
||||
|
|
|
@ -138,7 +138,7 @@ class Connection(api.Connection):
|
|||
return query
|
||||
|
||||
def get_bay_list(self, context, filters=None, limit=None, marker=None,
|
||||
sort_key=None, sort_dir=None):
|
||||
sort_key=None, sort_dir=None):
|
||||
query = model_query(models.Bay)
|
||||
query = self._add_tenant_filters(context, query)
|
||||
query = self._add_bays_filters(query, filters)
|
||||
|
@ -292,7 +292,7 @@ class Connection(api.Connection):
|
|||
query = query.filter_by(flavor_id=filters['flavor_id'])
|
||||
if 'master_flavor_id' in filters:
|
||||
query = query.filter_by(
|
||||
master_flavor_id=filters['master_flavor_id'])
|
||||
master_flavor_id=filters['master_flavor_id'])
|
||||
if 'keypair_id' in filters:
|
||||
query = query.filter_by(keypair_id=filters['keypair_id'])
|
||||
if 'external_network_id' in filters:
|
||||
|
@ -308,7 +308,7 @@ class Connection(api.Connection):
|
|||
return query
|
||||
|
||||
def get_baymodel_list(self, context, filters=None, limit=None, marker=None,
|
||||
sort_key=None, sort_dir=None):
|
||||
sort_key=None, sort_dir=None):
|
||||
query = model_query(models.BayModel)
|
||||
query = self._add_tenant_filters(context, query)
|
||||
query = self._add_baymodels_filters(query, filters)
|
||||
|
@ -599,8 +599,9 @@ class Connection(api.Connection):
|
|||
|
||||
# Prevent ironic_node_id overwriting
|
||||
if values.get("ironic_node_id") and ref.ironic_node_id:
|
||||
raise exception.NodeAssociated(node=node_id,
|
||||
instance=ref.ironic_node_id)
|
||||
raise exception.NodeAssociated(
|
||||
node=node_id,
|
||||
instance=ref.ironic_node_id)
|
||||
|
||||
ref.update(values)
|
||||
return ref
|
||||
|
@ -619,7 +620,7 @@ class Connection(api.Connection):
|
|||
return query
|
||||
|
||||
def get_pod_list(self, context, filters=None, limit=None, marker=None,
|
||||
sort_key=None, sort_dir=None):
|
||||
sort_key=None, sort_dir=None):
|
||||
query = model_query(models.Pod)
|
||||
query = self._add_tenant_filters(context, query)
|
||||
query = self._add_pods_filters(query, filters)
|
||||
|
@ -723,7 +724,7 @@ class Connection(api.Connection):
|
|||
return query
|
||||
|
||||
def get_service_list(self, context, filters=None, limit=None, marker=None,
|
||||
sort_key=None, sort_dir=None):
|
||||
sort_key=None, sort_dir=None):
|
||||
query = model_query(models.Service)
|
||||
query = self._add_tenant_filters(context, query)
|
||||
query = self._add_services_filters(query, filters)
|
||||
|
@ -827,7 +828,7 @@ class Connection(api.Connection):
|
|||
return query
|
||||
|
||||
def get_rc_list(self, context, filters=None, limit=None, marker=None,
|
||||
sort_key=None, sort_dir=None):
|
||||
sort_key=None, sort_dir=None):
|
||||
query = model_query(models.ReplicationController)
|
||||
query = self._add_tenant_filters(context, query)
|
||||
query = self._add_rcs_filters(query, filters)
|
||||
|
@ -845,7 +846,7 @@ class Connection(api.Connection):
|
|||
rc.save()
|
||||
except db_exc.DBDuplicateEntry:
|
||||
raise exception.ReplicationControllerAlreadyExists(
|
||||
uuid=values['uuid'])
|
||||
uuid=values['uuid'])
|
||||
return rc
|
||||
|
||||
def get_rc_by_id(self, context, rc_id):
|
||||
|
@ -868,7 +869,7 @@ class Connection(api.Connection):
|
|||
|
||||
def get_rcs_by_bay_uuid(self, bay_uuid):
|
||||
query = model_query(models.ReplicationController).filter_by(
|
||||
bay_uuid=bay_uuid)
|
||||
bay_uuid=bay_uuid)
|
||||
try:
|
||||
return query.all()
|
||||
except NoResultFound:
|
||||
|
@ -876,7 +877,7 @@ class Connection(api.Connection):
|
|||
|
||||
def get_rc_by_name(self, rc_name):
|
||||
query = model_query(models.ReplicationController).filter_by(
|
||||
name=rc_name)
|
||||
name=rc_name)
|
||||
try:
|
||||
return query.one()
|
||||
except MultipleResultsFound:
|
||||
|
|
|
@ -62,9 +62,9 @@ class TestCase(base.BaseTestCase):
|
|||
}
|
||||
}
|
||||
self.context = magnum_context.RequestContext(
|
||||
auth_token_info=token_info,
|
||||
project_id='fake_project',
|
||||
user_id='fake_user')
|
||||
auth_token_info=token_info,
|
||||
project_id='fake_project',
|
||||
user_id='fake_user')
|
||||
|
||||
def make_context(*args, **kwargs):
|
||||
# If context hasn't been constructed with token_info
|
||||
|
|
|
@ -29,40 +29,41 @@ class TestRootController(tests.FunctionalTest):
|
|||
self.assertEqual(expected, response.json)
|
||||
|
||||
def test_v1_controller(self):
|
||||
expected = {u'media_types':
|
||||
expected = {
|
||||
u'media_types':
|
||||
[{u'base': u'application/json',
|
||||
u'type': u'application/vnd.openstack.magnum.v1+json'}],
|
||||
u'type': u'application/vnd.openstack.magnum.v1+json'}],
|
||||
u'links': [{u'href': u'http://localhost/v1/',
|
||||
u'rel': u'self'},
|
||||
{u'href':
|
||||
u'http://docs.openstack.org/developer'
|
||||
'/magnum/dev/api-spec-v1.html',
|
||||
u'type': u'text/html', u'rel': u'describedby'}],
|
||||
u'rel': u'self'},
|
||||
{u'href':
|
||||
u'http://docs.openstack.org/developer'
|
||||
'/magnum/dev/api-spec-v1.html',
|
||||
u'type': u'text/html', u'rel': u'describedby'}],
|
||||
u'bays': [{u'href': u'http://localhost/v1/bays/',
|
||||
u'rel': u'self'},
|
||||
{u'href': u'http://localhost/bays/',
|
||||
u'rel': u'bookmark'}],
|
||||
u'rel': u'self'},
|
||||
{u'href': u'http://localhost/bays/',
|
||||
u'rel': u'bookmark'}],
|
||||
u'services': [{u'href': u'http://localhost/v1/services/',
|
||||
u'rel': u'self'},
|
||||
{u'href': u'http://localhost/services/',
|
||||
u'rel': u'bookmark'}],
|
||||
u'rel': u'self'},
|
||||
{u'href': u'http://localhost/services/',
|
||||
u'rel': u'bookmark'}],
|
||||
u'baymodels': [{u'href': u'http://localhost/v1/baymodels/',
|
||||
u'rel': u'self'},
|
||||
{u'href': u'http://localhost/bays/',
|
||||
u'rel': u'bookmark'}],
|
||||
u'rel': u'self'},
|
||||
{u'href': u'http://localhost/bays/',
|
||||
u'rel': u'bookmark'}],
|
||||
u'pods': [{u'href': u'http://localhost/v1/pods/',
|
||||
u'rel': u'self'},
|
||||
{u'href': u'http://localhost/pods/',
|
||||
u'rel': u'bookmark'}],
|
||||
u'rel': u'self'},
|
||||
{u'href': u'http://localhost/pods/',
|
||||
u'rel': u'bookmark'}],
|
||||
u'rcs': [{u'href': u'http://localhost/v1/rcs/',
|
||||
u'rel': u'self'},
|
||||
{u'href': u'http://localhost/rcs/',
|
||||
u'rel': u'bookmark'}],
|
||||
u'rel': u'self'},
|
||||
{u'href': u'http://localhost/rcs/',
|
||||
u'rel': u'bookmark'}],
|
||||
u'id': u'v1',
|
||||
u'containers': [{u'href': u'http://localhost/v1/containers/',
|
||||
u'rel': u'self'},
|
||||
{u'href': u'http://localhost/containers/',
|
||||
u'rel': u'bookmark'}]}
|
||||
u'rel': u'self'},
|
||||
{u'href': u'http://localhost/containers/',
|
||||
u'rel': u'bookmark'}]}
|
||||
|
||||
response = self.app.get('/v1/')
|
||||
self.assertEqual(expected, response.json)
|
||||
|
|
|
@ -81,8 +81,9 @@ class TestListBay(api_base.FunctionalTest):
|
|||
self.assertIn('node_addresses', response)
|
||||
|
||||
def test_get_one_by_name_not_found(self):
|
||||
response = self.get_json('/bays/not_found',
|
||||
expect_errors=True)
|
||||
response = self.get_json(
|
||||
'/bays/not_found',
|
||||
expect_errors=True)
|
||||
self.assertEqual(404, response.status_int)
|
||||
self.assertEqual('application/json', response.content_type)
|
||||
self.assertTrue(response.json['error_message'])
|
||||
|
@ -188,7 +189,7 @@ class TestPatch(api_base.FunctionalTest):
|
|||
response = self.get_json('/bays/%s' % self.bay.uuid)
|
||||
self.assertEqual(name, response['name'])
|
||||
return_updated_at = timeutils.parse_isotime(
|
||||
response['updated_at']).replace(tzinfo=None)
|
||||
response['updated_at']).replace(tzinfo=None)
|
||||
self.assertEqual(test_time, return_updated_at)
|
||||
# Assert nothing else was changed
|
||||
self.assertEqual(self.bay.uuid, response['uuid'])
|
||||
|
@ -210,7 +211,7 @@ class TestPatch(api_base.FunctionalTest):
|
|||
response = self.get_json('/bays/%s' % self.bay.uuid)
|
||||
self.assertEqual(name, response['name'])
|
||||
return_updated_at = timeutils.parse_isotime(
|
||||
response['updated_at']).replace(tzinfo=None)
|
||||
response['updated_at']).replace(tzinfo=None)
|
||||
self.assertEqual(test_time, return_updated_at)
|
||||
# Assert nothing else was changed
|
||||
self.assertEqual(self.bay.uuid, response['uuid'])
|
||||
|
@ -289,8 +290,9 @@ class TestPatch(api_base.FunctionalTest):
|
|||
|
||||
def test_add_ok(self):
|
||||
name = 'bay_example_B'
|
||||
response = self.patch_json('/bays/%s' % self.bay.uuid,
|
||||
[{'path': '/name', 'value': name, 'op': 'add'}])
|
||||
response = self.patch_json(
|
||||
'/bays/%s' % self.bay.uuid,
|
||||
[{'path': '/name', 'value': name, 'op': 'add'}])
|
||||
self.assertEqual('application/json', response.content_type)
|
||||
self.assertEqual(200, response.status_int)
|
||||
|
||||
|
@ -326,9 +328,10 @@ class TestPatch(api_base.FunctionalTest):
|
|||
self.assertEqual(self.bay.baymodel_id, response['baymodel_id'])
|
||||
|
||||
def test_add_non_existent_property(self):
|
||||
response = self.patch_json('/bays/%s' % self.bay.uuid,
|
||||
[{'path': '/foo', 'value': 'bar', 'op': 'add'}],
|
||||
expect_errors=True)
|
||||
response = self.patch_json(
|
||||
'/bays/%s' % self.bay.uuid,
|
||||
[{'path': '/foo', 'value': 'bar', 'op': 'add'}],
|
||||
expect_errors=True)
|
||||
self.assertEqual('application/json', response.content_type)
|
||||
self.assertEqual(400, response.status_int)
|
||||
self.assertTrue(response.json['error_message'])
|
||||
|
@ -366,9 +369,10 @@ class TestPatch(api_base.FunctionalTest):
|
|||
self.assertTrue(response.json['error_message'])
|
||||
|
||||
def test_remove_non_existent_property(self):
|
||||
response = self.patch_json('/bays/%s' % self.bay.uuid,
|
||||
[{'path': '/non-existent', 'op': 'remove'}],
|
||||
expect_errors=True)
|
||||
response = self.patch_json(
|
||||
'/bays/%s' % self.bay.uuid,
|
||||
[{'path': '/non-existent', 'op': 'remove'}],
|
||||
expect_errors=True)
|
||||
self.assertEqual('application/json', response.content_type)
|
||||
self.assertEqual(400, response.status_code)
|
||||
self.assertTrue(response.json['error_message'])
|
||||
|
@ -405,7 +409,7 @@ class TestPost(api_base.FunctionalTest):
|
|||
self.assertEqual(bdict['uuid'], response.json['uuid'])
|
||||
self.assertNotIn('updated_at', response.json.keys)
|
||||
return_created_at = timeutils.parse_isotime(
|
||||
response.json['created_at']).replace(tzinfo=None)
|
||||
response.json['created_at']).replace(tzinfo=None)
|
||||
self.assertEqual(test_time, return_created_at)
|
||||
|
||||
def test_create_bay_doesnt_contain_id(self):
|
||||
|
|
|
@ -85,19 +85,23 @@ class TestListBayModel(api_base.FunctionalTest):
|
|||
self.assertIn('coe', response)
|
||||
|
||||
def test_get_one_by_name_not_found(self):
|
||||
response = self.get_json('/baymodels/not_found',
|
||||
expect_errors=True)
|
||||
response = self.get_json(
|
||||
'/baymodels/not_found',
|
||||
expect_errors=True)
|
||||
self.assertEqual(404, response.status_int)
|
||||
self.assertEqual('application/json', response.content_type)
|
||||
self.assertTrue(response.json['error_message'])
|
||||
|
||||
def test_get_one_by_name_multiple_baymodel(self):
|
||||
obj_utils.create_test_baymodel(self.context, name='test_baymodel',
|
||||
uuid=utils.generate_uuid())
|
||||
obj_utils.create_test_baymodel(self.context, name='test_baymodel',
|
||||
uuid=utils.generate_uuid())
|
||||
response = self.get_json('/baymodels/test_baymodel',
|
||||
expect_errors=True)
|
||||
obj_utils.create_test_baymodel(
|
||||
self.context, name='test_baymodel',
|
||||
uuid=utils.generate_uuid())
|
||||
obj_utils.create_test_baymodel(
|
||||
self.context, name='test_baymodel',
|
||||
uuid=utils.generate_uuid())
|
||||
response = self.get_json(
|
||||
'/baymodels/test_baymodel',
|
||||
expect_errors=True)
|
||||
self.assertEqual(409, response.status_int)
|
||||
self.assertEqual('application/json', response.content_type)
|
||||
self.assertTrue(response.json['error_message'])
|
||||
|
@ -125,8 +129,9 @@ class TestListBayModel(api_base.FunctionalTest):
|
|||
def test_many(self):
|
||||
bm_list = []
|
||||
for id_ in range(5):
|
||||
baymodel = obj_utils.create_test_baymodel(self.context, id=id_,
|
||||
uuid=utils.generate_uuid())
|
||||
baymodel = obj_utils.create_test_baymodel(
|
||||
self.context, id=id_,
|
||||
uuid=utils.generate_uuid())
|
||||
bm_list.append(baymodel.uuid)
|
||||
response = self.get_json('/baymodels')
|
||||
self.assertEqual(len(bm_list), len(response['baymodels']))
|
||||
|
@ -147,7 +152,7 @@ class TestListBayModel(api_base.FunctionalTest):
|
|||
def test_collection_links(self):
|
||||
for id_ in range(5):
|
||||
obj_utils.create_test_baymodel(self.context, id=id_,
|
||||
uuid=utils.generate_uuid())
|
||||
uuid=utils.generate_uuid())
|
||||
response = self.get_json('/baymodels/?limit=3')
|
||||
self.assertEqual(3, len(response['baymodels']))
|
||||
|
||||
|
@ -170,21 +175,22 @@ class TestPatch(api_base.FunctionalTest):
|
|||
|
||||
def setUp(self):
|
||||
super(TestPatch, self).setUp()
|
||||
self.baymodel = obj_utils.create_test_baymodel(self.context,
|
||||
name='bay_model_example_A',
|
||||
image_id='nerdherd',
|
||||
apiserver_port=8080,
|
||||
fixed_network='private',
|
||||
docker_volume_size=20,
|
||||
ssh_authorized_key='ssh-rsa AAAAB3NzaC1ycEAAAADA'
|
||||
'v0XRqg3tm+jlsOKGO81lPDH+KaSJ'
|
||||
'Q7wvmjUqszP/H6NC/m+qiGp/sTis'
|
||||
'DYucqbeuM7nmJi+8Hb55y1xWoOZI'
|
||||
'KMa71G5/4EOQxuQ/sgW965OOO2Hq'
|
||||
'X8vjlQUnTK0HijrbSTLxp/9kazWW'
|
||||
'FrfsdB8RtZBN digambar@magnum',
|
||||
coe='swarm'
|
||||
)
|
||||
self.baymodel = obj_utils.create_test_baymodel(
|
||||
self.context,
|
||||
name='bay_model_example_A',
|
||||
image_id='nerdherd',
|
||||
apiserver_port=8080,
|
||||
fixed_network='private',
|
||||
docker_volume_size=20,
|
||||
ssh_authorized_key='ssh-rsa AAAAB3NzaC1ycEAAAADA'
|
||||
'v0XRqg3tm+jlsOKGO81lPDH+KaSJ'
|
||||
'Q7wvmjUqszP/H6NC/m+qiGp/sTis'
|
||||
'DYucqbeuM7nmJi+8Hb55y1xWoOZI'
|
||||
'KMa71G5/4EOQxuQ/sgW965OOO2Hq'
|
||||
'X8vjlQUnTK0HijrbSTLxp/9kazWW'
|
||||
'FrfsdB8RtZBN digambar@magnum',
|
||||
coe='swarm'
|
||||
)
|
||||
|
||||
def test_update_not_found(self):
|
||||
uuid = utils.generate_uuid()
|
||||
|
@ -212,7 +218,7 @@ class TestPatch(api_base.FunctionalTest):
|
|||
response = self.get_json('/baymodels/%s' % self.baymodel.uuid)
|
||||
self.assertEqual(name, response['name'])
|
||||
return_updated_at = timeutils.parse_isotime(
|
||||
response['updated_at']).replace(tzinfo=None)
|
||||
response['updated_at']).replace(tzinfo=None)
|
||||
self.assertEqual(test_time, return_updated_at)
|
||||
# Assert nothing else was changed
|
||||
self.assertEqual(self.baymodel.uuid, response['uuid'])
|
||||
|
@ -256,16 +262,17 @@ class TestPatch(api_base.FunctionalTest):
|
|||
|
||||
def test_remove_non_existent_property_fail(self):
|
||||
response = self.patch_json('/baymodels/%s' % self.baymodel.uuid,
|
||||
[{'path': '/non-existent', 'op': 'remove'}],
|
||||
expect_errors=True)
|
||||
[{'path': '/non-existent', 'op': 'remove'}],
|
||||
expect_errors=True)
|
||||
self.assertEqual('application/json', response.content_type)
|
||||
self.assertEqual(400, response.status_code)
|
||||
self.assertTrue(response.json['error_message'])
|
||||
|
||||
def test_add_root(self):
|
||||
name = 'bay_model_example_B'
|
||||
response = self.patch_json('/baymodels/%s' % self.baymodel.uuid,
|
||||
[{'path': '/name', 'value': name, 'op': 'add'}])
|
||||
response = self.patch_json(
|
||||
'/baymodels/%s' % self.baymodel.uuid,
|
||||
[{'path': '/name', 'value': name, 'op': 'add'}])
|
||||
self.assertEqual('application/json', response.content_type)
|
||||
self.assertEqual(200, response.status_int)
|
||||
|
||||
|
@ -282,9 +289,10 @@ class TestPatch(api_base.FunctionalTest):
|
|||
response['coe'])
|
||||
|
||||
def test_add_root_non_existent(self):
|
||||
response = self.patch_json('/baymodels/%s' % self.baymodel.uuid,
|
||||
[{'path': '/foo', 'value': 'bar', 'op': 'add'}],
|
||||
expect_errors=True)
|
||||
response = self.patch_json(
|
||||
'/baymodels/%s' % self.baymodel.uuid,
|
||||
[{'path': '/foo', 'value': 'bar', 'op': 'add'}],
|
||||
expect_errors=True)
|
||||
self.assertEqual('application/json', response.content_type)
|
||||
self.assertEqual(400, response.status_int)
|
||||
self.assertTrue(response.json['error_message'])
|
||||
|
@ -355,7 +363,7 @@ class TestPost(api_base.FunctionalTest):
|
|||
self.assertEqual(cdict['uuid'], response.json['uuid'])
|
||||
self.assertNotIn('updated_at', response.json.keys)
|
||||
return_created_at = timeutils.parse_isotime(
|
||||
response.json['created_at']).replace(tzinfo=None)
|
||||
response.json['created_at']).replace(tzinfo=None)
|
||||
self.assertEqual(test_time, return_created_at)
|
||||
|
||||
@mock.patch.object(api_baymodel.BayModelsController, '_get_image_data')
|
||||
|
@ -421,7 +429,7 @@ class TestPost(api_base.FunctionalTest):
|
|||
|
||||
@mock.patch.object(api_baymodel.BayModelsController, '_get_image_data')
|
||||
def test_create_baymodel_with_docker_volume_size(self,
|
||||
mock_image_data):
|
||||
mock_image_data):
|
||||
with mock.patch.object(self.dbapi, 'create_baymodel',
|
||||
wraps=self.dbapi.create_baymodel) as cc_mock:
|
||||
mock_image_data.return_value = {'name': 'mock_name',
|
||||
|
@ -429,7 +437,7 @@ class TestPost(api_base.FunctionalTest):
|
|||
cdict = apiutils.baymodel_post_data(docker_volume_size=99)
|
||||
response = self.post_json('/baymodels', cdict)
|
||||
self.assertEqual(cdict['docker_volume_size'],
|
||||
response.json['docker_volume_size'])
|
||||
response.json['docker_volume_size'])
|
||||
cc_mock.assert_called_once_with(mock.ANY)
|
||||
self.assertNotIn('id', cc_mock.call_args[0][0])
|
||||
|
||||
|
@ -554,9 +562,9 @@ class TestDelete(api_base.FunctionalTest):
|
|||
|
||||
def test_delete_multiple_baymodel_by_name(self):
|
||||
obj_utils.create_test_baymodel(self.context, name='test_baymodel',
|
||||
uuid=utils.generate_uuid())
|
||||
uuid=utils.generate_uuid())
|
||||
obj_utils.create_test_baymodel(self.context, name='test_baymodel',
|
||||
uuid=utils.generate_uuid())
|
||||
uuid=utils.generate_uuid())
|
||||
response = self.delete('/baymodels/test_baymodel', expect_errors=True)
|
||||
self.assertEqual(409, response.status_int)
|
||||
self.assertEqual('application/json', response.content_type)
|
||||
|
|
|
@ -171,8 +171,9 @@ class TestContainerController(db_base.DbTestCase):
|
|||
|
||||
response = self.app.get('/v1/containers/%s' % test_container['uuid'])
|
||||
|
||||
mock_container_get_by_uuid.assert_called_once_with(mock.ANY,
|
||||
test_container['uuid'])
|
||||
mock_container_get_by_uuid.assert_called_once_with(
|
||||
mock.ANY,
|
||||
test_container['uuid'])
|
||||
self.assertEqual(response.status_int, 200)
|
||||
self.assertEqual(response.json['uuid'],
|
||||
test_container['uuid'])
|
||||
|
@ -188,8 +189,9 @@ class TestContainerController(db_base.DbTestCase):
|
|||
|
||||
response = self.app.get('/v1/containers/%s' % test_container['name'])
|
||||
|
||||
mock_container_get_by_name.assert_called_once_with(mock.ANY,
|
||||
test_container['name'])
|
||||
mock_container_get_by_name.assert_called_once_with(
|
||||
mock.ANY,
|
||||
test_container['name'])
|
||||
self.assertEqual(response.status_int, 200)
|
||||
self.assertEqual(response.json['uuid'],
|
||||
test_container['uuid'])
|
||||
|
@ -206,8 +208,8 @@ class TestContainerController(db_base.DbTestCase):
|
|||
'op': 'replace'}]
|
||||
container_uuid = test_container.get('uuid')
|
||||
response = self.app.patch_json(
|
||||
'/v1/containers/%s' % container_uuid,
|
||||
params=params)
|
||||
'/v1/containers/%s' % container_uuid,
|
||||
params=params)
|
||||
|
||||
mock_save.assert_called_once_with()
|
||||
self.assertEqual(response.status_int, 200)
|
||||
|
@ -225,8 +227,8 @@ class TestContainerController(db_base.DbTestCase):
|
|||
'op': 'replace'}]
|
||||
container_name = test_container.get('name')
|
||||
response = self.app.patch_json(
|
||||
'/v1/containers/%s' % container_name,
|
||||
params=params)
|
||||
'/v1/containers/%s' % container_name,
|
||||
params=params)
|
||||
|
||||
mock_save.assert_called_once_with()
|
||||
self.assertEqual(response.status_int, 200)
|
||||
|
@ -252,70 +254,70 @@ class TestContainerController(db_base.DbTestCase):
|
|||
test_container = utils.get_test_container()
|
||||
self._action_test(test_container, 'start', 'uuid')
|
||||
mock_container_start.assert_called_once_with(
|
||||
test_container.get('uuid'))
|
||||
test_container.get('uuid'))
|
||||
|
||||
@patch('magnum.conductor.api.API.container_start')
|
||||
def test_start_by_name(self, mock_container_start):
|
||||
test_container = utils.get_test_container()
|
||||
self._action_test(test_container, 'start', 'name')
|
||||
mock_container_start.assert_called_once_with(
|
||||
test_container.get('uuid'))
|
||||
test_container.get('uuid'))
|
||||
|
||||
@patch('magnum.conductor.api.API.container_stop')
|
||||
def test_stop_by_uuid(self, mock_container_stop):
|
||||
test_container = utils.get_test_container()
|
||||
self._action_test(test_container, 'stop', 'uuid')
|
||||
mock_container_stop.assert_called_once_with(
|
||||
test_container.get('uuid'))
|
||||
test_container.get('uuid'))
|
||||
|
||||
@patch('magnum.conductor.api.API.container_stop')
|
||||
def test_stop_by_name(self, mock_container_stop):
|
||||
test_container = utils.get_test_container()
|
||||
self._action_test(test_container, 'stop', 'name')
|
||||
mock_container_stop.assert_called_once_with(
|
||||
test_container.get('uuid'))
|
||||
test_container.get('uuid'))
|
||||
|
||||
@patch('magnum.conductor.api.API.container_pause')
|
||||
def test_pause_by_uuid(self, mock_container_pause):
|
||||
test_container = utils.get_test_container()
|
||||
self._action_test(test_container, 'pause', 'uuid')
|
||||
mock_container_pause.assert_called_once_with(
|
||||
test_container.get('uuid'))
|
||||
test_container.get('uuid'))
|
||||
|
||||
@patch('magnum.conductor.api.API.container_pause')
|
||||
def test_pause_by_name(self, mock_container_pause):
|
||||
test_container = utils.get_test_container()
|
||||
self._action_test(test_container, 'pause', 'name')
|
||||
mock_container_pause.assert_called_once_with(
|
||||
test_container.get('uuid'))
|
||||
test_container.get('uuid'))
|
||||
|
||||
@patch('magnum.conductor.api.API.container_unpause')
|
||||
def test_unpause_by_uuid(self, mock_container_unpause):
|
||||
test_container = utils.get_test_container()
|
||||
self._action_test(test_container, 'unpause', 'uuid')
|
||||
mock_container_unpause.assert_called_once_with(
|
||||
test_container.get('uuid'))
|
||||
test_container.get('uuid'))
|
||||
|
||||
@patch('magnum.conductor.api.API.container_unpause')
|
||||
def test_unpause_by_name(self, mock_container_unpause):
|
||||
test_container = utils.get_test_container()
|
||||
self._action_test(test_container, 'unpause', 'name')
|
||||
mock_container_unpause.assert_called_once_with(
|
||||
test_container.get('uuid'))
|
||||
test_container.get('uuid'))
|
||||
|
||||
@patch('magnum.conductor.api.API.container_reboot')
|
||||
def test_reboot_by_uuid(self, mock_container_reboot):
|
||||
test_container = utils.get_test_container()
|
||||
self._action_test(test_container, 'reboot', 'uuid')
|
||||
mock_container_reboot.assert_called_once_with(
|
||||
test_container.get('uuid'))
|
||||
test_container.get('uuid'))
|
||||
|
||||
@patch('magnum.conductor.api.API.container_reboot')
|
||||
def test_reboot_by_name(self, mock_container_reboot):
|
||||
test_container = utils.get_test_container()
|
||||
self._action_test(test_container, 'reboot', 'name')
|
||||
mock_container_reboot.assert_called_once_with(
|
||||
test_container.get('uuid'))
|
||||
test_container.get('uuid'))
|
||||
|
||||
@patch('magnum.conductor.api.API.container_logs')
|
||||
@patch('magnum.objects.Container.get_by_uuid')
|
||||
|
|
|
@ -138,7 +138,7 @@ class TestPatch(api_base.FunctionalTest):
|
|||
response = self.get_json('/nodes/%s' % self.node.uuid)
|
||||
self.assertEqual(new_image, response['image_id'])
|
||||
return_updated_at = timeutils.parse_isotime(
|
||||
response['updated_at']).replace(tzinfo=None)
|
||||
response['updated_at']).replace(tzinfo=None)
|
||||
self.assertEqual(test_time, return_updated_at)
|
||||
|
||||
def test_replace_non_existent_node(self):
|
||||
|
@ -152,8 +152,9 @@ class TestPatch(api_base.FunctionalTest):
|
|||
|
||||
def test_add_ok(self):
|
||||
new_image = 'Ubuntu'
|
||||
response = self.patch_json('/nodes/%s' % self.node.uuid,
|
||||
[{'path': '/image_id', 'value': new_image, 'op': 'add'}])
|
||||
response = self.patch_json(
|
||||
'/nodes/%s' % self.node.uuid,
|
||||
[{'path': '/image_id', 'value': new_image, 'op': 'add'}])
|
||||
self.assertEqual('application/json', response.content_type)
|
||||
self.assertEqual(200, response.status_int)
|
||||
|
||||
|
@ -161,9 +162,10 @@ class TestPatch(api_base.FunctionalTest):
|
|||
self.assertEqual(new_image, response['image_id'])
|
||||
|
||||
def test_add_non_existent_property(self):
|
||||
response = self.patch_json('/nodes/%s' % self.node.uuid,
|
||||
[{'path': '/foo', 'value': 'bar', 'op': 'add'}],
|
||||
expect_errors=True)
|
||||
response = self.patch_json(
|
||||
'/nodes/%s' % self.node.uuid,
|
||||
[{'path': '/foo', 'value': 'bar', 'op': 'add'}],
|
||||
expect_errors=True)
|
||||
self.assertEqual('application/json', response.content_type)
|
||||
self.assertEqual(400, response.status_int)
|
||||
self.assertTrue(response.json['error_message'])
|
||||
|
@ -189,9 +191,10 @@ class TestPatch(api_base.FunctionalTest):
|
|||
self.assertTrue(response.json['error_message'])
|
||||
|
||||
def test_remove_non_existent_property(self):
|
||||
response = self.patch_json('/nodes/%s' % self.node.uuid,
|
||||
[{'path': '/non-existent', 'op': 'remove'}],
|
||||
expect_errors=True)
|
||||
response = self.patch_json(
|
||||
'/nodes/%s' % self.node.uuid,
|
||||
[{'path': '/non-existent', 'op': 'remove'}],
|
||||
expect_errors=True)
|
||||
self.assertEqual(400, response.status_code)
|
||||
self.assertEqual('application/json', response.content_type)
|
||||
self.assertTrue(response.json['error_message'])
|
||||
|
@ -216,7 +219,7 @@ class TestPost(api_base.FunctionalTest):
|
|||
self.assertEqual(node_dict['uuid'], response.json['uuid'])
|
||||
self.assertNotIn('updated_at', response.json.keys)
|
||||
return_created_at = timeutils.parse_isotime(
|
||||
response.json['created_at']).replace(tzinfo=None)
|
||||
response.json['created_at']).replace(tzinfo=None)
|
||||
self.assertEqual(test_time, return_created_at)
|
||||
|
||||
def test_create_node_doesnt_contain_id(self):
|
||||
|
|
|
@ -169,7 +169,7 @@ class TestPatch(api_base.FunctionalTest):
|
|||
response = self.get_json('/pods/%s' % self.pod.uuid)
|
||||
self.assertEqual(new_desc, response['desc'])
|
||||
return_updated_at = timeutils.parse_isotime(
|
||||
response['updated_at']).replace(tzinfo=None)
|
||||
response['updated_at']).replace(tzinfo=None)
|
||||
self.assertEqual(test_time, return_updated_at)
|
||||
|
||||
def test_replace_bay_uuid(self):
|
||||
|
@ -194,9 +194,10 @@ class TestPatch(api_base.FunctionalTest):
|
|||
self.assertTrue(response.json['error_message'])
|
||||
|
||||
def test_replace_internal_field(self):
|
||||
response = self.patch_json('/pods/%s' % self.pod.uuid,
|
||||
[{'path': '/labels', 'value': {}, 'op': 'replace'}],
|
||||
expect_errors=True)
|
||||
response = self.patch_json(
|
||||
'/pods/%s' % self.pod.uuid,
|
||||
[{'path': '/labels', 'value': {}, 'op': 'replace'}],
|
||||
expect_errors=True)
|
||||
self.assertEqual('application/json', response.content_type)
|
||||
self.assertEqual(400, response.status_code)
|
||||
self.assertTrue(response.json['error_message'])
|
||||
|
@ -225,8 +226,9 @@ class TestPatch(api_base.FunctionalTest):
|
|||
|
||||
def test_add_ok(self):
|
||||
new_desc = 'pod_example_B_desc'
|
||||
response = self.patch_json('/pods/%s' % self.pod.uuid,
|
||||
[{'path': '/desc', 'value': new_desc, 'op': 'add'}])
|
||||
response = self.patch_json(
|
||||
'/pods/%s' % self.pod.uuid,
|
||||
[{'path': '/desc', 'value': new_desc, 'op': 'add'}])
|
||||
self.assertEqual('application/json', response.content_type)
|
||||
self.assertEqual(200, response.status_int)
|
||||
|
||||
|
@ -261,9 +263,10 @@ class TestPatch(api_base.FunctionalTest):
|
|||
self.assertEqual(new_desc, response['desc'])
|
||||
|
||||
def test_add_non_existent_property(self):
|
||||
response = self.patch_json('/pods/%s' % self.pod.uuid,
|
||||
[{'path': '/foo', 'value': 'bar', 'op': 'add'}],
|
||||
expect_errors=True)
|
||||
response = self.patch_json(
|
||||
'/pods/%s' % self.pod.uuid,
|
||||
[{'path': '/foo', 'value': 'bar', 'op': 'add'}],
|
||||
expect_errors=True)
|
||||
self.assertEqual('application/json', response.content_type)
|
||||
self.assertEqual(400, response.status_int)
|
||||
self.assertTrue(response.json['error_message'])
|
||||
|
@ -305,9 +308,10 @@ class TestPatch(api_base.FunctionalTest):
|
|||
self.assertTrue(response.json['error_message'])
|
||||
|
||||
def test_remove_non_existent_property(self):
|
||||
response = self.patch_json('/pods/%s' % self.pod.uuid,
|
||||
[{'path': '/non-existent', 'op': 'remove'}],
|
||||
expect_errors=True)
|
||||
response = self.patch_json(
|
||||
'/pods/%s' % self.pod.uuid,
|
||||
[{'path': '/non-existent', 'op': 'remove'}],
|
||||
expect_errors=True)
|
||||
self.assertEqual(400, response.status_code)
|
||||
self.assertEqual('application/json', response.content_type)
|
||||
self.assertTrue(response.json['error_message'])
|
||||
|
@ -325,7 +329,7 @@ class TestPatch(api_base.FunctionalTest):
|
|||
response = self.get_json('/pods/%s' % self.pod.uuid)
|
||||
self.assertEqual('pod1', response['name'])
|
||||
return_updated_at = timeutils.parse_isotime(
|
||||
response['updated_at']).replace(tzinfo=None)
|
||||
response['updated_at']).replace(tzinfo=None)
|
||||
self.assertEqual(test_time, return_updated_at)
|
||||
|
||||
@mock.patch('oslo_utils.timeutils.utcnow')
|
||||
|
@ -388,7 +392,7 @@ class TestPost(api_base.FunctionalTest):
|
|||
self.assertEqual(pdict['uuid'], response.json['uuid'])
|
||||
self.assertNotIn('updated_at', response.json.keys)
|
||||
return_created_at = timeutils.parse_isotime(
|
||||
response.json['created_at']).replace(tzinfo=None)
|
||||
response.json['created_at']).replace(tzinfo=None)
|
||||
self.assertEqual(test_time, return_created_at)
|
||||
|
||||
def test_create_pod_doesnt_contain_id(self):
|
||||
|
|
|
@ -72,17 +72,20 @@ class TestListRC(api_base.FunctionalTest):
|
|||
self._assert_rc_fields(response)
|
||||
|
||||
def test_get_one_by_name_not_found(self):
|
||||
response = self.get_json('/rcs/not_found',
|
||||
expect_errors=True)
|
||||
response = self.get_json(
|
||||
'/rcs/not_found',
|
||||
expect_errors=True)
|
||||
self.assertEqual(404, response.status_int)
|
||||
self.assertEqual('application/json', response.content_type)
|
||||
self.assertTrue(response.json['error_message'])
|
||||
|
||||
def test_get_one_by_name_multiple_rc(self):
|
||||
obj_utils.create_test_rc(self.context, name='test_rc',
|
||||
uuid=utils.generate_uuid())
|
||||
obj_utils.create_test_rc(self.context, name='test_rc',
|
||||
uuid=utils.generate_uuid())
|
||||
obj_utils.create_test_rc(
|
||||
self.context, name='test_rc',
|
||||
uuid=utils.generate_uuid())
|
||||
obj_utils.create_test_rc(
|
||||
self.context, name='test_rc',
|
||||
uuid=utils.generate_uuid())
|
||||
response = self.get_json('/rcs/test_rc', expect_errors=True)
|
||||
self.assertEqual(409, response.status_int)
|
||||
self.assertEqual('application/json', response.content_type)
|
||||
|
@ -125,7 +128,7 @@ class TestListRC(api_base.FunctionalTest):
|
|||
def test_collection_links(self):
|
||||
for id_ in range(5):
|
||||
obj_utils.create_test_rc(self.context, id=id_,
|
||||
uuid=utils.generate_uuid())
|
||||
uuid=utils.generate_uuid())
|
||||
response = self.get_json('/rcs/?limit=3')
|
||||
self.assertEqual(3, len(response['rcs']))
|
||||
|
||||
|
@ -151,8 +154,9 @@ class TestPatch(api_base.FunctionalTest):
|
|||
obj_utils.create_test_bay(self.context)
|
||||
self.rc = obj_utils.create_test_rc(self.context,
|
||||
images=['rc_example_A_image'])
|
||||
self.another_bay = obj_utils.create_test_bay(self.context,
|
||||
uuid=utils.generate_uuid())
|
||||
self.another_bay = obj_utils.create_test_bay(
|
||||
self.context,
|
||||
uuid=utils.generate_uuid())
|
||||
|
||||
@mock.patch('oslo_utils.timeutils.utcnow')
|
||||
def test_replace_ok(self, mock_utcnow):
|
||||
|
@ -173,7 +177,7 @@ class TestPatch(api_base.FunctionalTest):
|
|||
response = self.get_json('/rcs/%s' % self.rc.uuid)
|
||||
self.assertEqual(new_image, response['images'][0])
|
||||
return_updated_at = timeutils.parse_isotime(
|
||||
response['updated_at']).replace(tzinfo=None)
|
||||
response['updated_at']).replace(tzinfo=None)
|
||||
self.assertEqual(test_time, return_updated_at)
|
||||
|
||||
def test_replace_bay_uuid(self):
|
||||
|
@ -196,9 +200,10 @@ class TestPatch(api_base.FunctionalTest):
|
|||
self.assertTrue(response.json['error_message'])
|
||||
|
||||
def test_replace_internal_field(self):
|
||||
response = self.patch_json('/rcs/%s' % self.rc.uuid,
|
||||
[{'path': '/labels', 'value': {}, 'op': 'replace'}],
|
||||
expect_errors=True)
|
||||
response = self.patch_json(
|
||||
'/rcs/%s' % self.rc.uuid,
|
||||
[{'path': '/labels', 'value': {}, 'op': 'replace'}],
|
||||
expect_errors=True)
|
||||
self.assertEqual('application/json', response.content_type)
|
||||
self.assertEqual(400, response.status_code)
|
||||
self.assertTrue(response.json['error_message'])
|
||||
|
@ -217,9 +222,9 @@ class TestPatch(api_base.FunctionalTest):
|
|||
@mock.patch.object(api_rc.ReplicationController, 'parse_manifest')
|
||||
def test_replace_with_manifest(self, parse_manifest, rc_update):
|
||||
response = self.patch_json('/rcs/%s' % self.rc.uuid,
|
||||
[{'path': '/manifest',
|
||||
'value': '{}',
|
||||
'op': 'replace'}])
|
||||
[{'path': '/manifest',
|
||||
'value': '{}',
|
||||
'op': 'replace'}])
|
||||
self.assertEqual(200, response.status_int)
|
||||
self.assertEqual('application/json', response.content_type)
|
||||
parse_manifest.assert_called_once_with()
|
||||
|
@ -238,9 +243,10 @@ class TestPatch(api_base.FunctionalTest):
|
|||
self.assertEqual(new_image, response['images'][0])
|
||||
|
||||
def test_add_non_existent_property(self):
|
||||
response = self.patch_json('/rcs/%s' % self.rc.uuid,
|
||||
[{'path': '/foo', 'value': 'bar', 'op': 'add'}],
|
||||
expect_errors=True)
|
||||
response = self.patch_json(
|
||||
'/rcs/%s' % self.rc.uuid,
|
||||
[{'path': '/foo', 'value': 'bar', 'op': 'add'}],
|
||||
expect_errors=True)
|
||||
self.assertEqual('application/json', response.content_type)
|
||||
self.assertEqual(400, response.status_int)
|
||||
self.assertTrue(response.json['error_message'])
|
||||
|
@ -282,9 +288,10 @@ class TestPatch(api_base.FunctionalTest):
|
|||
self.assertTrue(response.json['error_message'])
|
||||
|
||||
def test_remove_non_existent_property(self):
|
||||
response = self.patch_json('/rcs/%s' % self.rc.uuid,
|
||||
[{'path': '/non-existent', 'op': 'remove'}],
|
||||
expect_errors=True)
|
||||
response = self.patch_json(
|
||||
'/rcs/%s' % self.rc.uuid,
|
||||
[{'path': '/non-existent', 'op': 'remove'}],
|
||||
expect_errors=True)
|
||||
self.assertEqual(400, response.status_code)
|
||||
self.assertEqual('application/json', response.content_type)
|
||||
self.assertTrue(response.json['error_message'])
|
||||
|
@ -304,7 +311,7 @@ class TestPatch(api_base.FunctionalTest):
|
|||
|
||||
response = self.get_json('/rcs/%s' % self.rc.uuid)
|
||||
return_updated_at = timeutils.parse_isotime(
|
||||
response['updated_at']).replace(tzinfo=None)
|
||||
response['updated_at']).replace(tzinfo=None)
|
||||
self.assertEqual(test_time, return_updated_at)
|
||||
|
||||
@mock.patch('oslo_utils.timeutils.utcnow')
|
||||
|
@ -329,9 +336,9 @@ class TestPatch(api_base.FunctionalTest):
|
|||
mock_utcnow.return_value = test_time
|
||||
|
||||
obj_utils.create_test_rc(self.context, name='test_rc',
|
||||
uuid=utils.generate_uuid())
|
||||
uuid=utils.generate_uuid())
|
||||
obj_utils.create_test_rc(self.context, name='test_rc',
|
||||
uuid=utils.generate_uuid())
|
||||
uuid=utils.generate_uuid())
|
||||
|
||||
response = self.patch_json('/rcs/test_rc',
|
||||
[{'path': '/images/0',
|
||||
|
@ -373,7 +380,7 @@ class TestPost(api_base.FunctionalTest):
|
|||
self.assertEqual(rc_dict['uuid'], response.json['uuid'])
|
||||
self.assertNotIn('updated_at', response.json.keys)
|
||||
return_created_at = timeutils.parse_isotime(
|
||||
response.json['created_at']).replace(tzinfo=None)
|
||||
response.json['created_at']).replace(tzinfo=None)
|
||||
self.assertEqual(test_time, return_created_at)
|
||||
|
||||
def test_create_rc_doesnt_contain_id(self):
|
||||
|
@ -478,9 +485,9 @@ class TestDelete(api_base.FunctionalTest):
|
|||
|
||||
def test_delete_multiple_rc_by_name(self):
|
||||
obj_utils.create_test_rc(self.context, name='test_rc',
|
||||
uuid=utils.generate_uuid())
|
||||
uuid=utils.generate_uuid())
|
||||
obj_utils.create_test_rc(self.context, name='test_rc',
|
||||
uuid=utils.generate_uuid())
|
||||
uuid=utils.generate_uuid())
|
||||
response = self.delete('/rcs/test_rc', expect_errors=True)
|
||||
self.assertEqual(409, response.status_int)
|
||||
self.assertEqual('application/json', response.content_type)
|
||||
|
|
|
@ -72,17 +72,20 @@ class TestListService(api_base.FunctionalTest):
|
|||
self._assert_service_fields(response)
|
||||
|
||||
def test_get_one_by_name_not_found(self):
|
||||
response = self.get_json('/services/not_found',
|
||||
expect_errors=True)
|
||||
response = self.get_json(
|
||||
'/services/not_found',
|
||||
expect_errors=True)
|
||||
self.assertEqual(404, response.status_int)
|
||||
self.assertEqual('application/json', response.content_type)
|
||||
self.assertTrue(response.json['error_message'])
|
||||
|
||||
def test_get_one_by_name_multiple_service(self):
|
||||
obj_utils.create_test_service(self.context, name='test_service',
|
||||
uuid=utils.generate_uuid())
|
||||
obj_utils.create_test_service(self.context, name='test_service',
|
||||
uuid=utils.generate_uuid())
|
||||
obj_utils.create_test_service(
|
||||
self.context, name='test_service',
|
||||
uuid=utils.generate_uuid())
|
||||
obj_utils.create_test_service(
|
||||
self.context, name='test_service',
|
||||
uuid=utils.generate_uuid())
|
||||
response = self.get_json('/services/test_service',
|
||||
expect_errors=True)
|
||||
self.assertEqual(409, response.status_int)
|
||||
|
@ -176,9 +179,10 @@ class TestPatch(api_base.FunctionalTest):
|
|||
self.assertTrue(response.json['error_message'])
|
||||
|
||||
def test_replace_internal_field(self):
|
||||
response = self.patch_json('/services/%s' % self.service.uuid,
|
||||
[{'path': '/labels', 'value': {}, 'op': 'replace'}],
|
||||
expect_errors=True)
|
||||
response = self.patch_json(
|
||||
'/services/%s' % self.service.uuid,
|
||||
[{'path': '/labels', 'value': {}, 'op': 'replace'}],
|
||||
expect_errors=True)
|
||||
self.assertEqual('application/json', response.content_type)
|
||||
self.assertEqual(400, response.status_code)
|
||||
self.assertTrue(response.json['error_message'])
|
||||
|
@ -206,9 +210,10 @@ class TestPatch(api_base.FunctionalTest):
|
|||
self.assertTrue(service_update.is_called)
|
||||
|
||||
def test_add_non_existent_property(self):
|
||||
response = self.patch_json('/services/%s' % self.service.uuid,
|
||||
[{'path': '/foo', 'value': 'bar', 'op': 'add'}],
|
||||
expect_errors=True)
|
||||
response = self.patch_json(
|
||||
'/services/%s' % self.service.uuid,
|
||||
[{'path': '/foo', 'value': 'bar', 'op': 'add'}],
|
||||
expect_errors=True)
|
||||
self.assertEqual('application/json', response.content_type)
|
||||
self.assertEqual(400, response.status_int)
|
||||
self.assertTrue(response.json['error_message'])
|
||||
|
@ -239,8 +244,8 @@ class TestPatch(api_base.FunctionalTest):
|
|||
|
||||
def test_remove_non_existent_property(self):
|
||||
response = self.patch_json('/services/%s' % self.service.uuid,
|
||||
[{'path': '/non-existent', 'op': 'remove'}],
|
||||
expect_errors=True)
|
||||
[{'path': '/non-existent', 'op': 'remove'}],
|
||||
expect_errors=True)
|
||||
self.assertEqual(400, response.status_code)
|
||||
self.assertEqual('application/json', response.content_type)
|
||||
self.assertTrue(response.json['error_message'])
|
||||
|
@ -260,7 +265,7 @@ class TestPatch(api_base.FunctionalTest):
|
|||
response = self.get_json('/services/%s' % self.service.uuid)
|
||||
self.assertEqual('service1', response['name'])
|
||||
return_updated_at = timeutils.parse_isotime(
|
||||
response['updated_at']).replace(tzinfo=None)
|
||||
response['updated_at']).replace(tzinfo=None)
|
||||
self.assertEqual(test_time, return_updated_at)
|
||||
|
||||
@mock.patch('oslo_utils.timeutils.utcnow')
|
||||
|
@ -283,9 +288,9 @@ class TestPatch(api_base.FunctionalTest):
|
|||
mock_utcnow.return_value = test_time
|
||||
|
||||
obj_utils.create_test_service(self.context, name='test_service',
|
||||
uuid=utils.generate_uuid())
|
||||
uuid=utils.generate_uuid())
|
||||
obj_utils.create_test_service(self.context, name='test_service',
|
||||
uuid=utils.generate_uuid())
|
||||
uuid=utils.generate_uuid())
|
||||
|
||||
response = self.patch_json('/services/test_service',
|
||||
[{'path': '/bay_uuid',
|
||||
|
@ -328,7 +333,7 @@ class TestPost(api_base.FunctionalTest):
|
|||
self.assertEqual(sdict['uuid'], response.json['uuid'])
|
||||
self.assertNotIn('updated_at', response.json.keys)
|
||||
return_created_at = timeutils.parse_isotime(
|
||||
response.json['created_at']).replace(tzinfo=None)
|
||||
response.json['created_at']).replace(tzinfo=None)
|
||||
self.assertEqual(test_time, return_created_at)
|
||||
|
||||
def test_create_service_doesnt_contain_id(self):
|
||||
|
@ -432,9 +437,9 @@ class TestDelete(api_base.FunctionalTest):
|
|||
|
||||
def test_delete_multiple_service_by_name(self):
|
||||
obj_utils.create_test_service(self.context, name='test_service',
|
||||
uuid=utils.generate_uuid())
|
||||
uuid=utils.generate_uuid())
|
||||
obj_utils.create_test_service(self.context, name='test_service',
|
||||
uuid=utils.generate_uuid())
|
||||
uuid=utils.generate_uuid())
|
||||
response = self.delete('/services/test_service', expect_errors=True)
|
||||
self.assertEqual(409, response.status_int)
|
||||
self.assertEqual('application/json', response.content_type)
|
||||
|
|
|
@ -80,9 +80,10 @@ class TestJsonPatchType(base.FunctionalTest):
|
|||
self.app = webtest.TestApp(MyRoot(['restjson']).wsgiapp())
|
||||
|
||||
def _patch_json(self, params, expect_errors=False):
|
||||
return self.app.patch_json('/test', params=params,
|
||||
headers={'Accept': 'application/json'},
|
||||
expect_errors=expect_errors)
|
||||
return self.app.patch_json(
|
||||
'/test', params=params,
|
||||
headers={'Accept': 'application/json'},
|
||||
expect_errors=expect_errors)
|
||||
|
||||
def test_valid_patches(self):
|
||||
valid_patches = [{'path': '/extra/foo', 'op': 'remove'},
|
||||
|
|
|
@ -35,7 +35,7 @@ class ClientsTest(base.BaseTestCase):
|
|||
@mock.patch.object(clients.OpenStackClients, 'url_for')
|
||||
@mock.patch.object(clients.OpenStackClients, 'auth_url')
|
||||
def _test_clients_heat(self, expected_region_name, mock_auth, mock_url,
|
||||
mock_call):
|
||||
mock_call):
|
||||
mock_auth.__get__ = mock.Mock(return_value="keystone_url")
|
||||
con = mock.MagicMock()
|
||||
con.auth_token = "3bcc3d3a03f44e3d8377f9247b0ad155"
|
||||
|
@ -91,7 +91,7 @@ class ClientsTest(base.BaseTestCase):
|
|||
@mock.patch.object(clients.OpenStackClients, 'url_for')
|
||||
@mock.patch.object(clients.OpenStackClients, 'auth_url')
|
||||
def _test_clients_glance(self, expected_region_name, mock_auth, mock_url,
|
||||
mock_call):
|
||||
mock_call):
|
||||
mock_auth.__get__ = mock.Mock(return_value="keystone_url")
|
||||
con = mock.MagicMock()
|
||||
con.auth_token = "3bcc3d3a03f44e3d8377f9247b0ad155"
|
||||
|
|
|
@ -113,11 +113,11 @@ exit 1
|
|||
runs = fp.read()
|
||||
fp.close()
|
||||
self.assertNotEqual(runs.strip(), 'failure', 'stdin did not '
|
||||
'always get passed '
|
||||
'correctly')
|
||||
'always get passed '
|
||||
'correctly')
|
||||
runs = int(runs.strip())
|
||||
self.assertEqual(10, runs,
|
||||
'Ran %d times instead of 10.' % (runs,))
|
||||
'Ran %d times instead of 10.' % (runs,))
|
||||
finally:
|
||||
os.unlink(tmpfilename)
|
||||
os.unlink(tmpfilename2)
|
||||
|
@ -291,33 +291,36 @@ class GenericUtilsTestCase(base.TestCase):
|
|||
def test_is_valid_ipv6_cidr(self):
|
||||
self.assertTrue(utils.is_valid_ipv6_cidr("2600::/64"))
|
||||
self.assertTrue(utils.is_valid_ipv6_cidr(
|
||||
"abcd:ef01:2345:6789:abcd:ef01:192.168.254.254/48"))
|
||||
"abcd:ef01:2345:6789:abcd:ef01:192.168.254.254/48"))
|
||||
self.assertTrue(utils.is_valid_ipv6_cidr(
|
||||
"0000:0000:0000:0000:0000:0000:0000:0001/32"))
|
||||
"0000:0000:0000:0000:0000:0000:0000:0001/32"))
|
||||
self.assertTrue(utils.is_valid_ipv6_cidr(
|
||||
"0000:0000:0000:0000:0000:0000:0000:0001"))
|
||||
"0000:0000:0000:0000:0000:0000:0000:0001"))
|
||||
self.assertFalse(utils.is_valid_ipv6_cidr("foo"))
|
||||
self.assertFalse(utils.is_valid_ipv6_cidr("127.0.0.1"))
|
||||
|
||||
def test_get_shortened_ipv6(self):
|
||||
self.assertEqual("abcd:ef01:2345:6789:abcd:ef01:c0a8:fefe",
|
||||
utils.get_shortened_ipv6(
|
||||
"abcd:ef01:2345:6789:abcd:ef01:192.168.254.254"))
|
||||
self.assertEqual("::1", utils.get_shortened_ipv6(
|
||||
"0000:0000:0000:0000:0000:0000:0000:0001"))
|
||||
utils.get_shortened_ipv6(
|
||||
"abcd:ef01:2345:6789:abcd:ef01:192.168.254.254"))
|
||||
self.assertEqual("::1",
|
||||
utils.get_shortened_ipv6(
|
||||
"0000:0000:0000:0000:0000:0000:0000:0001"))
|
||||
self.assertEqual("caca::caca:0:babe:201:102",
|
||||
utils.get_shortened_ipv6(
|
||||
"caca:0000:0000:caca:0000:babe:0201:0102"))
|
||||
utils.get_shortened_ipv6(
|
||||
"caca:0000:0000:caca:0000:babe:0201:0102"))
|
||||
self.assertRaises(netaddr.AddrFormatError, utils.get_shortened_ipv6,
|
||||
"127.0.0.1")
|
||||
self.assertRaises(netaddr.AddrFormatError, utils.get_shortened_ipv6,
|
||||
"failure")
|
||||
|
||||
def test_get_shortened_ipv6_cidr(self):
|
||||
self.assertEqual("2600::/64", utils.get_shortened_ipv6_cidr(
|
||||
"2600:0000:0000:0000:0000:0000:0000:0000/64"))
|
||||
self.assertEqual("2600::/64", utils.get_shortened_ipv6_cidr(
|
||||
"2600::1/64"))
|
||||
self.assertEqual("2600::/64",
|
||||
utils.get_shortened_ipv6_cidr(
|
||||
"2600:0000:0000:0000:0000:0000:0000:0000/64"))
|
||||
self.assertEqual("2600::/64",
|
||||
utils.get_shortened_ipv6_cidr(
|
||||
"2600::1/64"))
|
||||
self.assertRaises(netaddr.AddrFormatError,
|
||||
utils.get_shortened_ipv6_cidr,
|
||||
"127.0.0.1")
|
||||
|
|
|
@ -101,7 +101,7 @@ class DockerClientTestCase(base.BaseTestCase):
|
|||
mock_url.assert_called_once_with('/containers/someid/pause')
|
||||
mock_post.assert_callend_once_with(mock_url.return_value)
|
||||
mock_raise_for_status.assert_called_once_with(
|
||||
mock_post.return_value)
|
||||
mock_post.return_value)
|
||||
|
||||
@mock.patch.object(docker_py_client.Client, '_raise_for_status')
|
||||
@mock.patch.object(docker_py_client.Client, '_post')
|
||||
|
@ -115,7 +115,7 @@ class DockerClientTestCase(base.BaseTestCase):
|
|||
mock_url.assert_called_once_with('/containers/someid/pause')
|
||||
mock_post.assert_callend_once_with(mock_url.return_value)
|
||||
mock_raise_for_status.assert_called_once_with(
|
||||
mock_post.return_value)
|
||||
mock_post.return_value)
|
||||
|
||||
@mock.patch.object(docker_py_client.Client, '_raise_for_status')
|
||||
@mock.patch.object(docker_py_client.Client, '_post')
|
||||
|
@ -128,7 +128,7 @@ class DockerClientTestCase(base.BaseTestCase):
|
|||
mock_url.assert_called_once_with('/containers/someid/unpause')
|
||||
mock_post.assert_callend_once_with(mock_url.return_value)
|
||||
mock_raise_for_status.assert_called_once_with(
|
||||
mock_post.return_value)
|
||||
mock_post.return_value)
|
||||
|
||||
@mock.patch.object(docker_py_client.Client, '_raise_for_status')
|
||||
@mock.patch.object(docker_py_client.Client, '_post')
|
||||
|
@ -142,7 +142,7 @@ class DockerClientTestCase(base.BaseTestCase):
|
|||
mock_url.assert_called_once_with('/containers/someid/unpause')
|
||||
mock_post.assert_callend_once_with(mock_url.return_value)
|
||||
mock_raise_for_status.assert_called_once_with(
|
||||
mock_post.return_value)
|
||||
mock_post.return_value)
|
||||
|
||||
@mock.patch.object(docker_py_client.Client, 'attach')
|
||||
def test_get_container_logs(self, mock_attach):
|
||||
|
|
|
@ -39,7 +39,7 @@ class TestKubeUtils(base.BaseTestCase):
|
|||
|
||||
@patch('magnum.conductor.handlers.common.kube_utils._k8s_create_with_path')
|
||||
def test_k8s_create_url(self,
|
||||
mock_create_with_path):
|
||||
mock_create_with_path):
|
||||
expected_url = 'url'
|
||||
api_address = 'api_address'
|
||||
mock_resource = mock.MagicMock()
|
||||
|
@ -77,7 +77,8 @@ class TestKubeUtils(base.BaseTestCase):
|
|||
mock_file.name = expected_filename
|
||||
mock_named_tempfile.return_value.__enter__.return_value = mock_file
|
||||
|
||||
kube_utils._k8s_create_with_data(expected_api_address,
|
||||
kube_utils._k8s_create_with_data(
|
||||
expected_api_address,
|
||||
expected_data)
|
||||
|
||||
mock_file.write.assert_called_once_with(expected_data)
|
||||
|
@ -137,7 +138,8 @@ class TestKubeUtils(base.BaseTestCase):
|
|||
mock_file.name = expected_filename
|
||||
mock_named_tempfile.return_value.__enter__.return_value = mock_file
|
||||
|
||||
kube_utils._k8s_update_with_data(expected_api_address,
|
||||
kube_utils._k8s_update_with_data(
|
||||
expected_api_address,
|
||||
expected_data)
|
||||
|
||||
mock_file.write.assert_called_once_with(expected_data)
|
||||
|
@ -155,8 +157,8 @@ class KubeClientTestCase(base.TestCase):
|
|||
expected_api_address = 'master-address'
|
||||
expected_pod_content = mock.MagicMock(manifest='pod_content')
|
||||
expected_command = [
|
||||
expected_api_address,
|
||||
expected_pod_content
|
||||
expected_api_address,
|
||||
expected_pod_content,
|
||||
]
|
||||
mock_k8s_create.return_value = ("", "")
|
||||
|
||||
|
@ -170,8 +172,8 @@ class KubeClientTestCase(base.TestCase):
|
|||
expected_api_address = 'master-address'
|
||||
expected_pod_content = mock.MagicMock(manifest='pod_content')
|
||||
expected_command = [
|
||||
expected_api_address,
|
||||
expected_pod_content
|
||||
expected_api_address,
|
||||
expected_pod_content,
|
||||
]
|
||||
mock_k8s_create.return_value = ("", "create failed")
|
||||
|
||||
|
@ -185,8 +187,8 @@ class KubeClientTestCase(base.TestCase):
|
|||
expected_api_address = 'master-address'
|
||||
expected_pod_content = mock.MagicMock(manifest='pod_content')
|
||||
expected_command = [
|
||||
expected_api_address,
|
||||
expected_pod_content
|
||||
expected_api_address,
|
||||
expected_pod_content,
|
||||
]
|
||||
mock_k8s_create.side_effect = Exception()
|
||||
result = self.kube_client.pod_create(expected_api_address,
|
||||
|
@ -199,8 +201,8 @@ class KubeClientTestCase(base.TestCase):
|
|||
expected_api_address = 'master-address'
|
||||
expected_pod_content = mock.MagicMock(manifest='pod_content')
|
||||
expected_command = [
|
||||
expected_api_address,
|
||||
expected_pod_content
|
||||
expected_api_address,
|
||||
expected_pod_content,
|
||||
]
|
||||
mock_k8s_update.return_value = ("", "")
|
||||
|
||||
|
@ -214,8 +216,8 @@ class KubeClientTestCase(base.TestCase):
|
|||
expected_api_address = 'master-address'
|
||||
expected_pod_content = mock.MagicMock(manifest='pod_content')
|
||||
expected_command = [
|
||||
expected_api_address,
|
||||
expected_pod_content
|
||||
expected_api_address,
|
||||
expected_pod_content,
|
||||
]
|
||||
mock_k8s_update.return_value = ("", "create failed")
|
||||
|
||||
|
@ -229,8 +231,8 @@ class KubeClientTestCase(base.TestCase):
|
|||
expected_api_address = 'master-address'
|
||||
expected_pod_content = mock.MagicMock(manifest='pod_content')
|
||||
expected_command = [
|
||||
expected_api_address,
|
||||
expected_pod_content
|
||||
expected_api_address,
|
||||
expected_pod_content,
|
||||
]
|
||||
mock_k8s_update.side_effect = Exception()
|
||||
result = self.kube_client.pod_update(expected_api_address,
|
||||
|
@ -324,7 +326,7 @@ class KubeClientTestCase(base.TestCase):
|
|||
mock_trycmd.return_value = ("", "")
|
||||
|
||||
result = self.kube_client.service_delete(expected_api_address,
|
||||
expected_service_name)
|
||||
expected_service_name)
|
||||
self.assertTrue(result)
|
||||
mock_trycmd.assert_called_once_with(*expected_command)
|
||||
|
||||
|
@ -339,7 +341,7 @@ class KubeClientTestCase(base.TestCase):
|
|||
mock_trycmd.side_effect = Exception()
|
||||
|
||||
result = self.kube_client.service_delete(expected_api_address,
|
||||
expected_service_name)
|
||||
expected_service_name)
|
||||
self.assertFalse(result)
|
||||
mock_trycmd.assert_called_once_with(*expected_command)
|
||||
|
||||
|
@ -348,8 +350,8 @@ class KubeClientTestCase(base.TestCase):
|
|||
expected_api_address = 'master-address'
|
||||
expected_service_content = mock.MagicMock(manifest='service_content')
|
||||
expected_command = [
|
||||
expected_api_address,
|
||||
expected_service_content
|
||||
expected_api_address,
|
||||
expected_service_content,
|
||||
]
|
||||
mock_k8s_update.return_value = ("", "")
|
||||
|
||||
|
@ -363,8 +365,8 @@ class KubeClientTestCase(base.TestCase):
|
|||
expected_api_address = 'master-address'
|
||||
expected_service_content = mock.MagicMock(manifest='service_content')
|
||||
expected_command = [
|
||||
expected_api_address,
|
||||
expected_service_content
|
||||
expected_api_address,
|
||||
expected_service_content,
|
||||
]
|
||||
mock_k8s_update.return_value = ("", "create failed")
|
||||
|
||||
|
@ -378,8 +380,8 @@ class KubeClientTestCase(base.TestCase):
|
|||
expected_api_address = 'master-address'
|
||||
expected_service_content = mock.MagicMock(manifest='service_content')
|
||||
expected_command = [
|
||||
expected_api_address,
|
||||
expected_service_content
|
||||
expected_api_address,
|
||||
expected_service_content,
|
||||
]
|
||||
mock_k8s_update.side_effect = Exception()
|
||||
result = self.kube_client.service_update(expected_api_address,
|
||||
|
@ -392,8 +394,8 @@ class KubeClientTestCase(base.TestCase):
|
|||
expected_api_address = 'master-address'
|
||||
expected_service_content = mock.MagicMock(manifest='service_content')
|
||||
expected_command = [
|
||||
expected_api_address,
|
||||
expected_service_content
|
||||
expected_api_address,
|
||||
expected_service_content,
|
||||
]
|
||||
mock_k8s_create.return_value = ("", "")
|
||||
|
||||
|
@ -407,8 +409,8 @@ class KubeClientTestCase(base.TestCase):
|
|||
expected_api_address = 'master-address'
|
||||
expected_service_content = mock.MagicMock(manifest='service_content')
|
||||
expected_command = [
|
||||
expected_api_address,
|
||||
expected_service_content
|
||||
expected_api_address,
|
||||
expected_service_content,
|
||||
]
|
||||
mock_k8s_create.return_value = ("", "create failed")
|
||||
|
||||
|
@ -422,8 +424,8 @@ class KubeClientTestCase(base.TestCase):
|
|||
expected_api_address = 'master-address'
|
||||
expected_service_content = mock.MagicMock(manifest='service_content')
|
||||
expected_command = [
|
||||
expected_api_address,
|
||||
expected_service_content
|
||||
expected_api_address,
|
||||
expected_service_content,
|
||||
]
|
||||
mock_k8s_create.side_effect = Exception()
|
||||
result = self.kube_client.service_create(expected_api_address,
|
||||
|
@ -436,8 +438,8 @@ class KubeClientTestCase(base.TestCase):
|
|||
expected_api_address = 'master-address'
|
||||
expected_rc_content = mock.MagicMock(manifest='rc_content')
|
||||
expected_command = [
|
||||
expected_api_address,
|
||||
expected_rc_content
|
||||
expected_api_address,
|
||||
expected_rc_content,
|
||||
]
|
||||
mock_k8s_update.return_value = ("", "")
|
||||
|
||||
|
@ -451,8 +453,8 @@ class KubeClientTestCase(base.TestCase):
|
|||
expected_api_address = 'master-address'
|
||||
expected_rc_content = mock.MagicMock(manifest='rc_content')
|
||||
expected_command = [
|
||||
expected_api_address,
|
||||
expected_rc_content
|
||||
expected_api_address,
|
||||
expected_rc_content,
|
||||
]
|
||||
mock_k8s_update.return_value = ("", "update failed")
|
||||
|
||||
|
@ -466,8 +468,8 @@ class KubeClientTestCase(base.TestCase):
|
|||
expected_api_address = 'master-address'
|
||||
expected_rc_content = mock.MagicMock(manifest='rc_content')
|
||||
expected_command = [
|
||||
expected_api_address,
|
||||
expected_rc_content
|
||||
expected_api_address,
|
||||
expected_rc_content,
|
||||
]
|
||||
mock_k8s_update.side_effect = Exception()
|
||||
result = self.kube_client.rc_update(expected_api_address,
|
||||
|
@ -480,8 +482,8 @@ class KubeClientTestCase(base.TestCase):
|
|||
expected_api_address = 'master-address'
|
||||
expected_rc_content = mock.MagicMock(manifest='rc_content')
|
||||
expected_command = [
|
||||
expected_api_address,
|
||||
expected_rc_content
|
||||
expected_api_address,
|
||||
expected_rc_content,
|
||||
]
|
||||
mock_k8s_create.return_value = ("", "")
|
||||
|
||||
|
@ -495,8 +497,8 @@ class KubeClientTestCase(base.TestCase):
|
|||
expected_api_address = 'master-address'
|
||||
expected_rc_content = mock.MagicMock(manifest='rc_content')
|
||||
expected_command = [
|
||||
expected_api_address,
|
||||
expected_rc_content
|
||||
expected_api_address,
|
||||
expected_rc_content,
|
||||
]
|
||||
mock_k8s_create.return_value = ("", "create failed")
|
||||
|
||||
|
@ -510,8 +512,8 @@ class KubeClientTestCase(base.TestCase):
|
|||
expected_api_address = 'master-address'
|
||||
expected_rc_content = mock.MagicMock(manifest='rc_content')
|
||||
expected_command = [
|
||||
expected_api_address,
|
||||
expected_rc_content
|
||||
expected_api_address,
|
||||
expected_rc_content,
|
||||
]
|
||||
mock_k8s_create.side_effect = Exception()
|
||||
result = self.kube_client.rc_create(expected_api_address,
|
||||
|
|
|
@ -64,15 +64,16 @@ class TestBayConductorWithK8s(base.TestCase):
|
|||
self.assertEqual(baymodel, fetched_baymodel)
|
||||
|
||||
@patch('magnum.objects.BayModel.get_by_uuid')
|
||||
def test_extract_template_definition(self,
|
||||
mock_objects_baymodel_get_by_uuid):
|
||||
def test_extract_template_definition(
|
||||
self,
|
||||
mock_objects_baymodel_get_by_uuid):
|
||||
baymodel = objects.BayModel(self.context, **self.baymodel_dict)
|
||||
mock_objects_baymodel_get_by_uuid.return_value = baymodel
|
||||
bay = objects.Bay(self.context, **self.bay_dict)
|
||||
|
||||
(template_path,
|
||||
definition) = bay_conductor._extract_template_definition(self.context,
|
||||
bay)
|
||||
bay)
|
||||
|
||||
expected = {
|
||||
'ssh_key_name': 'keypair_id',
|
||||
|
@ -89,9 +90,10 @@ class TestBayConductorWithK8s(base.TestCase):
|
|||
|
||||
@patch('requests.get')
|
||||
@patch('magnum.objects.BayModel.get_by_uuid')
|
||||
def test_extract_template_definition_coreos_with_disovery(self,
|
||||
mock_objects_baymodel_get_by_uuid,
|
||||
reqget):
|
||||
def test_extract_template_definition_coreos_with_disovery(
|
||||
self,
|
||||
mock_objects_baymodel_get_by_uuid,
|
||||
reqget):
|
||||
baymodel_dict = self.baymodel_dict
|
||||
baymodel_dict['cluster_distro'] = 'coreos'
|
||||
cfg.CONF.set_override('coreos_discovery_token_url',
|
||||
|
@ -105,7 +107,7 @@ class TestBayConductorWithK8s(base.TestCase):
|
|||
|
||||
(template_path,
|
||||
definition) = bay_conductor._extract_template_definition(self.context,
|
||||
bay)
|
||||
bay)
|
||||
|
||||
expected = {
|
||||
'ssh_key_name': 'keypair_id',
|
||||
|
@ -124,9 +126,10 @@ class TestBayConductorWithK8s(base.TestCase):
|
|||
|
||||
@patch('uuid.uuid4')
|
||||
@patch('magnum.objects.BayModel.get_by_uuid')
|
||||
def test_extract_template_definition_coreos_no_discoveryurl(self,
|
||||
mock_objects_baymodel_get_by_uuid,
|
||||
mock_uuid):
|
||||
def test_extract_template_definition_coreos_no_discoveryurl(
|
||||
self,
|
||||
mock_objects_baymodel_get_by_uuid,
|
||||
mock_uuid):
|
||||
baymodel_dict = self.baymodel_dict
|
||||
baymodel_dict['cluster_distro'] = 'coreos'
|
||||
cfg.CONF.set_override('coreos_discovery_token_url',
|
||||
|
@ -140,7 +143,7 @@ class TestBayConductorWithK8s(base.TestCase):
|
|||
|
||||
(template_path,
|
||||
definition) = bay_conductor._extract_template_definition(self.context,
|
||||
bay)
|
||||
bay)
|
||||
|
||||
expected = {
|
||||
'ssh_key_name': 'keypair_id',
|
||||
|
@ -158,8 +161,9 @@ class TestBayConductorWithK8s(base.TestCase):
|
|||
self.assertEqual(expected, definition)
|
||||
|
||||
@patch('magnum.objects.BayModel.get_by_uuid')
|
||||
def test_extract_template_definition_without_dns(self,
|
||||
mock_objects_baymodel_get_by_uuid):
|
||||
def test_extract_template_definition_without_dns(
|
||||
self,
|
||||
mock_objects_baymodel_get_by_uuid):
|
||||
baymodel_dict = self.baymodel_dict
|
||||
baymodel_dict['dns_nameserver'] = None
|
||||
baymodel = objects.BayModel(self.context, **baymodel_dict)
|
||||
|
@ -167,8 +171,9 @@ class TestBayConductorWithK8s(base.TestCase):
|
|||
bay = objects.Bay(self.context, **self.bay_dict)
|
||||
|
||||
(template_path,
|
||||
definition) = bay_conductor._extract_template_definition(self.context,
|
||||
bay)
|
||||
definition) = bay_conductor._extract_template_definition(
|
||||
self.context,
|
||||
bay)
|
||||
|
||||
expected = {
|
||||
'ssh_key_name': 'keypair_id',
|
||||
|
@ -183,8 +188,9 @@ class TestBayConductorWithK8s(base.TestCase):
|
|||
self.assertEqual(expected, definition)
|
||||
|
||||
@patch('magnum.objects.BayModel.get_by_uuid')
|
||||
def test_extract_template_definition_without_server_image(self,
|
||||
mock_objects_baymodel_get_by_uuid):
|
||||
def test_extract_template_definition_without_server_image(
|
||||
self,
|
||||
mock_objects_baymodel_get_by_uuid):
|
||||
baymodel_dict = self.baymodel_dict
|
||||
baymodel_dict['image_id'] = None
|
||||
baymodel = objects.BayModel(self.context, **baymodel_dict)
|
||||
|
@ -192,8 +198,9 @@ class TestBayConductorWithK8s(base.TestCase):
|
|||
bay = objects.Bay(self.context, **self.bay_dict)
|
||||
|
||||
(template_path,
|
||||
definition) = bay_conductor._extract_template_definition(self.context,
|
||||
bay)
|
||||
definition) = bay_conductor._extract_template_definition(
|
||||
self.context,
|
||||
bay)
|
||||
|
||||
expected = {
|
||||
'ssh_key_name': 'keypair_id',
|
||||
|
@ -208,8 +215,9 @@ class TestBayConductorWithK8s(base.TestCase):
|
|||
self.assertEqual(expected, definition)
|
||||
|
||||
@patch('magnum.objects.BayModel.get_by_uuid')
|
||||
def test_extract_template_definition_without_minion_flavor(self,
|
||||
mock_objects_baymodel_get_by_uuid):
|
||||
def test_extract_template_definition_without_minion_flavor(
|
||||
self,
|
||||
mock_objects_baymodel_get_by_uuid):
|
||||
baymodel_dict = self.baymodel_dict
|
||||
baymodel_dict['flavor_id'] = None
|
||||
baymodel = objects.BayModel(self.context, **baymodel_dict)
|
||||
|
@ -217,8 +225,9 @@ class TestBayConductorWithK8s(base.TestCase):
|
|||
bay = objects.Bay(self.context, **self.bay_dict)
|
||||
|
||||
(template_path,
|
||||
definition) = bay_conductor._extract_template_definition(self.context,
|
||||
bay)
|
||||
definition) = bay_conductor._extract_template_definition(
|
||||
self.context,
|
||||
bay)
|
||||
|
||||
expected = {
|
||||
'ssh_key_name': 'keypair_id',
|
||||
|
@ -233,8 +242,9 @@ class TestBayConductorWithK8s(base.TestCase):
|
|||
self.assertEqual(expected, definition)
|
||||
|
||||
@patch('magnum.objects.BayModel.get_by_uuid')
|
||||
def test_extract_template_definition_without_docker_volume_size(self,
|
||||
mock_objects_baymodel_get_by_uuid):
|
||||
def test_extract_template_definition_without_docker_volume_size(
|
||||
self,
|
||||
mock_objects_baymodel_get_by_uuid):
|
||||
baymodel_dict = self.baymodel_dict
|
||||
baymodel_dict['docker_volume_size'] = None
|
||||
baymodel = objects.BayModel(self.context, **baymodel_dict)
|
||||
|
@ -243,7 +253,7 @@ class TestBayConductorWithK8s(base.TestCase):
|
|||
|
||||
(template_path,
|
||||
definition) = bay_conductor._extract_template_definition(self.context,
|
||||
bay)
|
||||
bay)
|
||||
|
||||
expected = {
|
||||
'ssh_key_name': 'keypair_id',
|
||||
|
@ -258,8 +268,9 @@ class TestBayConductorWithK8s(base.TestCase):
|
|||
self.assertEqual(expected, definition)
|
||||
|
||||
@patch('magnum.objects.BayModel.get_by_uuid')
|
||||
def test_extract_template_definition_without_fixed_network(self,
|
||||
mock_objects_baymodel_get_by_uuid):
|
||||
def test_extract_template_definition_without_fixed_network(
|
||||
self,
|
||||
mock_objects_baymodel_get_by_uuid):
|
||||
baymodel_dict = self.baymodel_dict
|
||||
baymodel_dict['fixed_network'] = None
|
||||
baymodel = objects.BayModel(self.context, **baymodel_dict)
|
||||
|
@ -268,7 +279,7 @@ class TestBayConductorWithK8s(base.TestCase):
|
|||
|
||||
(template_path,
|
||||
definition) = bay_conductor._extract_template_definition(self.context,
|
||||
bay)
|
||||
bay)
|
||||
|
||||
expected = {
|
||||
'ssh_key_name': 'keypair_id',
|
||||
|
@ -283,8 +294,9 @@ class TestBayConductorWithK8s(base.TestCase):
|
|||
self.assertEqual(expected, definition)
|
||||
|
||||
@patch('magnum.objects.BayModel.get_by_uuid')
|
||||
def test_extract_template_definition_without_master_flavor(self,
|
||||
mock_objects_baymodel_get_by_uuid):
|
||||
def test_extract_template_definition_without_master_flavor(
|
||||
self,
|
||||
mock_objects_baymodel_get_by_uuid):
|
||||
baymodel_dict = self.baymodel_dict
|
||||
baymodel_dict['master_flavor_id'] = None
|
||||
baymodel = objects.BayModel(self.context, **baymodel_dict)
|
||||
|
@ -292,8 +304,9 @@ class TestBayConductorWithK8s(base.TestCase):
|
|||
bay = objects.Bay(self.context, **self.bay_dict)
|
||||
|
||||
(template_path,
|
||||
definition) = bay_conductor._extract_template_definition(self.context,
|
||||
bay)
|
||||
definition) = bay_conductor._extract_template_definition(
|
||||
self.context,
|
||||
bay)
|
||||
|
||||
expected = {
|
||||
'ssh_key_name': 'keypair_id',
|
||||
|
@ -308,8 +321,9 @@ class TestBayConductorWithK8s(base.TestCase):
|
|||
self.assertEqual(expected, definition)
|
||||
|
||||
@patch('magnum.objects.BayModel.get_by_uuid')
|
||||
def test_extract_template_definition_without_ssh_authorized_key(self,
|
||||
mock_objects_baymodel_get_by_uuid):
|
||||
def test_extract_template_definition_without_ssh_authorized_key(
|
||||
self,
|
||||
mock_objects_baymodel_get_by_uuid):
|
||||
baymodel_dict = self.baymodel_dict
|
||||
baymodel_dict['cluster_distro'] = 'coreos'
|
||||
baymodel_dict['ssh_authorized_key'] = None
|
||||
|
@ -319,7 +333,7 @@ class TestBayConductorWithK8s(base.TestCase):
|
|||
|
||||
(template_path,
|
||||
definition) = bay_conductor._extract_template_definition(self.context,
|
||||
bay)
|
||||
bay)
|
||||
|
||||
expected = {
|
||||
'ssh_key_name': 'keypair_id',
|
||||
|
@ -337,8 +351,9 @@ class TestBayConductorWithK8s(base.TestCase):
|
|||
self.assertEqual(expected, definition)
|
||||
|
||||
@patch('magnum.objects.BayModel.get_by_uuid')
|
||||
def test_extract_template_definition_without_apiserver_port(self,
|
||||
mock_objects_baymodel_get_by_uuid):
|
||||
def test_extract_template_definition_without_apiserver_port(
|
||||
self,
|
||||
mock_objects_baymodel_get_by_uuid):
|
||||
baymodel_dict = self.baymodel_dict
|
||||
baymodel_dict['apiserver_port'] = None
|
||||
baymodel = objects.BayModel(self.context, **baymodel_dict)
|
||||
|
@ -346,8 +361,9 @@ class TestBayConductorWithK8s(base.TestCase):
|
|||
bay = objects.Bay(self.context, **self.bay_dict)
|
||||
|
||||
(template_path,
|
||||
definition) = bay_conductor._extract_template_definition(self.context,
|
||||
bay)
|
||||
definition) = bay_conductor._extract_template_definition(
|
||||
self.context,
|
||||
bay)
|
||||
|
||||
expected = {
|
||||
'ssh_key_name': 'keypair_id',
|
||||
|
@ -363,8 +379,9 @@ class TestBayConductorWithK8s(base.TestCase):
|
|||
self.assertEqual(expected, definition)
|
||||
|
||||
@patch('magnum.objects.BayModel.get_by_uuid')
|
||||
def test_extract_template_definition_without_node_count(self,
|
||||
mock_objects_baymodel_get_by_uuid):
|
||||
def test_extract_template_definition_without_node_count(
|
||||
self,
|
||||
mock_objects_baymodel_get_by_uuid):
|
||||
bay_dict = self.bay_dict
|
||||
bay_dict['node_count'] = None
|
||||
baymodel = objects.BayModel(self.context, **self.baymodel_dict)
|
||||
|
@ -373,7 +390,7 @@ class TestBayConductorWithK8s(base.TestCase):
|
|||
|
||||
(template_path,
|
||||
definition) = bay_conductor._extract_template_definition(self.context,
|
||||
bay)
|
||||
bay)
|
||||
|
||||
expected = {
|
||||
'ssh_key_name': 'keypair_id',
|
||||
|
@ -397,16 +414,12 @@ class TestBayConductorWithK8s(base.TestCase):
|
|||
expected_node_addresses = ['ex_minion', 'address']
|
||||
|
||||
outputs = [
|
||||
{
|
||||
"output_value": expected_node_addresses,
|
||||
"description": "No description given",
|
||||
"output_key": "kube_minions_external"
|
||||
},
|
||||
{
|
||||
"output_value": expected_api_address,
|
||||
"description": "No description given",
|
||||
"output_key": "kube_master"
|
||||
}
|
||||
{"output_value": expected_node_addresses,
|
||||
"description": "No description given",
|
||||
"output_key": "kube_minions_external"},
|
||||
{"output_value": expected_api_address,
|
||||
"description": "No description given",
|
||||
"output_key": "kube_master"}
|
||||
]
|
||||
mock_stack = mock.MagicMock()
|
||||
mock_stack.outputs = outputs
|
||||
|
@ -446,7 +459,7 @@ class TestBayConductorWithK8s(base.TestCase):
|
|||
mock_bay.name = dummy_bay_name
|
||||
|
||||
bay_conductor._create_stack(self.context, mock_osc,
|
||||
mock_bay, expected_timeout)
|
||||
mock_bay, expected_timeout)
|
||||
|
||||
expected_args = {
|
||||
'stack_name': expected_stack_name,
|
||||
|
@ -461,10 +474,11 @@ class TestBayConductorWithK8s(base.TestCase):
|
|||
@patch('heatclient.common.template_utils.get_template_contents')
|
||||
@patch('magnum.conductor.handlers.bay_conductor'
|
||||
'._extract_template_definition')
|
||||
def test_create_stack_no_timeout_specified(self,
|
||||
mock_extract_template_definition,
|
||||
mock_get_template_contents,
|
||||
mock_generate_id):
|
||||
def test_create_stack_no_timeout_specified(
|
||||
self,
|
||||
mock_extract_template_definition,
|
||||
mock_get_template_contents,
|
||||
mock_generate_id):
|
||||
|
||||
mock_generate_id.return_value = 'xx-xx-xx-xx'
|
||||
expected_stack_name = 'expected_stack_name-xx-xx-xx-xx'
|
||||
|
@ -486,7 +500,7 @@ class TestBayConductorWithK8s(base.TestCase):
|
|||
mock_bay.name = dummy_bay_name
|
||||
|
||||
bay_conductor._create_stack(self.context, mock_osc,
|
||||
mock_bay, None)
|
||||
mock_bay, None)
|
||||
|
||||
expected_args = {
|
||||
'stack_name': expected_stack_name,
|
||||
|
@ -501,10 +515,11 @@ class TestBayConductorWithK8s(base.TestCase):
|
|||
@patch('heatclient.common.template_utils.get_template_contents')
|
||||
@patch('magnum.conductor.handlers.bay_conductor'
|
||||
'._extract_template_definition')
|
||||
def test_create_stack_timeout_is_zero(self,
|
||||
mock_extract_template_definition,
|
||||
mock_get_template_contents,
|
||||
mock_generate_id):
|
||||
def test_create_stack_timeout_is_zero(
|
||||
self,
|
||||
mock_extract_template_definition,
|
||||
mock_get_template_contents,
|
||||
mock_generate_id):
|
||||
|
||||
mock_generate_id.return_value = 'xx-xx-xx-xx'
|
||||
expected_stack_name = 'expected_stack_name-xx-xx-xx-xx'
|
||||
|
@ -527,7 +542,7 @@ class TestBayConductorWithK8s(base.TestCase):
|
|||
mock_bay.name = dummy_bay_name
|
||||
|
||||
bay_conductor._create_stack(self.context, mock_osc,
|
||||
mock_bay, bay_timeout)
|
||||
mock_bay, bay_timeout)
|
||||
|
||||
expected_args = {
|
||||
'stack_name': expected_stack_name,
|
||||
|
@ -721,8 +736,9 @@ class TestHandler(db_base.DbTestCase):
|
|||
@patch('magnum.conductor.handlers.bay_conductor.Handler._poll_and_check')
|
||||
@patch('magnum.conductor.handlers.bay_conductor._update_stack')
|
||||
@patch('magnum.common.clients.OpenStackClients')
|
||||
def test_update_node_count_success(self, mock_openstack_client_class,
|
||||
mock_update_stack, mock_poll_and_check):
|
||||
def test_update_node_count_success(
|
||||
self, mock_openstack_client_class,
|
||||
mock_update_stack, mock_poll_and_check):
|
||||
mock_heat_stack = mock.MagicMock()
|
||||
mock_heat_stack.stack_status = bay_status.CREATE_COMPLETE
|
||||
mock_heat_client = mock.MagicMock()
|
||||
|
@ -742,8 +758,9 @@ class TestHandler(db_base.DbTestCase):
|
|||
@patch('magnum.conductor.handlers.bay_conductor.Handler._poll_and_check')
|
||||
@patch('magnum.conductor.handlers.bay_conductor._update_stack')
|
||||
@patch('magnum.common.clients.OpenStackClients')
|
||||
def test_update_node_count_failure(self, mock_openstack_client_class,
|
||||
mock_update_stack, mock_poll_and_check):
|
||||
def test_update_node_count_failure(
|
||||
self, mock_openstack_client_class,
|
||||
mock_update_stack, mock_poll_and_check):
|
||||
mock_heat_stack = mock.MagicMock()
|
||||
mock_heat_stack.stack_status = bay_status.CREATE_FAILED
|
||||
mock_heat_client = mock.MagicMock()
|
||||
|
@ -804,15 +821,16 @@ class TestBayConductorWithSwarm(base.TestCase):
|
|||
}
|
||||
|
||||
@patch('magnum.objects.BayModel.get_by_uuid')
|
||||
def test_extract_template_definition_all_values(self,
|
||||
mock_objects_baymodel_get_by_uuid):
|
||||
def test_extract_template_definition_all_values(
|
||||
self,
|
||||
mock_objects_baymodel_get_by_uuid):
|
||||
baymodel = objects.BayModel(self.context, **self.baymodel_dict)
|
||||
mock_objects_baymodel_get_by_uuid.return_value = baymodel
|
||||
bay = objects.Bay(self.context, **self.bay_dict)
|
||||
|
||||
(template_path,
|
||||
definition) = bay_conductor._extract_template_definition(self.context,
|
||||
bay)
|
||||
bay)
|
||||
|
||||
expected = {
|
||||
'ssh_key_name': 'keypair_id',
|
||||
|
@ -827,8 +845,9 @@ class TestBayConductorWithSwarm(base.TestCase):
|
|||
self.assertEqual(expected, definition)
|
||||
|
||||
@patch('magnum.objects.BayModel.get_by_uuid')
|
||||
def test_extract_template_definition_only_required(self,
|
||||
mock_objects_baymodel_get_by_uuid):
|
||||
def test_extract_template_definition_only_required(
|
||||
self,
|
||||
mock_objects_baymodel_get_by_uuid):
|
||||
cfg.CONF.set_override('public_swarm_discovery', False, group='bay')
|
||||
cfg.CONF.set_override('swarm_discovery_url_format',
|
||||
'test_discovery', group='bay')
|
||||
|
@ -845,7 +864,7 @@ class TestBayConductorWithSwarm(base.TestCase):
|
|||
|
||||
(template_path,
|
||||
definition) = bay_conductor._extract_template_definition(self.context,
|
||||
bay)
|
||||
bay)
|
||||
|
||||
expected = {
|
||||
'ssh_key_name': 'keypair_id',
|
||||
|
|
|
@ -60,8 +60,8 @@ class TestDockerConductor(base.BaseTestCase):
|
|||
mock_container.bay_uuid = '9fb6c41e-a7e4-48b8-97c4-702b26034b8e'
|
||||
|
||||
actual_docker = self.conductor.get_docker_client(
|
||||
mock.sentinel.context,
|
||||
mock_container)
|
||||
mock.sentinel.context,
|
||||
mock_container)
|
||||
|
||||
self.assertEqual(mock_docker, actual_docker)
|
||||
|
||||
|
@ -98,8 +98,8 @@ class TestDockerConductor(base.BaseTestCase):
|
|||
args = ('tcp://1.1.1.1:2376', CONF.docker.docker_remote_api_version,
|
||||
CONF.docker.default_timeout)
|
||||
mock_container_get_by_uuid.assert_called_once_with(
|
||||
mock.sentinel.context,
|
||||
mock_container.uuid)
|
||||
mock.sentinel.context,
|
||||
mock_container.uuid)
|
||||
mock_bay_get_by_uuid.assert_called_once_with(mock.sentinel.context,
|
||||
mock_container.bay_uuid)
|
||||
mock_docker_client.DockerHTTPClient.assert_called_once_with(*args)
|
||||
|
@ -113,18 +113,19 @@ class TestDockerConductor(base.BaseTestCase):
|
|||
mock_container.image_id = 'test_image:some_tag'
|
||||
mock_container.command = None
|
||||
|
||||
container = self.conductor.container_create(None, 'some-name',
|
||||
'some-uuid', mock_container)
|
||||
container = self.conductor.container_create(
|
||||
None, 'some-name',
|
||||
'some-uuid', mock_container)
|
||||
|
||||
utf8_image_id = self.conductor._encode_utf8(mock_container.image_id)
|
||||
mock_docker.pull.assert_called_once_with('test_image',
|
||||
tag='some_tag')
|
||||
mock_docker.inspect_image.assert_called_once_with(utf8_image_id)
|
||||
mock_docker.create_container.assert_called_once_with(
|
||||
mock_container.image_id,
|
||||
name='some-name',
|
||||
hostname='some-uuid',
|
||||
command=None)
|
||||
mock_container.image_id,
|
||||
name='some-name',
|
||||
hostname='some-uuid',
|
||||
command=None)
|
||||
self.assertEqual(obj_container.STOPPED, container.status)
|
||||
|
||||
@mock.patch.object(docker_conductor.Handler, 'get_docker_client')
|
||||
|
@ -136,18 +137,19 @@ class TestDockerConductor(base.BaseTestCase):
|
|||
mock_container.image_id = 'test_image:some_tag'
|
||||
mock_container.command = 'env'
|
||||
|
||||
container = self.conductor.container_create(None, 'some-name',
|
||||
'some-uuid', mock_container)
|
||||
container = self.conductor.container_create(
|
||||
None, 'some-name',
|
||||
'some-uuid', mock_container)
|
||||
|
||||
utf8_image_id = self.conductor._encode_utf8(mock_container.image_id)
|
||||
mock_docker.pull.assert_called_once_with('test_image',
|
||||
tag='some_tag')
|
||||
tag='some_tag')
|
||||
mock_docker.inspect_image.assert_called_once_with(utf8_image_id)
|
||||
mock_docker.create_container.assert_called_once_with(
|
||||
mock_container.image_id,
|
||||
name='some-name',
|
||||
hostname='some-uuid',
|
||||
command='env')
|
||||
mock_container.image_id,
|
||||
name='some-name',
|
||||
hostname='some-uuid',
|
||||
command='env')
|
||||
self.assertEqual(obj_container.STOPPED, container.status)
|
||||
|
||||
@mock.patch.object(docker_conductor.Handler, 'get_docker_client')
|
||||
|
@ -158,15 +160,15 @@ class TestDockerConductor(base.BaseTestCase):
|
|||
mock_container.image_id = 'test_image:some_tag'
|
||||
with patch.object(errors.APIError, '__str__',
|
||||
return_value='hit error') as mock_init:
|
||||
mock_docker.pull = mock.Mock(side_effect=
|
||||
errors.APIError('Error', '', ''))
|
||||
mock_docker.pull = mock.Mock(
|
||||
side_effect=errors.APIError('Error', '', ''))
|
||||
|
||||
self.assertRaises(exception.ContainerException,
|
||||
self.conductor.container_create,
|
||||
None, 'some-name', 'some-uuid', mock_container)
|
||||
mock_docker.pull.assert_called_once_with(
|
||||
'test_image',
|
||||
tag='some_tag')
|
||||
'test_image',
|
||||
tag='some_tag')
|
||||
self.assertFalse(mock_docker.create_container.called)
|
||||
mock_init.assert_called_once_with()
|
||||
self.assertEqual(obj_container.ERROR, mock_container.status)
|
||||
|
@ -177,7 +179,7 @@ class TestDockerConductor(base.BaseTestCase):
|
|||
fake_response.content = 'not_found'
|
||||
fake_response.status_code = 404
|
||||
mock_docker.list_instances.side_effect = errors.APIError(
|
||||
'not_found', fake_response)
|
||||
'not_found', fake_response)
|
||||
ret = self.conductor._find_container_by_name(mock_docker, '1')
|
||||
self.assertEqual({}, ret)
|
||||
|
||||
|
@ -192,15 +194,16 @@ class TestDockerConductor(base.BaseTestCase):
|
|||
mock_find_container.return_value = mock_docker_id
|
||||
self.conductor.container_delete(None, mock_container_uuid)
|
||||
mock_docker.remove_container.assert_called_once_with(
|
||||
mock_docker_id)
|
||||
mock_docker_id)
|
||||
mock_find_container.assert_called_once_with(mock_docker,
|
||||
mock_container_uuid)
|
||||
|
||||
@patch.object(docker_conductor.Handler, '_find_container_by_name')
|
||||
@mock.patch.object(docker_conductor.Handler, 'get_docker_client')
|
||||
def test_container_delete_with_container_not_exist(self,
|
||||
mock_get_docker_client,
|
||||
mock_find_container):
|
||||
def test_container_delete_with_container_not_exist(
|
||||
self,
|
||||
mock_get_docker_client,
|
||||
mock_find_container):
|
||||
mock_docker = mock.MagicMock()
|
||||
mock_get_docker_client.return_value = mock_docker
|
||||
mock_container_uuid = 'd545a92d-609a-428f-8edb-16b02ad20ca1'
|
||||
|
@ -214,9 +217,10 @@ class TestDockerConductor(base.BaseTestCase):
|
|||
|
||||
@patch.object(docker_conductor.Handler, '_find_container_by_name')
|
||||
@mock.patch.object(docker_conductor.Handler, 'get_docker_client')
|
||||
def test_container_delete_with_failure(self,
|
||||
mock_get_docker_client,
|
||||
mock_find_container):
|
||||
def test_container_delete_with_failure(
|
||||
self,
|
||||
mock_get_docker_client,
|
||||
mock_find_container):
|
||||
mock_docker = mock.MagicMock()
|
||||
mock_get_docker_client.return_value = mock_docker
|
||||
mock_container_uuid = 'd545a92d-609a-428f-8edb-16b02ad20ca1'
|
||||
|
@ -224,13 +228,13 @@ class TestDockerConductor(base.BaseTestCase):
|
|||
mock_find_container.return_value = mock_docker_id
|
||||
with patch.object(errors.APIError, '__str__',
|
||||
return_value='hit error') as mock_init:
|
||||
mock_docker.remove_container = mock.Mock(side_effect=
|
||||
errors.APIError('Error', '', ''))
|
||||
mock_docker.remove_container = mock.Mock(
|
||||
side_effect=errors.APIError('Error', '', ''))
|
||||
self.assertRaises(exception.ContainerException,
|
||||
self.conductor.container_delete,
|
||||
None, mock_container_uuid)
|
||||
mock_docker.remove_container.assert_called_once_with(
|
||||
mock_docker_id)
|
||||
mock_docker_id)
|
||||
mock_find_container.assert_called_once_with(mock_docker,
|
||||
mock_container_uuid)
|
||||
mock_init.assert_called_once_with()
|
||||
|
@ -282,8 +286,8 @@ class TestDockerConductor(base.BaseTestCase):
|
|||
mock_find_container.return_value = mock_docker_id
|
||||
with patch.object(errors.APIError, '__str__',
|
||||
return_value='hit error') as mock_init:
|
||||
mock_docker.restart = mock.Mock(side_effect=
|
||||
errors.APIError('Error', '', ''))
|
||||
mock_docker.restart = mock.Mock(
|
||||
side_effect=errors.APIError('Error', '', ''))
|
||||
|
||||
self.assertRaises(exception.ContainerException,
|
||||
self.conductor.container_reboot,
|
||||
|
@ -323,8 +327,8 @@ class TestDockerConductor(base.BaseTestCase):
|
|||
mock_find_container.return_value = mock_docker_id
|
||||
with patch.object(errors.APIError, '__str__',
|
||||
return_value='hit error') as mock_init:
|
||||
mock_docker.start = mock.Mock(side_effect=
|
||||
errors.APIError('Error', '', ''))
|
||||
mock_docker.start = mock.Mock(
|
||||
side_effect=errors.APIError('Error', '', ''))
|
||||
|
||||
self.assertRaises(exception.ContainerException,
|
||||
self.conductor.container_start,
|
||||
|
@ -363,8 +367,8 @@ class TestDockerConductor(base.BaseTestCase):
|
|||
mock_find_container.return_value = mock_docker_id
|
||||
with patch.object(errors.APIError, '__str__',
|
||||
return_value='hit error') as mock_init:
|
||||
mock_docker.stop = mock.Mock(side_effect=
|
||||
errors.APIError('Error', '', ''))
|
||||
mock_docker.stop = mock.Mock(
|
||||
side_effect=errors.APIError('Error', '', ''))
|
||||
|
||||
self.assertRaises(exception.ContainerException,
|
||||
self.conductor.container_stop,
|
||||
|
@ -403,8 +407,8 @@ class TestDockerConductor(base.BaseTestCase):
|
|||
mock_find_container.return_value = mock_docker_id
|
||||
with patch.object(errors.APIError, '__str__',
|
||||
return_value='hit error') as mock_init:
|
||||
mock_docker.pause = mock.Mock(side_effect=
|
||||
errors.APIError('Error', '', ''))
|
||||
mock_docker.pause = mock.Mock(
|
||||
side_effect=errors.APIError('Error', '', ''))
|
||||
|
||||
self.assertRaises(exception.ContainerException,
|
||||
self.conductor.container_pause,
|
||||
|
@ -444,8 +448,8 @@ class TestDockerConductor(base.BaseTestCase):
|
|||
mock_find_container.return_value = mock_docker_id
|
||||
with patch.object(errors.APIError, '__str__',
|
||||
return_value='hit error') as mock_init:
|
||||
mock_docker.unpause = mock.Mock(side_effect=
|
||||
errors.APIError('Error', '', ''))
|
||||
mock_docker.unpause = mock.Mock(
|
||||
side_effect=errors.APIError('Error', '', ''))
|
||||
|
||||
self.assertRaises(exception.ContainerException,
|
||||
self.conductor.container_unpause,
|
||||
|
@ -469,7 +473,7 @@ class TestDockerConductor(base.BaseTestCase):
|
|||
mock_find_container.return_value = mock_docker_id
|
||||
self.conductor.container_show(None, mock_container_uuid)
|
||||
mock_docker.inspect_container.assert_called_once_with(
|
||||
mock_docker_id)
|
||||
mock_docker_id)
|
||||
mock_find_container.assert_called_once_with(mock_docker,
|
||||
mock_container_uuid)
|
||||
|
||||
|
@ -567,13 +571,13 @@ class TestDockerConductor(base.BaseTestCase):
|
|||
mock_find_container.return_value = mock_docker_id
|
||||
with patch.object(errors.APIError, '__str__',
|
||||
return_value='hit error') as mock_init:
|
||||
mock_docker.inspect_container = mock.Mock(side_effect=
|
||||
errors.APIError('Error', '', ''))
|
||||
mock_docker.inspect_container = mock.Mock(
|
||||
side_effect=errors.APIError('Error', '', ''))
|
||||
self.assertRaises(exception.ContainerException,
|
||||
self.conductor.container_show,
|
||||
None, mock_container_uuid)
|
||||
mock_docker.inspect_container.assert_called_once_with(
|
||||
mock_docker_id)
|
||||
mock_docker_id)
|
||||
mock_find_container.assert_called_once_with(mock_docker,
|
||||
mock_container_uuid)
|
||||
mock_init.assert_called_once_with()
|
||||
|
@ -593,11 +597,11 @@ class TestDockerConductor(base.BaseTestCase):
|
|||
mock_find_container.return_value = mock_docker_id
|
||||
with patch.object(errors.APIError, '__str__',
|
||||
return_value='404 error') as mock_init:
|
||||
mock_docker.inspect_container = mock.Mock(side_effect=
|
||||
errors.APIError('Error', '', ''))
|
||||
mock_docker.inspect_container = mock.Mock(
|
||||
side_effect=errors.APIError('Error', '', ''))
|
||||
self.conductor.container_show(None, mock_container_uuid)
|
||||
mock_docker.inspect_container.assert_called_once_with(
|
||||
mock_docker_id)
|
||||
mock_docker_id)
|
||||
mock_find_container.assert_called_once_with(mock_docker,
|
||||
mock_container_uuid)
|
||||
mock_init.assert_called_once_with()
|
||||
|
@ -616,10 +620,10 @@ class TestDockerConductor(base.BaseTestCase):
|
|||
mock_docker.exec_create.return_value = mock_create_res
|
||||
self.conductor.container_execute(None, mock_container_uuid, 'ls')
|
||||
mock_docker.exec_create.assert_called_once_with(mock_docker_id, 'ls',
|
||||
True, True, False)
|
||||
True, True, False)
|
||||
|
||||
mock_docker.exec_start.assert_called_once_with(mock_create_res,
|
||||
False, False, False)
|
||||
False, False, False)
|
||||
mock_find_container.assert_called_once_with(mock_docker,
|
||||
mock_container_uuid)
|
||||
|
||||
|
@ -635,13 +639,14 @@ class TestDockerConductor(base.BaseTestCase):
|
|||
mock_find_container.return_value = mock_docker_id
|
||||
with patch.object(errors.APIError, '__str__',
|
||||
return_value='hit error') as mock_init:
|
||||
mock_docker.exec_create = mock.Mock(side_effect=
|
||||
errors.APIError('Error', '', ''))
|
||||
mock_docker.exec_create = mock.Mock(
|
||||
side_effect=errors.APIError('Error', '', ''))
|
||||
self.assertRaises(exception.ContainerException,
|
||||
self.conductor.container_execute,
|
||||
None, mock_container_uuid, 'ls')
|
||||
mock_docker.exec_create.assert_called_once_with(mock_docker_id,
|
||||
'ls', True, True, False)
|
||||
'ls', True, True,
|
||||
False)
|
||||
mock_find_container.assert_called_once_with(mock_docker,
|
||||
mock_container_uuid)
|
||||
mock_init.assert_called_once_with()
|
||||
|
@ -657,7 +662,7 @@ class TestDockerConductor(base.BaseTestCase):
|
|||
mock_find_container.return_value = mock_docker_id
|
||||
self.conductor.container_logs(None, mock_container_uuid)
|
||||
mock_docker.get_container_logs.assert_called_once_with(
|
||||
mock_docker_id)
|
||||
mock_docker_id)
|
||||
mock_find_container.assert_called_once_with(mock_docker,
|
||||
mock_container_uuid)
|
||||
|
||||
|
@ -672,13 +677,13 @@ class TestDockerConductor(base.BaseTestCase):
|
|||
mock_find_container.return_value = mock_docker_id
|
||||
with patch.object(errors.APIError, '__str__',
|
||||
return_value='hit error') as mock_init:
|
||||
mock_docker.get_container_logs = mock.Mock(side_effect=
|
||||
errors.APIError('Error', '', ''))
|
||||
mock_docker.get_container_logs = mock.Mock(
|
||||
side_effect=errors.APIError('Error', '', ''))
|
||||
self.assertRaises(exception.ContainerException,
|
||||
self.conductor.container_logs,
|
||||
None, mock_container_uuid)
|
||||
mock_docker.get_container_logs.assert_called_once_with(
|
||||
mock_docker_id)
|
||||
mock_docker_id)
|
||||
mock_find_container.assert_called_once_with(mock_docker,
|
||||
mock_container_uuid)
|
||||
mock_init.assert_called_once_with()
|
||||
|
@ -692,4 +697,4 @@ class TestDockerConductor(base.BaseTestCase):
|
|||
'docker_client') as mock_docker:
|
||||
mock_docker.side_effect = Exception("So bad")
|
||||
self.assertRaises(exception.ContainerException,
|
||||
func, None, None)
|
||||
func, None, None)
|
||||
|
|
|
@ -52,7 +52,7 @@ class TestKube(base.TestCase):
|
|||
|
||||
@patch('magnum.objects.Bay.get_by_uuid')
|
||||
def test_retrieve_bay_from_pod(self,
|
||||
mock_bay_get_by_uuid):
|
||||
mock_bay_get_by_uuid):
|
||||
expected_context = 'context'
|
||||
expected_bay_uuid = 'bay_uuid'
|
||||
|
||||
|
@ -66,9 +66,10 @@ class TestKube(base.TestCase):
|
|||
|
||||
@patch('magnum.objects.Bay.get_by_uuid')
|
||||
@patch('magnum.objects.BayModel.get_by_uuid')
|
||||
def test_retrieve_k8s_master_url_from_pod(self,
|
||||
mock_baymodel_get_by_uuid,
|
||||
mock_bay_get_by_uuid):
|
||||
def test_retrieve_k8s_master_url_from_pod(
|
||||
self,
|
||||
mock_baymodel_get_by_uuid,
|
||||
mock_bay_get_by_uuid):
|
||||
expected_context = 'context'
|
||||
expected_api_address = 'api_address'
|
||||
expected_baymodel_id = 'e74c40e0-d825-11e2-a28f-0800200c9a61'
|
||||
|
@ -86,16 +87,17 @@ class TestKube(base.TestCase):
|
|||
mock_baymodel_get_by_uuid.return_value = baymodel
|
||||
|
||||
actual_api_address = kube._retrieve_k8s_master_url(expected_context,
|
||||
pod)
|
||||
pod)
|
||||
self.assertEqual("http://%s:%d" % (expected_api_address,
|
||||
expected_apiserver_port),
|
||||
actual_api_address)
|
||||
|
||||
@patch('magnum.objects.Bay.get_by_uuid')
|
||||
@patch('magnum.objects.BayModel.get_by_uuid')
|
||||
def test_retrieve_k8s_master_url_without_baymodel_apiserver_port(self,
|
||||
mock_baymodel_get_by_uuid,
|
||||
mock_bay_get_by_uuid):
|
||||
def test_retrieve_k8s_master_url_without_baymodel_apiserver_port(
|
||||
self,
|
||||
mock_baymodel_get_by_uuid,
|
||||
mock_bay_get_by_uuid):
|
||||
expected_context = 'context'
|
||||
expected_api_address = 'api_address'
|
||||
expected_baymodel_id = 'e74c40e0-d825-11e2-a28f-0800200c9a61'
|
||||
|
@ -114,11 +116,11 @@ class TestKube(base.TestCase):
|
|||
mock_baymodel_get_by_uuid.return_value = baymodel
|
||||
|
||||
actual_api_address = kube._retrieve_k8s_master_url(expected_context,
|
||||
resource)
|
||||
resource)
|
||||
self.assertEqual("%s://%s:%d" % (expected_protocol,
|
||||
expected_api_address,
|
||||
expected_apiserver_port),
|
||||
actual_api_address)
|
||||
actual_api_address)
|
||||
|
||||
@patch('magnum.conductor.handlers.kube._retrieve_k8s_master_url')
|
||||
def test_pod_create_with_success(self,
|
||||
|
@ -131,7 +133,7 @@ class TestKube(base.TestCase):
|
|||
mock_retrieve_k8s_master_url.return_value = expected_master_url
|
||||
with patch.object(self.kube_handler, '_k8s_api') as mock_kube_api:
|
||||
mock_kube_api.createPod.return_value = {'status':
|
||||
{'phase': 'Pending'}}
|
||||
{'phase': 'Pending'}}
|
||||
|
||||
self.kube_handler.pod_create(self.context, expected_pod)
|
||||
self.assertEqual('Pending', expected_pod.status)
|
||||
|
@ -160,8 +162,9 @@ class TestKube(base.TestCase):
|
|||
|
||||
@patch('magnum.conductor.handlers.kube._retrieve_k8s_master_url')
|
||||
@patch('ast.literal_eval')
|
||||
def test_pod_create_fail_on_existing_pod(self, mock_literal_eval,
|
||||
mock_retrieve_k8s_master_url):
|
||||
def test_pod_create_fail_on_existing_pod(
|
||||
self, mock_literal_eval,
|
||||
mock_retrieve_k8s_master_url):
|
||||
expected_master_url = 'api_address'
|
||||
expected_pod = self.mock_pod()
|
||||
expected_pod.create = mock.MagicMock()
|
||||
|
@ -198,8 +201,9 @@ class TestKube(base.TestCase):
|
|||
|
||||
self.kube_handler.pod_delete(self.context, mock_pod.uuid)
|
||||
|
||||
mock_kube_api.deletePod.assert_called_once_with(name=mock_pod.name,
|
||||
namespaces='default')
|
||||
mock_kube_api.deletePod.assert_called_once_with(
|
||||
name=mock_pod.name,
|
||||
namespaces='default')
|
||||
mock_pod.destroy.assert_called_once_with(self.context)
|
||||
|
||||
@patch('magnum.conductor.handlers.kube._object_has_stack')
|
||||
|
@ -227,18 +231,20 @@ class TestKube(base.TestCase):
|
|||
self.assertRaises(exception.KubernetesAPIFailed,
|
||||
self.kube_handler.pod_delete,
|
||||
self.context, mock_pod.uuid)
|
||||
mock_kube_api.deletePod.assert_called_once_with(name=mock_pod.name,
|
||||
namespaces='default')
|
||||
mock_kube_api.deletePod.assert_called_once_with(
|
||||
name=mock_pod.name,
|
||||
namespaces='default')
|
||||
self.assertFalse(mock_pod.destroy.called)
|
||||
|
||||
@patch('magnum.conductor.handlers.kube._object_has_stack')
|
||||
@patch('magnum.conductor.handlers.kube._retrieve_k8s_master_url')
|
||||
@patch('magnum.objects.Pod.get_by_uuid')
|
||||
@patch('ast.literal_eval')
|
||||
def test_pod_delete_succeeds_when_not_found(self, mock_literal_eval,
|
||||
mock_pod_get_by_uuid,
|
||||
mock_retrieve_k8s_master_url,
|
||||
mock_object_has_stack):
|
||||
def test_pod_delete_succeeds_when_not_found(
|
||||
self, mock_literal_eval,
|
||||
mock_pod_get_by_uuid,
|
||||
mock_retrieve_k8s_master_url,
|
||||
mock_object_has_stack):
|
||||
expected_master_url = 'api_address'
|
||||
mock_pod = mock.MagicMock()
|
||||
mock_pod.name = 'test-pod'
|
||||
|
@ -303,10 +309,11 @@ class TestKube(base.TestCase):
|
|||
@patch('magnum.conductor.handlers.kube._object_has_stack')
|
||||
@patch('magnum.conductor.handlers.kube._retrieve_k8s_master_url')
|
||||
@patch('magnum.objects.Service.get_by_uuid')
|
||||
def test_service_delete_with_success(self,
|
||||
mock_service_get_by_uuid,
|
||||
mock_retrieve_k8s_master_url,
|
||||
mock_object_has_stack):
|
||||
def test_service_delete_with_success(
|
||||
self,
|
||||
mock_service_get_by_uuid,
|
||||
mock_retrieve_k8s_master_url,
|
||||
mock_object_has_stack):
|
||||
expected_master_url = 'api_address'
|
||||
mock_service = mock.MagicMock()
|
||||
mock_service.name = 'test-service'
|
||||
|
@ -327,10 +334,11 @@ class TestKube(base.TestCase):
|
|||
@patch('magnum.conductor.handlers.kube._retrieve_k8s_master_url')
|
||||
@patch('magnum.objects.Service.get_by_uuid')
|
||||
@patch('ast.literal_eval')
|
||||
def test_service_delete_with_failure(self, mock_literal_eval,
|
||||
mock_service_get_by_uuid,
|
||||
mock_retrieve_k8s_master_url,
|
||||
mock_object_has_stack):
|
||||
def test_service_delete_with_failure(
|
||||
self, mock_literal_eval,
|
||||
mock_service_get_by_uuid,
|
||||
mock_retrieve_k8s_master_url,
|
||||
mock_object_has_stack):
|
||||
expected_master_url = 'api_address'
|
||||
mock_service = mock.MagicMock()
|
||||
mock_service.name = 'test-service'
|
||||
|
@ -357,10 +365,11 @@ class TestKube(base.TestCase):
|
|||
@patch('magnum.conductor.handlers.kube._retrieve_k8s_master_url')
|
||||
@patch('magnum.objects.Service.get_by_uuid')
|
||||
@patch('ast.literal_eval')
|
||||
def test_service_delete_succeeds_when_not_found(self, mock_literal_eval,
|
||||
mock_service_get_by_uuid,
|
||||
mock_retrieve_k8s_master_url,
|
||||
mock_object_has_stack):
|
||||
def test_service_delete_succeeds_when_not_found(
|
||||
self, mock_literal_eval,
|
||||
mock_service_get_by_uuid,
|
||||
mock_retrieve_k8s_master_url,
|
||||
mock_object_has_stack):
|
||||
expected_master_url = 'api_address'
|
||||
mock_service = mock.MagicMock()
|
||||
mock_service.name = 'test-service'
|
||||
|
@ -478,10 +487,11 @@ class TestKube(base.TestCase):
|
|||
@patch('magnum.conductor.handlers.kube._retrieve_k8s_master_url')
|
||||
@patch('magnum.objects.ReplicationController.get_by_uuid')
|
||||
@patch('ast.literal_eval')
|
||||
def test_rc_delete_succeeds_when_not_found(self, mock_literal_eval,
|
||||
mock_rc_get_by_uuid,
|
||||
mock_retrieve_k8s_master_url,
|
||||
mock_object_has_stack):
|
||||
def test_rc_delete_succeeds_when_not_found(
|
||||
self, mock_literal_eval,
|
||||
mock_rc_get_by_uuid,
|
||||
mock_retrieve_k8s_master_url,
|
||||
mock_object_has_stack):
|
||||
expected_master_url = 'api_address'
|
||||
mock_rc = mock.MagicMock()
|
||||
mock_rc.name = 'test-rc'
|
||||
|
@ -552,7 +562,7 @@ class TestKube(base.TestCase):
|
|||
|
||||
@patch('magnum.conductor.handlers.kube._retrieve_k8s_master_url')
|
||||
def test_service_update_with_success(self,
|
||||
mock_retrieve_k8s_master_url):
|
||||
mock_retrieve_k8s_master_url):
|
||||
expected_master_url = 'api_address'
|
||||
expected_service = self.mock_service()
|
||||
expected_service.uuid = 'test-uuid'
|
||||
|
@ -575,7 +585,7 @@ class TestKube(base.TestCase):
|
|||
@patch('magnum.conductor.handlers.kube._retrieve_k8s_master_url')
|
||||
@patch('ast.literal_eval')
|
||||
def test_service_update_with_failure(self, mock_literal_eval,
|
||||
mock_retrieve_k8s_master_url):
|
||||
mock_retrieve_k8s_master_url):
|
||||
expected_master_url = 'api_address'
|
||||
expected_service = self.mock_service()
|
||||
expected_service.uuid = 'test-uuid'
|
||||
|
@ -600,7 +610,7 @@ class TestKube(base.TestCase):
|
|||
|
||||
@patch('magnum.conductor.handlers.kube._retrieve_k8s_master_url')
|
||||
def test_pod_update_with_success(self,
|
||||
mock_retrieve_k8s_master_url):
|
||||
mock_retrieve_k8s_master_url):
|
||||
expected_master_url = 'api_address'
|
||||
expected_pod = self.mock_pod()
|
||||
expected_pod.uuid = 'test-uuid'
|
||||
|
@ -623,7 +633,7 @@ class TestKube(base.TestCase):
|
|||
@patch('magnum.conductor.handlers.kube._retrieve_k8s_master_url')
|
||||
@patch('ast.literal_eval')
|
||||
def test_pod_update_with_failure(self, mock_literal_eval,
|
||||
mock_retrieve_k8s_master_url):
|
||||
mock_retrieve_k8s_master_url):
|
||||
expected_master_url = 'api_address'
|
||||
expected_pod = self.mock_pod()
|
||||
expected_pod.uuid = 'test-uuid'
|
||||
|
|
|
@ -61,7 +61,8 @@ class BayLockTest(base.TestCase):
|
|||
|
||||
mock_object_create.assert_called_once_with(self.bay.uuid,
|
||||
self.conductor_id)
|
||||
mock_object_steal.assert_called_once_with(self.bay.uuid,
|
||||
mock_object_steal.assert_called_once_with(
|
||||
self.bay.uuid,
|
||||
'fake-conductor-id', self.conductor_id)
|
||||
|
||||
@patch('magnum.objects.BayLock.create', return_value='fake-conductor-id')
|
||||
|
@ -85,7 +86,8 @@ class BayLockTest(base.TestCase):
|
|||
|
||||
mock_object_create.assert_called_once_with(self.bay.uuid,
|
||||
self.conductor_id)
|
||||
mock_object_steal.assert_called_once_with(self.bay.uuid,
|
||||
mock_object_steal.assert_called_once_with(
|
||||
self.bay.uuid,
|
||||
'fake-conductor-id', self.conductor_id)
|
||||
|
||||
@patch('magnum.objects.BayLock.steal', side_effect=[True, None])
|
||||
|
|
|
@ -50,22 +50,28 @@ class TemplateDefinitionTestCase(base.TestCase):
|
|||
tdef.CoreOSK8sTemplateDefinition)
|
||||
|
||||
def test_get_vm_atomic_kubernetes_definition(self):
|
||||
definition = tdef.TemplateDefinition.get_template_definition('vm',
|
||||
'fedora-atomic', 'kubernetes')
|
||||
definition = tdef.TemplateDefinition.get_template_definition(
|
||||
'vm',
|
||||
'fedora-atomic',
|
||||
'kubernetes')
|
||||
|
||||
self.assertIsInstance(definition,
|
||||
tdef.AtomicK8sTemplateDefinition)
|
||||
|
||||
def test_get_vm_coreos_kubernetes_definition(self):
|
||||
definition = tdef.TemplateDefinition.get_template_definition('vm',
|
||||
'coreos', 'kubernetes')
|
||||
definition = tdef.TemplateDefinition.get_template_definition(
|
||||
'vm',
|
||||
'coreos',
|
||||
'kubernetes')
|
||||
|
||||
self.assertIsInstance(definition,
|
||||
tdef.CoreOSK8sTemplateDefinition)
|
||||
|
||||
def test_get_vm_atomic_swarm_definition(self):
|
||||
definition = tdef.TemplateDefinition.get_template_definition('vm',
|
||||
'fedora-atomic', 'swarm')
|
||||
definition = tdef.TemplateDefinition.get_template_definition(
|
||||
'vm',
|
||||
'fedora-atomic',
|
||||
'swarm')
|
||||
|
||||
self.assertIsInstance(definition,
|
||||
tdef.AtomicSwarmTemplateDefinition)
|
||||
|
|
|
@ -39,7 +39,7 @@ _DB_CACHE = None
|
|||
class Database(fixtures.Fixture):
|
||||
|
||||
def __init__(self, db_api, db_migrate, sql_connection,
|
||||
sqlite_db, sqlite_clean_db):
|
||||
sqlite_db, sqlite_clean_db):
|
||||
self.sql_connection = sql_connection
|
||||
self.sqlite_db = sqlite_db
|
||||
self.sqlite_clean_db = sqlite_clean_db
|
||||
|
|
|
@ -44,7 +44,7 @@ class SqlAlchemyCustomTypesTestCase(base.DbTestCase):
|
|||
self.assertRaises(db_exc.DBError,
|
||||
self.dbapi.create_pod,
|
||||
{'labels':
|
||||
['this is not a dict']})
|
||||
['this is not a dict']})
|
||||
|
||||
def test_JSONEncodedList_default_value(self):
|
||||
# Create pod w/o images
|
||||
|
@ -64,4 +64,4 @@ class SqlAlchemyCustomTypesTestCase(base.DbTestCase):
|
|||
self.assertRaises(db_exc.DBError,
|
||||
self.dbapi.create_pod,
|
||||
{'images':
|
||||
{'this is not a list': 'test'}})
|
||||
{'this is not a list': 'test'}})
|
||||
|
|
|
@ -78,10 +78,12 @@ class DbBayTestCase(base.DbTestCase):
|
|||
self.dbapi.create_baymodel(bm1)
|
||||
self.dbapi.create_baymodel(bm2)
|
||||
|
||||
bay1 = utils.create_test_bay(name='bay-one',
|
||||
bay1 = utils.create_test_bay(
|
||||
name='bay-one',
|
||||
uuid=magnum_utils.generate_uuid(),
|
||||
baymodel_id=bm1['uuid'])
|
||||
bay2 = utils.create_test_bay(name='bay-two',
|
||||
bay2 = utils.create_test_bay(
|
||||
name='bay-two',
|
||||
uuid=magnum_utils.generate_uuid(),
|
||||
baymodel_id=bm2['uuid'],
|
||||
node_count=1)
|
||||
|
|
|
@ -42,10 +42,14 @@ class DbBaymodelTestCase(base.DbTestCase):
|
|||
self.assertEqual(sorted(uuids), sorted(res_uuids))
|
||||
|
||||
def test_get_baymodel_list_with_filters(self):
|
||||
bm1 = self._create_test_baymodel(id=1, name='bm-one',
|
||||
bm1 = self._create_test_baymodel(
|
||||
id=1,
|
||||
name='bm-one',
|
||||
uuid=magnum_utils.generate_uuid(),
|
||||
image_id='image1')
|
||||
bm2 = self._create_test_baymodel(id=2, name='bm-two',
|
||||
bm2 = self._create_test_baymodel(
|
||||
id=2,
|
||||
name='bm-two',
|
||||
uuid=magnum_utils.generate_uuid(),
|
||||
image_id='image2')
|
||||
|
||||
|
@ -86,10 +90,12 @@ class DbBaymodelTestCase(base.DbTestCase):
|
|||
self.assertEqual(bm['uuid'], res.uuid)
|
||||
|
||||
def test_get_baymodel_by_name_multiple_baymodel(self):
|
||||
self._create_test_baymodel(id=1, name='bm',
|
||||
self._create_test_baymodel(
|
||||
id=1, name='bm',
|
||||
uuid=magnum_utils.generate_uuid(),
|
||||
image_id='image1')
|
||||
self._create_test_baymodel(id=2, name='bm',
|
||||
self._create_test_baymodel(
|
||||
id=2, name='bm',
|
||||
uuid=magnum_utils.generate_uuid(),
|
||||
image_id='image2')
|
||||
self.assertRaises(exception.Conflict, self.dbapi.get_baymodel_by_name,
|
||||
|
|
|
@ -72,9 +72,11 @@ class DbContainerTestCase(base.DbTestCase):
|
|||
self.assertEqual(sorted(uuids), sorted(res_uuids))
|
||||
|
||||
def test_get_container_list_with_filters(self):
|
||||
container1 = utils.create_test_container(name='container-one',
|
||||
container1 = utils.create_test_container(
|
||||
name='container-one',
|
||||
uuid=magnum_utils.generate_uuid())
|
||||
container2 = utils.create_test_container(name='container-two',
|
||||
container2 = utils.create_test_container(
|
||||
name='container-two',
|
||||
uuid=magnum_utils.generate_uuid())
|
||||
|
||||
res = self.dbapi.get_container_list(self.context,
|
||||
|
|
|
@ -72,10 +72,12 @@ class DbNodeTestCase(base.DbTestCase):
|
|||
self.assertEqual(sorted(uuids), sorted(res_uuids))
|
||||
|
||||
def test_get_node_list_with_filters(self):
|
||||
node1 = utils.create_test_node(type='virt',
|
||||
node1 = utils.create_test_node(
|
||||
type='virt',
|
||||
ironic_node_id=magnum_utils.generate_uuid(),
|
||||
uuid=magnum_utils.generate_uuid())
|
||||
node2 = utils.create_test_node(type='bare',
|
||||
node2 = utils.create_test_node(
|
||||
type='bare',
|
||||
uuid=magnum_utils.generate_uuid())
|
||||
|
||||
res = self.dbapi.get_node_list(self.context, filters={'type': 'virt'})
|
||||
|
|
|
@ -91,11 +91,13 @@ class DbPodTestCase(base.DbTestCase):
|
|||
self.dbapi.create_bay(bay1)
|
||||
self.dbapi.create_bay(bay2)
|
||||
|
||||
pod1 = utils.create_test_pod(name='pod-one',
|
||||
pod1 = utils.create_test_pod(
|
||||
name='pod-one',
|
||||
uuid=magnum_utils.generate_uuid(),
|
||||
bay_uuid=bay1['uuid'],
|
||||
status='status1')
|
||||
pod2 = utils.create_test_pod(name='pod-two',
|
||||
pod2 = utils.create_test_pod(
|
||||
name='pod-two',
|
||||
uuid=magnum_utils.generate_uuid(),
|
||||
bay_uuid=bay2['uuid'],
|
||||
status='status2')
|
||||
|
|
|
@ -75,7 +75,8 @@ class DbRCTestCase(base.DbTestCase):
|
|||
def test_get_rc_list(self):
|
||||
uuids = [self.rc.uuid]
|
||||
for i in range(1, 6):
|
||||
rc = utils.create_test_rc(bay_uuid=self.bay.uuid,
|
||||
rc = utils.create_test_rc(
|
||||
bay_uuid=self.bay.uuid,
|
||||
uuid=magnum_utils.generate_uuid())
|
||||
uuids.append(six.text_type(rc.uuid))
|
||||
rc = self.dbapi.get_rc_list(self.context)
|
||||
|
|
|
@ -75,7 +75,8 @@ class DbServiceTestCase(base.DbTestCase):
|
|||
def test_get_service_list(self):
|
||||
uuids = [self.service.uuid]
|
||||
for i in range(1, 6):
|
||||
service = utils.create_test_service(bay_uuid=self.bay.uuid,
|
||||
service = utils.create_test_service(
|
||||
bay_uuid=self.bay.uuid,
|
||||
uuid=magnum_utils.generate_uuid())
|
||||
uuids.append(six.text_type(service.uuid))
|
||||
res = self.dbapi.get_service_list(self.context)
|
||||
|
@ -88,11 +89,13 @@ class DbServiceTestCase(base.DbTestCase):
|
|||
self.dbapi.create_bay(bay1)
|
||||
self.dbapi.create_bay(bay2)
|
||||
|
||||
service1 = utils.create_test_service(name='service-one',
|
||||
service1 = utils.create_test_service(
|
||||
name='service-one',
|
||||
uuid=magnum_utils.generate_uuid(),
|
||||
bay_uuid=bay1['uuid'],
|
||||
ports=[{'port': 8000}])
|
||||
service2 = utils.create_test_service(name='service-two',
|
||||
service2 = utils.create_test_service(
|
||||
name='service-two',
|
||||
uuid=magnum_utils.generate_uuid(),
|
||||
bay_uuid=bay2['uuid'],
|
||||
ports=[{'port': 8001}])
|
||||
|
|
|
@ -105,7 +105,7 @@ class TestBayObject(base.DbTestCase):
|
|||
|
||||
mock_get_bay.assert_called_once_with(self.context, uuid)
|
||||
mock_update_bay.assert_called_once_with(
|
||||
uuid, {'node_count': 10})
|
||||
uuid, {'node_count': 10})
|
||||
self.assertEqual(self.context, bay._context)
|
||||
|
||||
def test_refresh(self):
|
||||
|
|
|
@ -40,7 +40,8 @@ class TestBayLockObject(base.DbTestCase):
|
|||
new_conductor_id = str(uuid.uuid4())
|
||||
objects.BayLock.steal(self.bay_uuid, old_conductor_id,
|
||||
new_conductor_id)
|
||||
mock_steal_baylock.assert_called_once_with(self.bay_uuid,
|
||||
mock_steal_baylock.assert_called_once_with(
|
||||
self.bay_uuid,
|
||||
old_conductor_id, new_conductor_id)
|
||||
|
||||
def test_release(self):
|
||||
|
|
|
@ -106,7 +106,7 @@ class TestBayModelObject(base.DbTestCase):
|
|||
|
||||
mock_get_baymodel.assert_called_once_with(self.context, uuid)
|
||||
mock_update_baymodel.assert_called_once_with(
|
||||
uuid, {'image_id': 'test-image'})
|
||||
uuid, {'image_id': 'test-image'})
|
||||
self.assertEqual(self.context, bm._context)
|
||||
|
||||
def test_refresh(self):
|
||||
|
|
|
@ -102,7 +102,7 @@ class TestContainerObject(base.DbTestCase):
|
|||
|
||||
mock_get_container.assert_called_once_with(self.context, uuid)
|
||||
mock_update_container.assert_called_once_with(
|
||||
uuid, {'image_id': 'container.img'})
|
||||
uuid, {'image_id': 'container.img'})
|
||||
self.assertEqual(self.context, container._context)
|
||||
|
||||
def test_refresh(self):
|
||||
|
|
|
@ -91,7 +91,7 @@ class TestNodeObject(base.DbTestCase):
|
|||
|
||||
mock_get_node.assert_called_once_with(self.context, uuid)
|
||||
mock_update_node.assert_called_once_with(
|
||||
uuid, {'type': 'bare'})
|
||||
uuid, {'type': 'bare'})
|
||||
self.assertEqual(self.context, node._context)
|
||||
|
||||
def test_refresh(self):
|
||||
|
|
|
@ -236,7 +236,7 @@ class _TestObject(object):
|
|||
'magnum_object.version': '1.0',
|
||||
'magnum_object.changes': ['bar'],
|
||||
'magnum_object.data': {'foo': 1,
|
||||
'bar': 'loaded!'}}
|
||||
'bar': 'loaded!'}}
|
||||
self.assertEqual(expected, obj.obj_to_primitive())
|
||||
|
||||
def test_changes_in_primitive(self):
|
||||
|
@ -333,8 +333,7 @@ class _TestObject(object):
|
|||
['created_at', 'updated_at'],
|
||||
'magnum_object.data':
|
||||
{'created_at': timeutils.isotime(dt),
|
||||
'updated_at': timeutils.isotime(dt),
|
||||
}
|
||||
'updated_at': timeutils.isotime(dt)}
|
||||
}
|
||||
actual = obj.obj_to_primitive()
|
||||
# magnum_object.changes is built from a set and order is undefined
|
||||
|
|
|
@ -100,7 +100,7 @@ class TestPodObject(base.DbTestCase):
|
|||
|
||||
mock_get_pod.assert_called_once_with(self.context, uuid)
|
||||
mock_update_pod.assert_called_once_with(
|
||||
uuid, {'desc': 'test-pod'})
|
||||
uuid, {'desc': 'test-pod'})
|
||||
self.assertEqual(self.context, pod._context)
|
||||
|
||||
def test_refresh(self):
|
||||
|
|
|
@ -95,7 +95,7 @@ class TestReplicationControllerObject(base.DbTestCase):
|
|||
|
||||
mock_get_rc.assert_called_once_with(self.context, uuid)
|
||||
mock_update_rc.assert_called_once_with(
|
||||
uuid, {'replicas': 10})
|
||||
uuid, {'replicas': 10})
|
||||
self.assertEqual(self.context, rc._context)
|
||||
|
||||
def test_refresh(self):
|
||||
|
|
|
@ -100,7 +100,7 @@ class TestServiceObject(base.DbTestCase):
|
|||
|
||||
mock_get_service.assert_called_once_with(self.context, uuid)
|
||||
mock_update_service.assert_called_once_with(
|
||||
uuid, {'ports': [{'port': 4567}]})
|
||||
uuid, {'ports': [{'port': 4567}]})
|
||||
self.assertEqual(self.context, service._context)
|
||||
|
||||
def test_refresh(self):
|
||||
|
|
2
tox.ini
2
tox.ini
|
@ -52,7 +52,7 @@ commands =
|
|||
# New from hacking 0.9: E129, E131, H407, H405, H904
|
||||
# E251 Skipped due to https://github.com/jcrocholl/pep8/issues/301
|
||||
|
||||
ignore = E121,E122,E123,E124,E125,E126,E127,E128,E129,E131,E251,H302,H405,H803,H904,E711
|
||||
ignore = E121,E122,E123,E124,E125,E131,E251,H302,H405,H803,H904,E711
|
||||
exclude = .venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,tools,magnum/common/pythonk8sclient
|
||||
|
||||
[testenv:pip-missing-reqs]
|
||||
|
|
Loading…
Reference in New Issue