Commit 44ac2cd0 authored by Mohammad Ismaeel's avatar Mohammad Ismaeel
Browse files

bugs fixed in TAPI model

parent 7465c4e2
Loading
Loading
Loading
Loading
+8 −6
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ from .models.DeviceModel import DeviceModel
from .models.OpticalLinkModel import OpticalLinkModel
from .models.TapiModel import (ChildTopologyDeviceModel, ChildTopologyOpticalLinkModel
                               , ChildTopologyModel , ChildTopologyEndponitModel , ChildOpticalLinkEndponitModel)
from .uuids.Context import context_get_uuid
from .uuids.Device import device_get_uuid

from .uuids.Tapi import topology_get_uuid

@@ -215,18 +215,20 @@ def child_get_device(db_engine : Engine, request : DeviceId) -> List[DeviceModel
    return obj


def get_topology_by_device_id(db_engine : Engine, request : DeviceId) -> List[DeviceModel]:
    device_uuid = request.device_id.device_uuid.uuid
def get_topology_by_device_id(db_engine : Engine,  messagebroker : MessageBroker, request : DeviceId) -> List[DeviceModel]:
    device_uuid_raw = request.device_uuid.uuid
    device_uuid = device_get_uuid(request, device_name='', allow_random=False)
    topology = ChildTopology()
    def callback(session: Session):
        obj= session.query(ChildTopologyModel)\
            .join(ChildTopologyModel.child_topology_devices)\
            .filter(ChildTopologyDeviceModel.device_uuid == device_uuid)\
            .first()
        return None if obj is None else obj.dump()
        return topology if obj is None else ChildTopology(**obj.dump())
    obj = run_transaction(sessionmaker(bind=db_engine), callback)
    if obj is None:
        raw_device_uuid = request.device_id.device_uuid.uuid
        raise NotFoundException('Device', raw_device_uuid, extra_details=[
        device_uuid_raw = request.device_uuid.uuid
        raise NotFoundException('Device', device_uuid_raw, extra_details=[
            'No Topology found for  device uuid : {:s}'.format(device_uuid)
        ])
    return obj
 No newline at end of file
+4 −3
Original line number Diff line number Diff line
@@ -50,9 +50,10 @@ class ChildTopologyModel (_Base):
    def dump(self) -> Dict:
        return {
            'topology_id'     : self.dump_id(),
            'name'            : self.topology_name,
            'device_ids'      : [{'device_uuid': {'uuid': td.device_uuid      }} for td in self.child_topology_devices      ],
            'optical_link_ids': [{'link_uuid'  : {'uuid': to.optical_link_uuid}} for to in self.child_topology_optical_links],
             'host'          : self.host,
             'port'          : self.port,
            'devices'      : [{'device_id': td.dump_id()} for td in self.child_topology_devices      ],
            'optical_links': [{'link_id':to.dump_id()} for to in self.child_topology_optical_links],
        }
        
    def dump_details(self) -> Dict:
+1 −0
Original line number Diff line number Diff line
@@ -75,6 +75,7 @@ def set_service () :
def create_service (): 
    
    data = request.json 
   
    _services ,host,port,topology_uuid =service_composer(data, context_client)
    logging.info(f"_services : {_services}")
    if len(_services['services'])> 0 : 
+2 −2
Original line number Diff line number Diff line
@@ -58,7 +58,7 @@ service_json = {

def service_composer (service_json,context_client) : 
    composed_service = {
        'name': service.service_id.service_uuid.uuid,
        'name': None,
        'type': None,
        'src_dev': None,
        'src_end': None,