def do_cluster_create(cs, args): """Create a cluster.""" args.command = 'cluster-create' utils.validate_name_args(args.positional_name, args.name) cluster_template = cs.cluster_templates.get(args.cluster_template) opts = dict() opts['name'] = args.positional_name or args.name opts['cluster_template_id'] = cluster_template.uuid opts['keypair'] = args.keypair if args.docker_volume_size is not None: opts['docker_volume_size'] = args.docker_volume_size opts['node_count'] = args.node_count opts['master_count'] = args.master_count opts['discovery_url'] = args.discovery_url opts['create_timeout'] = args.timeout try: cluster = cs.clusters.create(**opts) # support for non-async in 1.1 if args.magnum_api_version and args.magnum_api_version == '1.1': _show_cluster(cluster) else: uuid = str(cluster._info['uuid']) print("Request to create cluster %s has been accepted." % uuid) except Exception as e: print("Create for cluster %s failed: %s" % (opts['name'], e))
def do_cluster_template_create(cs, args): """Create a cluster template.""" args.command = 'cluster-template-create' utils.validate_name_args(args.positional_name, args.name) opts = {} opts['name'] = args.positional_name or args.name opts['flavor_id'] = args.flavor opts['master_flavor_id'] = args.master_flavor opts['image_id'] = args.image opts['keypair_id'] = args.keypair opts['external_network_id'] = args.external_network opts['fixed_network'] = args.fixed_network opts['fixed_subnet'] = args.fixed_subnet opts['network_driver'] = args.network_driver opts['volume_driver'] = args.volume_driver opts['dns_nameserver'] = args.dns_nameserver opts['docker_volume_size'] = args.docker_volume_size opts['docker_storage_driver'] = args.docker_storage_driver opts['coe'] = args.coe opts['http_proxy'] = args.http_proxy opts['https_proxy'] = args.https_proxy opts['no_proxy'] = args.no_proxy opts['labels'] = magnum_utils.handle_labels(args.labels) opts['tls_disabled'] = args.tls_disabled opts['public'] = args.public opts['registry_enabled'] = args.registry_enabled opts['server_type'] = args.server_type opts['master_lb_enabled'] = args.master_lb_enabled opts['floating_ip_enabled'] = args.floating_ip_enabled opts['insecure_registry'] = args.insecure_registry cluster_template = cs.cluster_templates.create(**opts) _show_cluster_template(cluster_template)
def do_cluster_template_create(cs, args): """Create a cluster template.""" args.command = 'cluster-template-create' utils.validate_name_args(args.positional_name, args.name) opts = {} opts['name'] = args.positional_name or args.name opts['flavor_id'] = args.flavor opts['master_flavor_id'] = args.master_flavor opts['image_id'] = args.image opts['keypair_id'] = args.keypair opts['external_network_id'] = args.external_network opts['fixed_network'] = args.fixed_network opts['fixed_subnet'] = args.fixed_subnet opts['network_driver'] = args.network_driver opts['volume_driver'] = args.volume_driver opts['dns_nameserver'] = args.dns_nameserver opts['docker_volume_size'] = args.docker_volume_size opts['docker_storage_driver'] = args.docker_storage_driver opts['coe'] = args.coe opts['http_proxy'] = args.http_proxy opts['https_proxy'] = args.https_proxy opts['no_proxy'] = args.no_proxy opts['labels'] = magnum_utils.handle_labels(args.labels) opts['tls_disabled'] = args.tls_disabled opts['public'] = args.public opts['registry_enabled'] = args.registry_enabled opts['server_type'] = args.server_type opts['master_lb_enabled'] = args.master_lb_enabled opts['insecure_registry'] = args.insecure_registry opts['hidden'] = args.hidden if len(args.floating_ip_enabled) > 1: raise InvalidAttribute('--floating-ip-enabled and ' '--floating-ip-disabled are ' 'mutually exclusive and ' 'should be specified only once.') elif len(args.floating_ip_enabled) == 1: opts['floating_ip_enabled'] = args.floating_ip_enabled[0] cluster_template = cs.cluster_templates.create(**opts) _show_cluster_template(cluster_template)