starcluster.commands.addnode

Package starcluster :: Package commands :: Module addnode |
[hide private]
[frames] | no frames]

# Source Code for Module starcluster.commands.addnode

     1  #!/usr/bin/env python
     2
     3  from completers import ClusterCompleter
     4
     5
     6 -class CmdAddNode(ClusterCompleter):
     7      """
     8      addnode [options] <cluster_tag>
     9
    10      Add a node to a running cluster
    11
    12      Example:
    13
    14          $ starcluster addnode mynewcluster
    15
    16      This will add a new node to mynewcluster. To give the node an alias:
    17
    18          $ starcluster addnode -a mynode mynewcluster
    19      """
    20      names = ['addnode', 'an']
    21
    22      tag = None
    23
    24 -    def addopts(self, parser):
    25          parser.add_option("-a", "--alias", dest="alias",
    26                            action="store", type="string", default=None,
    27                            help=("alias to give to the new node " + \
    28                                  "(e.g. node007, mynode, etc)"))
    29
    30 -    def execute(self, args):
    31          if len(args) != 1:
    32              self.parser.error("please specify a cluster <cluster_tag>")
    33          tag = self.tag = args[0]
    34          aliases = None
    35          if self.opts.alias:
    36              aliases = [self.opts.alias]
    37          self.cm.add_node(tag, aliases)
    38