diff options
author | Thomas Wiest <twiest@redhat.com> | 2015-12-09 15:48:15 -0500 |
---|---|---|
committer | Thomas Wiest <twiest@redhat.com> | 2015-12-09 15:48:15 -0500 |
commit | 14c69ad397be8ee101ef5b4edfa223d703e67ad0 (patch) | |
tree | 70eee046db8012061c178ab4e686650048265564 /bin | |
parent | 898290cb3aabbc9d98883181877ac857a2fe1faf (diff) | |
parent | b7b3e6dbdfd17e55055630ce963965818e830620 (diff) | |
download | openshift-14c69ad397be8ee101ef5b4edfa223d703e67ad0.tar.gz openshift-14c69ad397be8ee101ef5b4edfa223d703e67ad0.tar.bz2 openshift-14c69ad397be8ee101ef5b4edfa223d703e67ad0.tar.xz openshift-14c69ad397be8ee101ef5b4edfa223d703e67ad0.zip |
Merge remote-tracking branch 'upstream/master' into prod
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/cluster | 45 |
1 files changed, 35 insertions, 10 deletions
diff --git a/bin/cluster b/bin/cluster index 220f11d49..9b02b4347 100755 --- a/bin/cluster +++ b/bin/cluster @@ -67,6 +67,21 @@ class Cluster(object): self.action(args, inventory, env, playbook) + def addNodes(self, args): + """ + Add nodes to an existing cluster for given provider + :param args: command line arguments provided by user + """ + env = {'cluster_id': args.cluster_id, + 'deployment_type': self.get_deployment_type(args)} + playbook = "playbooks/{0}/openshift-cluster/addNodes.yml".format(args.provider) + inventory = self.setup_provider(args.provider) + + env['num_nodes'] = args.nodes + env['num_infra'] = args.infra + + self.action(args, inventory, env, playbook) + def terminate(self, args): """ Destroy OpenShift cluster @@ -163,7 +178,7 @@ class Cluster(object): boto_configs = [conf for conf in boto_conf_files if conf_exists(conf)] if len(key_missing) > 0 and len(boto_configs) == 0: - raise ValueError("PROVIDER aws requires {} environment variable(s). See README_AWS.md".format(key_missing)) + raise ValueError("PROVIDER aws requires {0} environment variable(s). See README_AWS.md".format(key_missing)) elif 'libvirt' == provider: inventory = '-i inventory/libvirt/hosts' @@ -171,7 +186,7 @@ class Cluster(object): inventory = '-i inventory/openstack/hosts' else: # this code should never be reached - raise ValueError("invalid PROVIDER {}".format(provider)) + raise ValueError("invalid PROVIDER {0}".format(provider)) return inventory @@ -186,18 +201,18 @@ class Cluster(object): verbose = '' if args.verbose > 0: - verbose = '-{}'.format('v' * args.verbose) + verbose = '-{0}'.format('v' * args.verbose) if args.option: for opt in args.option: k, v = opt.split('=', 1) env['cli_' + k] = v - ansible_env = '-e \'{}\''.format( + ansible_env = '-e \'{0}\''.format( ' '.join(['%s=%s' % (key, value) for (key, value) in env.items()]) ) - command = 'ansible-playbook {} {} {} {}'.format( + command = 'ansible-playbook {0} {1} {2} {3}'.format( verbose, inventory, ansible_env, playbook ) @@ -205,16 +220,16 @@ class Cluster(object): command = 'ANSIBLE_CALLBACK_PLUGINS=ansible-profile/callback_plugins ' + command if args.verbose > 1: - command = 'time {}'.format(command) + command = 'time {0}'.format(command) if args.verbose > 0: - sys.stderr.write('RUN [{}]\n'.format(command)) + sys.stderr.write('RUN [{0}]\n'.format(command)) sys.stderr.flush() try: subprocess.check_call(command, shell=True) except subprocess.CalledProcessError as exc: - raise ActionFailed("ACTION [{}] failed: {}" + raise ActionFailed("ACTION [{0}] failed: {1}" .format(args.action, exc)) @@ -292,6 +307,16 @@ if __name__ == '__main__': help='number of external etcd hosts to create in cluster') create_parser.set_defaults(func=cluster.create) + + create_parser = action_parser.add_parser('addNodes', help='Add nodes to a cluster', + parents=[meta_parser]) + create_parser.add_argument('-n', '--nodes', default=1, type=int, + help='number of nodes to add to the cluster') + create_parser.add_argument('-i', '--infra', default=1, type=int, + help='number of infra nodes to add to the cluster') + create_parser.set_defaults(func=cluster.addNodes) + + config_parser = action_parser.add_parser('config', help='Configure or reconfigure a cluster', parents=[meta_parser]) @@ -325,14 +350,14 @@ if __name__ == '__main__': args = parser.parse_args() if 'terminate' == args.action and not args.force: - answer = raw_input("This will destroy the ENTIRE {} environment. Are you sure? [y/N] ".format(args.cluster_id)) + answer = raw_input("This will destroy the ENTIRE {0} environment. Are you sure? [y/N] ".format(args.cluster_id)) if answer not in ['y', 'Y']: sys.stderr.write('\nACTION [terminate] aborted by user!\n') exit(1) if 'update' == args.action and not args.force: answer = raw_input( - "This is destructive and could corrupt {} environment. Continue? [y/N] ".format(args.cluster_id)) + "This is destructive and could corrupt {0} environment. Continue? [y/N] ".format(args.cluster_id)) if answer not in ['y', 'Y']: sys.stderr.write('\nACTION [update] aborted by user!\n') exit(1) |