Beispiel #1
0
 def get_security_groups(self,
                         context,
                         filters=None,
                         fields=None,
                         sorts=None,
                         limit=None,
                         marker=None,
                         page_reverse=False):
     return security_groups.get_security_groups(context, filters, fields,
                                                sorts, limit, marker,
                                                page_reverse)
Beispiel #2
0
def create_network(context, network):
    """Create a network.

    Create a network which represents an L2 network segment which
    can have a set of subnets and ports associated with it.
    : param context: neutron api request context
    : param network: dictionary describing the network, with keys
        as listed in the RESOURCE_ATTRIBUTE_MAP object in
        neutron/api/v2/attributes.py.  All keys will be populated.
    """
    LOG.info("create_network for tenant %s" % context.tenant_id)

    # Generate a uuid that we're going to hand to the backend and db
    net_uuid = uuidutils.generate_uuid()

    #TODO(mdietz) this will be the first component registry hook, but
    #             lets make it work first
    pnet_type, phys_net, seg_id = _adapt_provider_nets(context, network)
    net_attrs = network["network"]

    # NOTE(mdietz) I think ideally we would create the providernet
    # elsewhere as a separate driver step that could be
    # kept in a plugin and completely removed if desired. We could
    # have a pre-callback/observer on the netdriver create_network
    # that gathers any additional parameters from the network dict
    net_driver.create_network(context, net_attrs["name"], network_id=net_uuid,
                              phys_type=pnet_type, phys_net=phys_net,
                              segment_id=seg_id)

    subs = net_attrs.pop("subnets", [])

    net_attrs["id"] = net_uuid
    net_attrs["tenant_id"] = context.tenant_id
    new_net = db_api.network_create(context, **net_attrs)

    new_subnets = []
    for sub in subs:
        sub["subnet"]["network_id"] = new_net["id"]
        sub["subnet"]["tenant_id"] = context.tenant_id
        s = db_api.subnet_create(context, **sub["subnet"])
        new_subnets.append(s)
    new_net["subnets"] = new_subnets

    if not security_groups.get_security_groups(
            context,
            filters={"id": security_groups.DEFAULT_SG_UUID}):
        security_groups._create_default_security_group(context)
    return v._make_network_dict(new_net)
Beispiel #3
0
def create_network(context, network):
    """Create a network.

    Create a network which represents an L2 network segment which
    can have a set of subnets and ports associated with it.
    : param context: neutron api request context
    : param network: dictionary describing the network, with keys
        as listed in the RESOURCE_ATTRIBUTE_MAP object in
        neutron/api/v2/attributes.py.  All keys will be populated.
    """
    LOG.info("create_network for tenant %s" % context.tenant_id)

    # Generate a uuid that we're going to hand to the backend and db
    net_uuid = uuidutils.generate_uuid()

    # TODO(mdietz) this will be the first component registry hook, but
    #             lets make it work first
    pnet_type, phys_net, seg_id = _adapt_provider_nets(context, network)
    net_attrs = network["network"]

    # NOTE(mdietz) I think ideally we would create the providernet
    # elsewhere as a separate driver step that could be
    # kept in a plugin and completely removed if desired. We could
    # have a pre-callback/observer on the netdriver create_network
    # that gathers any additional parameters from the network dict
    net_driver.create_network(
        context, net_attrs["name"], network_id=net_uuid, phys_type=pnet_type, phys_net=phys_net, segment_id=seg_id
    )

    subs = net_attrs.pop("subnets", [])

    net_attrs["id"] = net_uuid
    net_attrs["tenant_id"] = context.tenant_id
    new_net = db_api.network_create(context, **net_attrs)

    new_subnets = []
    for sub in subs:
        sub["subnet"]["network_id"] = new_net["id"]
        sub["subnet"]["tenant_id"] = context.tenant_id
        s = db_api.subnet_create(context, **sub["subnet"])
        new_subnets.append(s)
    new_net["subnets"] = new_subnets

    if not security_groups.get_security_groups(context, filters={"id": security_groups.DEFAULT_SG_UUID}):
        security_groups._create_default_security_group(context)
    return v._make_network_dict(new_net)
Beispiel #4
0
 def get_security_groups(self, context, filters=None, fields=None,
                         sorts=None, limit=None, marker=None,
                         page_reverse=False):
     return security_groups.get_security_groups(context, filters, fields,
                                                sorts, limit, marker,
                                                page_reverse)