Add new networking model

Partially-Implements: blueprint json-network-config
Change-Id: Ifaa9c5a037196a70bf24ab0b3ab45c32d362856c
This commit is contained in:
Alessandro Pilotti 2018-08-26 01:08:44 +03:00
parent bde2be7e7d
commit 0dc65eb712
1 changed files with 106 additions and 0 deletions

View File

@ -14,6 +14,46 @@
import collections
LINK_TYPE_PHYSICAL = "physical"
LINK_TYPE_BOND = "bond"
LINK_TYPE_VLAN = "vlan"
# Based on: https://www.kernel.org/doc/Documentation/networking/bonding.txts
BOND_TYPE_8023AD = "802.3ad"
BOND_TYPE_BALANCE_RR = "balance-rr"
BOND_TYPE_ACTIVE_BACKUP = "active-backup"
BOND_TYPE_BALANCE_XOR = "balance-xor"
BOND_TYPE_BROADCAST = "broadcast"
BOND_TYPE_BALANCE_TLB = "balance-tlb"
BOND_TYPE_BALANCE_ALB = "balance-alb"
AVAILABLE_BOND_TYPES = [
BOND_TYPE_8023AD,
BOND_TYPE_BALANCE_RR,
BOND_TYPE_ACTIVE_BACKUP,
BOND_TYPE_BALANCE_XOR,
BOND_TYPE_BROADCAST,
BOND_TYPE_BALANCE_TLB,
BOND_TYPE_BALANCE_ALB,
]
BOND_LB_ALGO_L2 = "layer2"
BOND_LB_ALGO_L2_L3 = "layer2+3"
BOND_LB_ALGO_L3_L4 = "layer3+4"
BOND_LB_ENCAP_L2_L3 = "encap2+3"
BOND_LB_ENCAP_L3_L4 = "encap3+4"
AVAILABLE_BOND_LB_ALGORITHMS = [
BOND_LB_ALGO_L2,
BOND_LB_ALGO_L2_L3,
BOND_LB_ALGO_L3_L4,
BOND_LB_ENCAP_L2_L3,
BOND_LB_ENCAP_L3_L4,
]
BOND_LACP_RATE_SLOW = "slow"
BOND_LACP_RATE_FAST = "fast"
NetworkDetails = collections.namedtuple(
"NetworkDetails",
@ -30,3 +70,69 @@ NetworkDetails = collections.namedtuple(
"dnsnameservers",
]
)
NetworkDetailsV2 = collections.namedtuple(
"NetworkDetailsV2",
[
"links",
"networks",
"services"
]
)
Link = collections.namedtuple(
"Link",
[
"id",
"name",
"type",
"enabled",
"mac_address",
"mtu",
"bond",
"vlan_link",
"vlan_id"
]
)
Bond = collections.namedtuple(
"Bond",
[
"members",
"type",
"lb_algorithm",
"lacp_rate"
]
)
Network = collections.namedtuple(
"Network",
[
"link",
"address_cidr",
"dns_nameservers",
"routes",
]
)
Route = collections.namedtuple(
"Route",
[
"network_cidr",
"gateway"
]
)
NameServerService = collections.namedtuple(
"NameServerService",
[
"addresses",
"search"
]
)