def deleteFlow():
    for i in range(1,9):
        print "openflow:"+str(i)
        odl_http_delete(
                        url_suffix = "config/opendaylight-inventory:nodes/node/openflow:%s/table/0/" % str(i),
                        expected_status_code=200
                        )
def acl_unapply_packet_filter(
    device_name,
    interface_name,
    bound,
    acl_name
):
    url_params = {'node-id' : device_name, 'interface-id' : interface_name, 'bound' : bound}
    odl_http_delete(_url_unapply_template, url_params, expected_status_code=200)
Esempio n. 3
0
def acl_unapply_packet_filter(
    device_name,
    interface_name,
    bound,
    acl_name
):
    url_suffix = _url_unapply_template % (quote_plus(device_name), quote_plus(interface_name), bound)
    odl_http_delete(url_suffix, expected_status_code=200)
def deleteFlow():
    for i in range(1, 9):
        print "openflow:" + str(i)
        odl_http_delete(
            url_suffix=
            "config/opendaylight-inventory:nodes/node/openflow:%s/table/0/" %
            str(i),
            expected_status_code=200)
Esempio n. 5
0
def device_dismount(
    device_name
):
    """    Remove one network device from the inventory of the Controller.
    
    It is not necessary for the device to be connected. 
    The outcome is undefined if the device is not already mounted.
    """
    odl_http_delete(_url_connector, {'node-id' : device_name}, 'application/xml', expected_status_code=200)
Esempio n. 6
0
def acl_unapply_packet_filter(device_name, interface_name, bound, acl_name):
    url_params = {
        'node-id': device_name,
        'interface-id': interface_name,
        'bound': bound
    }
    odl_http_delete(_url_unapply_template,
                    url_params,
                    expected_status_code=200)
Esempio n. 7
0
def device_dismount(device_name):
    """    Remove one network device from the inventory of the Controller.
    
    It is not necessary for the device to be connected. 
    The outcome is undefined if the device is not already mounted.
    """
    odl_http_delete(_url_connector, {'node-id': device_name},
                    'application/xml',
                    expected_status_code=200)
Esempio n. 8
0
def dismount_device(
    device_name
):
    'Dismount a network device that has been mounted on the ODL server.'
#     request_content = _request_content_template % (device_name, device_address, device_port, device_username, device_password)
#     request_content = _request_content_template % (quote_plus(device_name), 'dummy_address', 'dummy_port', 'dummy_username', 'dummy_password')
    dismount_url_suffix = _dismount_url_suffix_template % device_name
    print odl_http_get(dismount_url_suffix, 'application/xml', expected_status_code=200).text
    odl_http_delete(dismount_url_suffix, 'application/xml', expected_status_code=200)
    print odl_http_get(dismount_url_suffix, 'application/xml', expected_status_code=200).text
def dismount(node_id):
    """Remove node_id from the topology of the Controller.
    
    It is not necessary for the device to be connected. 
    The outcome is undefined if the device is not already mounted.
    """
    request_url = _url_connector.format(**{'config': 'config', 
                                          'topology-id': 'topology-netconf',
                                          'node-id': quote_plus(node_id),
                                          })
    odl_http_delete(request_url, {}, 'application/json', expected_status_code=200)
Esempio n. 10
0
def dismount(node_id):
    """Remove node_id from the topology of the Controller.
    
    It is not necessary for the device to be connected. 
    The outcome is undefined if the device is not already mounted.
    """
    request_url = _url_connector.format(**{'config': 'config', 
                                          'topology-id': 'topology-netconf',
                                          'node-id': quote_plus(node_id),
                                          })
    odl_http_delete(request_url, 'application/json', expected_status_code=200)
