@@ -47,7 +47,7 @@ def list(self, detailed=True):
4747 return self ._list ("/images%s" % detail , "images" )
4848
4949
50- def create (self , server , image_type = None , name = None , rotation = None ):
50+ def create (self , server , name , image_type = None , backup_type = None , rotation = None ):
5151 """
5252 Create a new image by snapshotting a running :class:`Server`
5353
@@ -58,17 +58,20 @@ def create(self, server, image_type=None, name=None, rotation=None):
5858 if image_type is None :
5959 image_type = "snapshot"
6060
61- if image_type not in ("daily" , "weekly" , "snapshot" ):
62- raise Exception ("Invalid image_type: must be daily, "
63- "weekly or snapshot" )
61+ if image_type not in ("backup" , "snapshot" ):
62+ raise Exception ("Invalid image_type: must be backup or snapshot" )
6463
65- if image_type == "snapshot" and not name :
66- raise Exception ("name is required for snapshots" )
67- elif image_type != "snapshot" and not rotation :
68- raise Exception ("rotation is required for backups" )
64+ if image_type == "backup" :
65+ if not rotation :
66+ raise Exception ("rotation is required for backups" )
67+ elif not backup_type :
68+ raise Exception ("backup_type required for backups" )
69+ elif backup_type not in ("daily" , "weekly" ):
70+ raise Exception ("Invalid backup_type: must be daily or weekly" )
6971
7072 data = {"image" : {"serverId" : base .getid (server ), "name" : name ,
71- "image_type" : image_type , "rotation" : rotation }}
73+ "image_type" : image_type , "backup_type" : backup_type ,
74+ "rotation" : rotation }}
7275 return self ._create ("/images" , data , "image" )
7376
7477 def delete (self , image ):
0 commit comments