@@ -29,7 +29,7 @@ def __call__(self, *filters):
2929 """
3030 return self .client ._get_and_filter (Image , * filters )
3131
32- def create (self , disk , label = None , description = None ):
32+ def create (self , disk , label = None , description = None , cloud_init = False ):
3333 """
3434 Creates a new Image from a disk you own.
3535
@@ -42,6 +42,8 @@ def create(self, disk, label=None, description=None):
4242 :type label: str
4343 :param description: The description for the new Image.
4444 :type description: str
45+ :param cloud_init: Whether this Image supports cloud-init.
46+ :type cloud_init: bool
4547
4648 :returns: The new Image.
4749 :rtype: Image
@@ -56,6 +58,9 @@ def create(self, disk, label=None, description=None):
5658 if description is not None :
5759 params ["description" ] = description
5860
61+ if cloud_init :
62+ params ["cloud_init" ] = cloud_init
63+
5964 result = self .client .post ("/images" , data = params )
6065
6166 if not "id" in result :
@@ -68,7 +73,11 @@ def create(self, disk, label=None, description=None):
6873 return Image (self .client , result ["id" ], result )
6974
7075 def create_upload (
71- self , label : str , region : str , description : str = None
76+ self ,
77+ label : str ,
78+ region : str ,
79+ description : str = None ,
80+ cloud_init : bool = False ,
7281 ) -> Tuple [Image , str ]:
7382 """
7483 Creates a new Image and returns the corresponding upload URL.
@@ -81,12 +90,17 @@ def create_upload(
8190 :type region: str
8291 :param description: The description for the new Image.
8392 :type description: str
93+ :param cloud_init: Whether this Image supports cloud-init.
94+ :type cloud_init: bool
8495
8596 :returns: A tuple containing the new image and the image upload URL.
8697 :rtype: (Image, str)
8798 """
8899 params = {"label" : label , "region" : region , "description" : description }
89100
101+ if cloud_init :
102+ params ["cloud_init" ] = cloud_init
103+
90104 result = self .client .post ("/images/upload" , data = drop_null_keys (params ))
91105
92106 if "image" not in result :
0 commit comments