Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions 75 linode_api4/objects/linode_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,41 @@ class LinodeInterfaceVPCIPv4Options(JSONObject):
ranges: Optional[List[LinodeInterfaceVPCIPv4RangeOptions]] = None


@dataclass
class LinodeInterfaceVPCIPv6SLAACOptions(JSONObject):
"""
Options accepted for a single SLAAC when creating or updating the IPv6 configuration of a VPC Linode Interface.

NOTE: Linode interfaces may not currently be available to all users.
"""

range: Optional[str] = None


@dataclass
class LinodeInterfaceVPCIPv6RangeOptions(JSONObject):
"""
Options accepted for a single range when creating or updating the IPv6 configuration of a VPC Linode Interface.

NOTE: Linode interfaces may not currently be available to all users.
"""

range: Optional[str] = None


@dataclass
class LinodeInterfaceVPCIPv6Options(JSONObject):
"""
Options accepted when creating or updating the IPv6 configuration of a VPC Linode Interface.

NOTE: Linode interfaces may not currently be available to all users.
"""

is_public: Optional[bool] = None
slaac: Optional[List[LinodeInterfaceVPCIPv6SLAACOptions]] = None
ranges: Optional[List[LinodeInterfaceVPCIPv6RangeOptions]] = None


@dataclass
class LinodeInterfaceVPCOptions(JSONObject):
"""
Expand All @@ -114,6 +149,7 @@ class LinodeInterfaceVPCOptions(JSONObject):

subnet_id: int = 0
ipv4: Optional[LinodeInterfaceVPCIPv4Options] = None
ipv6: Optional[LinodeInterfaceVPCIPv6Options] = None


@dataclass
Expand Down Expand Up @@ -265,6 +301,44 @@ class LinodeInterfaceVPCIPv4(JSONObject):
ranges: List[LinodeInterfaceVPCIPv4Range] = field(default_factory=list)


@dataclass
class LinodeInterfaceVPCIPv6SLAAC(JSONObject):
"""
A single SLAAC entry under the IPv6 configuration of a VPC Linode Interface.

NOTE: Linode interfaces may not currently be available to all users.
"""

range: str = ""
address: str = ""


@dataclass
class LinodeInterfaceVPCIPv6Range(JSONObject):
"""
A single range under the IPv6 configuration of a VPC Linode Interface.

NOTE: Linode interfaces may not currently be available to all users.
"""

range: str = ""


@dataclass
class LinodeInterfaceVPCIPv6(JSONObject):
"""
A single address under the IPv6 configuration of a VPC Linode Interface.

NOTE: Linode interfaces may not currently be available to all users.
"""

put_class = LinodeInterfaceVPCIPv6Options

is_public: bool = False
slaac: List[LinodeInterfaceVPCIPv6SLAAC] = field(default_factory=list)
ranges: List[LinodeInterfaceVPCIPv6Range] = field(default_factory=list)


@dataclass
class LinodeInterfaceVPC(JSONObject):
"""
Expand All @@ -279,6 +353,7 @@ class LinodeInterfaceVPC(JSONObject):
subnet_id: int = 0

ipv4: Optional[LinodeInterfaceVPCIPv4] = None
ipv6: Optional[LinodeInterfaceVPCIPv6] = None


@dataclass
Expand Down
14 changes: 14 additions & 0 deletions 14 test/fixtures/linode_instances_124_interfaces.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,20 @@
"range": "192.168.22.32/28"
}
]
},
"ipv6": {
"is_public": true,
"slaac": [
{
"range": "1234::/64",
"address": "1234::5678"
}
],
"ranges": [
{
"range": "4321::/64"
}
]
}
},
"public": null,
Expand Down
16 changes: 15 additions & 1 deletion 16 test/fixtures/linode_instances_124_interfaces_456.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"vpc": {
"vpc_id": 123456,
"subnet_id": 789,
"ipv4" : {
"ipv4": {
"addresses": [
{
"address": "192.168.22.3",
Expand All @@ -21,6 +21,20 @@
{ "range": "192.168.22.16/28"},
{ "range": "192.168.22.32/28"}
]
},
"ipv6": {
"is_public": true,
"slaac": [
{
"range": "1234::/64",
"address": "1234::5678"
}
],
"ranges": [
{
"range": "4321::/64"
}
]
}
},
"public": null,
Expand Down
14 changes: 14 additions & 0 deletions 14 test/fixtures/linode_instances_124_upgrade-interfaces.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,20 @@
"range": "192.168.22.32/28"
}
]
},
"ipv6": {
"is_public": true,
"slaac": [
{
"range": "1234::/64",
"address": "1234::5678"
}
],
"ranges": [
{
"range": "4321::/64"
}
]
}
},
"public": null,
Expand Down
25 changes: 25 additions & 0 deletions 25 test/unit/objects/linode_interface_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
LinodeInterfaceVPCIPv4AddressOptions,
LinodeInterfaceVPCIPv4Options,
LinodeInterfaceVPCIPv4RangeOptions,
LinodeInterfaceVPCIPv6SLAACOptions,
LinodeInterfaceVPCOptions,
)

Expand Down Expand Up @@ -149,6 +150,13 @@ def assert_linode_124_interface_456(iface: LinodeInterface):
assert iface.vpc.ipv4.ranges[0].range == "192.168.22.16/28"
assert iface.vpc.ipv4.ranges[1].range == "192.168.22.32/28"

assert iface.vpc.ipv6.is_public

assert iface.vpc.ipv6.slaac[0].range == "1234::/64"
assert iface.vpc.ipv6.slaac[0].address == "1234::5678"

assert iface.vpc.ipv6.ranges[0].range == "4321::/64"

@staticmethod
def assert_linode_124_interface_789(iface: LinodeInterface):
assert iface.id == 789
Expand Down Expand Up @@ -261,6 +269,18 @@ def test_update_vpc(self):
)
]

iface.vpc.ipv6.is_public = False

iface.vpc.ipv6.slaac = [
LinodeInterfaceVPCIPv6SLAACOptions(
range="1233::/64",
)
]

iface.vpc.ipv6.ranges = [
LinodeInterfacePublicIPv6RangeOptions(range="9876::/64")
]

with self.mock_put("/linode/instances/124/interfaces/456") as m:
iface.save()

Expand All @@ -282,6 +302,11 @@ def test_update_vpc(self):
],
"ranges": [{"range": "192.168.22.17/28"}],
},
"ipv6": {
"is_public": False,
"slaac": [{"range": "1233::/64"}],
"ranges": [{"range": "9876::/64"}],
},
},
}

Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.