def Run(self, args):
    client = BmsClient()
    volume = args.CONCEPTS.volume.Parse()
    labels_update = None
    labels_diff = labels_util.Diff.FromUpdateArgs(args)

    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?`')

    orig_resource = client.GetVolume(volume)
    labels_update = labels_diff.Apply(
        client.messages.Volume.LabelsValue,
        orig_resource.labels).GetOrNone()

    op_ref = client.UpdateVolume(
        volume_resource=volume,
        labels=labels_update,
        snapshot_schedule_policy_resource=None,
        remove_snapshot_schedule_policy=None,
        snapshot_auto_delete=None)

    if op_ref.done:
      log.UpdatedResource(volume.Name(), kind='volume')
      return op_ref

    if args.async_:
      log.status.Print('Update request issued for: [{}]\nCheck operation '
                       '[{}] for status.'.format(volume.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(volume.Name(), kind='volume')
    return res
Пример #2
0
 def Run(self, args):
     volume = args.CONCEPTS.volume.Parse()
     client = BmsClient()
     return client.GetVolume(volume)