Commit 55b6eb9f authored by Maria Ruiz's avatar Maria Ruiz
Browse files

updates

parent 2fefbaab
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -289,7 +289,6 @@ class NSController:
                    # Realizer
                    tfs_request = self.__realizer(intent)
                    requests["services"].append(tfs_request)
                    logging.info("*************DEBUGGING1*************")
                    logging.info("Realizing request: {tfs_request}")
            else:
                return self.__send_response(False, code=404, message="No intents found")
@@ -1329,6 +1328,7 @@ class NSController:
       
        # Construcción del diccionario intent
        intent = {
            
            "src_node_id":  ietf_intent.get("ietf-network-slice-service:network-slice-services", {})
                .get("slice-service", [{}])[0]
                .get("sdps", {}).get("sdp", [{}])[0]
@@ -1357,6 +1357,10 @@ class NSController:
                .get("service-match-criteria", {}).get("match-criterion", [{}])[0]
                .get("value"),

            "QoS_profile": ietf_intent.get("ietf-network-slice-service:network-slice-services", {})
                .get("slo-sle-templates", {}).get("slo-sle-template", [{}])[0]
                .get("id"),

            "bandwidth": bandwidth,
            "latency": latency,
            "tolerance": tolerance,
+89 −9
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@

# This file is an original contribution from Telefonica Innovación Digital S.L.

import ipaddress, logging
import logging
import requests
from requests.auth import HTTPBasicAuth
from http import HTTPStatus
@@ -37,13 +37,33 @@ class SAT_NMS:
        src_node_ip = json_data.get("src_node_ip", None)
        dst_node_ip = json_data.get("dst_node_ip", None)
        vlan_id = json_data.get("vlan_id", None)
        QoS_profile = json_data.get("QoS_profile", None)
        bandwidth = json_data.get("bandwidth", None)
        latency = json_data.get("latency", None)
        tolerance = json_data.get("tolerance", None)

        new_service = self.new_service(self.satnms_ip, vlan_id)
        print(f'\n\n{new_service}\n')

        if new_service is not None:
            num_service = new_service.get("reply",{}).get("%row")
            
            #mapeo QoS:
            if QoS_profile == "A":
                qos_mapped = "qos:0 QoS_P7"
            elif QoS_profile == "B":
                qos_mapped = "qos:2 QoS_P4"
            elif QoS_profile == "C":
                qos_mapped = "qos:1 QoS_P1"
            else:
                qos_mapped = "qos:0 QoS_P7" #default

            add_route_controller = self.add_routes_controller(self.satnms_ip, num_service, vlan_id, qos_mapped)
            print(f'\n\n{add_route_controller}\n')

            add_route_station = self.add_routes_station(self.satnms_ip, num_service, vlan_id, qos_mapped)
            print(f'\n\n{add_route_station}\n')
        else: 
            print("No se pudo crear la Slice")

    def loggin_NMS(self,ip):

@@ -54,15 +74,13 @@ class SAT_NMS:
        if HTTPStatus.OK == response.status_code:
            cookies = response.cookies
            logging.info("sesion iniciada en el NMS")
            print(f'\n\n{cookies}\n')
            #print(f'\n\n{cookies}\n')
            return cookies
            
        else:
            print(f"error al obtener la informacion de la IP; {response.status_code}")
            return None
    
   
   
    def new_service(self,ip, vlan_id):

        session = self.loggin_NMS(ip)
@@ -75,7 +93,7 @@ class SAT_NMS:
        
        body_dict = {
            "uprow": "LAB_TEL",
            "name": "test_106",
            "name": "SLICE_"+str(vlan_id),
            "accesses": "",
            "hub_vlan": vlan_id,
            "stn_vlan": vlan_id,
@@ -95,12 +113,74 @@ class SAT_NMS:

        payload = json.dumps(body_dict)
        response = requests.post(url, cookies=session, auth=('admin', '12345'), data=payload)
        error_code = response.json().get("error_code",None)

        if response.status_code==200:
        if response.status_code==200 and error_code !="0":
            logging.info("servicio creado en el NMS")
            return response.json()
        else:
            print(f"error al crear el servicio; {response.status_code}")
            print(f"Error al crear el servicio; error code:"+str(response.json().get("error_code",None))+ "; error log: "+str(response.json().get("error_log",None)))
            return None
        
    def add_routes_controller(self,ip, num_service, vlan_id, qos_mapped):

        session = self.loggin_NMS(ip)
        
        if session is None:
            print("No se pudo iniciar sesion en el NMS")
            return None
        
        #Añadir la ruta al controller: 
        url= "http://"+ip+":8000/api/object/write/controller=0/new_item=route"

        body_dict = {
            "type": "L2_bridge",
            "service": "service:"+str(num_service)+" "+str(vlan_id),
            "forward_qos": qos_mapped,
            "return_qos": qos_mapped,
            "override_vlan": "OFF"
        }

        payload = json.dumps(body_dict)
        response = requests.post(url, cookies=session, auth=('admin', '12345'), data=payload)
        error_code = response.json().get("error_code",None)

        if response.status_code==200 and error_code !="0":
            logging.info("Nueva ruta añadida en HUB")
            #print(f'\n\n{payload}\n')
            return response.json()
        else:
            print(f"Error al añadir la ruta en HUB; error code:"+str(response.json().get("error_code",None))+ "; error log: "+str(response.json().get("error_log",None)))
            return None

    def add_routes_station(self,ip, num_service, vlan_id, qos_mapped):

        session = self.loggin_NMS(ip)
        
        if session is None:
            print("No se pudo iniciar sesion en el NMS")
            return None
        
        #Añadir la ruta al controller: 
        url= "http://"+ip+":8000/api/object/write/station=0/new_item=route"

        body_dict = {
            "type": "L2_bridge",
            "service": "service:"+str(num_service)+" "+str(vlan_id),
            "forward_qos": qos_mapped,
            "return_qos": qos_mapped,
            "override_vlan": "OFF"
        }

        payload = json.dumps(body_dict)
        response = requests.post(url, cookies=session, auth=('admin', '12345'), data=payload)
        error_code = response.json().get("error_code",None)

        if response.status_code==200 and error_code !="0":
            logging.info("Nueva rua añadida en STATION")
            return response.json()
        else:
            print(f"Error al añadir la ruta en STATION;  error code:"+str(response.json().get("error_code",None))+ "; error log: "+str(response.json().get("error_log",None)))
            return None      

        
+3984 −0

File changed.

Preview size limit exceeded, changes collapsed.

+22 −11
Original line number Diff line number Diff line
@@ -4,10 +4,21 @@
      "slo-sle-templates": {
        "slo-sle-template": [
          {
            "id": "",
            "id": "A",
            "description": "",
            "slo-policy": {
              "metric-bound": []
              "metric-bound": [
                {
                  "metric-type": "one-way-bandwidth",
                  "metric-unit": "kbps",
                  "bound": 2
                },
                {
                  "metric-type": "one-way-delay-maximum",
                  "metric-unit": "milliseconds",
                  "bound": 20
                }
              ]
            },
            "sle-policy": {
              "security": "",
@@ -26,8 +37,8 @@
      },
      "slice-service": [
        {
          "id": "5GSliceMapping",
          "description": "example 5G Slice mapping",
          "id": "slice-service-8473f01e-ff21-4c89-8ff1-2dc2c15d2096",
          "description": "Transport network slice mapped with 3GPP slice NetworkSlice1",
          "service-tags": {
            "tag-type": {
              "tag-type": "",
@@ -35,7 +46,7 @@
            }
          },
          "slo-sle-policy": {
            "slo-sle-template": "SAT"
            "slo-sle-template": "A"
          },
          "status": {},
          "sdps": {
@@ -52,7 +63,7 @@
                      "index": 1,
                      "match-type": "VLAN",
                      "value": "106",
                      "target-connection-group-id": "HUB_STATION_106"
                      "target-connection-group-id": "HUB_STATION"
                    }
                  ]
                },
@@ -70,7 +81,7 @@
                      "ac-ipv4-address": "192.168.27.68",
                      "ac-ipv4-prefix-length": 0,
                      "sdp-peering": {
                        "peer-sap-id": "H"
                        "peer-sap-id": "HUB"
                      },
                      "status": {}
                    }
@@ -91,7 +102,7 @@
                      "index": 1,
                      "match-type": "VLAN",
                      "value": "106",
                      "target-connection-group-id": "HUB_STATION_106"
                      "target-connection-group-id": "HUB_STATION"
                    }
                  ]
                },
@@ -109,7 +120,7 @@
                      "ac-ipv4-address": "192.168.27.69",
                      "ac-ipv4-prefix-length": 0,
                      "sdp-peering": {
                        "peer-sap-id": "S"
                        "peer-sap-id": "STATION"
                      },
                      "status": {}
                    }
