Commit f2950733 authored by Pablo Armingol's avatar Pablo Armingol
Browse files

code clean up

parent 3de33cb0
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ class OpenConfigServicer(DeviceServiceServicer):
    def AddOpenConfigDevice(self, request : OpticalConfig, context : grpc.ServicerContext) -> DeviceId:
            device_uuid = request.device_id.device_uuid.uuid
            check_no_endpoints(request.device_endpoints)

            context_client = ContextClient()
            device = get_device(context_client, device_uuid, rw_copy=True)
            if device is None:
+0 −1
Original line number Diff line number Diff line
@@ -112,4 +112,3 @@ def preload_drivers(driver_instance_cache : DriverInstanceCache) -> None:
    context_client = ContextClient()
    devices = context_client.ListDevices(Empty())
    for device in devices.devices: get_driver(driver_instance_cache, device)
+3 −3
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ def parse(xml_data : ET.Element) -> List[Tuple[str, Dict[str, Any]]]:
        if interface_name is None or interface_name.text is None: continue
        add_value_from_tag(interface, 'name', interface_name)

        sap_interface = ET.Element('dummy')                                                           #SAP-ID
        sap_interface = ET.Element('dummy')
        sap_interface.text =str(sap_interface_counter) 
        aux =str(sap_interface_counter) 
        add_value_from_tag(interface, 'sap_id', sap_interface)
@@ -83,7 +83,7 @@ def parse(xml_data : ET.Element) -> List[Tuple[str, Dict[str, Any]]]:
            vlan_id = xml_subinterface.find('ocv:vlan/ocv:match/ocv:single-tagged/ocv:config/ocv:vlan-id', namespaces=NAMESPACES)
            add_value_from_tag(subinterface, 'vlan_id', vlan_id, cast=int)

            sap_subinterface = ET.Element('dummy')                                                  #SAP-ID
            sap_subinterface = ET.Element('dummy')
            value = (aux  + chr(sap_subinterface_counter))
            sap_subinterface.text = value
            add_value_from_tag(subinterface, 'sap_id', sap_subinterface)
+0 −26
Original line number Diff line number Diff line
cd ~/tfs-ctrl/src/nbi/service/rest_server/nbi_plugins/ietf_network

python

from bindings import ietf_network
import pyangbind.lib.pybindJSON as pybindJSON

ietf_nets_obj = ietf_network()
ietf_net_obj = ietf_nets_obj.networks.network.add('my-topo')

ietf_node_obj = ietf_net_obj.node.add('my-node')
ietf_tp_obj = ietf_node_obj.termination_point.add('my-tp')

ietf_link_obj = ietf_net_obj.link.add('my-link')

ietf_link_obj.te._set_oper_status('up')
print(pybindJSON.dumps(ietf_nets_obj, mode='ietf'))

ietf_link_obj.te.te_link_attributes.admin_status = 'down'
print(pybindJSON.dumps(ietf_nets_obj, mode='ietf'))


ietf_link_obj.te.te_link_attributes.max_link_bandwidth.te_bandwidth.eth_bandwidth = 10_000_000 # Kbps
unresv_bw = ietf_link_obj.te.te_link_attributes.unreserved_bandwidth.add(7)
unresv_bw.te_bandwidth.eth_bandwidth = 10_000_000 # Kbps
print(pybindJSON.dumps(ietf_link_obj, mode='ietf'))