def do_service_parameter_add(cc, args): """Add Service Parameter.""" attributes = utils.extract_keypairs(args) if len(attributes.items()) > 1 \ and (args.resource is not None or args.personality is not None): raise exc.CommandError( "Cannot specify multiple parameters with custom resource.") try: parms = cc.service_parameter.create(args.service, args.section, args.personality, args.resource, attributes) except exc.HTTPNotFound: raise exc.CommandError('Failed to create Service parameters: %s ' % attributes) for p in parms.parameters: uuid = p['uuid'] if uuid is not None: try: parameter = cc.service_parameter.get(uuid) except exc.HTTPNotFound: raise exc.CommandError('Service parameter not found: %s' % uuid) _print_service_parameter_show(parameter)
def do_service_parameter_modify(cc, args): """Modify Service Parameter attributes.""" patch = [] attributes = utils.extract_keypairs(args) if len(attributes.items()) > 1 \ and (args.resource is not None or args.personality is not None): raise exc.CommandError( "Cannot specify multiple parameters with custom resource.") for (name, value) in attributes.items(): service_parameter = _find_service_parameter(cc, args.service, args.section, name) if service_parameter: patch.append({'op': 'replace', 'path': '/name', 'value': name}) patch.append({'op': 'replace', 'path': '/value', 'value': value}) if args.personality: patch.append({ 'op': 'replace', 'path': '/personality', 'value': args.personality }) if args.resource: patch.append({ 'op': 'replace', 'path': '/resource', 'value': args.resource }) parameter = cc.service_parameter.update(service_parameter.uuid, patch) _print_service_parameter_show(parameter)
def do_host_label_assign(cc, args): """Update the Kubernetes labels on a host.""" attributes = utils.extract_keypairs(args) ihost = ihost_utils._find_ihost(cc, args.hostnameorid) new_labels = cc.label.assign(ihost.uuid, attributes) for p in new_labels.labels: uuid = p['uuid'] if uuid is not None: try: label_obj = cc.label.get(uuid) except exc.HTTPNotFound: raise exc.CommandError('Host label not found: %s' % uuid) _print_label_show(label_obj)