コード例 #1
0
ファイル: utils.py プロジェクト: Kryndex/sdnvpn
def create_network(neutron_client,
                   net,
                   subnet1,
                   cidr1,
                   router,
                   subnet2=None,
                   cidr2=None):
    """Network assoc won't work for networks/subnets created by this function.
    It is an ODL limitation due to it handling routers as vpns.
    See https://bugs.opendaylight.org/show_bug.cgi?id=6962"""
    network_dic = os_utils.create_network_full(neutron_client, net, subnet1,
                                               router, cidr1)
    if not network_dic:
        logger.error(
            "There has been a problem when creating the neutron network")
        sys.exit(-1)
    net_id = network_dic["net_id"]
    subnet_id = network_dic["subnet_id"]
    router_id = network_dic["router_id"]

    if subnet2 is not None:
        logger.debug("Creating and attaching a second subnet...")
        subnet_id = os_utils.create_neutron_subnet(neutron_client, subnet2,
                                                   cidr2, net_id)
        if not subnet_id:
            logger.error(
                "There has been a problem when creating the second subnet")
            sys.exit(-1)
        logger.debug("Subnet '%s' created successfully" % subnet_id)
    return net_id, subnet_id, router_id
コード例 #2
0
ファイル: utils.py プロジェクト: Kryndex/sdnvpn
def create_subnet(neutron_client, name, cidr, net_id):
    logger.debug("Creating subnet %s in network %s with cidr %s", name, net_id,
                 cidr)
    subnet_id = os_utils.create_neutron_subnet(neutron_client, name, cidr,
                                               net_id)
    if not subnet_id:
        logger.error(
            "There has been a problem when creating the neutron subnet")
        sys.exit(-1)
    return subnet_id