Beispiel #1
0
def add_network_profile(netp_name, netp_type, db_session=None):
    """
    Create a network profile.

    :param netp_name: string representing the name of the network profile
    :param netp_type: string representing the type of the network profile
    :param db_session: database session
    :returns: network profile object
    """
    db_session = db_session or db.get_session()
    netp = n1kv_models.NetworkProfile(name=netp_name, segment_type=netp_type)
    db_session.add(netp)
    db_session.flush()
    return netp
Beispiel #2
0
 def _add_network_profile(self, network_profile, db_session=None):
     """Create a network profile."""
     db_session = db_session or db.get_session()
     with db_session.begin(subtransactions=True):
         kwargs = {
             "name": network_profile["name"],
             "segment_type": network_profile["segment_type"]
         }
         if network_profile["segment_type"] == p_const.TYPE_VXLAN:
             kwargs["multicast_ip_index"] = 0
             kwargs["multicast_ip_range"] = network_profile[
                 "multicast_ip_range"]
             kwargs["sub_type"] = network_profile["sub_type"]
         elif network_profile["segment_type"] == n1kv_const.TYPE_TRUNK:
             kwargs["sub_type"] = network_profile["sub_type"]
         net_profile = n1kv_models.NetworkProfile(**kwargs)
         db_session.add(net_profile)
         return net_profile