Remove service instance related stuff and fix unittests
Change-Id: I8052d9d683a1a2e80d8c160c70d2ea8f8b7240cd Closes-bug: 1519968
This commit is contained in:
parent
ad5381a91d
commit
f342ea9c7a
@ -1,4 +1,4 @@
|
||||
[DEFAULT]
|
||||
test_command=OS_STDOUT_CAPTURE=1 OS_STDERR_CAPTURE=1 ${PYTHON:-python} -m subunit.run discover -t ./ . $LISTOPT $IDOPTION
|
||||
test_command=OS_STDOUT_CAPTURE=1 OS_STDERR_CAPTURE=1 ${PYTHON:-python} -m subunit.run discover -t ./ ${OS_TEST_PATH:-./tackerclient/tests/unit/vm} $LISTOPT $IDOPTION
|
||||
test_id_option=--load-list $IDFILE
|
||||
test_list_option=--list
|
||||
|
@ -35,5 +35,4 @@ TYPE_DICT = "dict"
|
||||
|
||||
|
||||
PLURALS = {'templates': 'template',
|
||||
'devices': 'device',
|
||||
'services': 'service'}
|
||||
'devices': 'device'}
|
||||
|
@ -60,15 +60,6 @@ class CreateDevice(tackerV10.CreateCommand):
|
||||
dest='attributes',
|
||||
default=[],
|
||||
help='instance specific argument')
|
||||
parser.add_argument(
|
||||
'--service-context',
|
||||
metavar='<network-id=network-uuid,subnet-id=subnet-uuid,'
|
||||
'port-id=port-uuid,router-id=router-uuid,'
|
||||
'role=role-string,index=int>',
|
||||
action='append',
|
||||
dest='service_context',
|
||||
default=[],
|
||||
help='service context to insert service')
|
||||
|
||||
def args2body(self, parsed_args):
|
||||
body = {
|
||||
@ -86,20 +77,6 @@ class CreateDevice(tackerV10.CreateCommand):
|
||||
raise exceptions.TackerCLIError(msg)
|
||||
if attributes:
|
||||
body[self.resource]['attributes'] = attributes
|
||||
if parsed_args.service_context:
|
||||
try:
|
||||
service_contexts = [dict(
|
||||
(k.replace('-', '_'), v)
|
||||
for k, v in (key_value.split('=', 1)
|
||||
for key_value in entry_string.split(',')))
|
||||
for entry_string in parsed_args.service_context]
|
||||
except ValueError:
|
||||
msg = (_('invalid argument for --service-context %s') %
|
||||
parsed_args.service_context)
|
||||
raise exceptions.TackerCLIError(msg)
|
||||
|
||||
if service_contexts:
|
||||
body[self.resource]['service_contexts'] = service_contexts
|
||||
|
||||
tackerV10.update_dict(parsed_args, body[self.resource], ['tenant_id'])
|
||||
return body
|
||||
|
@ -204,15 +204,7 @@ class CLITestV10Base(testtools.TestCase):
|
||||
self.mox.StubOutWithMock(cmd, "get_client")
|
||||
self.mox.StubOutWithMock(self.client.httpclient, "request")
|
||||
cmd.get_client().MultipleTimes().AndReturn(self.client)
|
||||
non_admin_status_resources = ['subnet', 'floatingip', 'security_group',
|
||||
'security_group_rule', 'qos_queue',
|
||||
'network_gateway', 'gateway_device',
|
||||
'credential', 'network_profile',
|
||||
'policy_profile', 'ikepolicy',
|
||||
'ipsecpolicy', 'metering_label',
|
||||
'metering_label_rule', 'net_partition',
|
||||
'device_template', 'device',
|
||||
'service_instance']
|
||||
non_admin_status_resources = ['device_template', 'device']
|
||||
if (resource in non_admin_status_resources):
|
||||
body = {resource: {}, }
|
||||
else:
|
||||
|
@ -40,36 +40,13 @@ class CLITestV10VmDeviceJSON(test_cli10.CLITestV10Base):
|
||||
template_id = 'template_id'
|
||||
key = 'key'
|
||||
value = 'value'
|
||||
network_id = 'network_id'
|
||||
subnet_id = 'subnet_id'
|
||||
port_id = 'port_id'
|
||||
router_id = 'router_id'
|
||||
role = 'role'
|
||||
index = 1
|
||||
|
||||
args = [
|
||||
'--device-template-id', template_id,
|
||||
'--kwargs', '%s=%s' % (key, value),
|
||||
'--service-context',
|
||||
('network-id=%s,subnet-id=%s,port-id=%s,router-id=%s,'
|
||||
'role=%s,index=%s' % (network_id, subnet_id, port_id, router_id,
|
||||
role, index))
|
||||
]
|
||||
'--%s' % key, value]
|
||||
position_names = ['template_id']
|
||||
position_values = [template_id]
|
||||
extra_body = {
|
||||
'kwargs': {
|
||||
key: value
|
||||
},
|
||||
'service_context': [{
|
||||
'network_id': network_id,
|
||||
'subnet_id': subnet_id,
|
||||
'port_id': port_id,
|
||||
'router_id': router_id,
|
||||
'role': role,
|
||||
'index': str(index),
|
||||
}],
|
||||
}
|
||||
extra_body = {key: value}
|
||||
self._test_create_resource(self._RESOURCE, cmd, None, my_id,
|
||||
args, position_names, position_values,
|
||||
extra_body=extra_body)
|
||||
@ -109,18 +86,14 @@ class CLITestV10VmDeviceJSON(test_cli10.CLITestV10Base):
|
||||
def test_update_device(self):
|
||||
cmd = device.UpdateDevice(test_cli10.MyApp(sys.stdout), None)
|
||||
my_id = 'my-id'
|
||||
key = 'new-key'
|
||||
key = 'new_key'
|
||||
value = 'new-value'
|
||||
self._test_update_resource(self._RESOURCE, cmd, my_id,
|
||||
[my_id, '--kwargs', '%s=%s' % (key, value)],
|
||||
{'kwargs': {key: value}})
|
||||
[my_id, '--%s' % key, value],
|
||||
{key: value})
|
||||
|
||||
def test_delete_device(self):
|
||||
cmd = device.DeleteDevice(test_cli10.MyApp(sys.stdout), None)
|
||||
my_id = 'my-id'
|
||||
args = [my_id]
|
||||
self._test_delete_resource(self._RESOURCE, cmd, my_id, args)
|
||||
|
||||
|
||||
class CLITestV10VmDeviceXML(CLITestV10VmDeviceJSON):
|
||||
format = 'xml'
|
||||
|
@ -43,6 +43,7 @@ class CLITestV10VmDeviceTemplateJSON(test_cli10.CLITestV10Base):
|
||||
service_type = 'MY-SERVICE'
|
||||
device_driver = 'device-driver'
|
||||
mgmt_driver = 'mgmt-driver'
|
||||
infra_driver = 'infra-driver'
|
||||
attr_key = 'attr-key'
|
||||
attr_val = 'attr-val'
|
||||
args = [
|
||||
@ -51,11 +52,14 @@ class CLITestV10VmDeviceTemplateJSON(test_cli10.CLITestV10Base):
|
||||
'--template-service-type', service_type,
|
||||
'--device-driver', device_driver,
|
||||
'--mgmt-driver', mgmt_driver,
|
||||
'--infra-driver', infra_driver,
|
||||
'--attribute', attr_key, attr_val,
|
||||
]
|
||||
position_names = ['name', 'description',
|
||||
'device_driver', 'mgmt_driver']
|
||||
position_values = [name, description, device_driver, mgmt_driver]
|
||||
'device_driver', 'mgmt_driver',
|
||||
'infra_driver']
|
||||
position_values = [name, description, device_driver,
|
||||
mgmt_driver, infra_driver]
|
||||
extra_body = {
|
||||
'service_types': [{'service_type': service_type}],
|
||||
'attributes': {attr_key: attr_val},
|
||||
@ -71,13 +75,15 @@ class CLITestV10VmDeviceTemplateJSON(test_cli10.CLITestV10Base):
|
||||
service_type = 'MY-SERVICE'
|
||||
device_driver = 'device-driver'
|
||||
mgmt_driver = 'mgmt-driver'
|
||||
infra_driver = 'infra-driver'
|
||||
args = [
|
||||
'--template-service-type', service_type,
|
||||
'--device-driver', device_driver,
|
||||
'--mgmt-driver', mgmt_driver,
|
||||
'--infra-driver', infra_driver,
|
||||
]
|
||||
position_names = ['device_driver', 'mgmt_driver']
|
||||
position_values = [device_driver, mgmt_driver]
|
||||
position_names = ['device_driver', 'mgmt_driver', 'infra_driver']
|
||||
position_values = [device_driver, mgmt_driver, infra_driver]
|
||||
extra_body = {
|
||||
'service_types': [{'service_type': service_type}],
|
||||
}
|
||||
@ -126,7 +132,3 @@ class CLITestV10VmDeviceTemplateJSON(test_cli10.CLITestV10Base):
|
||||
my_id = 'my-id'
|
||||
args = [my_id]
|
||||
self._test_delete_resource(self._RESOURCE, cmd, my_id, args)
|
||||
|
||||
|
||||
class CLITestV10VmDeviceTemplateXML(CLITestV10VmDeviceTemplateJSON):
|
||||
format = 'xml'
|
||||
|
@ -1,155 +0,0 @@
|
||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2014 Intel
|
||||
# Copyright 2014 Isaku Yamahata <isaku.yamahata at intel com>
|
||||
# <isaku.yamahata at gmail com>
|
||||
# All Rights Reserved.
|
||||
#
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
# @author: Isaku Yamahata, Intel
|
||||
|
||||
import sys
|
||||
|
||||
from tackerclient.tacker.v1_0.vm import service_instance
|
||||
from tackerclient.tests.unit import test_cli10
|
||||
|
||||
|
||||
class CLITestV10VmServiceInstanceJSON(test_cli10.CLITestV10Base):
|
||||
_RESOURCE = 'service_instance'
|
||||
_RESOURCES = 'service_instances'
|
||||
|
||||
def setUp(self):
|
||||
plurals = {'service_instances': 'service_instance'}
|
||||
super(CLITestV10VmServiceInstanceJSON, self).setUp(plurals=plurals)
|
||||
|
||||
def test_create_service_instance_all_params(self):
|
||||
cmd = service_instance.CreateServiceInstance(
|
||||
test_cli10.MyApp(sys.stdout), None)
|
||||
my_id = 'my-id'
|
||||
name = 'my-name'
|
||||
service_type_id = 'service-type-id'
|
||||
service_table_id = 'service-table-id'
|
||||
mgmt_driver = 'mgmt-driver'
|
||||
network_id = 'network_id'
|
||||
subnet_id = 'subnet_id'
|
||||
port_id = 'port_id'
|
||||
router_id = 'router_id'
|
||||
role = 'role'
|
||||
index = 1
|
||||
|
||||
device = 'my-device'
|
||||
|
||||
key = 'key'
|
||||
value = 'value'
|
||||
|
||||
args = [
|
||||
'--name', name,
|
||||
'--service-type-id', service_type_id,
|
||||
'--service-table-id', service_table_id,
|
||||
'--mgmt-driver', mgmt_driver,
|
||||
'--service-context',
|
||||
('network-id=%s,subnet-id=%s,port-id=%s,router-id=%s,'
|
||||
'role=%s,index=%s' % (network_id, subnet_id, port_id, router_id,
|
||||
role, index)),
|
||||
'--device', device,
|
||||
'--kwargs', '%s=%s' % (key, value),
|
||||
]
|
||||
position_names = ['name', 'service_type_id', 'service_table_id',
|
||||
'mgmt_driver']
|
||||
position_values = [name, service_type_id, service_table_id,
|
||||
mgmt_driver]
|
||||
extra_body = {
|
||||
'devices': [device],
|
||||
'service_context': [{
|
||||
'network_id': network_id,
|
||||
'subnet_id': subnet_id,
|
||||
'port_id': port_id,
|
||||
'router_id': router_id,
|
||||
'role': role,
|
||||
'index': str(index),
|
||||
}],
|
||||
'kwargs': {
|
||||
key: value
|
||||
},
|
||||
}
|
||||
self._test_create_resource(self._RESOURCE, cmd, None, my_id,
|
||||
args, position_names, position_values,
|
||||
extra_body=extra_body)
|
||||
|
||||
def test_create_service_instance_with_mandatory_params(self):
|
||||
cmd = service_instance.CreateServiceInstance(
|
||||
test_cli10.MyApp(sys.stdout), None)
|
||||
my_id = 'my-id'
|
||||
service_type_id = 'service-type-id'
|
||||
service_table_id = 'service-table-id'
|
||||
device = 'my-device'
|
||||
args = [
|
||||
'--service-type-id', service_type_id,
|
||||
'--service-table-id', service_table_id,
|
||||
'--device', device,
|
||||
]
|
||||
position_names = ['service_type_id', 'service_table_id']
|
||||
position_values = [service_type_id, service_table_id]
|
||||
extra_body = {
|
||||
'devices': [device],
|
||||
}
|
||||
self._test_create_resource(self._RESOURCE, cmd, None, my_id,
|
||||
args, position_names, position_values,
|
||||
extra_body=extra_body)
|
||||
|
||||
def test_list_service_instances(self):
|
||||
cmd = service_instance.ListServiceInstance(
|
||||
test_cli10.MyApp(sys.stdout), None)
|
||||
self._test_list_resources(self._RESOURCES, cmd, True)
|
||||
|
||||
def test_list_service_instances_pagenation(self):
|
||||
cmd = service_instance.ListServiceInstance(
|
||||
test_cli10.MyApp(sys.stdout), None)
|
||||
self._test_list_resources(self._RESOURCES, cmd, True)
|
||||
|
||||
def test_show_service_instance_id(self):
|
||||
cmd = service_instance.ShowServiceInstance(
|
||||
test_cli10.MyApp(sys.stdout), None)
|
||||
args = ['--fields', 'id', self.test_id]
|
||||
self._test_show_resource(self._RESOURCE, cmd, self.test_id, args,
|
||||
['id'])
|
||||
|
||||
def test_show_service_instance_id_name(self):
|
||||
cmd = service_instance.ShowServiceInstance(
|
||||
test_cli10.MyApp(sys.stdout), None)
|
||||
args = ['--fields', 'id', '--fields', 'name', self.test_id]
|
||||
self._test_show_resource(self._RESOURCE, cmd, self.test_id,
|
||||
args, ['id', 'name'])
|
||||
|
||||
def test_update_service_instance(self):
|
||||
cmd = service_instance.UpdateServiceInstance(
|
||||
test_cli10.MyApp(sys.stdout), None)
|
||||
my_id = 'my-id'
|
||||
key = 'new-key'
|
||||
value = 'new-value'
|
||||
self._test_update_resource(self._RESOURCE, cmd, my_id,
|
||||
[my_id, '--kwargs', '%s=%s' % (key, value)],
|
||||
{'kwargs': {key: value}})
|
||||
|
||||
def test_delete_service_instance(self):
|
||||
cmd = service_instance.DeleteServiceInstance(
|
||||
test_cli10.MyApp(sys.stdout), None)
|
||||
my_id = 'my-id'
|
||||
args = [my_id]
|
||||
self._test_delete_resource(self._RESOURCE, cmd, my_id, args)
|
||||
|
||||
|
||||
class CLITestV10VmServiceInstanceXML(CLITestV10VmServiceInstanceJSON):
|
||||
format = 'xml'
|
Loading…
Reference in New Issue
Block a user