예제 #1
0
 def get_ofc_item_random_params(self):
     """create random parameters for ofc_item test"""
     tenant_id = uuidutils.generate_uuid()
     network_id = uuidutils.generate_uuid()
     port_id = uuidutils.generate_uuid()
     portinfo = nmodels.PortInfo(id=port_id, datapath_id="0x123456789",
                                 port_no=1234, vlan_id=321,
                                 mac="11:22:33:44:55:66")
     return tenant_id, network_id, portinfo
예제 #2
0
 def get_ofc_item_random_params(self):
     """create random parameters for ofc_item test."""
     tenant_id = uuidutils.generate_uuid()
     network_id = uuidutils.generate_uuid()
     port_id = uuidutils.generate_uuid()
     mac = ':'.join(['%x' % random.randint(0, 255) for i in xrange(6)])
     portinfo = nmodels.PortInfo(id=port_id,
                                 datapath_id="0x123456789",
                                 port_no=1234,
                                 vlan_id=321,
                                 mac=mac)
     return tenant_id, network_id, portinfo
예제 #3
0
파일: api.py 프로젝트: whitekid/quantum
def add_portinfo(id, datapath_id='', port_no=0, vlan_id=OFP_VLAN_NONE, mac=''):
    session = db.get_session()
    try:
        portinfo = nmodels.PortInfo(id=id,
                                    datapath_id=datapath_id,
                                    port_no=port_no,
                                    vlan_id=vlan_id,
                                    mac=mac)
        session.add(portinfo)
        session.flush()
    except sa.exc.IntegrityError as exc:
        LOG.exception(exc)
        raise nexc.NECDBException
    return portinfo
예제 #4
0
def add_portinfo(session,
                 id,
                 datapath_id='',
                 port_no=0,
                 vlan_id=OFP_VLAN_NONE,
                 mac=''):
    try:
        portinfo = nmodels.PortInfo(id=id,
                                    datapath_id=datapath_id,
                                    port_no=port_no,
                                    vlan_id=vlan_id,
                                    mac=mac)
        with session.begin(subtransactions=True):
            session.add(portinfo)
    except Exception as exc:
        LOG.exception(exc)
        raise nexc.NECDBException(reason=exc.message)
    return portinfo