Skip to content

Commit 9a1b547

Browse files
Add interfaces argument to instance_create
1 parent 6e7f7ad commit 9a1b547

2 files changed

Lines changed: 29 additions & 3 deletions

File tree

linode_api4/groups/linode.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import base64
22
import os
33
from collections.abc import Iterable
4-
from typing import Any, Dict, Optional, Union
4+
from typing import Any, Dict, List, Optional, Union
55

66
from linode_api4.common import load_and_validate_keys
77
from linode_api4.errors import UnexpectedResponseError
@@ -13,6 +13,8 @@
1313
InstanceDiskEncryptionType,
1414
InterfaceGeneration,
1515
Kernel,
16+
LinodeInterface,
17+
NetworkInterface,
1618
PlacementGroup,
1719
StackScript,
1820
Type,
@@ -154,6 +156,9 @@ def instance_create(
154156
int,
155157
]
156158
] = None,
159+
interfaces: Optional[
160+
List[Union[LinodeInterface, NetworkInterface, Dict[str, Any]],]
161+
] = None,
157162
interface_generation: Optional[Union[InterfaceGeneration, str]] = None,
158163
network_helper: Optional[bool] = None,
159164
**kwargs,
@@ -299,6 +304,8 @@ def instance_create(
299304
:type interfaces: list[ConfigInterface] or list[dict[str, Any]]
300305
:param placement_group: A Placement Group to create this Linode under.
301306
:type placement_group: Union[InstancePlacementGroupAssignment, PlacementGroup, Dict[str, Any], int]
307+
:param interfaces: The interfaces to create this Linode with.
308+
:type interfaces: List of LinodeInterface, NetworkInterface (deprecated), or Dict[str, Any]
302309
:param interface_generation: The generation of network interfaces this Linode uses.
303310
:type interface_generation: InterfaceGeneration or str
304311
:param network_helper: Whether this instance should have Network Helper enabled.
@@ -343,6 +350,7 @@ def instance_create(
343350
if placement_group
344351
else None
345352
),
353+
"interfaces": interfaces,
346354
"interface_generation": interface_generation,
347355
"network_helper": network_helper,
348356
}

test/unit/objects/linode_interface_test.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from datetime import datetime
22
from test.unit.base import ClientBaseCase
33

4-
54
from linode_api4 import (
65
LinodeInterface,
76
LinodeInterfacePublicIPv4AddressUpdateOptions,
@@ -201,7 +200,6 @@ def test_update_vpc(self):
201200

202201
assert m.called
203202

204-
print(m.call_data)
205203
assert m.call_data == {
206204
"default_route": {
207205
"ipv4": False,
@@ -220,3 +218,23 @@ def test_update_vpc(self):
220218
},
221219
},
222220
}
221+
222+
def test_update_vlan(self):
223+
iface = LinodeInterface(self.client, 789, 124)
224+
225+
self.assert_linode_124_interface_789(iface)
226+
227+
iface.vlan.ipam_address = "10.0.0.2/24"
228+
iface.vlan.vlan_label = "my_vlan_updated"
229+
230+
with self.mock_put("/linode/instances/124/interfaces/789") as m:
231+
iface.save()
232+
233+
assert m.called
234+
235+
assert m.call_data == {
236+
"vlan": {
237+
"vlan_label": "my_vlan_updated",
238+
"ipam_address": "10.0.0.1/24",
239+
},
240+
}

0 commit comments

Comments
 (0)