def create(args):
    if args.network:
        cidr_regex = r'^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/\d{1,2}$'
        if not re.search(cidr_regex, args.network):
            sys.stderr.write(
                'Network {} is not in CIDR (a.b.c.d/e) format.\n'.format(
                    args.network))
            sys.exit(1)

    config = common.ecluster_config(args.econfig)
    cluster_config = config.cluster_conf[args.cluster]
    try:
        cluster = config.load_cluster(args.cluster)
        cluster_storage_path = cluster.repository.storage_path
    except elasticluster.exceptions.ClusterNotFound:
        # Assume the default storage path if the cluster doesn't exist,
        # so we can start an ICEL stack in parallel with cluster startup.
        cluster_storage_path = common.get_storage_dir(args.econfig)
        if not os.path.exists(cluster_storage_path):
            os.makedirs(cluster_storage_path)

    if not args.setup:
        icel_param = {
            'oss_count': args.oss_count,
            'ost_vol_size': args.size / args.oss_count / args.lun_count,
            'ost_vol_count': args.lun_count,
        }
        template_url = _upload_icel_cf_template(
            icel_param, args.bucket, cluster_config['cloud'])
        _create_stack(
            args.stack_name, template_url, args.network,
            args.cluster, cluster_config, args.recreate)
        try:
            sys.stdout.write('Waiting for stack to launch (this will take '
                             'a few minutes)')
            sys.stdout.flush()
            _wait_for_stack(args.stack_name, 'CREATE_COMPLETE',
                            15 * 60, cluster_config['cloud'])
        except Exception as e:
            sys.stderr.write('{}\n'.format(str(e)))
            sys.exit(1)

    ssh_config_path = os.path.join(
        cluster_storage_path, 'icel-{}.ssh_config'.format(args.stack_name))
    _write_ssh_config(ssh_config_path, args.stack_name, cluster_config)

    ansible_config_path = os.path.join(
        cluster_storage_path,
        'icel-{}.ansible_config'.format(args.stack_name))
    _write_ansible_config(
        ansible_config_path, args.stack_name, cluster_storage_path)

    inventory_path = os.path.join(
        cluster_storage_path,
        'icel-{}.inventory'.format(args.stack_name))
    _write_inventory(inventory_path, args.stack_name, cluster_config['cloud'])

    playbook_path = os.path.join(
        common.ANSIBLE_BASE, "roles", "icel", "tasks", "main.yml")
    common.run_ansible_pb(
        inventory_path, playbook_path, args, ansible_cfg=ansible_config_path)
dataset/ETHPy150Open chapmanb/bcbio-nextgen-vm/bcbiovm/aws/icel.py/create/original