@@ -1526,8 +1526,7 @@ async def integrate(self, relation1, relation2):
15261526 remote_endpoint .source = current .controller_name
15271527 # consume the remote endpoint
15281528 await self .consume (remote_endpoint .string (),
1529- application_alias = remote_endpoint .application ,
1530- controller_name = remote_endpoint .source )
1529+ application_alias = remote_endpoint .application )
15311530
15321531 log .debug (
15331532 'Adding relation %s <-> %s' , endpoints [0 ], endpoints [1 ])
@@ -2535,7 +2534,15 @@ async def consume(self, endpoint, application_alias="", controller_name=None, co
25352534 """
25362535 Adds a remote offer to the model. Relations can be created later using
25372536 "juju relate".
2537+
2538+ If consuming a relation from a model on different controller the
2539+ controller name must be included in the endpoint. The controller_name
2540+ argument is being deprecated.
25382541 """
2542+ if controller_name :
2543+ log .warning (
2544+ 'controller_name argument will soon be deprecated, controller '
2545+ 'should be specified in endpoint url' )
25392546 if controller and controller_name :
25402547 raise JujuError ("cannot set both controller_name and controller" )
25412548 try :
@@ -2549,9 +2556,8 @@ async def consume(self, endpoint, application_alias="", controller_name=None, co
25492556 offer .user = self .info .username
25502557 endpoint = offer .string ()
25512558
2552- source = None
2553- if controller_name :
2554- source = await self ._get_source_api (offer , controller_name = controller_name )
2559+ if offer .source :
2560+ source = await self ._get_source_api (offer )
25552561 else :
25562562 if controller :
25572563 source = controller
@@ -2766,12 +2772,15 @@ async def revoke_secret(self, secret_name, application, *applications):
27662772 if result_error .error is not None :
27672773 raise JujuAPIError (result_error .error )
27682774
2769- async def _get_source_api (self , url , controller_name = None ):
2775+ async def _get_source_api (self , url ):
27702776 controller = Controller ()
27712777 if url .has_empty_source ():
27722778 async with ConnectedController (self .connection ()) as current :
27732779 if current .controller_name is not None :
27742780 controller_name = current .controller_name
2781+ else :
2782+ controller_name = url .source
2783+
27752784 await controller .connect (controller_name = controller_name )
27762785 return controller
27772786
0 commit comments