Skip to content

Instantly share code, notes, and snippets.

@akrnmd
Last active October 9, 2020 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akrnmd/03da85b73c412cdedf84dfb811e3cdd6 to your computer and use it in GitHub Desktop.
Save akrnmd/03da85b73c412cdedf84dfb811e3cdd6 to your computer and use it in GitHub Desktop.
Connect/Disconnect All L1 Routes. #python #orchestrationscript #CloudShell
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