Commit 8fcdf991 authored by Pablo Armingol's avatar Pablo Armingol
Browse files

Merge branch 'develop' of https://labs.etsi.org/rep/tfs/controller into feat/tid_L3SM

parents e55ebe3b 92c9cc24
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line
@@ -31,10 +31,6 @@ def parse(xml_data : ET.Element) -> List[Tuple[str, Dict[str, Any]]]:

        interface = {}

        interface_name = xml_interface.find('oci:name', namespaces=NAMESPACES)
        if interface_name is None or interface_name.text is None: continue
        add_value_from_tag(interface, 'name', interface_name)

        #interface_type = xml_interface.find('oci:config/oci:type', namespaces=NAMESPACES)
        #add_value_from_tag(interface, 'type', interface_type)

@@ -42,8 +38,11 @@ def parse(xml_data : ET.Element) -> List[Tuple[str, Dict[str, Any]]]:
            interface_type = xml_interface.find('oci:config/oci:type', namespaces=NAMESPACES)
        elif xml_interface.find('oci:state/oci:type', namespaces=NAMESPACES) is not None:
            interface_type = xml_interface.find('oci:state/oci:type', namespaces=NAMESPACES)
        else:
            interface_type = ''
        else: continue
            
        interface_name = xml_interface.find('oci:name', namespaces=NAMESPACES)
        if interface_name is None or interface_name.text is None: continue
        add_value_from_tag(interface, 'name', interface_name)
            
        # Get the type of interface according to the vendor's type
        if 'ianaift:' in interface_type.text:
+3 −4
Original line number Diff line number Diff line
@@ -54,7 +54,6 @@ XPATH_PORTS = "//ocp:components/ocp:component"

def parse(xml_data : ET.Element) -> List[Tuple[str, Dict[str, Any]]]:
    response = []
    LOGGER.debug("InventoryPrueba")
    parent_types = {}
    for xml_component in xml_data.xpath(XPATH_PORTS, namespaces=NAMESPACES):
        LOGGER.info('xml_component inventario = {:s}'.format(str(ET.tostring(xml_component))))
@@ -78,8 +77,8 @@ def parse(xml_data : ET.Element) -> List[Tuple[str, Dict[str, Any]]]:
            add_value_from_tag(inventory['attributes'], 'location', component_location)
        
        component_type = xml_component.find('ocp:state/ocp:type', namespaces=NAMESPACES)
        if component_type is not None:
            component_type.text = component_type.text.replace('oc-platform-types:','')
        if component_type is None: continue
            add_value_from_tag(inventory, 'class', component_type)
        
        if inventory['class'] == 'CPU' or inventory['class'] == 'STORAGE': continue
+1 −1
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@ def parse(xml_data : ET.Element) -> List[Tuple[str, Dict[str, Any]]]:
        #LOGGER.info('xml_policy_definition = {:s}'.format(str(ET.tostring(xml_policy_definition))))

        policy_definition = {}

        statement_name = ''
        policy_name = xml_policy_definition.find('ocrp:name', namespaces=NAMESPACES)
        if policy_name is None or policy_name.text is None: continue
        add_value_from_tag(policy_definition, 'policy_name', policy_name)
