meraki / automation-scripts

MIT License
391 stars 198 forks source link

migrate_cat3k.py question #44

Open Lanlord7 opened 1 year ago

Lanlord7 commented 1 year ago

Is there a forum for this script? I'd love to review some tips and tricks to get it to work. It seems to kick off but I only see a connection in the change log for new networks and not for this existing one.

C:\data\OneDrive - DYOPATHCORP\Mailing List\Cisco Notes\Meraki Notes\Scripting>C:\Users\"Jeff G"\AppData\Local\Programs\Python\Python310\python migrate_cat3k.py -k -o "Transport Service" -i migrate_cat3k_JTG2.txt Reading init config file... Fetching dashboard organization... Reading configuration from source devices... Parsing source configration... Creating networks... Claiming devices... Configuring devices... Committing action batch: [{'resource': '/devices/Q2NW-784P-XXXX/switchPorts/36', 'operation': 'update', 'body': {'vlan': '19'}}, {'resource': '/devices/Q2NW-784P-XXXX/switchPorts/37', 'operation': 'update', 'body': {'vlan': '23'}}, {'resource': '/devices/Q2NW-784P-XXXX/switchPorts/38', 'operation': 'update', 'body': {'type': 'trunk', 'tags': ''}}, {'resource': '/devices/Q2NW-784P-HVQN/switchPorts/39', 'operation': 'update', 'body': {'vlan': '23'}}, {'resource': '/devices/Q2NW-784P-XXXX/switchPorts/40', 'operation': 'update', 'body': {'type': 'access', 'vlan': '19'}}] Waiting for action batches to complete...

End of script.

mpapazog commented 1 year ago

There is no official support forum for scripts in this repository, but you can always try the Meraki Community API section, if you want input from people who have run them: https://community.meraki.com/t5/Developers-APIs/bd-p/api

If you suspect that you might be hitting a bug, then a GitHub issue, like the one you created, is the correct way to get our attention.

Could you elaborate a bit more on the symptom you are experiencing? What do you refer to as new networks vs an existing one?

Lanlord7 commented 1 year ago

Thanks, I'll check out Meraki's resources.

The symptom is that the script seems to run but I don't see an entry in the change log.

Reading init config file... Fetching dashboard organization... Reading configuration from source devices... Parsing source configration... Creating networks... Claiming devices... Configuring devices... Committing action batch: [{'resource': '/devices/Q2NW-784P-XXXX/switchPorts/36', 'operation': 'update', 'body': {'vlan': '19'}}, {'resource': '/devices/Q2NW-784P-XXXX/switchPorts/37', 'operation': 'update', 'body': {'vlan': '23'}}}] Waiting for action batches to complete...

End of script.

Here is the Cat config file. Morton is an existing network that contains the switch Q2NW-784P-XXXX

net=Morton file IOS-3750X-config2.txt Q2NW-784P-XXXX

If I change the network name to something that does not exist, I see an entry in the change log and the new network is created.

net=Network for switch stack file IOS-3750X-config2.txt Q2NW-784P-XXXX

My bottom line question is if this script can be used on existing networks and switches or if it's just use to build new networks and switches?

Thanks,

Jeff

