Skip to content

Commit

Permalink
[Network] Upgrade network sdk (#1977)
Browse files Browse the repository at this point in the history
* upgrade network sdk

* support creating route table v3 without route
  • Loading branch information
jsntcy authored Jul 7, 2020
1 parent c07e991 commit c5b05c0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
25 changes: 13 additions & 12 deletions src/virtual-wan/azext_vwan/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ def remove_hub_route(cmd, resource_group_name, virtual_hub_name, index, no_wait=


# pylint: disable=inconsistent-return-statements
def create_vhub_route_table(cmd, resource_group_name, virtual_hub_name, route_table_name, destination_type,
destinations, next_hop_type, next_hops=None, attached_connections=None, next_hop=None,
def create_vhub_route_table(cmd, resource_group_name, virtual_hub_name, route_table_name, destination_type=None,
destinations=None, next_hop_type=None, next_hops=None, attached_connections=None, next_hop=None,
route_name=None, labels=None, no_wait=False):
if attached_connections: # route table v2
if next_hops is None:
Expand All @@ -229,27 +229,28 @@ def create_vhub_route_table(cmd, resource_group_name, virtual_hub_name, route_ta
)

VirtualHubRouteTableV2, VirtualHubRouteV2 = cmd.get_models('VirtualHubRouteTableV2', 'VirtualHubRouteV2')
client = _v2_route_table_client(cmd.cli_ctx)
route = VirtualHubRouteV2(destination_type=destination_type,
destinations=destinations,
next_hop_type=next_hop_type,
next_hops=next_hops)
route_table = VirtualHubRouteTableV2(attached_connections=attached_connections, routes=[route])
client = _v2_route_table_client(cmd.cli_ctx)
else: # route table v3
if next_hop is None or route_name is None:
raise CLIError(
'Usage error: --next-hop and --route-name must be provided when --connections is not provided.')
if next_hops is not None:
raise CLIError('Usage error: --next-hops is not supported when --connections is not provided.')

HubRouteTable, HubRoute = cmd.get_models('HubRouteTable', 'HubRoute')
route_table = HubRouteTable(labels=labels)

if route_name is not None:
route = HubRoute(name=route_name,
destination_type=destination_type,
destinations=destinations,
next_hop_type=next_hop_type,
next_hop=next_hop)
route_table.routes = [route]

client = _v3_route_table_client(cmd.cli_ctx)
route = HubRoute(name=route_name,
destination_type=destination_type,
destinations=destinations,
next_hop_type=next_hop_type,
next_hop=next_hop)
route_table = HubRouteTable(routes=[route], labels=labels)

return sdk_no_wait(no_wait, client.create_or_update, resource_group_name,
virtual_hub_name, route_table_name, route_table)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8677,8 +8677,8 @@ class HubRouteTable(SubResource):
'id': {'key': 'id', 'type': 'str'},
'routes': {'key': 'properties.routes', 'type': '[HubRoute]'},
'labels': {'key': 'properties.labels', 'type': '[str]'},
'associated_connections': {'key': 'properties.associatedConnections', 'type': '[SubResource]'},
'propagating_connections': {'key': 'properties.propagatingConnections', 'type': '[SubResource]'},
'associated_connections': {'key': 'properties.associatedConnections', 'type': '[str]'},
'propagating_connections': {'key': 'properties.propagatingConnections', 'type': '[str]'},
'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'},
'name': {'key': 'name', 'type': 'str'},
'etag': {'key': 'etag', 'type': 'str'},
Expand Down

0 comments on commit c5b05c0

Please sign in to comment.