Commit 2fa63e3c authored by douomo's avatar douomo
Browse files

added check on last change for alarm, added bridge type in vlan deployment...

added check on last change for alarm, added bridge type in vlan deployment xml, fixed the xml for provisionin test
parent 8857b873
Loading
Loading
Loading
Loading
+8 −8
Original line number Original line Diff line number Diff line
@@ -43,18 +43,18 @@ Mute ODU and Query Alarms
    BuiltIn.Sleep    2s
    BuiltIn.Sleep    2s
    #Set RSL Threshold    ${m}    ${par["testInterface"]}    ${par["rslThreshold"]}    #check this
    #Set RSL Threshold    ${m}    ${par["testInterface"]}    ${par["rslThreshold"]}    #check this
    ${alarms}=    Get Filtered Config    ${m}    filters/alarms-list.xml
    ${alarms}=    Get Filtered Config    ${m}    filters/alarms-list.xml
    ${alarms_num_start}=    Count Alarm    ${alarms}
    ${last_alarms_start}=    Check Time Last Alarm    ${alarms}
    Log    ${alarms}    console=yes
    Log    ${alarms}    console=yes
    Mute ODU    ${t}    ${transmitter["testInterface"]}    #Interface name to mute #On transmitter node: need to connect to the TX and change ${m} with the reference to the transmitter
    Mute ODU    ${t}    ${transmitter["testInterface"]}    #Interface name to mute #On transmitter node: need to connect to the TX and change ${m} with the reference to the transmitter
    BuiltIn.Sleep    2s
    BuiltIn.Sleep    5s
    ${alarms}=    Get Filtered Config    ${m}    filters/alarms-list.xml
    ${alarms}=    Get Filtered Config    ${m}    filters/alarms-list.xml
    Log    ${alarms}    console=yes
    Log    ${alarms}    console=yes
    ${alarms_num_end}=    Count Alarm    ${alarms}
    ${last_alarms_end}=    Check Time Last Alarm    ${alarms}
    ${SNR}=    Get Iface Metrics    ${m}    ${par["testInterface"]}    "actual-snir"    #99.8 for Nokia
    ${SNR}=    Get Iface Metrics    ${m}    ${par["testInterface"]}    "actual-snir"    #99.8 for Nokia
    ${ok}=    Evaluate    float(${SNR}) < 15
    ${ok}=    Evaluate    float(${SNR}) < 15
    ${ok_nokia}=    Evaluate    float(${SNR}) == 99.8
    ${ok_nokia}=    Evaluate    float(${SNR}) == 99.8
    Should Be True      ${ok} or ${ok_nokia}    msg=SNR (${SNR}) must be less than 15
    Should Be True      ${ok} or ${ok_nokia}    msg=SNR (${SNR}) must be less than 15
    Should Be True    ${alarms_num_start} < ${alarms_num_end}
    Should Be True    ${last_alarms_start} < ${last_alarms_end}
    Close Current Session    ${m}
    Close Current Session    ${m}
    Close Current Session    ${t}
    Close Current Session    ${t}


@@ -67,10 +67,10 @@ Mute ODU and Receive RSL Alarms
    Unmute ODU    ${t}    ${transmitter["testInterface"]}    #Interface name to mute #On transmitter node: need to connect to the TX and change ${m} with the reference to the transmitter
    Unmute ODU    ${t}    ${transmitter["testInterface"]}    #Interface name to mute #On transmitter node: need to connect to the TX and change ${m} with the reference to the transmitter
    Set TX Power    ${t}    ${transmitter["testInterface"]}    ${transmitter["maxTxPower"]}    
    Set TX Power    ${t}    ${transmitter["testInterface"]}    ${transmitter["maxTxPower"]}    
    Set RSL Threshold    ${m}    ${par["testInterface"]}    ${par["rslThreshold"]}
    Set RSL Threshold    ${m}    ${par["testInterface"]}    ${par["rslThreshold"]}
    BuiltIn.Sleep    2s
    BuiltIn.Sleep    5s
    ${resp}=    Call Method    ${m}    create_subscription    stream_name=NETCONF
    ${resp}=    Call Method    ${m}    create_subscription    stream_name=NETCONF
    Mute ODU    ${t}    ${transmitter["testInterface"]}
    Mute ODU    ${t}    ${transmitter["testInterface"]}
    BuiltIn.Sleep    2s
    BuiltIn.Sleep    5s
    ${notif}=    Call Method    ${m}    take_notification    timeout=${TIMEOUT}
    ${notif}=    Call Method    ${m}    take_notification    timeout=${TIMEOUT}
    ${notif_xml}=    Set Variable    ${notif.notification_xml}
    ${notif_xml}=    Set Variable    ${notif.notification_xml}
    Should Not Be Empty    ${notif_xml}
    Should Not Be Empty    ${notif_xml}
