def _disconnect_all_my_connectors(session, resource_name, reservation_id, logger): """ :param CloudShellAPISession session: :param str resource_name: :param str reservation_id: """ reservation_details = session.GetReservationDetails(reservation_id) connectors = reservation_details.ReservationDescription.Connectors endpoints = [] for endpoint in connectors: if endpoint.Target == resource_name or endpoint.Source == resource_name: endpoints.append(endpoint.Target) endpoints.append(endpoint.Source) if len(endpoints) == 0: logger.info("No routes to disconnect for resource {0} in reservation {1}" .format(resource_name, reservation_id)) return logger.info("Executing disconnect routes for resource {0} in reservation {1}" .format(resource_name, reservation_id)) try: session.DisconnectRoutesInReservation(reservation_id, endpoints) except Exception as exc: logger.error("Error disconnecting routes for resource {0} in reservation {1}. Error: {2}" .format(resource_name, reservation_id, get_error_message_from_exception(exc)))
def _disconnect_all_my_connectors(session, resource_name, reservation_id, logger): """ :param CloudShellAPISession session: :param str resource_name: :param str reservation_id: """ reservation_details = session.GetReservationDetails(reservation_id) connectors = reservation_details.ReservationDescription.Connectors endpoints = [] for endpoint in connectors: if endpoint.Target == resource_name or endpoint.Source == resource_name: endpoints.append(endpoint.Target) endpoints.append(endpoint.Source) if len(endpoints) == 0: logger.info( "No routes to disconnect for resource {0} in reservation {1}". format(resource_name, reservation_id)) return logger.info( "Executing disconnect routes for resource {0} in reservation {1}". format(resource_name, reservation_id)) try: session.DisconnectRoutesInReservation(reservation_id, endpoints) except Exception as exc: logger.error( "Error disconnecting routes for resource {0} in reservation {1}. Error: {2}" .format(resource_name, reservation_id, get_error_message_from_exception(exc)))
def _create_error_action_res(action, e): error_result = ActionResult() error_result.actionId = action.actionId error_result.type = action.type error_result.errorMessage = get_error_message_from_exception(e) error_result.infoMessage = None error_result.success = False error_result.updatedInterface = ConnectionCommandOrchestrator._get_mac(action) return error_result