command: device-template and device
Change-Id: I8142d7a9fb4bf04e0148d5c44afb890c4db8ec62
This commit is contained in:
@@ -24,6 +24,7 @@ import re
|
||||
from cliff.formatters import table
|
||||
from cliff import lister
|
||||
from cliff import show
|
||||
from oslo.serialization import jsonutils
|
||||
import six
|
||||
|
||||
from tackerclient.common import command
|
||||
@@ -386,12 +387,12 @@ class TackerCommand(command.OpenStackCommand):
|
||||
if self.resource in data:
|
||||
for k, v in data[self.resource].iteritems():
|
||||
if isinstance(v, list):
|
||||
value = '\n'.join(utils.dumps(
|
||||
value = '\n'.join(jsonutils.dumps(
|
||||
i, indent=self.json_indent) if isinstance(i, dict)
|
||||
else str(i) for i in v)
|
||||
data[self.resource][k] = value
|
||||
elif isinstance(v, dict):
|
||||
value = utils.dumps(v, indent=self.json_indent)
|
||||
value = jsonutils.dumps(v, indent=self.json_indent)
|
||||
data[self.resource][k] = value
|
||||
elif v is None:
|
||||
data[self.resource][k] = ''
|
||||
|
||||
@@ -87,7 +87,7 @@ class CreateDevice(tackerV10.CreateCommand):
|
||||
body[self.resource]['attributes'] = attributes
|
||||
if parsed_args.service_context:
|
||||
try:
|
||||
service_context = [dict(
|
||||
service_contexts = [dict(
|
||||
(k.replace('-', '_'), v)
|
||||
for k, v in (key_value.split('=', 1)
|
||||
for key_value in entry_string.split(',')))
|
||||
@@ -97,8 +97,8 @@ class CreateDevice(tackerV10.CreateCommand):
|
||||
parsed_args.service_context)
|
||||
raise exceptions.TackerCLIError(msg)
|
||||
|
||||
if service_context:
|
||||
body[self.resource]['service_context'] = service_context
|
||||
if service_contexts:
|
||||
body[self.resource]['service_contexts'] = service_contexts
|
||||
|
||||
tackerV10.update_dict(parsed_args, body[self.resource], ['tenant_id'])
|
||||
return body
|
||||
|
||||
@@ -54,8 +54,8 @@ class CreateDeviceTemplate(tackerV10.CreateCommand):
|
||||
action='append',
|
||||
help='Add a servicetype for the devicetemplate')
|
||||
parser.add_argument(
|
||||
'--device-driver',
|
||||
help='Set a device driver name for the devicetemplate')
|
||||
'--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')
|
||||
@@ -71,7 +71,7 @@ class CreateDeviceTemplate(tackerV10.CreateCommand):
|
||||
'service_types': [
|
||||
{'service_type': service_type}
|
||||
for service_type in parsed_args.template_service_type],
|
||||
'device_driver': parsed_args.device_driver,
|
||||
'infra_driver': parsed_args.infra_driver,
|
||||
'mgmt_driver': parsed_args.mgmt_driver,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user