Esempio n. 11
0
def static_route_delete(device_name, destination_network=None):
    """
    Delete zero, one or more static routes from the specified device.
    
    Parameters:
    - device_name
        Identifies the network device.
    - destination_network
        Either None or an instance of type ipaddress._BaseNetwork
        - Unspecified
            Delete all static routes on the device.
            An exception is raised if there are no routes found on the device.
        - Specified
            Delete the route with the specified destination.
            An exception is raised if the specified route is not found on the device.

    No value is returned.
    An exception is raised if the static route does not exist on the device.
    """
    if destination_network:
        assert isinstance(destination_network, _BaseNetwork)
        url_params = {
            "node-id": device_name,
            "ip-address": destination_network.network_address,
            "prefix-length": destination_network.prefixlen,
        }
        url_template = _static_route_uni_url_template
    else:
        url_params = {"node-id": device_name}
        url_template = _static_route_url_template
    response = odl_http_delete(url_template, url_params, "application/json", expected_status_code=[200, 404, 500])
    if response.status_code != 200:
        raise Exception(_error_message(response.json()))
Esempio n. 12
0
def static_route_delete(device_name, destination_network):
    """ Delete the specified 'static route' from the specified device.
    
        No value is returned.
        An exception is raised if the static route does not exist on the device.
    """
    assert isinstance(destination_network, _BaseNetwork)
    url_suffix = _static_route_uni_url_template % (device_name, destination_network)
    response = odl_http_delete(url_suffix, expected_status_code=[200, 500])
    if response.status_code != 200:
        raise Exception(_error_message(response.json()))
Esempio n. 13
0
def acl_delete(device_name, acl_name):
    """ Delete the specified ACL from the specified device.
    
        No value is returned.
        An exception is raised if the ACL does not exist on the device.
        If the ACL is currently 'applied' then it is not deleted.
    """
    url_suffix = _url_named_acl % (quote_plus(device_name),
                                   quote_plus(acl_name))
    response = odl_http_delete(url_suffix, expected_status_code=[200, 500])
    if response.status_code != 200:
        raise Exception(_error_message(response.json()))
def static_route_delete(device_name, destination_network=None, prefixlen=0):
    """
    Delete zero, one or more static routes from the specified device.
    
    Parameters:
    - device_name
        Identifies the network device.
    - destination_network
        Either None or an instance of type ipaddress._BaseNetwork
        - Unspecified
            Delete all static routes on the device.
            An exception is raised if there are no routes found on the device.
        - Specified
            Delete the route with the specified destination.
            An exception is raised if the specified route is not found on the device.

    No value is returned.
    An exception is raised if the static route does not exist on the device.
    """
    
    if destination_network:
        route_list = static_route_json(device_name)
        for route in route_list:
            if route['prefix'] == destination_network:
                url_params = {
                'node-id' : device_name, 
                'ip-address' : destination_network, 
                'prefix-length' : prefixlen
                }
                url_template = _static_route_uni_url_template
                response = odl_http_delete(url_template, url_params, 'application/json', expected_status_code=[200, 404, 500])
                if response.status_code != 200:
                    return False
                    #raise Exception(_error_message(response.json()))
                return True
    else:
         url_params_all = {'node-id' : device_name} 
         url_template_all = _static_route_url_template
         response = odl_http_delete(url_template_all, url_params_all, 'application/json', expected_status_code=[200, 404, 500])
         return True
Esempio n. 15
0
def acl_delete(
    device_name,
    acl_name
):
    """ Delete the specified ACL from the specified device.
    
        No value is returned.
        An exception is raised if the ACL does not exist on the device.
        If the ACL is currently 'applied' then it is not deleted.
    """
    response = odl_http_delete(_url_named_acl, {'node-id' : device_name, 'access-id' : acl_name}, expected_status_code=[200, 500])
    if response.status_code != 200:
        raise Exception(_error_message(response.json()))
Esempio n. 16
0
def acl_delete(
    device_name,
    acl_name
):
    """ Delete the specified ACL from the specified device.
    
        No value is returned.
        An exception is raised if the ACL does not exist on the device.
        If the ACL is currently 'applied' then it is not deleted.
    """
    response = odl_http_delete(_url_named_acl, {'node-id' : device_name, 'access-id' : acl_name}, expected_status_code=[200, 500])
    if response.status_code != 200:
        raise Exception(_error_message(response.json()))