+12 −0
Original line number Diff line number Diff line
@@ -151,6 +151,11 @@ def test_device_ietf_actn_configure(
    retrieved_driver_config_rules = sorted(driver.GetConfig(), key=operator.itemgetter(0))
    LOGGER.info('driver_config = {:s}'.format(str(retrieved_driver_config_rules)))
    assert isinstance(retrieved_driver_config_rules, list)
    retrieved_driver_config_rules = [
        (resource_key, resource_value)
        for resource_key, resource_value in retrieved_driver_config_rules
        if resource_key != '/endpoints/endpoint[mgmt]'
    ]
    if len(retrieved_driver_config_rules) > 0:
        LOGGER.error('PRE DRIVER CONFIG RULES - Differences:\n{:s}'.format(str(retrieved_driver_config_rules)))
    assert len(retrieved_driver_config_rules) == 0
@@ -186,6 +191,7 @@ def test_device_ietf_actn_configure(
    retrieved_driver_config_rules = [
        {'action': 1, 'custom': {'resource_key': resource_key, 'resource_value': resource_value}}
        for resource_key, resource_value in retrieved_driver_config_rules
        if resource_key != '/endpoints/endpoint[mgmt]'
    ]
    with open(DATA_FILE_CONFIG_RULES, 'r', encoding='UTF-8') as f:
        expected_driver_config_rules = sorted(json.load(f), key=lambda cr: cr['custom']['resource_key'])
@@ -231,6 +237,7 @@ def test_device_ietf_actn_deconfigure(
    retrieved_driver_config_rules = [
        {'action': 1, 'custom': {'resource_key': resource_key, 'resource_value': resource_value}}
        for resource_key, resource_value in retrieved_driver_config_rules
        if resource_key != '/endpoints/endpoint[mgmt]'
    ]
    with open(DATA_FILE_CONFIG_RULES, 'r', encoding='UTF-8') as f:
        expected_driver_config_rules = sorted(json.load(f), key=lambda cr: cr['custom']['resource_key'])
@@ -266,6 +273,11 @@ def test_device_ietf_actn_deconfigure(
    retrieved_driver_config_rules = sorted(driver.GetConfig(), key=operator.itemgetter(0))
    LOGGER.info('retrieved_driver_config_rules = {:s}'.format(str(retrieved_driver_config_rules)))
    assert isinstance(retrieved_driver_config_rules, list)
    retrieved_driver_config_rules = [
        (resource_key, resource_value)
        for resource_key, resource_value in retrieved_driver_config_rules
        if resource_key != '/endpoints/endpoint[mgmt]'
    ]
    if len(retrieved_driver_config_rules) > 0:
        LOGGER.error('POST DRIVER CONFIG RULES - Differences:\n{:s}'.format(str(retrieved_driver_config_rules)))
    assert len(retrieved_driver_config_rules) == 0
+34 −5
Original line number Diff line number Diff line
@@ -12,8 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
 
import logging
import json
import json, logging

from typing import Dict, List
from flask import request
@@ -50,6 +49,35 @@ class L3VPN_Services(Resource):
        # LOGGER.debug('Request: {:s}'.format(str(request_data)))
        LOGGER.debug('Request: {:s}'.format(str(jsonAValidarDict)))

        errors = list()
        if 'ietf-l3vpn-svc:l3vpn-services' in request_data:
            # processing multiple L3VPN service requests formatted as:
            #{
            #  "ietf-l3vpn-svc:l3vpn-services": {
            #    "l3vpn-svc": [
            #      {
            #        "service-id": "vpn1",
            #        "vpn-services": {
            #          "vpn-service": [
            for l3vpn_svc in request_data['ietf-l3vpn-svc:l3vpn-services']['l3vpn-svc']:
                l3vpn_svc.pop('service-id', None)
                l3vpn_svc_request_data = {'ietf-l3vpn-svc:l3vpn-svc': l3vpn_svc}
                errors.extend(self._process_l3vpn(l3vpn_svc_request_data))
        elif 'ietf-l3vpn-svc:l3vpn-svc' in request_data:
            # processing single (standard) L3VPN service request formatted as:
            #{
            #  "ietf-l3vpn-svc:l3vpn-svc": {
            #    "vpn-services": {
            #      "vpn-service": [
            errors.extend(self._process_l3vpn(request_data))
        else:
            errors.append('unexpected request: {:s}'.format(str(request_data)))

        response = jsonify(errors)
        response.status_code = HTTP_CREATED if len(errors) == 0 else HTTP_SERVERERROR
        return response

    def _process_l3vpn(self, request_data : Dict) -> List[Dict]:
        yang_validator = YangValidator('ietf-l3vpn-svc')
        request_data = yang_validator.parse_to_dict(jsonAValidarDict)
        yang_validator.destroy()
@@ -88,7 +116,7 @@ class L3VPN_Services(Resource):

        ######

        # errors = []
        errors = []

        # for vpn_service in request_data['l3vpn-svc']['vpn-services']['vpn-service']:
        #     process_vpn_service(vpn_service, errors)
@@ -100,3 +128,4 @@ class L3VPN_Services(Resource):
        # response.status_code = HTTP_CREATED if len(errors) == 0 else HTTP_SERVERERROR
        # return response
    
        return errors
Loading