示例#1
0
 def Run(self, args):
   """Create a Cloud Filestore instance in the current project."""
   instance_ref = args.CONCEPTS.instance.Parse()
   client = filestore_client.FilestoreClient(self._API_VERSION)
   tier = instances_flags.GetTierArg(
       client.messages).GetEnumForChoice(args.tier)
   labels = labels_util.ParseCreateArgs(args,
                                        client.messages.Instance.LabelsValue)
   instance = client.ParseFilestoreConfig(
       tier=tier, description=args.description,
       file_share=args.file_share, network=args.network,
       labels=labels, zone=instance_ref.locationsId)
   try:
     client.ValidateFileShares(instance)
   except filestore_client.InvalidCapacityError as e:
     raise exceptions.InvalidArgumentException('--file-share',
                                               six.text_type(e))
   result = client.CreateInstance(instance_ref, args.async, instance)
   if args.async:
     command = properties.VALUES.metrics.command_name.Get().split('.')
     if command:
       command[-1] = 'list'
     log.status.Print(
         'Check the status of the new instance by listing all instances:\n  '
         '$ {} '.format(' '.join(command)))
   return result
示例#2
0
 def Run(self, args):
     """Create a Cloud Filestore instance in the current project."""
     instance_ref = args.CONCEPTS.instance.Parse()
     messages = filestore_util.GetMessages()
     tier = instances_flags.GetTierArg(messages).GetEnumForChoice(args.tier)
     labels = labels_util.ParseCreateArgs(args,
                                          messages.Instance.LabelsValue)
     instance = filestore_util.ParseFilestoreConfig(
         tier=tier,
         description=args.description,
         file_share=args.file_share,
         network=args.network,
         labels=labels)
     client = filestore_client.FilestoreClient()
     try:
         client.ValidateFileshares(instance)
     except filestore_client.InvalidCapacityError as e:
         raise exceptions.InvalidArgumentException('--file-share',
                                                   six.text_type(e))
     result = client.CreateInstance(instance_ref, args. async, instance)
     if args. async:
         log.status.Print(
             '\nCheck the status of the new instance by listing all instances:\n  '
             '$ gcloud alpha filestore instances list')
     return result
 def Run(self, args):
     """Create a Filestore instance in the current project."""
     instance_ref = args.CONCEPTS.instance.Parse()
     client = filestore_client.FilestoreClient(self._API_VERSION)
     tier = instances_flags.GetTierArg(
         client.messages, self._API_VERSION).GetEnumForChoice(args.tier)
     labels = labels_util.ParseCreateArgs(
         args, client.messages.Instance.LabelsValue)
     try:
         nfs_export_options = client.MakeNFSExportOptionsMsg(
             messages=client.messages,
             nfs_export_options=args.file_share.get('nfs-export-options',
                                                    []))
     except KeyError as err:
         raise exceptions.InvalidArgumentException('--file-share',
                                                   six.text_type(err))
     instance = client.ParseFilestoreConfig(
         tier=tier,
         description=args.description,
         file_share=args.file_share,
         network=args.network,
         labels=labels,
         zone=instance_ref.locationsId,
         nfs_export_options=nfs_export_options,
         kms_key_name=instances_flags.GetAndValidateKmsKeyName(args))
     result = client.CreateInstance(instance_ref, args.async_, instance)
     if args.async_:
         command = properties.VALUES.metrics.command_name.Get().split('.')
         if command:
             command[-1] = 'list'
         log.status.Print(
             'Check the status of the new instance by listing all instances:\n  '
             '$ {} '.format(' '.join(command)))
     return result
示例#4
0
 def Args(parser):
     concept_parsers.ConceptParser([
         flags.GetInstancePresentationSpec('The instance to create.')
     ]).AddToParser(parser)
     instances_flags.AddDescriptionArg(parser)
     messages = filestore_util.GetMessages()
     instances_flags.GetTierArg(messages).choice_arg.AddToParser(parser)
     instances_flags.AddAsyncFlag(parser, 'create')
     instances_flags.AddFileshareArg(parser)
     instances_flags.AddNetworkArg(parser)
     labels_util.AddCreateLabelsFlags(parser)