def cmd_partition(opts):
config = load_config(opts.config)<EOL>b = get_blockade(config, opts)<EOL>if opts.random:<EOL><INDENT>if opts.partitions:<EOL><INDENT>raise BlockadeError("<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>b.random_partition()<EOL><DEDENT>else:<EOL><INDENT>partitions = []<EOL>for partition in opts.partitions:<EOL><INDENT>names = []<EOL>for name in partition.split("<STR_LIT:U+002C>"):<EOL><INDENT>name = name.strip()<EOL>if name:<EOL><INDENT>names.append(name)<EOL><DEDENT><DEDENT>partitions.append(names)<EOL><DEDENT>if not partitions:<EOL><INDENT>raise BlockadeError("<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>b.partition(partitions)<EOL><DEDENT>
Partition the network between containers

    Replaces any existing partitions outright. Any containers NOT specified
    in arguments will be globbed into a single implicit partition. For
    example if you have three containers: c1, c2, and c3 and you run:

        blockade partition c1

    The result will be a partition with just c1 and another partition with
    c2 and c3.

    Alternatively, --random may be specified, and zero or more random
    partitions will be generated by blockade.