Last active
October 9, 2020 14:08
-
-
Save akrnmd/03da85b73c412cdedf84dfb811e3cdd6 to your computer and use it in GitHub Desktop.
Connect/Disconnect All L1 Routes. #python #orchestrationscript #CloudShell
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
import cloudshell.helpers.scripts.cloudshell_scripts_helpers as helpers | |
# How to use this file | |
# | |
# from Proc_L1ConnectionController import L1ConnectionController | |
# L1CC = L1ConnectionController() | |
# L1CC.ChangeStateOfAllL1Routes("Connect") | |
class L1ConnectionController: | |
def __init__(self): | |
self.reservation_id = helpers.get_reservation_context_details().id | |
self.session = helpers.get_api_session() | |
self.routes = self.session.GetReservationDetails(self.reservation_id).ReservationDescription.RequestedRoutesInfo | |
def ChangeStateOfAllL1Routes(self, TargetState): | |
for route in self.routes: | |
endpoints = [] | |
routeType = route.RouteType | |
endpoints.append(route.Source) | |
endpoints.append(route.Target) | |
if TargetState == "Connect": | |
self.session.WriteMessageToReservationOutput(self.reservation_id, "Connect route: " + route.Source + " to:" + route.Target) | |
self.session.ConnectRoutesInReservation(self.reservation_id, endpoints, routeType) | |
if TargetState == "Disconnect": | |
self.session.WriteMessageToReservationOutput(self.reservation_id, | |
"DisConnect route: " + route.Source + " to:" + route.Target) | |
self.session.DisconnectRoutesInReservation(self.reservation_id, endpoints) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment