@@ -1670,7 +1670,7 @@ async def deploy(
16701670 self , entity_url , application_name = None , bind = None ,
16711671 channel = None , config = None , constraints = None , force = False ,
16721672 num_units = 1 , overlays = [], plan = None , resources = None , series = None ,
1673- storage = None , to = None , devices = None , trust = False ):
1673+ storage = None , to = None , devices = None , trust = False , attach_storage = [] ):
16741674 """Deploy a new service or bundle.
16751675
16761676 :param str entity_url: Charm or bundle url
@@ -1700,6 +1700,8 @@ async def deploy(
17001700 with access to trusted credentials. Hooks run by the charm can access
17011701 cloud credentials and other trusted access credentials.
17021702
1703+ :param str[] attach_storage: Existing storage to attach to the deployed unit
1704+ (not available on k8s models)
17031705 TODO::
17041706
17051707 - support local file resources
@@ -1713,6 +1715,9 @@ async def deploy(
17131715 if trust and (self .info .agent_version < client .Number .from_json ('2.4.0' )):
17141716 raise NotImplementedError ("trusted is not supported on model version {}" .format (self .info .agent_version ))
17151717
1718+ if not all ([type (st ) == str for st in attach_storage ]):
1719+ raise JujuError ("Expected attach_storage to be a list of strings, given {}" .format (attach_storage ))
1720+
17161721 # Ensure what we pass in, is a string.
17171722 entity_url = str (entity_url )
17181723 if is_local_charm (entity_url ) and not entity_url .startswith ("local:" ):
@@ -1820,7 +1825,8 @@ async def deploy(
18201825 num_units = num_units ,
18211826 placement = parse_placement (to ),
18221827 devices = devices ,
1823- charm_origin = charm_origin
1828+ charm_origin = charm_origin ,
1829+ attach_storage = attach_storage ,
18241830 )
18251831
18261832 async def _add_charm (self , charm_url , origin ):
@@ -2037,7 +2043,7 @@ async def add_local_resources(self, application, entity_url, metadata, resources
20372043 async def _deploy (self , charm_url , application , series , config ,
20382044 constraints , endpoint_bindings , resources , storage ,
20392045 channel = None , num_units = None , placement = None ,
2040- devices = None , charm_origin = None ):
2046+ devices = None , charm_origin = None , attach_storage = [] ):
20412047 """Logic shared between `Model.deploy` and `BundleHandler.deploy`.
20422048 """
20432049 log .info ('Deploying %s' , charm_url )
@@ -2064,6 +2070,7 @@ async def _deploy(self, charm_url, application, series, config,
20642070 storage = storage ,
20652071 placement = placement ,
20662072 devices = devices ,
2073+ attach_storage = attach_storage ,
20672074 )
20682075 result = await app_facade .Deploy (applications = [app ])
20692076 errors = [r .error .message for r in result .results if r .error ]
0 commit comments