service instance: drop command related to service instance
Since rest api related to service intances are dropped, drop corresponding cli command. Change-Id: I13c310ddb6cda186b411ed218a7b8950fa849390
This commit is contained in:
parent
c5b4e28a6e
commit
bd5bbfbe92
@ -36,7 +36,6 @@ from tackerclient.openstack.common import strutils
|
||||
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 service_instance
|
||||
from tackerclient.version import __version__
|
||||
|
||||
|
||||
@ -79,11 +78,6 @@ COMMAND_V1 = {
|
||||
'device-template-show': device_template.ShowDeviceTemplate,
|
||||
'device-template-update': device_template.UpdateDeviceTemplate,
|
||||
'device-template-delete': device_template.DeleteDeviceTemplate,
|
||||
'service-instance-create': service_instance.CreateServiceInstance,
|
||||
'service-instance-list': service_instance.ListServiceInstance,
|
||||
'service-instance-show': service_instance.ShowServiceInstance,
|
||||
'service-instance-update': service_instance.UpdateServiceInstance,
|
||||
'service-instance-delete': service_instance.DeleteServiceInstance,
|
||||
'device-create': device.CreateDevice,
|
||||
'device-list': device.ListDevice,
|
||||
'device-show': device.ShowDevice,
|
||||
|
@ -1,164 +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.
|
||||
#
|
||||
# @author: Isaku Yamahata, Intel
|
||||
|
||||
from tackerclient.common import exceptions
|
||||
from tackerclient.openstack.common.gettextutils import _
|
||||
from tackerclient.tacker import v1_0 as tackerV10
|
||||
|
||||
|
||||
_SERVICE_INSTANCE = 'service_instance'
|
||||
|
||||
|
||||
class ListServiceInstance(tackerV10.ListCommand):
|
||||
"""List service instance that belong to a given tenant."""
|
||||
|
||||
resource = _SERVICE_INSTANCE
|
||||
|
||||
|
||||
class ShowServiceInstance(tackerV10.ShowCommand):
|
||||
"""show information of a given ServiceInstance."""
|
||||
|
||||
resource = _SERVICE_INSTANCE
|
||||
|
||||
|
||||
class CreateServiceInstance(tackerV10.CreateCommand):
|
||||
"""create a ServiceInstance."""
|
||||
|
||||
resource = _SERVICE_INSTANCE
|
||||
|
||||
def add_known_arguments(self, parser):
|
||||
parser.add_argument(
|
||||
'--name',
|
||||
default=None,
|
||||
help='Set a name for the devicetemplate')
|
||||
parser.add_argument(
|
||||
'--service-type-id',
|
||||
required=True,
|
||||
help='service type id to create service instance based on')
|
||||
parser.add_argument(
|
||||
'--service-table-id',
|
||||
required=True,
|
||||
help='service type id to create service instance based on')
|
||||
parser.add_argument(
|
||||
'--mgmt-driver',
|
||||
default=None,
|
||||
help='Set a manegement driver name for the service instance')
|
||||
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')
|
||||
parser.add_argument(
|
||||
'--device',
|
||||
required=True,
|
||||
help='Set a device for the service instance to create on')
|
||||
parser.add_argument(
|
||||
'--kwargs',
|
||||
metavar='<key>=<value>',
|
||||
action='append',
|
||||
dest='kwargs',
|
||||
default=[],
|
||||
help='instance specific argument')
|
||||
|
||||
def args2body(self, parsed_args):
|
||||
body = {
|
||||
self.resource: {
|
||||
'service_type_id': parsed_args.service_type_id,
|
||||
'service_table_id': parsed_args.service_table_id,
|
||||
'devices': [parsed_args.device],
|
||||
}
|
||||
}
|
||||
if parsed_args.name is not None:
|
||||
body[self.resource]['name'] = parsed_args.name
|
||||
if parsed_args.mgmt_driver is not None:
|
||||
body[self.resource]['mgmt_driver'] = parsed_args.mgmt_driver
|
||||
if parsed_args.kwargs:
|
||||
try:
|
||||
kwargs = dict(key_value.split('=', 1)
|
||||
for key_value in parsed_args.kwargs)
|
||||
except ValueError:
|
||||
msg = (_('invalid argument for --kwargs %s') %
|
||||
parsed_args.kwargs)
|
||||
raise exceptions.TackerCLIError(msg)
|
||||
if kwargs:
|
||||
body[self.resource]['kwargs'] = kwargs
|
||||
if parsed_args.service_context:
|
||||
try:
|
||||
service_context = [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_context:
|
||||
body[self.resource]['service_context'] = service_context
|
||||
|
||||
tackerV10.update_dict(parsed_args, body[self.resource], ['tenant_id'])
|
||||
return body
|
||||
|
||||
|
||||
class UpdateServiceInstance(tackerV10.UpdateCommand):
|
||||
"""Update a given ServiceInstance."""
|
||||
|
||||
resource = _SERVICE_INSTANCE
|
||||
|
||||
def add_known_arguments(self, parser):
|
||||
parser.add_argument(
|
||||
'--name',
|
||||
help='Set a name for the devicetemplate')
|
||||
parser.add_argument(
|
||||
'--kwargs',
|
||||
metavar='<key>=<value>',
|
||||
action='append',
|
||||
dest='kwargs',
|
||||
default=[],
|
||||
help='instance specific argument')
|
||||
|
||||
def args2body(self, parsed_args):
|
||||
body = {self.resource: {}}
|
||||
if parsed_args.name:
|
||||
body[self.resource]['name'] = parsed_args.name
|
||||
if parsed_args.kwargs:
|
||||
try:
|
||||
kwargs = dict(key_value.split('=', 1)
|
||||
for key_value in parsed_args.kwargs)
|
||||
except ValueError:
|
||||
msg = (_('invalid argument for --kwargs %s') %
|
||||
parsed_args.kwargs)
|
||||
raise exceptions.TackerCLIError(msg)
|
||||
if kwargs:
|
||||
body[self.resource]['kwargs'] = kwargs
|
||||
tackerV10.update_dict(parsed_args, body[self.resource], ['tenant_id'])
|
||||
return body
|
||||
|
||||
|
||||
class DeleteServiceInstance(tackerV10.DeleteCommand):
|
||||
"""Delete a given ServiceInstance."""
|
||||
|
||||
resource = _SERVICE_INSTANCE
|
@ -148,8 +148,6 @@ class Client(object):
|
||||
|
||||
device_templates_path = '/device-templates'
|
||||
device_template_path = '/device-templates/%s'
|
||||
service_instances_path = '/service-instances'
|
||||
service_instance_path = '/service-instances/%s'
|
||||
devices_path = '/devices'
|
||||
device_path = '/devices/%s'
|
||||
|
||||
@ -202,29 +200,6 @@ class Client(object):
|
||||
def delete_device_template(self, device_template):
|
||||
return self.delete(self.device_template_path % device_template)
|
||||
|
||||
@APIParamsCall
|
||||
def list_service_instances(self, retrieve_all=True, **_params):
|
||||
return self.list('service_instances', self.service_instances_path,
|
||||
retrieve_all, **_params)
|
||||
|
||||
@APIParamsCall
|
||||
def show_service_instance(self, service_instance, **_params):
|
||||
return self.get(self.service_instance_path % service_instance,
|
||||
params=_params)
|
||||
|
||||
@APIParamsCall
|
||||
def update_service_instance(self, service_instance, body=None):
|
||||
return self.put(self.service_instance_path % service_instance,
|
||||
body=body)
|
||||
|
||||
@APIParamsCall
|
||||
def create_service_instance(self, body=None):
|
||||
return self.post(self.service_instances_path, body=body)
|
||||
|
||||
@APIParamsCall
|
||||
def delete_service_instance(self, service_instance):
|
||||
return self.delete(self.service_instance_path % service_instance)
|
||||
|
||||
@APIParamsCall
|
||||
def list_devices(self, retrieve_all=True, **_params):
|
||||
return self.list('devices', self.devices_path, retrieve_all, **_params)
|
||||
|
Loading…
Reference in New Issue
Block a user