From 1057333085ccc40842c57728ba1b210d4065e2b6 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 12 Feb 2021 15:46:10 +0000 Subject: [PATCH 1/2] details in PRESALES-1401 --- ...commission_CE_Remove_CE_and_update_IPAM.py | 8 ++++-- ...eta_General_network_service_automation.xml | 8 ++++-- ...New_CE_Provision_and_activate_CE_device.py | 8 ++++-- ...New_L3VPN_Configure_CE_-_PE_connections.py | 8 ++++-- .../.meta_Remove_L3VPN_Clean_up_IPAM.py | 8 ++++-- ...commission_CE_Remove_CE_and_update_IPAM.py | 3 +-- .../General_network_service_automation.xml | 11 ++++++-- ...New_CE_Provision_and_activate_CE_device.py | 27 +++++++------------ ...New_L3VPN_Configure_CE_-_PE_connections.py | 2 +- .../Remove_L3VPN_Clean_up_IPAM.py | 1 - 10 files changed, 51 insertions(+), 33 deletions(-) diff --git a/General_Network_Service_Automation/.meta_Decommission_CE_Remove_CE_and_update_IPAM.py b/General_Network_Service_Automation/.meta_Decommission_CE_Remove_CE_and_update_IPAM.py index 57138bb92..ea1e3da5a 100755 --- a/General_Network_Service_Automation/.meta_Decommission_CE_Remove_CE_and_update_IPAM.py +++ b/General_Network_Service_Automation/.meta_Decommission_CE_Remove_CE_and_update_IPAM.py @@ -1,9 +1,13 @@ + + DISPLAYNAME + Decommission_CE_Remove_CE_and_update_IPAM.py + DATE_MODIFICATION - 1606077676711 + 1613065059594 REPOSITORY @@ -11,7 +15,7 @@ DATE_CREATION - 1606077676704 + 1613065059589 TAG diff --git a/General_Network_Service_Automation/.meta_General_network_service_automation.xml b/General_Network_Service_Automation/.meta_General_network_service_automation.xml index c4119a531..63f41eb0c 100755 --- a/General_Network_Service_Automation/.meta_General_network_service_automation.xml +++ b/General_Network_Service_Automation/.meta_General_network_service_automation.xml @@ -1,9 +1,13 @@ + + DISPLAYNAME + General_network_service_automation.xml + DATE_MODIFICATION - 1606077677406 + 1613143839654 REPOSITORY @@ -11,7 +15,7 @@ DATE_CREATION - 1606077677403 + 1613143839647 MODEL diff --git a/General_Network_Service_Automation/.meta_New_CE_Provision_and_activate_CE_device.py b/General_Network_Service_Automation/.meta_New_CE_Provision_and_activate_CE_device.py index b6753ded0..312089bfd 100755 --- a/General_Network_Service_Automation/.meta_New_CE_Provision_and_activate_CE_device.py +++ b/General_Network_Service_Automation/.meta_New_CE_Provision_and_activate_CE_device.py @@ -1,9 +1,13 @@ + + DISPLAYNAME + New_CE_Provision_and_activate_CE_device.py + DATE_MODIFICATION - 1602160641226 + 1613143838873 REPOSITORY @@ -11,7 +15,7 @@ DATE_CREATION - 1602160641214 + 1613143838869 TAG diff --git a/General_Network_Service_Automation/.meta_New_L3VPN_Configure_CE_-_PE_connections.py b/General_Network_Service_Automation/.meta_New_L3VPN_Configure_CE_-_PE_connections.py index 2970fe568..17eb1e88b 100755 --- a/General_Network_Service_Automation/.meta_New_L3VPN_Configure_CE_-_PE_connections.py +++ b/General_Network_Service_Automation/.meta_New_L3VPN_Configure_CE_-_PE_connections.py @@ -1,9 +1,13 @@ + + DISPLAYNAME + New_L3VPN_Configure_CE_-_PE_connections.py + DATE_MODIFICATION - 1601980973728 + 1613142201550 REPOSITORY @@ -11,7 +15,7 @@ DATE_CREATION - 1601980973719 + 1613142201545 TAG diff --git a/General_Network_Service_Automation/.meta_Remove_L3VPN_Clean_up_IPAM.py b/General_Network_Service_Automation/.meta_Remove_L3VPN_Clean_up_IPAM.py index 478c28ff4..463f7755a 100755 --- a/General_Network_Service_Automation/.meta_Remove_L3VPN_Clean_up_IPAM.py +++ b/General_Network_Service_Automation/.meta_Remove_L3VPN_Clean_up_IPAM.py @@ -1,9 +1,13 @@ + + DISPLAYNAME + Remove_L3VPN_Clean_up_IPAM.py + DATE_MODIFICATION - 1606074391321 + 1613065045994 REPOSITORY @@ -11,7 +15,7 @@ DATE_CREATION - 1606074391314 + 1613065045989 TAG diff --git a/General_Network_Service_Automation/Decommission_CE_Remove_CE_and_update_IPAM.py b/General_Network_Service_Automation/Decommission_CE_Remove_CE_and_update_IPAM.py index d3fc5073a..8753eeb8e 100755 --- a/General_Network_Service_Automation/Decommission_CE_Remove_CE_and_update_IPAM.py +++ b/General_Network_Service_Automation/Decommission_CE_Remove_CE_and_update_IPAM.py @@ -73,7 +73,7 @@ #Find CE device name Orchestration.update_asynchronous_task_details(*async_update_list, 'Retrieve information about CE device on the site... ') -while ce_device_name is None or counter < len(objects_list): +while ce_device_name is None and counter < len(objects_list): util.log_to_process_file(process_id, 'DEBUG: {}'.format(IpamOrderObject.command_objects_instances_by_id(ms_ipam_device, objects_list[counter]))) device_object = IpamOrderObject.command_objects_instances_by_id(ms_ipam_device, objects_list[counter])[ms_ipam_device][objects_list[counter]] @@ -119,7 +119,6 @@ Orchestration.update_asynchronous_task_details(*async_update_list, 'Update IPAM... OK') time.sleep(3) - success_comment = 'CE device has been moved to {} on site {}'.format(context['status'], context['site']) del context['status'] del context['site'] diff --git a/General_Network_Service_Automation/General_network_service_automation.xml b/General_Network_Service_Automation/General_network_service_automation.xml index 775e66b8f..56657fee1 100755 --- a/General_Network_Service_Automation/General_network_service_automation.xml +++ b/General_Network_Service_Automation/General_network_service_automation.xml @@ -1,7 +1,7 @@ - + @@ -23,6 +23,7 @@ Start to work with customer CREATE 0 + /opt/fmc_repository/Process/General_Network_Service_Automation Define variables @@ -36,11 +37,13 @@ Delete DELETE 5 + New CE UPDATE 0 + /opt/fmc_repository/Process/General_Network_Service_Automation Create CE device @@ -54,6 +57,7 @@ New L3VPN UPDATE 5 + /opt/fmc_repository/Process/General_Network_Service_Automation Prepare IP address schema @@ -71,11 +75,13 @@ New L2VPN UPDATE 5 + Remove L3VPN UPDATE 5 + /opt/fmc_repository/Process/General_Network_Service_Automation Gather information from IPAM @@ -93,6 +99,7 @@ Decommission CE UPDATE 5 + /opt/fmc_repository/Process/General_Network_Service_Automation Remove CE and update IPAM @@ -104,7 +111,7 @@ service_id python 10000 - 0 + 5 General network service automation diff --git a/General_Network_Service_Automation/New_CE_Provision_and_activate_CE_device.py b/General_Network_Service_Automation/New_CE_Provision_and_activate_CE_device.py index 415f595bf..a2169fdf6 100755 --- a/General_Network_Service_Automation/New_CE_Provision_and_activate_CE_device.py +++ b/General_Network_Service_Automation/New_CE_Provision_and_activate_CE_device.py @@ -55,7 +55,7 @@ #Create CE device object CeDeviceObject = Device(device_id = ce_device_id, device_external = ce_device_external_reference) -pretty_formatted_bar = list('------------------------') +pretty_formatted_bar = list(10*'-') Orchestration.update_asynchronous_task_details(*async_update_list, 'Provisioning of CE device... [{}]'.format(''.join(pretty_formatted_bar))) #If the device mgmt interface is REST-based, add required configuration variables @@ -63,6 +63,12 @@ for variable, value in ce_local_context['msa_specific']['rest_headers'].items(): CeDeviceObject.create_configuration_variable(name = variable, value = value) +#Attach configuration profile +Orchestration.update_asynchronous_task_details(*async_update_list, 'Attaching configuration deployment settings profile... ') +CeDeviceObject.profile_attach(ce_local_context['msa_specific']['deployment_settings_ref']) +Orchestration.update_asynchronous_task_details(*async_update_list, 'Attaching configuration deployment settings profile... OK') +time.sleep(3) + #Provision device CeDeviceObject.initial_provisioning() @@ -70,34 +76,21 @@ while CeDeviceObject.provision_status()['status'] != 'OK': pretty_formatted_bar.insert(0,'*') Orchestration.update_asynchronous_task_details(*async_update_list, 'Provisioning of CE device... [{}]'.format(''.join(pretty_formatted_bar))) - time.sleep(10) + time.sleep(5) -for counter in range(0, 24): +for counter in range(0, 10): pretty_formatted_bar.insert(0,'*') pretty_formatted_bar.pop() Orchestration.update_asynchronous_task_details(*async_update_list, 'Provisioning of CE device... [{}]'.format(''.join(pretty_formatted_bar))) - time.sleep(5) + time.sleep(3) Orchestration.update_asynchronous_task_details(*async_update_list, 'Provisioning of CE device... [{}] OK'.format(''.join(pretty_formatted_bar))) time.sleep(3) - -#Attach configuration profile -Orchestration.update_asynchronous_task_details(*async_update_list, 'Attaching configuration deployment settings profile... ') -CeDeviceObject.profile_attach(ce_local_context['msa_specific']['deployment_settings_ref']) - - - -#Create CE device order object -CeOrderObject = Order(ce_device_id) -response = CeOrderObject.command_synchronize(300) - device_object = IpamOrderObject.command_objects_instances_by_id(ms_ipam_device, ce_device_name)[ms_ipam_device][ce_device_name.replace('.', '_')] -Orchestration.update_asynchronous_task_details(*async_update_list, 'Attaching configuration deployment settings profile... OK') - Orchestration.update_asynchronous_task_details(*async_update_list, 'Marking device {} as "ACTIVE" in IPAM system...'.format(ce_device_name)) #Mark the device as Active in IPAM ms_dict = {ms_ipam_device: diff --git a/General_Network_Service_Automation/New_L3VPN_Configure_CE_-_PE_connections.py b/General_Network_Service_Automation/New_L3VPN_Configure_CE_-_PE_connections.py index 5b4932eab..cbf996ec8 100755 --- a/General_Network_Service_Automation/New_L3VPN_Configure_CE_-_PE_connections.py +++ b/General_Network_Service_Automation/New_L3VPN_Configure_CE_-_PE_connections.py @@ -181,7 +181,7 @@ Orchestration.update_asynchronous_task_details(*async_update_list, 'Configuring PE device... BGP peer for {}... OK'.format(ce_device_name)) pe_order_list[-1].command_synchronize(300) -pretty_formatted_bar = list('------------') +pretty_formatted_bar = list(12*'-') for counter in range(0, 12): pretty_formatted_bar.insert(0,'*') pretty_formatted_bar.pop() diff --git a/General_Network_Service_Automation/Remove_L3VPN_Clean_up_IPAM.py b/General_Network_Service_Automation/Remove_L3VPN_Clean_up_IPAM.py index 784eb238f..c82357fc1 100755 --- a/General_Network_Service_Automation/Remove_L3VPN_Clean_up_IPAM.py +++ b/General_Network_Service_Automation/Remove_L3VPN_Clean_up_IPAM.py @@ -113,7 +113,6 @@ IpamOrderObject.command_synchronize(300) - #Clean up context del context['ce_connections'] del context['ce_device_details'] From 5a440bcb1dfdc768d71e351f77c5cf9e8b631d53 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 12 Feb 2021 16:46:34 +0000 Subject: [PATCH 2/2] Topology updated --- Topology/.meta_Topology.xml | 4 +-- Topology/Common/Topology_common.php | 35 +++++++++++---------------- Topology/Common/Topology_populate.php | 14 +++++------ Topology/Topology.xml | 5 ++-- Topology/Topology_Types/SNMP.php | 8 +++--- Topology/Topology_Types/VLAN.php | 10 ++++---- Topology/Topology_Types/VRF.php | 9 +++---- 7 files changed, 36 insertions(+), 49 deletions(-) diff --git a/Topology/.meta_Topology.xml b/Topology/.meta_Topology.xml index 14d0759d1..446f782f0 100755 --- a/Topology/.meta_Topology.xml +++ b/Topology/.meta_Topology.xml @@ -3,7 +3,7 @@ DATE_MODIFICATION - 1606224624688 + 1602162156567 REPOSITORY @@ -11,7 +11,7 @@ DATE_CREATION - 1606224624662 + 1602162156561 MODEL diff --git a/Topology/Common/Topology_common.php b/Topology/Common/Topology_common.php index 22bbda6f1..e4729f11d 100755 --- a/Topology/Common/Topology_common.php +++ b/Topology/Common/Topology_common.php @@ -102,14 +102,8 @@ function topology_update_service_view($ipam_device_id) { logToFile("*** topology_update_view"); - if (!isset($context ["Nodes"])) { - $context ['Nodes'] = array (); - } - - if (!isset($context ["Nodes_MAJ"])) { - $context ['Nodes_MAJ'] = array (); - } - + $context ['Nodes'] = array (); + $context ['Nodes_MAJ'] = array (); $response = json_decode(import_objects($ipam_device_id, array('vrf')), True); $object_ids_array = $response['wo_newparams']['vrf']; @@ -199,10 +193,17 @@ function topology_update_view() { function processDevice($device_id, $name, $device_nature, $status) { logToFile("*** processDevice <$name> ID: $device_id STATUS: $status"); try { - if($status == "OK") { - calculateDeviceTopology($device_id, $name, $device_nature, $status); + //$status = getStatus($device_id); + if($status == "UP") { + calculateDeviceTopology($device_id, $name, $device_nature); } else { - createTopology($device_id, $name, $device_nature, "router", "", $status); + if($status == "UNREACHABLE") { + createTopology($device_id, $name, $device_nature, "router", "style/topology/img/router_ERROR.svg"); + } else if($status == "NEVERREACHED") { + createTopology($device_id, $name, $device_nature, "router", "style/topology/img/router_NEVERREACHED.svg"); + } else if($status == "CRITICAL") { + createTopology($device_id, $name, $device_nature, "router", "style/topology/img/router_CRITICAL.svg"); + } } } catch (Exception $e) { logTofile(debug_dump($e, "************** processDevice ERROR **************")); @@ -214,19 +215,11 @@ function processDevice($device_id, $name, $device_nature, $status) { function getStatus($device_id) { $info = json_decode(_device_get_status($device_id), true); $status = $info ["wo_newparams"]; - logToFile("*** getStatus <$device_id> => $status"); - + if (empty($status) || $status == "") { return "Managed Entity with id " . $device_id . " was not found"; } else { - if ($status == "UP") { - return "OK"; - } else if ($status == "UNREACHABLE") { - return "ERROR"; - } else if ($status == "CRITICAL") { - return "CRITICAL"; - } - return "NEVERREACHED"; + return $status; } } diff --git a/Topology/Common/Topology_populate.php b/Topology/Common/Topology_populate.php index d01e94263..4d1fc03f6 100755 --- a/Topology/Common/Topology_populate.php +++ b/Topology/Common/Topology_populate.php @@ -15,18 +15,17 @@ function _topology_exist_object_this_instance($nodeId) { * creates a new topology element for a managed entity * return: the node index in the array $context['Nodes'] */ -function createTopology($nodeId, $name, $device_nature, $subtype, $image, $status) { +function createTopology($nodeId, $name, $device_nature, $subtype, $image) { global $context; - logTofile("*** createTopology nodeId: ".$nodeId. " name " .$name." subtype ". $subtype." status ".$status." \n"); - + $place = _topology_exist_object_this_instance($nodeId); if ($place == -1) { $context['Nodes'][] = array( - "primary_key" => (string)$nodeId, + "primary_key" => $nodeId, "device_nature" => $device_nature, "name" => $name, - "object_id" => (string)$nodeId, + "object_id" => $nodeId, "x" => "", "y" => "", "description" => "", @@ -34,8 +33,7 @@ function createTopology($nodeId, $name, $device_nature, $subtype, $image, $statu "image" => $image, "color" => "#acd7e5", "hidden" => "false", - "cluster_id" => "", - "status" => $status + "cluster_id" => "" ); $place = _topology_exist_object_this_instance($nodeId); @@ -43,13 +41,13 @@ function createTopology($nodeId, $name, $device_nature, $subtype, $image, $statu unset($context['Nodes'][$place]["link"]); $context['Nodes'][$place]["name"] = $name; $context['Nodes'][$place]["image"] = $image; - $context['Nodes'][$place]["status"] = $status; } $context['Nodes_MAJ'][] = array( "object_id" => $nodeId, "primary_key" => $nodeId ); + logTofile("*** createTopology nodeId: ".$nodeId. " name " .$name." subtype ". $subtype." place ". $place."\n"); //logTofile(debug_dump($context, "*** createTopology context \n")); return $place; diff --git a/Topology/Topology.xml b/Topology/Topology.xml index 075e2a55f..864942694 100755 --- a/Topology/Topology.xml +++ b/Topology/Topology.xml @@ -10,17 +10,16 @@ - - + + - diff --git a/Topology/Topology_Types/SNMP.php b/Topology/Topology_Types/SNMP.php index abebd12e3..7f906ecc9 100755 --- a/Topology/Topology_Types/SNMP.php +++ b/Topology/Topology_Types/SNMP.php @@ -3,12 +3,10 @@ require_once '/opt/fmc_repository/Process/Topology/Common/Topology_common.php'; require_once '/opt/fmc_repository/Process/Reference/Common/Library/topology_rest.php'; -function calculateDeviceTopology($deviceId, $name, $device_nature, $status) { +function calculateDeviceTopology($deviceId, $name, $device_nature) { global $context; - - logTofile("*** calculateDeviceTopology deviceId: $deviceId name: $name status: $status \n"); - - $nodePlace = createTopology($deviceId, $name, $device_nature, "router", "", $status); + + $nodePlace = createTopology($deviceId, $name, $device_nature, "router", "style/topology/img/router_OK.svg"); $error = readInformationsFromDevice($deviceId, $community, $address); if ($error == "") { diff --git a/Topology/Topology_Types/VLAN.php b/Topology/Topology_Types/VLAN.php index 1d699d151..84bc29897 100755 --- a/Topology/Topology_Types/VLAN.php +++ b/Topology/Topology_Types/VLAN.php @@ -3,12 +3,12 @@ require_once '/opt/fmc_repository/Process/Topology/Common/Topology_common.php'; require_once '/opt/fmc_repository/Process/Reference/Common/Library/topology_rest.php'; -function calculateDeviceTopology($deviceId, $name, $device_nature, $status) { +function calculateDeviceTopology($deviceId, $name, $device_nature) { global $context; - - logTofile("*** calculateDeviceTopology deviceId: $deviceId name: $name status: $status \n"); - $nodePlace = createTopology($deviceId, $name, $device_nature, "router", "", $status); + logTofile("*** calculateDeviceTopology deviceId: ".$deviceId." name: ".$name."\n"); + + $nodePlace = createTopology($deviceId, $name, $device_nature, "router", "style/topology/img/router_OK.svg"); $instances_objname = "vlan"; $array = array ( @@ -31,7 +31,7 @@ function calculateDeviceTopology($deviceId, $name, $device_nature, $status) { } else { createTopologyNetwork($vlan_id, $vlan_id, "network", ""); } - $context ['Nodes'] [$nodePlace] ["links"] [] = $vlan_id; + $context ['Nodes'] [$nodePlace] ["link"] [] ["id"] = $vlan_id; } logTofile(debug_dump($context ['Nodes'], "*** calculateDeviceTopology Nodes ***\n")); diff --git a/Topology/Topology_Types/VRF.php b/Topology/Topology_Types/VRF.php index 7b5bf286d..2b6fb9cda 100755 --- a/Topology/Topology_Types/VRF.php +++ b/Topology/Topology_Types/VRF.php @@ -4,13 +4,12 @@ require_once '/opt/fmc_repository/Process/Reference/Common/Library/topology_rest.php'; require_once '/opt/fmc_repository/Process/Reference/Common/common.php'; -function calculateDeviceTopology($deviceId, $name, $device_nature, $status) { +function calculateDeviceTopology($deviceId, $name, $device_nature) { global $context; - logTofile("*** calculateDeviceTopology deviceId: $deviceId name: $name status: $status \n"); - - $customer_ref = get_customer_ref(); - $nodePlace = createTopology($deviceId, $name, $device_nature, "router", "", $status); + logTofile("*** calculateDeviceTopology deviceId: ".$deviceId." name: ".$name."\n"); + $customer_ref = get_customer_ref(); + $nodePlace = createTopology($deviceId, $name, $device_nature, "router", "style/topology/img/router_OK.svg"); if (strpos($name, 'PE') !== false) { $instances_objname = "vrf"; $array = array (