def validate()

in ccmlib/cmds/command.py [0:0]


    def validate(self, parser, options, args, cluster_name=False, node_name=False, load_cluster=False, load_node=True):
        self.options = options
        self.args = args
        if options.config_dir is None:
            self.path = common.get_default_path()
        else:
            self.path = options.config_dir

        if cluster_name:
            if len(args) == 0:
                print_('Missing cluster name', file=sys.stderr)
                parser.print_help()
                exit(1)
            if not re.match('^[a-zA-Z0-9_-]+$', args[0]):
                print_('Cluster name should only contain word characters or hyphen', file=sys.stderr)
                exit(1)
            self.name = args[0]
        if node_name:
            if len(args) == 0:
                print_('Missing node name', file=sys.stderr)
                parser.print_help()
                exit(1)
            self.name = args[0]

        if load_cluster:
            self.cluster = self._load_current_cluster()
            if node_name and load_node:
                try:
                    self.node = self.cluster.nodes[self.name]
                except KeyError:
                    print_('Unknown node %s in cluster %s' % (self.name, self.cluster.name), file=sys.stderr)
                    exit(1)