Merge "Removing "device" CLI from master branch."
This commit is contained in:
commit
5e6e59aa46
@ -46,8 +46,6 @@ from tackerclient.common import extension as client_extension
|
||||
from tackerclient.common import utils
|
||||
from tackerclient.i18n import _
|
||||
from tackerclient.tacker.v1_0 import extension
|
||||
from tackerclient.tacker.v1_0.vm import device
|
||||
from tackerclient.tacker.v1_0.vm import device_template
|
||||
from tackerclient.tacker.v1_0.vm import vnf
|
||||
from tackerclient.tacker.v1_0.vm import vnfd
|
||||
from tackerclient.version import __version__
|
||||
@ -103,16 +101,6 @@ COMMAND_V1 = {
|
||||
'bash-completion': BashCompletionCommand,
|
||||
'ext-list': extension.ListExt,
|
||||
'ext-show': extension.ShowExt,
|
||||
'device-template-create': device_template.CreateDeviceTemplate,
|
||||
'device-template-list': device_template.ListDeviceTemplate,
|
||||
'device-template-show': device_template.ShowDeviceTemplate,
|
||||
'device-template-update': device_template.UpdateDeviceTemplate,
|
||||
'device-template-delete': device_template.DeleteDeviceTemplate,
|
||||
'device-create': device.CreateDevice,
|
||||
'device-list': device.ListDevice,
|
||||
'device-show': device.ShowDevice,
|
||||
'device-update': device.UpdateDevice,
|
||||
'device-delete': device.DeleteDevice,
|
||||
|
||||
# MANO lingo
|
||||
'vnfd-create': vnfd.CreateVNFD,
|
||||
|
@ -1,116 +0,0 @@
|
||||
#
|
||||
# Copyright 2013 Intel
|
||||
# Copyright 2013 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.
|
||||
|
||||
from tackerclient.common import exceptions
|
||||
from tackerclient.openstack.common.gettextutils import _
|
||||
from tackerclient.tacker import v1_0 as tackerV10
|
||||
|
||||
|
||||
_DEVICE = 'device'
|
||||
|
||||
|
||||
class ListDevice(tackerV10.ListCommand):
|
||||
"""List device that belong to a given tenant."""
|
||||
|
||||
resource = _DEVICE
|
||||
list_columns = ['id', 'name', 'description', 'mgmt_url', 'status']
|
||||
|
||||
|
||||
class ShowDevice(tackerV10.ShowCommand):
|
||||
"""show information of a given Device."""
|
||||
|
||||
resource = _DEVICE
|
||||
|
||||
|
||||
class CreateDevice(tackerV10.CreateCommand):
|
||||
"""create a Device."""
|
||||
|
||||
resource = _DEVICE
|
||||
|
||||
def add_known_arguments(self, parser):
|
||||
parser.add_argument(
|
||||
'--name',
|
||||
help='Set a name for the devicef')
|
||||
parser.add_argument(
|
||||
'--device-template-id',
|
||||
required=True,
|
||||
help='device template id to create device based on')
|
||||
parser.add_argument(
|
||||
'--attributes',
|
||||
metavar='<key>=<value>',
|
||||
action='append',
|
||||
dest='attributes',
|
||||
default=[],
|
||||
help='instance specific argument')
|
||||
|
||||
def args2body(self, parsed_args):
|
||||
body = {
|
||||
self.resource: {
|
||||
'template_id': parsed_args.device_template_id,
|
||||
}
|
||||
}
|
||||
if parsed_args.attributes:
|
||||
try:
|
||||
attributes = dict(key_value.split('=', 1)
|
||||
for key_value in parsed_args.attributes)
|
||||
except ValueError:
|
||||
msg = (_('invalid argument for --attributes %s') %
|
||||
parsed_args.attributes)
|
||||
raise exceptions.TackerCLIError(msg)
|
||||
if attributes:
|
||||
body[self.resource]['attributes'] = attributes
|
||||
|
||||
tackerV10.update_dict(parsed_args, body[self.resource], ['tenant_id'])
|
||||
return body
|
||||
|
||||
|
||||
class UpdateDevice(tackerV10.UpdateCommand):
|
||||
"""Update a given Device."""
|
||||
|
||||
resource = _DEVICE
|
||||
|
||||
def add_known_arguments(self, parser):
|
||||
parser.add_argument(
|
||||
'--attributes',
|
||||
metavar='<key>=<value>',
|
||||
action='append',
|
||||
dest='attributes',
|
||||
default=[],
|
||||
help='instance specific argument')
|
||||
|
||||
def args2body(self, parsed_args):
|
||||
body = {self.resource: {}}
|
||||
if parsed_args.attributes:
|
||||
try:
|
||||
attributes = dict(key_value.split('=', 1)
|
||||
for key_value in parsed_args.attributes)
|
||||
except ValueError:
|
||||
msg = (_('invalid argument for --attributes %s') %
|
||||
parsed_args.attributes)
|
||||
raise exceptions.TackerCLIError(msg)
|
||||
if attributes:
|
||||
body[self.resource]['attributes'] = attributes
|
||||
tackerV10.update_dict(parsed_args, body[self.resource], ['tenant_id'])
|
||||
return body
|
||||
|
||||
|
||||
class DeleteDevice(tackerV10.DeleteCommand):
|
||||
"""Delete a given Device."""
|
||||
|
||||
resource = _DEVICE
|
@ -1,93 +0,0 @@
|
||||
#
|
||||
# Copyright 2013 Intel
|
||||
# Copyright 2013 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.
|
||||
#
|
||||
|
||||
from tackerclient.tacker import v1_0 as tackerV10
|
||||
|
||||
|
||||
_DEVICE_TEMPLATE = "device_template"
|
||||
|
||||
|
||||
class ListDeviceTemplate(tackerV10.ListCommand):
|
||||
"""List device template that belong to a given tenant."""
|
||||
|
||||
resource = _DEVICE_TEMPLATE
|
||||
|
||||
|
||||
class ShowDeviceTemplate(tackerV10.ShowCommand):
|
||||
"""show information of a given DeviceTemplate."""
|
||||
|
||||
resource = _DEVICE_TEMPLATE
|
||||
|
||||
|
||||
class CreateDeviceTemplate(tackerV10.CreateCommand):
|
||||
"""create a DeviceTemplate."""
|
||||
|
||||
resource = _DEVICE_TEMPLATE
|
||||
|
||||
def add_known_arguments(self, parser):
|
||||
parser.add_argument(
|
||||
'--name',
|
||||
help='Set a name for the devicetemplate')
|
||||
parser.add_argument(
|
||||
'--description',
|
||||
help='Set a description for the devicetemplate')
|
||||
parser.add_argument(
|
||||
'--template-service-type',
|
||||
action='append',
|
||||
help='Add a servicetype for the devicetemplate')
|
||||
parser.add_argument(
|
||||
'--infra-driver',
|
||||
help='Set a infra driver name for the devicetemplate')
|
||||
parser.add_argument(
|
||||
'--mgmt-driver',
|
||||
help='Set a manegement driver name for the devicetemplate')
|
||||
parser.add_argument(
|
||||
'--attribute',
|
||||
nargs=2,
|
||||
action='append',
|
||||
help='Set a servicetypes for the devicetemplate')
|
||||
|
||||
def args2body(self, parsed_args):
|
||||
body = {
|
||||
self.resource: {
|
||||
'service_types': [
|
||||
{'service_type': service_type}
|
||||
for service_type in parsed_args.template_service_type],
|
||||
'infra_driver': parsed_args.infra_driver,
|
||||
'mgmt_driver': parsed_args.mgmt_driver,
|
||||
}
|
||||
}
|
||||
if parsed_args.attribute:
|
||||
body[self.resource]['attributes'] = dict(parsed_args.attribute)
|
||||
tackerV10.update_dict(parsed_args, body[self.resource],
|
||||
['tenant_id', 'name', 'description'])
|
||||
return body
|
||||
|
||||
|
||||
class UpdateDeviceTemplate(tackerV10.UpdateCommand):
|
||||
"""Update a given DeviceTemplate."""
|
||||
|
||||
resource = _DEVICE_TEMPLATE
|
||||
allow_names = False
|
||||
|
||||
|
||||
class DeleteDeviceTemplate(tackerV10.DeleteCommand):
|
||||
"""Delete a given DeviceTemplate."""
|
||||
resource = _DEVICE_TEMPLATE
|
@ -204,7 +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 = ['device_template', 'device']
|
||||
non_admin_status_resources = ['vnfd', 'vnf']
|
||||
if (resource in non_admin_status_resources):
|
||||
body = {resource: {}, }
|
||||
else:
|
||||
|
@ -93,8 +93,8 @@ class ShellTest(testtools.TestCase):
|
||||
|
||||
def test_help_on_subcommand(self):
|
||||
required = [
|
||||
'.*?^usage: .* device-template-list']
|
||||
stdout, stderr = self.shell('help device-template-list')
|
||||
'.*?^usage: .* vnfd-list']
|
||||
stdout, stderr = self.shell('help vnfd-list')
|
||||
for r in required:
|
||||
self.assertThat(
|
||||
stdout,
|
||||
@ -112,7 +112,7 @@ class ShellTest(testtools.TestCase):
|
||||
def test_unknown_auth_strategy(self):
|
||||
self.useFixture(fixtures.FakeLogger(level=logging.DEBUG))
|
||||
stdout, stderr = self.shell('--os-auth-strategy fake '
|
||||
'device-template-list')
|
||||
'vnfd-list')
|
||||
self.assertFalse(stdout)
|
||||
self.assertEqual('You must provide a service URL via '
|
||||
'either --os-url or env[OS_URL]', stderr.strip())
|
||||
@ -133,13 +133,13 @@ class ShellTest(testtools.TestCase):
|
||||
service_type='nfv-orchestration',
|
||||
endpoint_type='publicURL', insecure=False, ca_cert=None,
|
||||
log_credentials=True)
|
||||
tacker_shell.run_subcommand(['device-template-list'])
|
||||
tacker_shell.run_subcommand(['vnfd-list'])
|
||||
self.mox.ReplayAll()
|
||||
cmdline = ('--os-username test '
|
||||
'--os-password test '
|
||||
'--os-tenant-name test '
|
||||
'--os-auth-url http://127.0.0.1:5000/ '
|
||||
'--os-auth-strategy keystone device-template-list')
|
||||
'--os-auth-strategy keystone vnfd-list')
|
||||
tacker_shell.run(cmdline.split())
|
||||
self.mox.VerifyAll()
|
||||
|
||||
|
@ -1,132 +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.
|
||||
|
||||
import sys
|
||||
|
||||
from tackerclient.tacker.v1_0.vm import device_template
|
||||
from tackerclient.tests.unit import test_cli10
|
||||
|
||||
|
||||
class CLITestV10VmDeviceTemplateJSON(test_cli10.CLITestV10Base):
|
||||
_RESOURCE = 'device_template'
|
||||
_RESOURCES = 'device_templates'
|
||||
|
||||
def setUp(self):
|
||||
plurals = {'device_templates': 'device_template'}
|
||||
super(CLITestV10VmDeviceTemplateJSON, self).setUp(plurals=plurals)
|
||||
|
||||
def test_create_device_template_all_params(self):
|
||||
cmd = device_template.CreateDeviceTemplate(
|
||||
test_cli10.MyApp(sys.stdout), None)
|
||||
my_id = 'my-id'
|
||||
name = 'my-name'
|
||||
description = 'my-description'
|
||||
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 = [
|
||||
'--name', name,
|
||||
'--description', description,
|
||||
'--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',
|
||||
'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},
|
||||
}
|
||||
self._test_create_resource(self._RESOURCE, cmd, None, my_id,
|
||||
args, position_names, position_values,
|
||||
extra_body=extra_body)
|
||||
|
||||
def test_create_device_template_with_mandatory_params(self):
|
||||
cmd = device_template.CreateDeviceTemplate(
|
||||
test_cli10.MyApp(sys.stdout), None)
|
||||
my_id = 'my-id'
|
||||
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', 'infra_driver']
|
||||
position_values = [device_driver, mgmt_driver, infra_driver]
|
||||
extra_body = {
|
||||
'service_types': [{'service_type': service_type}],
|
||||
}
|
||||
self._test_create_resource(self._RESOURCE, cmd, None, my_id,
|
||||
args, position_names, position_values,
|
||||
extra_body=extra_body)
|
||||
|
||||
def test_list_device_templates(self):
|
||||
cmd = device_template.ListDeviceTemplate(test_cli10.MyApp(sys.stdout),
|
||||
None)
|
||||
self._test_list_resources(self._RESOURCES, cmd, True)
|
||||
|
||||
def test_list_device_templates_pagenation(self):
|
||||
cmd = device_template.ListDeviceTemplate(test_cli10.MyApp(sys.stdout),
|
||||
None)
|
||||
self._test_list_resources(self._RESOURCES, cmd, True)
|
||||
|
||||
def test_show_device_template_id(self):
|
||||
cmd = device_template.ShowDeviceTemplate(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_device_template_id_name(self):
|
||||
cmd = device_template.ShowDeviceTemplate(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_device_template(self):
|
||||
cmd = device_template.UpdateDeviceTemplate(
|
||||
test_cli10.MyApp(sys.stdout), None)
|
||||
my_id = 'my-id'
|
||||
name = 'new-name'
|
||||
description = 'new-description'
|
||||
self._test_update_resource(self._RESOURCE, cmd, my_id,
|
||||
[my_id, '--name', name,
|
||||
'--description', description],
|
||||
{'name': name, 'description': description})
|
||||
|
||||
def test_delete_device_tempalte(self):
|
||||
cmd = device_template.DeleteDeviceTemplate(
|
||||
test_cli10.MyApp(sys.stdout), None)
|
||||
my_id = 'my-id'
|
||||
args = [my_id]
|
||||
self._test_delete_resource(self._RESOURCE, cmd, my_id, args)
|
157
tackerclient/tests/unit/vm/test_cli10_vnf.py
Normal file
157
tackerclient/tests/unit/vm/test_cli10_vnf.py
Normal file
@ -0,0 +1,157 @@
|
||||
# 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.
|
||||
import mox
|
||||
|
||||
import sys
|
||||
|
||||
from tackerclient import shell
|
||||
from tackerclient.tacker import v1_0 as tackerV1_0
|
||||
from tackerclient.tacker.v1_0.vm import vnf
|
||||
from tackerclient.tests.unit import test_cli10
|
||||
|
||||
API_VERSION = "1.0"
|
||||
FORMAT = 'json'
|
||||
TOKEN = 'testtoken'
|
||||
ENDURL = 'localurl'
|
||||
|
||||
|
||||
class CLITestV10VmVNFJSON(test_cli10.CLITestV10Base):
|
||||
_RESOURCE = 'vnf'
|
||||
_RESOURCES = 'vnfs'
|
||||
|
||||
def setUp(self):
|
||||
plurals = {'vnfs': 'vnf'}
|
||||
super(CLITestV10VmVNFJSON, self).setUp(plurals=plurals)
|
||||
|
||||
def _test_create_resource(self, resource, cmd,
|
||||
name, myid, args,
|
||||
position_names, position_values, tenant_id=None,
|
||||
tags=None, admin_state_up=True, extra_body=None,
|
||||
**kwargs):
|
||||
self.mox.StubOutWithMock(cmd, "get_client")
|
||||
self.mox.StubOutWithMock(self.client.httpclient, "request")
|
||||
cmd.get_client().MultipleTimes().AndReturn(self.client)
|
||||
non_admin_status_resources = ['vnfd', 'vnf']
|
||||
if (resource in non_admin_status_resources):
|
||||
body = {resource: {}, }
|
||||
else:
|
||||
body = {resource: {'admin_state_up': admin_state_up, }, }
|
||||
if tenant_id:
|
||||
body[resource].update({'tenant_id': tenant_id})
|
||||
if tags:
|
||||
body[resource].update({'tags': tags})
|
||||
if extra_body:
|
||||
body[resource].update(extra_body)
|
||||
body[resource].update(kwargs)
|
||||
|
||||
for i in range(len(position_names)):
|
||||
body[resource].update({position_names[i]: position_values[i]})
|
||||
ress = {resource:
|
||||
{self.id_field: myid}, }
|
||||
if name:
|
||||
ress[resource].update({'name': name})
|
||||
self.client.format = self.format
|
||||
resstr = self.client.serialize(ress)
|
||||
# url method body
|
||||
resource_plural = tackerV1_0._get_resource_plural(resource,
|
||||
self.client)
|
||||
path = getattr(self.client, resource_plural + "_path")
|
||||
# Work around for LP #1217791. XML deserializer called from
|
||||
# MyComparator does not decodes XML string correctly.
|
||||
if self.format == 'json':
|
||||
mox_body = test_cli10.MyComparator(body, self.client)
|
||||
else:
|
||||
mox_body = self.client.serialize(body)
|
||||
self.client.httpclient.request(
|
||||
test_cli10.end_url(path, format=self.format), 'POST',
|
||||
body=mox_body,
|
||||
headers=mox.ContainsKeyValue(
|
||||
'X-Auth-Token', TOKEN)).AndReturn((
|
||||
test_cli10.MyResp(200), resstr))
|
||||
args.extend(['--request-format', self.format])
|
||||
args.extend(['--vnfd-id', 'vnfd'])
|
||||
self.mox.ReplayAll()
|
||||
cmd_parser = cmd.get_parser('create_' + resource)
|
||||
shell.run_command(cmd, cmd_parser, args)
|
||||
self.mox.VerifyAll()
|
||||
|
||||
def test_create_vnf_all_params(self):
|
||||
cmd = vnf.CreateVNF(test_cli10.MyApp(sys.stdout), None)
|
||||
my_id = 'my-id'
|
||||
vnfd_id = 'vnfd'
|
||||
key = 'key'
|
||||
value = 'value'
|
||||
|
||||
args = [
|
||||
'--vnfd-id', vnfd_id,
|
||||
'--%s' % key, value]
|
||||
position_names = ['vnfd_id', 'attributes']
|
||||
position_values = [vnfd_id, {}]
|
||||
extra_body = {key: value}
|
||||
self._test_create_resource(self._RESOURCE, cmd, None, my_id,
|
||||
args, position_names, position_values,
|
||||
extra_body=extra_body)
|
||||
|
||||
def test_create_vnf_with_mandatory_params(self):
|
||||
cmd = vnf.CreateVNF(test_cli10.MyApp(sys.stdout), None)
|
||||
my_id = 'my-id'
|
||||
vnfd_id = 'vnfd'
|
||||
args = [
|
||||
'--vnfd-id', vnfd_id,
|
||||
]
|
||||
position_names = ['vnfd_id', 'attributes']
|
||||
position_values = [vnfd_id, {}]
|
||||
self._test_create_resource(self._RESOURCE, cmd, None, my_id,
|
||||
args, position_names, position_values)
|
||||
|
||||
def test_list_vnfs(self):
|
||||
cmd = vnf.ListVNF(test_cli10.MyApp(sys.stdout), None)
|
||||
self._test_list_resources(self._RESOURCES, cmd, True)
|
||||
|
||||
def test_list_vnfs_pagenation(self):
|
||||
cmd = vnf.ListVNF(test_cli10.MyApp(sys.stdout), None)
|
||||
self._test_list_resources(self._RESOURCES, cmd, True)
|
||||
|
||||
def test_show_vnf_id(self):
|
||||
cmd = vnf.ShowVNF(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_vnf_id_name(self):
|
||||
cmd = vnf.ShowVNF(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_vnf(self):
|
||||
cmd = vnf.UpdateVNF(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, '--%s' % key, value],
|
||||
{key: value})
|
||||
|
||||
def test_delete_vnf(self):
|
||||
cmd = vnf.DeleteVNF(test_cli10.MyApp(sys.stdout), None)
|
||||
my_id = 'my-id'
|
||||
args = [my_id]
|
||||
self._test_delete_resource(self._RESOURCE, cmd, my_id, args)
|
@ -20,78 +20,81 @@
|
||||
|
||||
import sys
|
||||
|
||||
from tackerclient.tacker.v1_0.vm import device
|
||||
from tackerclient.tacker.v1_0.vm import vnfd
|
||||
from tackerclient.tests.unit import test_cli10
|
||||
|
||||
|
||||
class CLITestV10VmDeviceJSON(test_cli10.CLITestV10Base):
|
||||
_RESOURCE = 'device'
|
||||
_RESOURCES = 'devices'
|
||||
class CLITestV10VmVNFDJSON(test_cli10.CLITestV10Base):
|
||||
_RESOURCE = 'vnfd'
|
||||
_RESOURCES = 'vnfds'
|
||||
|
||||
def setUp(self):
|
||||
plurals = {'devices': 'device'}
|
||||
super(CLITestV10VmDeviceJSON, self).setUp(plurals=plurals)
|
||||
plurals = {'vnfds': 'vnfd'}
|
||||
super(CLITestV10VmVNFDJSON, self).setUp(plurals=plurals)
|
||||
|
||||
def test_create_device_all_params(self):
|
||||
cmd = device.CreateDevice(test_cli10.MyApp(sys.stdout), None)
|
||||
def test_create_vnfd_all_params(self):
|
||||
cmd = vnfd.CreateVNFD(
|
||||
test_cli10.MyApp(sys.stdout), None)
|
||||
my_id = 'my-id'
|
||||
template_id = 'template_id'
|
||||
key = 'key'
|
||||
value = 'value'
|
||||
|
||||
name = 'my-name'
|
||||
mgmt_driver = 'noop'
|
||||
infra_driver = 'heat'
|
||||
attr_key = 'vnfd'
|
||||
attr_val = 'vnfd'
|
||||
args = [
|
||||
'--device-template-id', template_id,
|
||||
'--%s' % key, value]
|
||||
position_names = ['template_id']
|
||||
position_values = [template_id]
|
||||
extra_body = {key: value}
|
||||
'--name', name,
|
||||
'--vnfd', 'vnfd'
|
||||
]
|
||||
position_names = ['name', 'mgmt_driver', 'infra_driver']
|
||||
position_values = [name, mgmt_driver, infra_driver]
|
||||
extra_body = {
|
||||
'service_types': [{'service_type': 'vnfd'}],
|
||||
'attributes': {attr_key: attr_val},
|
||||
}
|
||||
self._test_create_resource(self._RESOURCE, cmd, None, my_id,
|
||||
args, position_names, position_values,
|
||||
extra_body=extra_body)
|
||||
|
||||
def test_create_device_with_mandatory_params(self):
|
||||
cmd = device.CreateDevice(test_cli10.MyApp(sys.stdout), None)
|
||||
def test_create_vnfd_with_mandatory_params(self):
|
||||
cmd = vnfd.CreateVNFD(
|
||||
test_cli10.MyApp(sys.stdout), None)
|
||||
my_id = 'my-id'
|
||||
template_id = 'template_id'
|
||||
args = [
|
||||
'--device-template-id', template_id,
|
||||
]
|
||||
position_names = ['template_id']
|
||||
position_values = [template_id]
|
||||
mgmt_driver = 'noop'
|
||||
infra_driver = 'heat'
|
||||
args = ['--vnfd', 'vnfd', ]
|
||||
position_names = ['mgmt_driver', 'infra_driver']
|
||||
position_values = [mgmt_driver, infra_driver]
|
||||
extra_body = {
|
||||
'service_types': [{'service_type': 'vnfd'}],
|
||||
'attributes': {'vnfd': 'vnfd'}
|
||||
}
|
||||
self._test_create_resource(self._RESOURCE, cmd, None, my_id,
|
||||
args, position_names, position_values)
|
||||
args, position_names, position_values,
|
||||
extra_body=extra_body)
|
||||
|
||||
def test_list_devices(self):
|
||||
cmd = device.ListDevice(test_cli10.MyApp(sys.stdout), None)
|
||||
def test_list_vnfds(self):
|
||||
cmd = vnfd.ListVNFD(test_cli10.MyApp(sys.stdout), None)
|
||||
self._test_list_resources(self._RESOURCES, cmd, True)
|
||||
|
||||
def test_list_devices_pagenation(self):
|
||||
cmd = device.ListDevice(test_cli10.MyApp(sys.stdout), None)
|
||||
def test_list_vnfds_pagenation(self):
|
||||
cmd = vnfd.ListVNFD(test_cli10.MyApp(sys.stdout), None)
|
||||
self._test_list_resources(self._RESOURCES, cmd, True)
|
||||
|
||||
def test_show_device_id(self):
|
||||
cmd = device.ShowDevice(test_cli10.MyApp(sys.stdout), None)
|
||||
def test_show_vnfd_id(self):
|
||||
cmd = vnfd.ShowVNFD(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_device_id_name(self):
|
||||
cmd = device.ShowDevice(test_cli10.MyApp(sys.stdout), None)
|
||||
def test_show_vnfd_id_name(self):
|
||||
cmd = vnfd.ShowVNFD(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_device(self):
|
||||
cmd = device.UpdateDevice(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, '--%s' % key, value],
|
||||
{key: value})
|
||||
|
||||
def test_delete_device(self):
|
||||
cmd = device.DeleteDevice(test_cli10.MyApp(sys.stdout), None)
|
||||
def test_delete_vnfd(self):
|
||||
cmd = vnfd.DeleteVNFD(
|
||||
test_cli10.MyApp(sys.stdout), None)
|
||||
my_id = 'my-id'
|
||||
args = [my_id]
|
||||
self._test_delete_resource(self._RESOURCE, cmd, my_id, args)
|
@ -357,47 +357,6 @@ class Client(ClientBase):
|
||||
"""Fetch a list of all exts on server side."""
|
||||
return self.get(self.extension_path % ext_alias, params=_params)
|
||||
|
||||
def list_device_templates(self, retrieve_all=True, **_params):
|
||||
return self.list('device_templates', self.device_templates_path,
|
||||
retrieve_all, **_params)
|
||||
|
||||
@APIParamsCall
|
||||
def show_device_template(self, device_template, **_params):
|
||||
return self.get(self.device_template_path % device_template,
|
||||
params=_params)
|
||||
|
||||
@APIParamsCall
|
||||
def update_device_template(self, device_template, body=None):
|
||||
return self.put(self.device_template_path % device_template, body=body)
|
||||
|
||||
@APIParamsCall
|
||||
def create_device_template(self, body=None):
|
||||
return self.post(self.device_templates_path, body=body)
|
||||
|
||||
@APIParamsCall
|
||||
def delete_device_template(self, device_template):
|
||||
return self.delete(self.device_template_path % device_template)
|
||||
|
||||
@APIParamsCall
|
||||
def list_devices(self, retrieve_all=True, **_params):
|
||||
return self.list('devices', self.devices_path, retrieve_all, **_params)
|
||||
|
||||
@APIParamsCall
|
||||
def show_device(self, device, **_params):
|
||||
return self.get(self.device_path % device, params=_params)
|
||||
|
||||
@APIParamsCall
|
||||
def update_device(self, device, body=None):
|
||||
return self.put(self.device_path % device, body=body)
|
||||
|
||||
@APIParamsCall
|
||||
def create_device(self, body=None):
|
||||
return self.post(self.devices_path, body=body)
|
||||
|
||||
@APIParamsCall
|
||||
def delete_device(self, device):
|
||||
return self.delete(self.device_path % device)
|
||||
|
||||
_VNFD = "vnfd"
|
||||
|
||||
@APIParamsCall
|
||||
|
Loading…
x
Reference in New Issue
Block a user