From: mpapazog @.> Sent: Wednesday, March 15, 2023 9:24 AM To: meraki/automation-scripts @.> Cc: Jeff Gricus @.>; Author @.> Subject: Re: [meraki/automation-scripts] migrate_cat3k.py question (Issue #44)

CAUTION: This email originated from outside of DYOPATH. Do not click links or open attachments unless you recognize the sender and know the content is safe.

There is no official support forum for scripts in this repository, but you can always try the Meraki Community API section, if you want input from people who have run them: https://community.meraki.com/t5/Developers-APIs/bd-p/apihttps://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcommunity.meraki.com%2Ft5%2FDevelopers-APIs%2Fbd-p%2Fapi&data=05%7C01%7Cjeff.gricus%40dyopath.com%7C6feb34aa1bf845ab41b108db2560f2a8%7C07d31664362c414dbfb08cc6340972cb%7C1%7C0%7C638144870542843430%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=gbAR2l8mC8j8YDwkTcx6zfZpWgeMttRLPPOo36cPVAI%3D&reserved=0

If you suspect that you might be hitting a bug, then a GitHub issue, like the one you created, is the correct way to get our attention.

Could you elaborate a bit more on the symptom you are experiencing? What do you refer to as new networks vs an existing one?

- Reply to this email directly, view it on GitHubhttps://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmeraki%2Fautomation-scripts%2Fissues%2F44%23issuecomment-1470101808&data=05%7C01%7Cjeff.gricus%40dyopath.com%7C6feb34aa1bf845ab41b108db2560f2a8%7C07d31664362c414dbfb08cc6340972cb%7C1%7C0%7C638144870542843430%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=CYsBXpPAk9%2BmdgYd13TKqov3Gnn7fkri6uaiPZXtyps%3D&reserved=0, or unsubscribehttps://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FA6PZB64YNYJ75MGK6ZJPCALW4HGIXANCNFSM6AAAAAAV27HTFQ&data=05%7C01%7Cjeff.gricus%40dyopath.com%7C6feb34aa1bf845ab41b108db2560f2a8%7C07d31664362c414dbfb08cc6340972cb%7C1%7C0%7C638144870542843430%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=VU11lpiklVw5c0C1RQB3VW5PI9jSpsEJwlCg1WleqWw%3D&reserved=0. You are receiving this because you authored the thread.Message ID: @.***>

mpapazog commented 1 year ago
  1. Do you see configuration changes being applied though? If you see config being applied, but no entries in the Change log, then that would be an issue in the Change log itself, and not something that can be fixed in this piece of code. If that is the case, I would recommend opening a case with Meraki support. If you are not seeing config being applied, even though it should, let me know, as it might be caused by an issue in the script.

  2. It is a very long time since I wrote this script, but if I decipher my code correctly, it should work for existing networks as well. It attempts to add networks if they do not exist, and after that attempts to apply config to both newly created and existing networks. That is the intention at least. If your results are different, let me know.

Lanlord7 commented 1 year ago

Thank you so much for the response.

  1. No, I am not seeing the config changes reflected on the ports.

  2. I've got another build that I can test in a few weeks where I can create a new network and see if it can add the network and switch and modify the ports. Ideally, the script would work at any time on new and existing switches.

Thanks,

Jeff

From: mpapazog @.> Sent: Thursday, March 16, 2023 4:09 AM To: meraki/automation-scripts @.> Cc: Jeff Gricus @.>; Author @.> Subject: Re: [meraki/automation-scripts] migrate_cat3k.py question (Issue #44)

CAUTION: This email originated from outside of DYOPATH. Do not click links or open attachments unless you recognize the sender and know the content is safe.

  1. Do you see configuration changes being applied though? If you see config being applied, but no entries in the Change log, then that would be an issue in the Change log itself, and not something that can be fixed in this piece of code. If that is the case, I would recommend opening a case with Meraki support. If you are not seeing config being applied, even though it should, let me know, as it might be caused by an issue in the script.
  2. It is a very long time since I wrote this script, but if I decipher my code correctly, it should work for existing networks as well. It attempts to add networks if they do not exist, and after that attempts to apply config to both newly created and existing networks. That is the intention at least. If your results are different, let me know.

- Reply to this email directly, view it on GitHubhttps://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmeraki%2Fautomation-scripts%2Fissues%2F44%23issuecomment-1471565980&data=05%7C01%7Cjeff.gricus%40dyopath.com%7Ca5a1be08a02b4cbcf77f08db25fe0c74%7C07d31664362c414dbfb08cc6340972cb%7C1%7C0%7C638145545317520936%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=S35SWKWSg88VqD2Pv1HCFD2%2FhGpDfUqdmrZ93DA2fCY%3D&reserved=0, or unsubscribehttps://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FA6PZB654R3ICUAVJHTCDWVLW4LKB3ANCNFSM6AAAAAAV27HTFQ&data=05%7C01%7Cjeff.gricus%40dyopath.com%7Ca5a1be08a02b4cbcf77f08db25fe0c74%7C07d31664362c414dbfb08cc6340972cb%7C1%7C0%7C638145545317520936%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=w8Vaa4fGA8yHRpumzKMBf6Z6YL8TvpGdFm3ZzS1DDK4%3D&reserved=0. You are receiving this because you authored the thread.Message ID: @.***>

mpapazog commented 1 year ago

Sounds like the script has a bug or could use an additional feature. I am working on something else right now, so cannot take a look at possible modifications immediately.

If someone in the community would like to take a stab at improving this script, let me know. Otherwise, I will look into this more closely once I am able to.

Lanlord7 commented 1 year ago

Thanks so much. I'm afraid that I don't know anyone in the community so I guess I'll have to wait for you to take a look. Any time you can find would be appreciated.

Thanks,

Jeff

From: mpapazog @.> Sent: Thursday, March 16, 2023 10:06 AM To: meraki/automation-scripts @.> Cc: Jeff Gricus @.>; Author @.> Subject: Re: [meraki/automation-scripts] migrate_cat3k.py question (Issue #44)

CAUTION: This email originated from outside of DYOPATH. Do not click links or open attachments unless you recognize the sender and know the content is safe.

Sounds like the script has a bug or could use an additional feature. I am working on something else right now, so cannot take a look at possible modifications immediately.

If someone in the community would like to take a stab at improving this script, let me know. Otherwise, I will look into this more closely once I am able to.

- Reply to this email directly, view it on GitHubhttps://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmeraki%2Fautomation-scripts%2Fissues%2F44%23issuecomment-1472158947&data=05%7C01%7Cjeff.gricus%40dyopath.com%7C651dd8e13c2140d0744c08db262ff019%7C07d31664362c414dbfb08cc6340972cb%7C1%7C0%7C638145759559425704%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=lcJ%2FaJF64cSxeyFBNF1Dk6Zra8ZMFkNDqfDlrdBkPig%3D&reserved=0, or unsubscribehttps://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FA6PZB66VLQGBV7FRI76WQWTW4MT5BANCNFSM6AAAAAAV27HTFQ&data=05%7C01%7Cjeff.gricus%40dyopath.com%7C651dd8e13c2140d0744c08db262ff019%7C07d31664362c414dbfb08cc6340972cb%7C1%7C0%7C638145759559425704%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=BrMM5g%2BsBBQK361aYxV9DcqVq1JmLiDa%2F1iJzor90co%3D&reserved=0. You are receiving this because you authored the thread.Message ID: @.***>

Lanlord7 commented 1 year ago

As an update, I learned that v0 has been sunsetted and is to be replaced with v1.

https://developer.cisco.com/meraki/api/#!introduction/meraki-dashboard-api-v0

Having done that, I'm now getting some errors.

C:\data\OneDrive - DYOPATHCORP\Mailing List\Cisco Notes\Meraki Notes\Scripting>C:\Users\"Jeff G"\AppData\Local\Programs\Python\Python311\python.exe migrate_cat3k.py -k -o -i migrate_cat3k_JTG3.txt Reading init config file... Fetching dashboard organization... Reading configuration from source devices... ERROR 09: Could not read source config file: IOS-3750X-config3.cfg ERROR 18: Unable to read configuration from source "IOS-3750X-config3.cfg" Parsing source configration... Creating networks... Traceback (most recent call last): File "C:\data\OneDrive - DYOPATHCORP\Mailing List\Cisco Notes\Meraki Notes\Scripting\migrate_cat3k.py", line 922, in main(sys.argv[1:]) File "C:\data\OneDrive - DYOPATHCORP\Mailing List\Cisco Notes\Meraki Notes\Scripting\migrate_cat3k.py", line 752, in main if not existing['type'] in ['switch', 'combined']:


KeyError: 'type'

Here is the contents of the init config file.

interface GigabitEthernet1/0/9
 description Reserved for CVCUPS01 - Eth 0
 switchport access vlan 102
 switchport mode access
 spanning-tree portfast edge

Is there a certain file structure I should be using?

Thanks in advance.

Jeff