@@ -52,6 +52,15 @@ class UpcloudCreateNodeRequestBody:
5252 :param ex_username: User's username, which is created.
5353 Default is 'root'. (optional)
5454 :type ex_username: ``str``
55+
56+ :param ex_storage_devices: Additional UpCloud storage_device dictionaries.
57+ (optional)
58+ :type ex_storage_devices: ``list`` of ``dict``
59+
60+ :param ex_metadata: Whether to enable the UpCloud metadata service,
61+ ``"yes"`` or ``"no"``. Cloud-init templates require
62+ this to be enabled. (optional)
63+ :type ex_metadata: ``str``
5564 """
5665
5766 def __init__ (
@@ -63,17 +72,25 @@ def __init__(
6372 auth = None ,
6473 ex_hostname = "localhost" ,
6574 ex_username = "root" ,
75+ ex_storage_devices = None ,
76+ ex_metadata = None ,
6677 ):
78+ storage_devices = _StorageDevice (image , size ).to_dict ()
79+ if ex_storage_devices :
80+ storage_devices ["storage_device" ].extend (ex_storage_devices )
81+
6782 self .body = {
6883 "server" : {
6984 "title" : name ,
7085 "hostname" : ex_hostname ,
7186 "plan" : size .id ,
7287 "zone" : location .id ,
7388 "login_user" : _LoginUser (ex_username , auth ).to_dict (),
74- "storage_devices" : _StorageDevice ( image , size ). to_dict () ,
89+ "storage_devices" : storage_devices ,
7590 }
7691 }
92+ if ex_metadata is not None :
93+ self .body ["server" ]["metadata" ] = ex_metadata
7794
7895 def to_json (self ):
7996 """
@@ -169,9 +186,18 @@ def stop_node(self, node_id):
169186 """
170187 body = {"stop_server" : {"stop_type" : "hard" }}
171188 self .connection .request (
172- "1.2 /server/{}/stop" .format (node_id ), method = "POST" , data = json .dumps (body )
189+ "1.3 /server/{}/stop" .format (node_id ), method = "POST" , data = json .dumps (body )
173190 )
174191
192+ def start_node (self , node_id ):
193+ """
194+ Starts the node
195+
196+ :param node_id: Id of the Node
197+ :type node_id: ``int``
198+ """
199+ self .connection .request ("1.3/server/{}/start" .format (node_id ), method = "POST" )
200+
175201 def get_node_state (self , node_id ):
176202 """
177203 Get the state of the node.
@@ -182,7 +208,7 @@ def get_node_state(self, node_id):
182208 :rtype: ``str``
183209 """
184210
185- action = "1.2 /server/{}" .format (node_id )
211+ action = "1.3 /server/{}" .format (node_id )
186212 try :
187213 response = self .connection .request (action )
188214 return response .object ["server" ]["state" ]
@@ -198,7 +224,7 @@ def destroy_node(self, node_id):
198224 :param node_id: Id of the Node
199225 :type node_id: ``int``
200226 """
201- self .connection .request ("1.2 /server/{}" .format (node_id ), method = "DELETE" )
227+ self .connection .request ("1.3 /server/{}" .format (node_id ), method = "DELETE" )
202228
203229
204230class PlanPrice :
0 commit comments