Skip to content

Commit 97c48a3

Browse files
authored
feat(baremetal): expose user_data field for cloud-init (#1329)
1 parent c9d82c0 commit 97c48a3

File tree

6 files changed

+94
-0
lines changed

6 files changed

+94
-0
lines changed

scaleway-async/scaleway_async/baremetal/v1/api.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
from scaleway_core.api import API
88
from scaleway_core.bridge import (
9+
ScwFile,
910
Zone as ScwZone,
1011
)
1112
from scaleway_core.utils import (
@@ -288,6 +289,7 @@ async def create_server(
288289
tags: Optional[list[str]] = None,
289290
install: Optional[CreateServerRequestInstall] = None,
290291
option_ids: Optional[list[str]] = None,
292+
user_data: Optional[str] = None,
291293
) -> Server:
292294
"""
293295
Create an Elastic Metal server.
@@ -304,6 +306,7 @@ async def create_server(
304306
:param tags: Tags to associate to the server.
305307
:param install: Object describing the configuration details of the OS installation on the server.
306308
:param option_ids: IDs of options to enable on server.
309+
:param user_data: Configuration data to pass to cloud-init such as a YAML cloud config data or a user-data script.
307310
:return: :class:`Server <Server>`
308311
309312
Usage:
@@ -332,6 +335,7 @@ async def create_server(
332335
tags=tags,
333336
install=install,
334337
option_ids=option_ids,
338+
user_data=user_data,
335339
project_id=project_id,
336340
organization_id=organization_id,
337341
),
@@ -351,6 +355,7 @@ async def update_server(
351355
description: Optional[str] = None,
352356
tags: Optional[list[str]] = None,
353357
protected: Optional[bool] = None,
358+
user_data: Optional[str] = None,
354359
) -> Server:
355360
"""
356361
Update an Elastic Metal server.
@@ -361,6 +366,7 @@ async def update_server(
361366
:param description: Description associated with the server, max 255 characters, not updated if null.
362367
:param tags: Tags associated with the server, not updated if null.
363368
:param protected: If enabled, the server can not be deleted.
369+
:param user_data: Configuration data to pass to cloud-init such as a YAML cloud config data or a user-data script.
364370
:return: :class:`Server <Server>`
365371
366372
Usage:
@@ -385,6 +391,7 @@ async def update_server(
385391
description=description,
386392
tags=tags,
387393
protected=protected,
394+
user_data=user_data,
388395
),
389396
self.client,
390397
),
@@ -406,6 +413,7 @@ async def install_server(
406413
service_user: Optional[str] = None,
407414
service_password: Optional[str] = None,
408415
partitioning_schema: Optional[Schema] = None,
416+
user_data: Optional[ScwFile] = None,
409417
) -> Server:
410418
"""
411419
Install an Elastic Metal server.
@@ -420,6 +428,7 @@ async def install_server(
420428
:param service_user: User used for the service to install.
421429
:param service_password: Password used for the service to install.
422430
:param partitioning_schema: Partitioning schema.
431+
:param user_data: Configuration data to pass to cloud-init such as a YAML cloud config data or a user-data script.
423432
:return: :class:`Server <Server>`
424433
425434
Usage:
@@ -451,6 +460,7 @@ async def install_server(
451460
service_user=service_user,
452461
service_password=service_password,
453462
partitioning_schema=partitioning_schema,
463+
user_data=user_data,
454464
),
455465
self.client,
456466
),

scaleway-async/scaleway_async/baremetal/v1/marshalling.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from scaleway_core.profile import ProfileDefaults
88
from scaleway_core.bridge import (
99
unmarshal_Money,
10+
marshal_ScwFile,
1011
unmarshal_TimeSeries,
1112
)
1213
from scaleway_core.utils import (
@@ -706,6 +707,12 @@ def unmarshal_Server(data: Any) -> Server:
706707
else:
707708
args["rescue_server"] = None
708709

710+
field = data.get("user_data", None)
711+
if field is not None:
712+
args["user_data"] = field
713+
else:
714+
args["user_data"] = None
715+
709716
return Server(**args)
710717

711718

@@ -1930,6 +1937,9 @@ def marshal_CreateServerRequest(
19301937
if request.option_ids is not None:
19311938
output["option_ids"] = request.option_ids
19321939

1940+
if request.user_data is not None:
1941+
output["user_data"] = request.user_data
1942+
19331943
return output
19341944

19351945

@@ -1977,6 +1987,9 @@ def marshal_InstallServerRequest(
19771987
request.partitioning_schema, defaults
19781988
)
19791989

1990+
if request.user_data is not None:
1991+
output["user_data"] = marshal_ScwFile(request.user_data, defaults)
1992+
19801993
return output
19811994

19821995

@@ -2076,6 +2089,9 @@ def marshal_UpdateServerRequest(
20762089
if request.protected is not None:
20772090
output["protected"] = request.protected
20782091

2092+
if request.user_data is not None:
2093+
output["user_data"] = request.user_data
2094+
20792095
return output
20802096

20812097

scaleway-async/scaleway_async/baremetal/v1/types.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
from scaleway_core.bridge import (
1111
Money,
12+
ScwFile,
1213
TimeSeries,
1314
Zone as ScwZone,
1415
)
@@ -661,6 +662,11 @@ class CreateServerRequest:
661662
IDs of options to enable on server.
662663
"""
663664

665+
user_data: Optional[str] = None
666+
"""
667+
Configuration data to pass to cloud-init such as a YAML cloud config data or a user-data script.
668+
"""
669+
664670
project_id: Optional[str] = None
665671

666672
organization_id: Optional[str] = None
@@ -768,6 +774,11 @@ class Server:
768774
Configuration of rescue boot.
769775
"""
770776

777+
user_data: Optional[str] = None
778+
"""
779+
Optional configuration data passed to cloud-init.
780+
"""
781+
771782

772783
@dataclass
773784
class OS:
@@ -1325,6 +1336,11 @@ class InstallServerRequest:
13251336
Partitioning schema.
13261337
"""
13271338

1339+
user_data: Optional[ScwFile] = None
1340+
"""
1341+
Configuration data to pass to cloud-init such as a YAML cloud config data or a user-data script.
1342+
"""
1343+
13281344

13291345
@dataclass
13301346
class ListOSRequest:
@@ -1868,6 +1884,11 @@ class UpdateServerRequest:
18681884
If enabled, the server can not be deleted.
18691885
"""
18701886

1887+
user_data: Optional[str] = None
1888+
"""
1889+
Configuration data to pass to cloud-init such as a YAML cloud config data or a user-data script.
1890+
"""
1891+
18711892

18721893
@dataclass
18731894
class UpdateSettingRequest:

scaleway/scaleway/baremetal/v1/api.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
from scaleway_core.api import API
88
from scaleway_core.bridge import (
9+
ScwFile,
910
Zone as ScwZone,
1011
)
1112
from scaleway_core.utils import (
@@ -288,6 +289,7 @@ def create_server(
288289
tags: Optional[list[str]] = None,
289290
install: Optional[CreateServerRequestInstall] = None,
290291
option_ids: Optional[list[str]] = None,
292+
user_data: Optional[str] = None,
291293
) -> Server:
292294
"""
293295
Create an Elastic Metal server.
@@ -304,6 +306,7 @@ def create_server(
304306
:param tags: Tags to associate to the server.
305307
:param install: Object describing the configuration details of the OS installation on the server.
306308
:param option_ids: IDs of options to enable on server.
309+
:param user_data: Configuration data to pass to cloud-init such as a YAML cloud config data or a user-data script.
307310
:return: :class:`Server <Server>`
308311
309312
Usage:
@@ -332,6 +335,7 @@ def create_server(
332335
tags=tags,
333336
install=install,
334337
option_ids=option_ids,
338+
user_data=user_data,
335339
project_id=project_id,
336340
organization_id=organization_id,
337341
),
@@ -351,6 +355,7 @@ def update_server(
351355
description: Optional[str] = None,
352356
tags: Optional[list[str]] = None,
353357
protected: Optional[bool] = None,
358+
user_data: Optional[str] = None,
354359
) -> Server:
355360
"""
356361
Update an Elastic Metal server.
@@ -361,6 +366,7 @@ def update_server(
361366
:param description: Description associated with the server, max 255 characters, not updated if null.
362367
:param tags: Tags associated with the server, not updated if null.
363368
:param protected: If enabled, the server can not be deleted.
369+
:param user_data: Configuration data to pass to cloud-init such as a YAML cloud config data or a user-data script.
364370
:return: :class:`Server <Server>`
365371
366372
Usage:
@@ -385,6 +391,7 @@ def update_server(
385391
description=description,
386392
tags=tags,
387393
protected=protected,
394+
user_data=user_data,
388395
),
389396
self.client,
390397
),
@@ -406,6 +413,7 @@ def install_server(
406413
service_user: Optional[str] = None,
407414
service_password: Optional[str] = None,
408415
partitioning_schema: Optional[Schema] = None,
416+
user_data: Optional[ScwFile] = None,
409417
) -> Server:
410418
"""
411419
Install an Elastic Metal server.
@@ -420,6 +428,7 @@ def install_server(
420428
:param service_user: User used for the service to install.
421429
:param service_password: Password used for the service to install.
422430
:param partitioning_schema: Partitioning schema.
431+
:param user_data: Configuration data to pass to cloud-init such as a YAML cloud config data or a user-data script.
423432
:return: :class:`Server <Server>`
424433
425434
Usage:
@@ -451,6 +460,7 @@ def install_server(
451460
service_user=service_user,
452461
service_password=service_password,
453462
partitioning_schema=partitioning_schema,
463+
user_data=user_data,
454464
),
455465
self.client,
456466
),

scaleway/scaleway/baremetal/v1/marshalling.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from scaleway_core.profile import ProfileDefaults
88
from scaleway_core.bridge import (
99
unmarshal_Money,
10+
marshal_ScwFile,
1011
unmarshal_TimeSeries,
1112
)
1213
from scaleway_core.utils import (
@@ -706,6 +707,12 @@ def unmarshal_Server(data: Any) -> Server:
706707
else:
707708
args["rescue_server"] = None
708709

710+
field = data.get("user_data", None)
711+
if field is not None:
712+
args["user_data"] = field
713+
else:
714+
args["user_data"] = None
715+
709716
return Server(**args)
710717

711718

@@ -1930,6 +1937,9 @@ def marshal_CreateServerRequest(
19301937
if request.option_ids is not None:
19311938
output["option_ids"] = request.option_ids
19321939

1940+
if request.user_data is not None:
1941+
output["user_data"] = request.user_data
1942+
19331943
return output
19341944

19351945

@@ -1977,6 +1987,9 @@ def marshal_InstallServerRequest(
19771987
request.partitioning_schema, defaults
19781988
)
19791989

1990+
if request.user_data is not None:
1991+
output["user_data"] = marshal_ScwFile(request.user_data, defaults)
1992+
19801993
return output
19811994

19821995

@@ -2076,6 +2089,9 @@ def marshal_UpdateServerRequest(
20762089
if request.protected is not None:
20772090
output["protected"] = request.protected
20782091

2092+
if request.user_data is not None:
2093+
output["user_data"] = request.user_data
2094+
20792095
return output
20802096

20812097

scaleway/scaleway/baremetal/v1/types.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
from scaleway_core.bridge import (
1111
Money,
12+
ScwFile,
1213
TimeSeries,
1314
Zone as ScwZone,
1415
)
@@ -661,6 +662,11 @@ class CreateServerRequest:
661662
IDs of options to enable on server.
662663
"""
663664

665+
user_data: Optional[str] = None
666+
"""
667+
Configuration data to pass to cloud-init such as a YAML cloud config data or a user-data script.
668+
"""
669+
664670
project_id: Optional[str] = None
665671

666672
organization_id: Optional[str] = None
@@ -768,6 +774,11 @@ class Server:
768774
Configuration of rescue boot.
769775
"""
770776

777+
user_data: Optional[str] = None
778+
"""
779+
Optional configuration data passed to cloud-init.
780+
"""
781+
771782

772783
@dataclass
773784
class OS:
@@ -1325,6 +1336,11 @@ class InstallServerRequest:
13251336
Partitioning schema.
13261337
"""
13271338

1339+
user_data: Optional[ScwFile] = None
1340+
"""
1341+
Configuration data to pass to cloud-init such as a YAML cloud config data or a user-data script.
1342+
"""
1343+
13281344

13291345
@dataclass
13301346
class ListOSRequest:
@@ -1868,6 +1884,11 @@ class UpdateServerRequest:
18681884
If enabled, the server can not be deleted.
18691885
"""
18701886

1887+
user_data: Optional[str] = None
1888+
"""
1889+
Configuration data to pass to cloud-init such as a YAML cloud config data or a user-data script.
1890+
"""
1891+
18711892

18721893
@dataclass
18731894
class UpdateSettingRequest:

0 commit comments

Comments
 (0)