@@ -86,7 +86,7 @@ Mute ODU Receive RSL Alarms and Unmute
    #${t}=    Connect With Credentials    ${transmitter["host"]}    ${transmitter["port"]}    ${transmitter["username"]}    ${transmitter["password"]}
    #${t}=    Connect With Credentials    ${transmitter["host"]}    ${transmitter["port"]}    ${transmitter["username"]}    ${transmitter["password"]}
    Unmute ODU    ${t}    ${transmitter["testInterface"]}
    Unmute ODU    ${t}    ${transmitter["testInterface"]}
    Set TX Power    ${t}    ${transmitter["testInterface"]}    ${transmitter["maxTxPower"]}    
    Set TX Power    ${t}    ${transmitter["testInterface"]}    ${transmitter["maxTxPower"]}    
    BuiltIn.Sleep    2s
    BuiltIn.Sleep    5s
    Set RSL Threshold    ${m}    ${par["testInterface"]}    ${par["rslThreshold"]}
    Set RSL Threshold    ${m}    ${par["testInterface"]}    ${par["rslThreshold"]}
    #${resp}=    Evaluate    ${m}.create_subscription()
    #${resp}=    Evaluate    ${m}.create_subscription()
    ${resp}=    Call Method    ${m}    create_subscription    stream_name=NETCONF
    ${resp}=    Call Method    ${m}    create_subscription    stream_name=NETCONF
@@ -98,7 +98,7 @@ Mute ODU Receive RSL Alarms and Unmute
    Log    ${notif_xml}    console=yes
    Log    ${notif_xml}    console=yes
    Unmute ODU    ${t}    ${transmitter["testInterface"]}
    Unmute ODU    ${t}    ${transmitter["testInterface"]}
    Set TX Power    ${t}    ${transmitter["testInterface"]}    ${transmitter["maxTxPower"]}    
    Set TX Power    ${t}    ${transmitter["testInterface"]}    ${transmitter["maxTxPower"]}    
    BuiltIn.Sleep    2s
    BuiltIn.Sleep    5s
    ${actual-recevied}=    Get Iface Metrics    ${m}    ${par["testInterface"]}    "actual-received-level"
    ${actual-recevied}=    Get Iface Metrics    ${m}    ${par["testInterface"]}    "actual-received-level"
    #Should Be True    ${actual-recevied}>0
    #Should Be True    ${actual-recevied}>0
    ${ok}=    Evaluate    float(${actual-recevied}) > -40
    ${ok}=    Evaluate    float(${actual-recevied}) > -40
+1 −1
Original line number Original line Diff line number Diff line
@@ -90,7 +90,7 @@ Reaction to Alarm
    # ${t}=    Connect With Credentials    ${transmitter["host"]}    ${transmitter["port"]}    ${transmitter["username"]}    ${transmitter["password"]}
    # ${t}=    Connect With Credentials    ${transmitter["host"]}    ${transmitter["port"]}    ${transmitter["username"]}    ${transmitter["password"]}
    Set TX Power    ${t}    ${transmitter["testInterface"]}    ${transmitter["maxTxPower"]}    #On transmitter node: need to connect to the TX and change ${m} with the reference to the transmitter
    Set TX Power    ${t}    ${transmitter["testInterface"]}    ${transmitter["maxTxPower"]}    #On transmitter node: need to connect to the TX and change ${m} with the reference to the transmitter
    BuiltIn.Sleep    5s
    BuiltIn.Sleep    5s
    Set RSL Threshold    ${m}    ${par["testInterface"]}    -40.0
    Set RSL Threshold    ${m}    ${par["testInterface"]}    ${par["rslThreshold"]}
    ${init_RSL} =    Get Iface Metrics    ${m}    ${par["testInterface"]}    "actual-received-level"
    ${init_RSL} =    Get Iface Metrics    ${m}    ${par["testInterface"]}    "actual-received-level"
    ${resp}=    Call Method    ${m}    create_subscription    stream_name=NETCONF
    ${resp}=    Call Method    ${m}    create_subscription    stream_name=NETCONF
    Set TX Power    ${t}    ${transmitter["testInterface"]}    ${transmitter["minTxPower"]}    #On transmitter node: need to connect to the TX and change ${m} with the reference to the transmitter
    Set TX Power    ${t}    ${transmitter["testInterface"]}    ${transmitter["minTxPower"]}    #On transmitter node: need to connect to the TX and change ${m} with the reference to the transmitter
