def Run(self, args):
        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`?'
            )

        nfs_share = args.CONCEPTS.nfs_share.Parse()
        client = BmsClient()
        orig_resource = client.GetNfsShare(nfs_share)
        labels_update = labels_diff.Apply(client.messages.NfsShare.LabelsValue,
                                          orig_resource.labels).GetOrNone()

        op_ref = client.UpdateNfsShare(nfs_share_resource=nfs_share,
                                       labels=labels_update)

        if op_ref.done:
            log.UpdatedResource(nfs_share.Name(), kind='NFS share')
            return op_ref

        if args.async_:
            log.status.Print(
                'Update request issued for: [{}]\nCheck operation '
                '[{}] for status.'.format(nfs_share.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(nfs_share.Name(), kind='NFS share')
        return res
예제 #2
0
 def Run(self, args):
     nfs_share = args.CONCEPTS.nfs_share.Parse()
     client = BmsClient()
     return client.GetNfsShare(nfs_share)