Exemplo n.º 1
0
    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 = self.context['clusteradmin']
        cluster = self.context['clusteradmin-msgs'].Cluster
        storage_options = {
            'HDD': cluster.DefaultStorageTypeValueValuesEnum.STORAGE_HDD,
            'SSD': cluster.DefaultStorageTypeValueValuesEnum.STORAGE_SSD
        }
        msg = self.context['clusteradmin-msgs'].CreateClusterRequest(
            name=util.ZoneUrl(args),
            clusterId=args.cluster,
            cluster=cluster(displayName=args.description,
                            serveNodes=args.nodes,
                            defaultStorageType=storage_options[args.storage]))
        result = cli.projects_zones_clusters.Create(msg)
        if not args. async:
            util.WaitForOp(self.context, result.currentOperation.name,
                           'Creating cluster')
        return result
    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 = self.context['clusteradmin']
        msg = self.context['clusteradmin-msgs'].Cluster(
            name=util.ClusterUrl(args),
            displayName=args.description,
            serveNodes=args.nodes)
        result = cli.projects_zones_clusters.Update(msg)
        if not args. async:
            util.WaitForOp(self.context, result.currentOperation.name,
                           'Updating cluster')
        return result