+13 −2
Original line number Original line Diff line number Diff line
@@ -7,11 +7,15 @@ from jinja2 import Environment, FileSystemLoader
import time
import time
from robot.libraries.BuiltIn import BuiltIn
from robot.libraries.BuiltIn import BuiltIn
from ncclient.operations import RPCError
from ncclient.operations import RPCError

import dateutil


def get_filtered_config(mgr, filter):   
def get_filtered_config(mgr, filter):   
    tree = ET.parse(filter)
    tree = ET.parse(filter)
    root = tree.getroot()
    root = tree.getroot()
    for elem in root.iter():
        if elem.tag == '{urn:ietf:params:xml:ns:yang:ietf-interfaces}type':
            elem.set('xmlns:ianaift', 'urn:ietf:params:xml:ns:yang:iana-if-type')
    ET.dump(root)
    xmlstr = ET.tostring(root, encoding='unicode', method='xml')
    xmlstr = ET.tostring(root, encoding='unicode', method='xml')
    print(xmlstr)
    print(xmlstr)
    return mgr.get(filter=("subtree", xmlstr)).data_xml
    return mgr.get(filter=("subtree", xmlstr)).data_xml
@@ -161,3 +165,10 @@ def count_alarm(xml_reply):
    tree = ET.fromstring(xml_reply)
    tree = ET.fromstring(xml_reply)
    alarm = tree.findall(".//ns0:status-change", namespaces={"ns0": "urn:ietf:params:xml:ns:yang:ietf-alarms"})
    alarm = tree.findall(".//ns0:status-change", namespaces={"ns0": "urn:ietf:params:xml:ns:yang:ietf-alarms"})
    return len(alarm)
    return len(alarm)

def check_time_last_alarm(xml_reply):
    tree = ET.fromstring(xml_reply)
    last = tree.findall(".//ns0:last-changed", namespaces={"ns0": "urn:ietf:params:xml:ns:yang:ietf-alarms"})
    dt = dateutil.parser.isoparse(last[0].text)
    ts = dt.timestamp()
    return(ts)
 No newline at end of file
+34 −12
Original line number Original line Diff line number Diff line
@@ -10,7 +10,7 @@ from ncclient import manager
from jinja2 import Environment, FileSystemLoader
from jinja2 import Environment, FileSystemLoader
import xml.etree.ElementTree as ET
import xml.etree.ElementTree as ET


vlan_creation_xml = "features/steps/cvlan_creation.xml.pyformat"
#vlan_creation_xml = "features/steps/cvlan_creation.xml.pyformat"
vlan_delation_xml = "features/steps/cvlan_deletion.xml.pyformat"
vlan_delation_xml = "features/steps/cvlan_deletion.xml.pyformat"


