@@ -120,25 +120,32 @@ async def resolved(self, retry=False):
120120 retry = retry ,
121121 tags = {'entities' : [{'tag' : self .tag }]})
122122
123- async def add_storage (self , storage_name , storage_constraint = "" ):
123+ async def add_storage (self , storage_name , pool = None , count = 1 , size = 1024 ):
124124 """Creates a storage and adds it to this unit.
125125
126126 :param: str storage_name: Name of the storage
127- :param: str storage_constraint: description of how Juju should provision storage instances for the unit.
128- The following three forms are accepted:
129- <storage-pool>[,<count>][,<size>]
130- <count>[,<size>]
131- <size>
127+ :param: str pool: the storage pool to provision storage instances from. Must
128+ be a name from 'juju storage-pools'. The default pool is available via
129+ executing 'juju model-config storage-default-block-source'.
130+ :param: int count: the number of storage instances to provision from <storage-pool> of
131+ <size>. Must be a positive integer. The default count is "1". May be restricted
132+ by the charm, which can specify a maximum number of storage instances per unit.
133+ :param: int size: the required size of the storage instance, in MiB.
132134
133135 :return:
134136 """
135- # TODO (cderici) : storage_constraints
137+ constraints = None
138+ if pool :
139+ constraints = client .StorageConstraints (pool = pool , count = count , size = size )
136140
137141 storage_facade = client .StorageFacade .from_connection (self .connection )
138- return await storage_facade .AddToUnit (storages = [client .StorageAddParams (
142+ res = await storage_facade .AddToUnit (storages = [client .StorageAddParams (
139143 name = storage_name ,
140144 unit = tag .unit (self .name ),
145+ storage = constraints ,
141146 )])
147+ import pdb ;pdb .set_trace ()
148+ return res
142149
143150 async def run (self , command , timeout = None ):
144151 """Run command on this unit.
0 commit comments