def Run(self, args): """This is what gets called when the user runs this command. Args: args: an argparse namespace. All the arguments that were provided to this command invocation. Returns: Some value that we want to have printed later. """ cli = bigtable_util.GetAdminClient() ref = bigtable_util.GetInstanceRef(args.instance) parent_ref = resources.REGISTRY.Create('bigtableadmin.projects', projectId=ref.projectsId) msgs = bigtable_util.GetAdminMessages() instance_type = msgs.Instance.TypeValueValuesEnum(args.instance_type) num_nodes = arguments.ProcessInstanceTypeAndNodes(args, instance_type) msg = msgs.CreateInstanceRequest( instanceId=ref.Name(), parent=parent_ref.RelativeName(), instance=msgs.Instance(displayName=args.display_name, type=msgs.Instance.TypeValueValuesEnum( args.instance_type)), clusters=msgs.CreateInstanceRequest. ClustersValue(additionalProperties=[ msgs.CreateInstanceRequest.ClustersValue.AdditionalProperty( key=args.cluster, value=msgs.Cluster( serveNodes=num_nodes, defaultStorageType=( msgs.Cluster.DefaultStorageTypeValueValuesEnum( args.cluster_storage_type.upper())), # TODO(b/36056455): switch location to resource # when b/29566669 is fixed on API location=bigtable_util.LocationUrl(args.cluster_zone))) ])) result = cli.projects_instances.Create(msg) operation_ref = bigtable_util.GetOperationRef(result) if args.async_: log.CreatedResource(operation_ref, kind='bigtable instance {0}'.format( ref.Name()), is_async=True) return result return bigtable_util.AwaitInstance( operation_ref, 'Creating bigtable instance {0}'.format(ref.Name()))
def Run(self, args): """This is what gets called when the user runs this command. Args: args: an argparse namespace. All the arguments that were provided to this command invocation. Returns: Some value that we want to have printed later. """ cli = util.GetAdminClient() ref = args.CONCEPTS.instance.Parse() # TODO(b/153576330): This is a workaround for inconsistent collection names. parent_ref = resources.REGISTRY.Create('bigtableadmin.projects', projectId=ref.projectsId) msgs = util.GetAdminMessages() instance_type = msgs.Instance.TypeValueValuesEnum(args.instance_type) clusters = self._Clusters(args) clusters_properties = [] for cluster_id, cluster in sorted(clusters.items()): clusters_properties.append( msgs.CreateInstanceRequest.ClustersValue.AdditionalProperty( key=cluster_id, value=cluster)) msg = msgs.CreateInstanceRequest( instanceId=ref.Name(), parent=parent_ref.RelativeName(), instance=msgs.Instance(displayName=args.display_name, type=instance_type), clusters=msgs.CreateInstanceRequest.ClustersValue( additionalProperties=clusters_properties)) result = cli.projects_instances.Create(msg) operation_ref = util.GetOperationRef(result) if args.async_: log.CreatedResource(operation_ref.RelativeName(), kind='bigtable instance {0}'.format( ref.Name()), is_async=True) return result return util.AwaitInstance( operation_ref, 'Creating bigtable instance {0}'.format(ref.Name()))
def Run(self, args): """This is what gets called when the user runs this command. Args: args: an argparse namespace. All the arguments that were provided to this command invocation. Returns: Some value that we want to have printed later. """ op = instances.Upgrade(args.instance) if args.async_: result = op else: op_ref = resources.REGISTRY.ParseRelativeName( op.name, collection='bigtableadmin.operations') message = 'Upgrading bigtable instance {0}'.format(args.instance) result = util.AwaitInstance(op_ref, message) log.UpdatedResource(args.instance, kind='instance', is_async=args.async_) return result
def _Run(self, args): """Implements Run() with different possible features flags.""" cli = util.GetAdminClient() ref = args.CONCEPTS.instance.Parse() # TODO(b/153576330): This is a workaround for inconsistent collection names. parent_ref = resources.REGISTRY.Create('bigtableadmin.projects', projectId=ref.projectsId) msgs = util.GetAdminMessages() instance_type = msgs.Instance.TypeValueValuesEnum(args.instance_type) new_clusters = self._Clusters(args) clusters_properties = [] for cluster_id, cluster in sorted(new_clusters.items()): clusters_properties.append( msgs.CreateInstanceRequest.ClustersValue.AdditionalProperty( key=cluster_id, value=cluster)) msg = msgs.CreateInstanceRequest( instanceId=ref.Name(), parent=parent_ref.RelativeName(), instance=msgs.Instance(displayName=args.display_name, type=instance_type), clusters=msgs.CreateInstanceRequest.ClustersValue( additionalProperties=clusters_properties)) result = cli.projects_instances.Create(msg) operation_ref = util.GetOperationRef(result) if args.async_: log.CreatedResource(operation_ref.RelativeName(), kind='bigtable instance {0}'.format( ref.Name()), is_async=True) return result return util.AwaitInstance( operation_ref, 'Creating bigtable instance {0}'.format(ref.Name()))