class NetworkElement(NamedTuple):
class NetworkElement(NamedTuple):
@@ -55,9 +55,13 @@ class NetconfLibrary:
            m = connect_with_key(ne.address, ne.mgmt_port, ne.username, ne.key_filename)
            m = connect_with_key(ne.address, ne.mgmt_port, ne.username, ne.key_filename)
            #m = connect_with_credentials(ne.address, ne.mgmt_port, ne.username, ne.password)
            #m = connect_with_credentials(ne.address, ne.mgmt_port, ne.username, ne.password)
            BuiltIn().log_to_console("connected to device")
            BuiltIn().log_to_console("connected to device")
            xml = create_VLAN_xml(ne,vlan_id, "tagged")
            xml = None
            if vlan_id<200:
                xml = create_VLAN_xml(ne,vlan_id, "CB")
            elif vlan_id>=200:
                xml = create_VLAN_xml(ne,vlan_id, "PB")
            if ne.edgeIface != None:
            if ne.edgeIface != None:
                xml = create_VLAN_xml(ne,vlan_id, "untagged")
                xml = create_VLAN_xml(ne,vlan_id, "PEB")
            target = "candidate"
            target = "candidate"
            m.edit_config(target=target, config=xml)
            m.edit_config(target=target, config=xml)
            m.commit()
            m.commit()
@@ -134,6 +138,12 @@ class NetconfLibrary:
            if ne.edgeIface!=None:
            if ne.edgeIface!=None:
                m = connect_with_key(ne.address, ne.mgmt_port, ne.username, ne.key_filename)
                m = connect_with_key(ne.address, ne.mgmt_port, ne.username, ne.key_filename)
                #m = connect_with_credentials(ne.address, ne.mgmt_port, ne.username, ne.password)
                #m = connect_with_credentials(ne.address, ne.mgmt_port, ne.username, ne.password)
                #xml = create_VLAN_xml(ne,cvid1,"PB")
                #m.edit_config(target="candidate", config=xml)
                #m.commit()
                #xml = create_VLAN_xml(ne,cvid2,"PB")
                #m.edit_config(target="candidate", config=xml)
                #m.commit()
                env = Environment( loader=FileSystemLoader("."), autoescape=False)
                env = Environment( loader=FileSystemLoader("."), autoescape=False)
                context = {
                context = {
                    "port1_name":ne.edgeIface,
                    "port1_name":ne.edgeIface,
@@ -165,6 +175,12 @@ class NetconfLibrary:
                xml = env.get_template("features/steps/svlan_2_registration_deletion.xml.pyformat").render(context)
                xml = env.get_template("features/steps/svlan_2_registration_deletion.xml.pyformat").render(context)
                m.edit_config(target="candidate", config=xml)
                m.edit_config(target="candidate", config=xml)
                m.commit()
                m.commit()
                xml = delete_VLAN_xml(ne, cvid1)
                #m.edit_config(target="candidate", config=xml)
                #m.commit()
                #xml = delete_VLAN_xml(ne, cvid2)
                #m.edit_config(target="candidate", config=xml)
                #m.commit()
                m.close_session()
                m.close_session()
            
            


@@ -191,8 +207,9 @@ def connect_with_credentials(host, port, username, password):
        look_for_keys=False
        look_for_keys=False
    )
    )


def create_VLAN_xml(ne, vlanID, tag):
def create_VLAN_xml(ne, vlanID, mode):
    env = Environment( loader=FileSystemLoader("."), autoescape=False)
    env = Environment( loader=FileSystemLoader("."), autoescape=False)
    vlan_creation_xml = None
    context = {
    context = {
            "vid":vlanID,
            "vid":vlanID,
            "bridge_name" : ne.bridgeName,
            "bridge_name" : ne.bridgeName,
@@ -200,8 +217,13 @@ def create_VLAN_xml(ne, vlanID, tag):
            "vlan_name" : "TestVLAN",
            "vlan_name" : "TestVLAN",
            "port1_portref": ne.port_1,
            "port1_portref": ne.port_1,
            "port2_portref" : ne.port_2,
            "port2_portref" : ne.port_2,
        "tagged" : tag
        }
        }
    if(mode=="CB"):
        vlan_creation_xml = "features/steps/cvlan_creation.xml.pyformat"
    elif(mode=="PB"):
         vlan_creation_xml = "features/steps/svlan_creation.xml.pyformat"
    elif(mode=="PEB"):
        vlan_creation_xml = "features/steps/svlan_2_creation.xml.pyformat"
    return env.get_template(vlan_creation_xml).render(context)
    return env.get_template(vlan_creation_xml).render(context)


def delete_VLAN_xml(ne, vlanID):
def delete_VLAN_xml(ne, vlanID):
Loading