Esempio n. 17
0
def acl_delete(
    device_name,
    acl_name
):
    """ Delete the specified ACL from the specified device.
    
        No value is returned.
        An exception is raised if the ACL does not exist on the device.
        If the ACL is currently 'applied' then it is not deleted.
    """
    url_suffix = _url_named_acl % (quote_plus(device_name), quote_plus(acl_name))
    response = odl_http_delete(url_suffix, expected_status_code=[200, 500])
    if response.status_code != 200:
        raise Exception(_error_message(response.json()))
def dismount_device(
    device_name
):
    'Dismount a network device that has been mounted on the ODL server.'
    url_suffix = _url_template % quote_plus(device_name)
    odl_http_delete(url_suffix)
Esempio n. 19
0
def acl_unapply_packet_filter(device_name, interface_name, bound, acl_name):
    url_suffix = _url_unapply_template % (quote_plus(device_name),
                                          quote_plus(interface_name), bound)
    odl_http_delete(url_suffix, expected_status_code=200)
Esempio n. 20
0
def device_dismount_http(
    device_name
):
    'Remove one network device from the inventory of the Controller.'
    url_suffix = _url_connector % device_name
    return odl_http_delete(url_suffix, 'application/xml', expected_status_code=200)
Esempio n. 21
0
        
        if not flag:
            count = count + 1

        time.sleep(5)
    
    #read MD-SAL sjtest yang,get threshold value
    response = odl_http_get('config/sjtest:sjtest',accept='application/json', expected_status_code=200)
    print("the response is :"+response.text)
    threshold  = response.text.sjtest.threshold
    
    #if count > threshold, shutdown iosxrv-1 and iosxrv-5 ,start up another line 
    if count > threshold:
        url_params1 = {'prefix-length': 32, 'node-id': 'iosxrv-1', 'ip-address': '27.27.27.27'}
        url_template1 = "config/opendaylight-inventory:nodes/node/{node-id}/yang-ext:mount/Cisco-IOS-XR-ip-static-cfg:router-static/default-vrf/address-family/vrfipv4/vrf-unicast/vrf-prefixes/vrf-prefix/{ip-address}/{prefix-length}"
        response = odl_http_delete(url_template1, url_params1, 'application/json', expected_status_code=[200, 404, 500])
        
        url_params5 = {'prefix-length': 32, 'node-id': 'iosxrv-5', 'ip-address': '21.21.21.21'}
        url_template5 = "config/opendaylight-inventory:nodes/node/{node-id}/yang-ext:mount/Cisco-IOS-XR-ip-static-cfg:router-static/default-vrf/address-family/vrfipv4/vrf-unicast/vrf-prefixes/vrf-prefix/{ip-address}/{prefix-length}"
        response = odl_http_delete(url_template5, url_params5, 'application/json', expected_status_code=[200, 404, 500])
        
        ##shutdown
        device_name_new1 = 'iosxrv-1'
        request_content_new1 = {'Cisco-IOS-XR-ip-static-cfg:vrf-prefix': [{'prefix': '27.27.27.27', 'vrf-route': {'vrf-next-hops': {'next-hop-address': [{'next-hop-address': '58.0.0.22'}]}}, 'prefix-length': 32}]}
        response1 = odl_http_post(_static_route_url_template, {'node-id' : device_name_new1}, 'application/json', request_content_new1, expected_status_code=[204, 409])
        
        device_name_new2 = 'iosxrv-2'
        request_content_new2 = {'Cisco-IOS-XR-ip-static-cfg:vrf-prefix': [{'prefix': '27.27.27.27', 'vrf-route': {'vrf-next-hops': {'next-hop-address': [{'next-hop-address': '48.0.0.27'}]}}, 'prefix-length': 32}]}
        response1 = odl_http_post(_static_route_url_template, {'node-id' : device_name_new2}, 'application/json', request_content_new2, expected_status_code=[204, 409])
        
        device_name_new2_1 = 'iosxrv-2'