def Run(self, args): client = BmsClient() instance = args.CONCEPTS.instance.Parse() labels_update = None labels_diff = labels_util.Diff.FromUpdateArgs(args) if labels_diff.MayHaveUpdates(): orig_resource = client.GetInstance(instance) labels_update = labels_diff.Apply( client.messages.Instance.LabelsValue, orig_resource.labels).GetOrNone() if not labels_diff.MayHaveUpdates(): raise exceptions.NoConfigurationChangeError( 'No configuration change was requested. Did you mean to include the ' 'flags `--update-labels` `--remove-labels` or `--clear-labels`?') op_ref = client.UpdateInstance( instance_resource=instance, labels=labels_update) if op_ref.done: log.UpdatedResource(instance.Name(), kind='instance') return op_ref if args.async_: log.status.Print('Update request issued for: [{}]\nCheck operation ' '[{}] for status.'.format(instance.Name(), op_ref.name)) return op_ref op_resource = resources.REGISTRY.ParseRelativeName( op_ref.name, collection='baremetalsolution.operations', api_version='v1') poller = waiter.CloudOperationPollerNoResources(client.operation_service) res = waiter.WaitFor( poller, op_resource, 'Waiting for operation [{}] to complete'.format(op_ref.name)) log.UpdatedResource(instance.Name(), kind='instance') return res
def Run(self, args): instance = args.CONCEPTS.instance.Parse() client = BmsClient() return client.GetInstance(instance)