Routers: cloud.routers¶
Access via cloud.routers. List and get inspect router records. Creation and
deletion support only MTN's neutronRouter type; the type is resolved automatically.
list_external_networks(*, group: str | int, resource_pool: str | int, cloud_id: int | None = None) -> list[ExternalNetwork]¶
- Endpoint:
GET /api/options/openstackExternalNetworks, after group, pool, and MTN router-type resolution. - Parameters:
group: group name or numeric ID.resource_pool: project name, code, or numeric ID, scoped to the selected group and cloud.cloud_id: optional cloud ID; inferred only if the group has exactly one cloud.
- Returns: gateway options with
nameand numeric Morpheusid. These IDs may not be readable through the ordinary networks endpoint. An empty list means no gateways are available in the selected scope. - Raises:
NotFoundErrorfor a missing group/pool,ValueErrorfor ambiguous or invalid scope, and common API exceptions.
get_external_network(name: str, *, group: str | int, resource_pool: str | int, cloud_id: int | None = None) -> ExternalNetwork¶
- Uses the same scoped discovery as
list_external_networks(). - Returns: one exact-name match, with an
idsuitable forcreate(external_network_id=...). - Raises:
NotFoundErrorwith available names if no match exists,ValueErrorif the name is empty or ambiguous, and the same scope/API errors as listing.
list(max_results=None, offset=0, sort=None, direction=None, phrase=None, **filters) -> list[Router]¶
- Endpoint:
GET /api/networks/routers - Parameters: shared list query arguments; see API conventions.
- Returns: router records visible to the account, including their type and status.
- Raises: common API exceptions.
get(resource_id: int) -> Router¶
- Endpoint:
GET /api/networks/routers/{id} - Parameters: numeric Morpheus router ID.
- Returns:
Router, includingstatus,type,site,zone,interfaces,external_network,external_ip, andexternal_idwhen available. - Raises:
NotFoundErrorwhen absent; common API exceptions.
create(name: str, *, group_id: int, cloud_id: int, resource_pool_id: int, internal_subnet_ids: list[int], external_network_id: int | None = None, enabled: bool = True) -> Router¶
- Endpoint:
POST /api/networks/routers, followed by a router read. - Parameters:
name: nonempty router name.group_id,cloud_id: group and its selected cloud.resource_pool_id: numeric project ID frominstances.get_resource_pool(...).id.internal_subnet_ids: nonempty list of positive Morpheus subnet IDs fromnetworks.list_subnets(...). Subnets must belong to the selected project.external_network_id: optional public network ID fromrouters.get_external_network(...).id.enabled: whether the router is enabled; defaults toTrue.
- Returns: initial
Routerrecord. Provisioning may still be in progress. - Raises: Pydantic
ValidationErrorfor invalid inputs;ValueErrorwhen the MTN router type is unavailable; common API exceptions. A failed read after successful submission raisesMTNCloudErrorwithresponse["router_id"]for cleanup.
Call wait_until_ready(router.id) to confirm backend readiness.
delete(router_id: int) -> bool¶
- Endpoints: reads the router to check its type, then
DELETE /api/networks/routers/{id}. - Returns:
Truewhen deletion is submitted or the router is already absent. - Raises:
ValueErrorfor a non-MTN router; common API exceptions.
Call wait_until_deleted(router_id) to confirm removal. Existing networks and
resource pools are not deleted.
wait_until_ready(router_id: int, timeout: float = 300, poll_interval: float = 5) -> Router¶
- Endpoint: polls
GET /api/networks/routers/{id}. - Parameters: router ID and positive timeout/poll interval in seconds.
- Returns: router with status
ok,available, oractive. - Raises:
MTNCloudErrorforfailed/errorstatus, SDKTimeoutErroron timeout,ValueErrorfor invalid timing or a non-MTN router, and common API exceptions. Provisioning failure and polling timeout errors includeresponse["router_id"].
wait_until_deleted(router_id: int, timeout: float = 300, poll_interval: float = 5) -> bool¶
- Endpoint: polls
GET /api/networks/routers/{id}until it returns 404. - Returns:
Trueafter removal. - Raises: SDK
TimeoutErrorwithresponse["router_id"],ValueErrorfor invalid timing, and common API exceptions. Authorization and server errors are not treated as successful deletion.
See the Networking guide for a complete example.