예제 #1
0
    def Run(self, args):
        volume = args.CONCEPTS.volume.Parse()
        client = BmsClient()
        op_ref = client.RestoreVolumeSnapshot(volume, args.snapshot)

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

        if args.async_:
            log.status.Print(
                'Restore 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.RestoredResource(volume.Name(), kind='volume')
        return res
 def Run(self, args):
     region = args.CONCEPTS.region.Parse()
     client = BmsClient()
     if region is None:
         project = properties.VALUES.core.project.Get(required=True)
         return client.AggregateListNfsShares(project, limit=args.limit)
     return client.ListNfsShares(region, limit=args.limit)
 def Run(self, args):
     ssh_key = args.CONCEPTS.serial_console_ssh_key.Parse()
     message = 'You are about to remove the SSH key [{}]'.format(
         ssh_key.Name())
     console_io.PromptContinue(message=message, cancel_on_no=True)
     client = BmsClient()
     return client.DeleteSshKey(ssh_key)
예제 #4
0
    def Run(self, args):
        volume = args.CONCEPTS.volume.Parse()
        client = BmsClient()

        res = client.CreateVolumeSnapshot(resource=volume,
                                          description=args.description)
        log.CreatedResource(res.name.split('/')[-1], 'snapshot')
        return res
예제 #5
0
 def Run(self, args):
   client = BmsClient()
   if args.key_file:
     public_key = files.ReadFileContents(args.key_file)
   else:
     public_key = args.key
   return client.CreateSshKey(
       resource=args.CONCEPTS.serial_console_ssh_key.Parse(),
       public_key=public_key)
예제 #6
0
 def Run(self, args):
     policy = args.CONCEPTS.snapshot_schedule_policy.Parse()
     description = args.description
     client = BmsClient()
     return client.CreateSnapshotSchedulePolicy(
         policy_resource=policy,
         labels=labels_util.ParseCreateArgs(
             args, client.messages.SnapshotSchedulePolicy.LabelsValue),
         description=description,
         schedules=args.schedule)
    def Run(self, args):
        snapshot = args.CONCEPTS.snapshot.Parse()
        client = BmsClient()

        console_io.PromptContinue(
            message=('You are about to delete the snapshot '
                     '[{0}]'.format(snapshot.Name())),
            cancel_on_no=True)

        return client.DeleteVolumeSnapshot(snapshot)
    def Run(self, args):
        policy = args.CONCEPTS.snapshot_schedule_policy.Parse()

        console_io.PromptContinue(
            message=('You are about to delete the snapshot schedule policy '
                     '[{0}]'.format(policy.Name())),
            cancel_on_no=True)

        client = BmsClient()
        return client.DeleteSnapshotSchedulePolicy(policy)
예제 #9
0
 def Run(self, args):
     region = args.CONCEPTS.region.Parse()
     client = BmsClient()
     if region is None:
         project = properties.VALUES.core.project.Get(required=True)
         for instance in client.AggregateListInstances(project,
                                                       limit=args.limit):
             synthesized_instance = self.synthesizedInstance(
                 instance, client)
             yield synthesized_instance
     else:
         for instance in client.ListInstances(region, limit=args.limit):
             synthesized_instance = self.synthesizedInstance(
                 instance, client)
             yield synthesized_instance
  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
예제 #11
0
    def Run(self, args):
        client = BmsClient()
        policy = args.CONCEPTS.snapshot_schedule_policy.Parse()
        description = args.description
        schedules = args.schedule
        labels_update = None
        labels_diff = labels_util.Diff.FromUpdateArgs(args)
        if labels_diff.MayHaveUpdates():
            orig_resource = client.GetSnapshotSchedulePolicy(policy)
            labels_update = labels_diff.Apply(
                client.messages.SnapshotSchedulePolicy.LabelsValue,
                orig_resource.labels).GetOrNone()

        if not description and not schedules and not labels_diff.MayHaveUpdates(
        ):
            raise exceptions.NoConfigurationChangeError(
                'No configuration change was requested. Did you mean to include the '
                'flags `--description` `--schedule` `--update-labels`'
                '`--remove-labels` or `--clear-labels`?')

        return client.UpdateSnapshotSchedulePolicy(policy_resource=policy,
                                                   labels=labels_update,
                                                   description=description,
                                                   schedules=schedules)
 def Run(self, args):
     policy = args.CONCEPTS.snapshot_schedule_policy.Parse()
     client = BmsClient()
     return client.GetSnapshotSchedulePolicy(policy)
 def Run(self, args):
     client = BmsClient()
     project = properties.VALUES.core.project.Get(required=True)
     return client.ListSshKeys(project_resource=project, limit=args.limit)
예제 #14
0
 def Run(self, args):
     volume = args.CONCEPTS.volume.Parse()
     client = BmsClient()
     return client.GetVolume(volume)
 def Run(self, args):
   snapshot = args.CONCEPTS.snapshot.Parse()
   client = BmsClient()
   return client.GetVolumeSnapshot(snapshot)
예제 #16
0
 def Run(self, args):
     instance = args.CONCEPTS.instance.Parse()
     client = BmsClient()
     return client.GetInstance(instance)
예제 #17
0
 def Run(self, args):
   network = args.CONCEPTS.network.Parse()
   client = BmsClient()
   return client.GetNetwork(network)
예제 #18
0
 def Run(self, args):
     volume = args.CONCEPTS.volume.Parse()
     client = BmsClient()
     return client.ListSnapshotsForVolume(volume, limit=args.limit)
예제 #19
0
 def Run(self, args):
     nfs_share = args.CONCEPTS.nfs_share.Parse()
     client = BmsClient()
     return client.GetNfsShare(nfs_share)