-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Microwave station ZTP workflow has been added #137
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
Microwave_station_provisioning/.meta_Microwave_station_provisioning.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<metadata> | ||
<map> | ||
<entry> | ||
<key>DATE_MODIFICATION</key> | ||
<value>1605082987078</value> | ||
</entry> | ||
<entry> | ||
<key>REPOSITORY</key> | ||
<value>Process</value> | ||
</entry> | ||
<entry> | ||
<key>DATE_CREATION</key> | ||
<value>1605082987071</value> | ||
</entry> | ||
<entry> | ||
<key>MODEL</key> | ||
<value>0</value> | ||
</entry> | ||
<entry> | ||
<key>TAG</key> | ||
</entry> | ||
<entry> | ||
<key>FILE_TYPE</key> | ||
<value>text</value> | ||
</entry> | ||
<entry> | ||
<key>MANUFACTURER</key> | ||
<value>0</value> | ||
</entry> | ||
<entry> | ||
<key>TYPE</key> | ||
<value>FILE</value> | ||
</entry> | ||
<entry> | ||
<key>COMMENT</key> | ||
</entry> | ||
</map> | ||
</metadata> |
31 changes: 31 additions & 0 deletions
31
...n_provisioning/.meta_Provision_microwave_station_Check_microwave_station_availablility.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<metadata> | ||
<map> | ||
<entry> | ||
<key>DATE_MODIFICATION</key> | ||
<value>1605082986461</value> | ||
</entry> | ||
<entry> | ||
<key>REPOSITORY</key> | ||
<value>Process</value> | ||
</entry> | ||
<entry> | ||
<key>DATE_CREATION</key> | ||
<value>1605082986457</value> | ||
</entry> | ||
<entry> | ||
<key>TAG</key> | ||
</entry> | ||
<entry> | ||
<key>FILE_TYPE</key> | ||
<value>text</value> | ||
</entry> | ||
<entry> | ||
<key>TYPE</key> | ||
<value>UPLOAD</value> | ||
</entry> | ||
<entry> | ||
<key>COMMENT</key> | ||
</entry> | ||
</map> | ||
</metadata> |
31 changes: 31 additions & 0 deletions
31
...ave_station_provisioning/.meta_Provision_microwave_station_Configure_microwave_station.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<metadata> | ||
<map> | ||
<entry> | ||
<key>DATE_MODIFICATION</key> | ||
<value>1605041591834</value> | ||
</entry> | ||
<entry> | ||
<key>REPOSITORY</key> | ||
<value>Process</value> | ||
</entry> | ||
<entry> | ||
<key>DATE_CREATION</key> | ||
<value>1605041591829</value> | ||
</entry> | ||
<entry> | ||
<key>TAG</key> | ||
</entry> | ||
<entry> | ||
<key>FILE_TYPE</key> | ||
<value>text</value> | ||
</entry> | ||
<entry> | ||
<key>TYPE</key> | ||
<value>UPLOAD</value> | ||
</entry> | ||
<entry> | ||
<key>COMMENT</key> | ||
</entry> | ||
</map> | ||
</metadata> |
31 changes: 31 additions & 0 deletions
31
...tion_provisioning/.meta_Provision_microwave_station_Create_and_activate_managed_entity.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<metadata> | ||
<map> | ||
<entry> | ||
<key>DATE_MODIFICATION</key> | ||
<value>1605041499896</value> | ||
</entry> | ||
<entry> | ||
<key>REPOSITORY</key> | ||
<value>Process</value> | ||
</entry> | ||
<entry> | ||
<key>DATE_CREATION</key> | ||
<value>1605041499890</value> | ||
</entry> | ||
<entry> | ||
<key>TAG</key> | ||
</entry> | ||
<entry> | ||
<key>FILE_TYPE</key> | ||
<value>text</value> | ||
</entry> | ||
<entry> | ||
<key>TYPE</key> | ||
<value>UPLOAD</value> | ||
</entry> | ||
<entry> | ||
<key>COMMENT</key> | ||
</entry> | ||
</map> | ||
</metadata> |
31 changes: 31 additions & 0 deletions
31
Microwave_station_provisioning/.meta_Provision_microwave_station_Verify_configuration.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<metadata> | ||
<map> | ||
<entry> | ||
<key>DATE_MODIFICATION</key> | ||
<value>1605041677558</value> | ||
</entry> | ||
<entry> | ||
<key>REPOSITORY</key> | ||
<value>Process</value> | ||
</entry> | ||
<entry> | ||
<key>DATE_CREATION</key> | ||
<value>1605041677553</value> | ||
</entry> | ||
<entry> | ||
<key>TAG</key> | ||
</entry> | ||
<entry> | ||
<key>FILE_TYPE</key> | ||
<value>text</value> | ||
</entry> | ||
<entry> | ||
<key>TYPE</key> | ||
<value>UPLOAD</value> | ||
</entry> | ||
<entry> | ||
<key>COMMENT</key> | ||
</entry> | ||
</map> | ||
</metadata> |
67 changes: 67 additions & 0 deletions
67
Microwave_station_provisioning/Microwave_station_provisioning.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<ObjectDefinition> | ||
<variables frozen="0"> | ||
<variable displayName="Hostname" name="params.hostname" startIncrement="0" type="String" mandatoryArray="false" visible="true" description="" groupSeparator="" groupDisplayName="" displayOrder="1" increment="0" refServiceURI="" keepOnImport="false" editable="false" onlyDetailView="false" localVarNameMatch="" remoteVarNameMatch="" arrayCanAdd="true" arrayCanRemove="true" arrayCanMove="true" arrayCanEdit="true" displayNameHeader="" fullDisplayName="" default="TEST_VR_STATION" isMandatory="false" isUserLocked="false" isGrouped="false" isSearchable="false" isUniqueGlobal="false"/> | ||
<variable displayName="Microwave station IP address" name="params.ip_address" startIncrement="0" type="String" mandatoryArray="false" visible="true" description="" groupSeparator="" groupDisplayName="" displayOrder="0" increment="0" refServiceURI="" keepOnImport="false" editable="false" onlyDetailView="false" localVarNameMatch="" remoteVarNameMatch="" arrayCanAdd="true" arrayCanRemove="true" arrayCanMove="true" arrayCanEdit="true" displayNameHeader="" fullDisplayName="" default="192.168.1.11" isMandatory="false" isUserLocked="false" isGrouped="false" isSearchable="false" isUniqueGlobal="false"/> | ||
<variable displayName="Trunk port" name="params.trunk_port" startIncrement="0" type="String" mandatoryArray="false" visible="true" description="" groupSeparator="" groupDisplayName="" displayOrder="4" increment="0" refServiceURI="" keepOnImport="false" editable="false" onlyDetailView="false" localVarNameMatch="" remoteVarNameMatch="" arrayCanAdd="true" arrayCanRemove="true" arrayCanMove="true" arrayCanEdit="true" displayNameHeader="" fullDisplayName="" default="0/4" isMandatory="false" isUserLocked="false" isGrouped="false" isSearchable="false" isUniqueGlobal="false"> | ||
<values> | ||
<values displayValue="0/1">0/1</values> | ||
<values displayValue="0/2">0/2</values> | ||
<values displayValue="0/3">0/3</values> | ||
<values displayValue="0/4">0/4</values> | ||
<values displayValue="0/5">0/5</values> | ||
<values displayValue="0/6">0/6</values> | ||
</values> | ||
</variable> | ||
<variable displayName="VLAN ID" name="params.vlan_list.0.id" startIncrement="0" type="String" mandatoryArray="false" visible="true" description="" groupSeparator="" groupDisplayName="" displayOrder="2" increment="0" refServiceURI="" keepOnImport="false" editable="false" onlyDetailView="false" localVarNameMatch="" remoteVarNameMatch="" arrayCanAdd="true" arrayCanRemove="true" arrayCanMove="true" arrayCanEdit="true" displayNameHeader="" fullDisplayName="" default="1212" isMandatory="false" isUserLocked="false" isGrouped="false" isSearchable="false" isUniqueGlobal="false"/> | ||
<variable displayName="VLAN Name" name="params.vlan_list.0.name" startIncrement="0" type="String" mandatoryArray="false" visible="true" description="" groupSeparator="" groupDisplayName="" displayOrder="3" increment="0" refServiceURI="" keepOnImport="false" editable="false" onlyDetailView="false" localVarNameMatch="" remoteVarNameMatch="" arrayCanAdd="true" arrayCanRemove="true" arrayCanMove="true" arrayCanEdit="true" displayNameHeader="" fullDisplayName="" default="TEST_VLAN" isMandatory="false" isUserLocked="false" isGrouped="false" isSearchable="false" isUniqueGlobal="false"/> | ||
<variable displayName="Use IPAM integration to get VLANs" name="params.use_ipam" startIncrement="0" type="String" mandatoryArray="false" visible="true" description="" groupSeparator="" groupDisplayName="" displayOrder="7" increment="0" refServiceURI="" keepOnImport="false" editable="false" onlyDetailView="false" localVarNameMatch="" remoteVarNameMatch="" arrayCanAdd="true" arrayCanRemove="true" arrayCanMove="true" arrayCanEdit="true" displayNameHeader="" fullDisplayName="" isMandatory="false" isUserLocked="false" isGrouped="false" isSearchable="false" isUniqueGlobal="false"> | ||
<values> | ||
<values displayValue="Yes">yes</values> | ||
<values displayValue="No">no</values> | ||
</values> | ||
</variable> | ||
<variable displayName="IPAM system" name="params.ipam_device" startIncrement="0" type="Device" mandatoryArray="false" visible="true" description="" groupSeparator="" groupDisplayName="" displayOrder="5" increment="0" refServiceURI="" keepOnImport="false" editable="false" onlyDetailView="false" localVarNameMatch="" remoteVarNameMatch="" arrayCanAdd="true" arrayCanRemove="true" arrayCanMove="true" arrayCanEdit="true" displayNameHeader="" fullDisplayName="" isMandatory="false" isUserLocked="false" isGrouped="false" isSearchable="false" isUniqueGlobal="false"/> | ||
<variable displayName="Site where the station is located" name="params.site" startIncrement="0" type="OBMFRef" mandatoryArray="false" visible="true" description="" groupSeparator="" groupDisplayName="" displayOrder="6" increment="0" refServiceURI="" refDeviceIdVar="params.ipam_device" keepOnImport="false" editable="false" onlyDetailView="false" localVarNameMatch="" remoteVarNameMatch="" arrayCanAdd="true" arrayCanRemove="true" arrayCanMove="true" arrayCanEdit="true" displayNameHeader="" fullDisplayName="" default="NULL" isMandatory="false" isUserLocked="false" isGrouped="false" isSearchable="false" isUniqueGlobal="false"> | ||
<classes> | ||
<class>CommandDefinition/NETBOX/sites.xml</class> | ||
</classes> | ||
</variable> | ||
</variables> | ||
<example/> | ||
<process name="Process/Microwave_station_provisioning/Provision_microwave_station"> | ||
<displayName>Provision microwave station</displayName> | ||
<type>CREATE</type> | ||
<visibility>5</visibility> | ||
<task name="Provision_microwave_station_Check_microwave_station_availablility.py"> | ||
<processPath>/opt/fmc_repository/Process/Microwave_station_provisioning</processPath> | ||
<displayName>Check microwave station availablility</displayName> | ||
</task> | ||
<task name="Provision_microwave_station_Create_and_activate_managed_entity.py"> | ||
<processPath>/opt/fmc_repository/Process/Microwave_station_provisioning</processPath> | ||
<displayName>Create and activate managed entity</displayName> | ||
</task> | ||
<task name="Provision_microwave_station_Configure_microwave_station.py"> | ||
<processPath>/opt/fmc_repository/Process/Microwave_station_provisioning</processPath> | ||
<displayName>Configure microwave station</displayName> | ||
</task> | ||
<task name="Provision_microwave_station_Verify_configuration.py"> | ||
<processPath>/opt/fmc_repository/Process/Microwave_station_provisioning</processPath> | ||
<displayName>Verify configuration</displayName> | ||
</task> | ||
</process> | ||
<process name="Process/Microwave_station_provisioning/DELETE"> | ||
<displayName>DELETE</displayName> | ||
<type>DELETE</type> | ||
<visibility>5</visibility> | ||
</process> | ||
<information> | ||
<icon/> | ||
<description>The workflow provides a zero touch provisioning demo for NEC iPasolink microwave stations</description> | ||
<displayField>service_id</displayField> | ||
<serviceTaskType>python</serviceTaskType> | ||
<order>10000</order> | ||
<visibility>5</visibility> | ||
<name>Microwave station provisioning</name> | ||
<group/> | ||
</information> | ||
</ObjectDefinition> |
102 changes: 102 additions & 0 deletions
102
...station_provisioning/Provision_microwave_station_Check_microwave_station_availablility.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
from msa_sdk.variables import Variables | ||
from msa_sdk.msa_api import MSA_API | ||
from msa_sdk.order import Order | ||
from msa_sdk.device import Device | ||
from msa_sdk.orchestration import Orchestration | ||
from datetime import datetime | ||
from msa_sdk import constants | ||
from msa_sdk import lookup | ||
from msa_sdk import util | ||
import ipaddress | ||
import time | ||
import re | ||
import json | ||
import sys | ||
import os | ||
|
||
""" | ||
The proposals of the task are: | ||
- Monitor IP address availability by simple ICMP echo | ||
- Finish sucessfully in case if the IP address is available | ||
""" | ||
|
||
|
||
#New Variables object | ||
TaskVariables = Variables() | ||
|
||
#Add new variables | ||
TaskVariables.add('ip_address', var_type = 'String') | ||
TaskVariables.add('hostname', var_type = 'String') | ||
TaskVariables.add('vlan_list.0.id', var_type = 'String') | ||
TaskVariables.add('vlan_list.0.name', var_type = 'String') | ||
TaskVariables.add('trunk_port', var_type = 'String') | ||
TaskVariables.add('ipam_device', var_type = 'Device') | ||
TaskVariables.add('site', var_type = 'String') | ||
TaskVariables.add('use_ipam', var_type = 'String') | ||
#Add vars to context | ||
context = Variables.task_call(TaskVariables) | ||
|
||
#Import microservice alias list | ||
with open('/opt/fmc_repository/Process/Microwave_station_provisioning/microservices_list.json', 'r') as alias_file: | ||
context['ms_aliases'] = json.load(alias_file) | ||
|
||
ms_ipam_vlan = context['ms_aliases']['IPAM VLAN management'] | ||
|
||
#Variables to finish the task properlly | ||
fail_comment = str() | ||
success_comment = str() | ||
fail_string = f'{{"wo_status": "FAIL", "wo_comment": "{fail_comment}"}}' | ||
success_string = f'{{"wo_status": "ENDED", "wo_comment": "{success_comment}"}}' | ||
|
||
#Create Orchestration object to update GUI dynamically | ||
Orchestration = Orchestration(context['UBIQUBEID']) | ||
async_update_list = (context['PROCESSINSTANCEID'], context['TASKID'], context['EXECNUMBER']) | ||
|
||
|
||
#Create VLAN list if IPAM is used | ||
if context['use_ipam'] == 'yes': | ||
Orchestration.update_asynchronous_task_details(*async_update_list, 'IPAM integration is used. Retrive VLAN info from IPAM... ') | ||
context['ipam_device'] = re.match('^\D+?(\d+?)$', context['ipam_device']).group(1) | ||
|
||
#Retrive information about VLANs | ||
IpamOrderObject = Order(context['ipam_device']) | ||
IpamOrderObject.command_synchronize(300) | ||
|
||
objects_list = IpamOrderObject.command_objects_instances(ms_ipam_vlan) | ||
vlan_string = str() | ||
counter = 0 | ||
context['vlan_list'] = dict() | ||
for vlan_name in objects_list: | ||
vlan_object = IpamOrderObject.command_objects_instances_by_id(ms_ipam_vlan, vlan_name)[ms_ipam_vlan][vlan_name] | ||
if 'site' in vlan_object: | ||
if vlan_object['site'] == context['site']: | ||
context['vlan_list'][counter] = {'id': vlan_object['vid'], | ||
'name': vlan_object['object_id'], | ||
"__index__": counter | ||
} | ||
vlan_string += '{} '.format(vlan_object['object_id']) | ||
counter += 1 | ||
|
||
Orchestration.update_asynchronous_task_details(*async_update_list, 'IPAM integration is used. Retrive VLAN info from IPAM... OK. VLANs: {}'.format(vlan_string)) | ||
time.sleep(3) | ||
|
||
#Flag to know when microwave station becoms available | ||
is_available = False | ||
|
||
Orchestration.update_asynchronous_task_details(*async_update_list, 'Check microwave station availability. IP is {}... '.format(context['ip_address'])) | ||
#String to check availability | ||
ping_string = "ping -c 1 -W 1 {} | grep -oP '(0|100)%\s+?packet\s+?loss'".format(context['ip_address']) | ||
|
||
while not is_available: | ||
if os.popen(ping_string).read().startswith('0%'): | ||
is_available = True | ||
else: | ||
time.sleep(10) | ||
|
||
Orchestration.update_asynchronous_task_details(*async_update_list, 'Check microwave station availability. IP is {}... OK'.format(context['ip_address'])) | ||
|
||
|
||
#Finish the task correctlly | ||
result = MSA_API.process_content('ENDED', 'Station with IP {} is available now.'.format(context['ip_address']), context, True) | ||
print(result) | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo in availablility