@@ -123,8 +134,8 @@
          "connection-groups": {
            "connection-group": [
              {
                "id": "HUB_STATION_106",
                "connectivity-type": "ietf-vpn-common:point-to-point",
                "id": "HUB_STATION",
                "connectivity-type": "ietf-vpn-common:any-to-any",
                "connectivity-construct": [
                  {
                    "id": 1,
+122 −138
Original line number Diff line number Diff line
{
  "ietf-network-slice-service:network-slice-services": {
    "slo-sle-templates": {
      "slo-sle-template": [
  "NetworkSlice1": {
    "operationalState": "",
    "administrativeState": "",
    "serviceProfileList": [],
    "networkSliceSubnetRef": "TopSliceSubnet1"
  },
  "TopSliceSubnet1": {
    "operationalState": "",
    "administrativeState": "",
    "nsInfo": {},
    "managedFunctionRef": [],
    "networkSliceSubnetType": "TOP_SLICESUBNET",
    "SliceProfileList": [
      {
          "id": "",
          "description": "",
          "slo-policy": {
            "metric-bound": []
        "sliceProfileId": "TopId",
        "pLMNInfoList": null,
        "TopSliceSubnetProfile": {
          "dLThptPerSliceSubnet": {
            "GuaThpt": 310,
            "MaxThpt": 620
          },
          "sle-policy": {
            "security": "",
            "isolation": "",
            "path-constraints": {
              "service-functions": "",
              "diversity": {
                "diversity": {
                  "diversity-type": ""
                }
              }
            }
          "uLThptPerSliceSubnet": {
            "GuaThpt": 160,
            "MaxThpt": 320
          },
          "dLLatency": 20,
          "uLLatency": 20
        }
      }
    ],
    "networkSliceSubnetRef": [
      "RANSliceSubnet1"
    ]
  },
    "slice-service": [
  "RANSliceSubnet1": {
    "operationalState": "",
    "administrativeState": "",
    "nsInfo": {},
    "managedFunctionRef": [],
    "networkSliceSubnetType": "RAN_SLICESUBNET",
    "SliceProfileList": [
      {
        "id": "5GSliceMapping",
        "description": "example 5G Slice mapping",
        "service-tags": {
          "tag-type": {
            "tag-type": "",
            "value": ""
          }
        "sliceProfileId": "RANId",
        "pLMNInfoList": null,
        "RANSliceSubnetProfile": {
          "dLThptPerSliceSubnet": {
            "GuaThpt": 310,
            "MaxThpt": 620
          },
        "slo-sle-policy": {
          "slo-sle-template": "SAT"
          "uLThptPerSliceSubnet": {
            "GuaThpt": 160,
            "MaxThpt": 320
          },
        "status": {},
        "sdps": {
          "sdp": [
            {
              "id": "",
              "geo-location": "",
              "node-id": "HUB",
              "sdp-ip-address": "192.168.27.68",
              "tp-ref": "",
              "service-match-criteria": {
                "match-criterion": [
                  {
                    "index": 1,
                    "match-type": "VLAN",
                    "value": "106",
                    "target-connection-group-id": "HUB_STATION_106"
          "dLLatency": 20,
          "uLLatency": 20
        }
      }
    ],
    "networkSliceSubnetRef": [
      "BackhaulSliceSubnetN2"
    ]
  },
              "incoming-qos-policy": "",
              "outgoing-qos-policy": "",
              "sdp-peering": {
                "peer-sap-id": "",
                "protocols": ""
              },
              "ac-svc-ref": [],
              "attachment-circuits": {
                "attachment-circuit": [
  "BackhaulSliceSubnetN2": {
    "operationalState": "",
    "administrativeState": "",
    "nsInfo": {},
    "managedFunctionRef": [],
    "networkSliceSubnetType": "RAN_SLICESUBNET",
    "SliceProfileList": [
      {
                    "id": "100",
                    "ac-ipv4-address": "192.168.27.68",
                    "ac-ipv4-prefix-length": 0,
                    "sdp-peering": {
                      "peer-sap-id": "H"
        "sliceProfileId": "BackhaulId",
        "pLMNInfoList": null,
        "RANSliceSubnetProfile": {
          "dLThptPerSliceSubnet": {
            "GuaThpt": 1,
            "MaxThpt": 2
          },
                    "status": {}
                  }
                ]
          "uLThptPerSliceSubnet": {
            "GuaThpt": 1,
            "MaxThpt": 2
          },
              "status": {},
              "sdp-monitoring": ""
            },
            {
              "id": "",
              "geo-location": "",
              "node-id": "STATION",
              "sdp-ip-address": "192.168.27.69",
              "tp-ref": "",
              "service-match-criteria": {
                "match-criterion": [
                  {
                    "index": 1,
                    "match-type": "VLAN",
                    "value": "106",
                    "target-connection-group-id": "HUB_STATION_106"
          "dLLatency": 20,
          "uLLatency": 20
        }
      }
    ],
    "EpTransport": [
      "EpTransport HUB",
      "EpTransport STATION"
    ]
  },
              "incoming-qos-policy": "",
              "outgoing-qos-policy": "",
              "sdp-peering": {
                "peer-sap-id": "",
                "protocols": ""
              },
              "ac-svc-ref": [],
              "attachment-circuits": {
                "attachment-circuit": [
                  {
                    "id": "200",
                    "ac-ipv4-address": "192.168.27.69",
                    "ac-ipv4-prefix-length": 0,
                    "sdp-peering": {
                      "peer-sap-id": "S"
  "EpTransport HUB": {
    "IpAddress": "192.168.27.68",
    "logicalInterfaceInfo": {
      "logicalInterfaceType": "VLAN",
      "logicalInterfaceId": "106"
    },
                    "status": {}
                  }
    "NextHopInfo": "HUB",
    "qosProfile": "A",
    "EpApplicationRef": [
      "EP_N2 HUB"
    ]
  },
              "status": {},
              "sdp-monitoring": ""
            }
  "EP_N2 HUB": {
    "localAddress": "192.168.27.68",
    "remoteAddress": "192.168.27.69",
    "epTransportRef": [
      "EpTransport HUB"
    ]
  },
        "connection-groups": {
          "connection-group": [
            {
              "id": "HUB_STATION_106",
              "connectivity-type": "ietf-vpn-common:point-to-point",
              "connectivity-construct": [
                {
                  "id": 1,
                  "a2a-sdp": [
                    {
                      "sdp-id": "01"
  "EpTransport STATION": {
    "IpAddress": "192.168.27.69",
    "logicalInterfaceInfo": {
      "logicalInterfaceType": "VLAN",
      "logicalInterfaceId": "106"
    },
                    {
                      "sdp-id": "02"
                    }
                  ]
                }
              ],
              "status": {}
            }
    "NextHopInfo": "STATION",
    "qosProfile": "A",
    "EpApplicationRef": [
      "EP_N2 STATION"
    ]
        }
      }
  },
  "EP_N2 STATION": {
    "localAddress": "192.168.27.69",
    "remoteAddress": "192.168.27.68",
    "epTransportRef": [
      "EpTransport UPF-N2"
    ]
  }
}
 No newline at end of file
Loading