code: async def connect_model(self, model_name=None):
          
  
          try:
              controller_name, model_name = self.jujudata.parse_model(model_name)
              controller = self.jujudata.controllers().get(controller_name)
          except JujuError as e:
              raise JujuConnectionError(e.message) from e
          if controller is None:
              raise JujuConnectionError('Controller {} not found'.format(
                  controller_name))
          # TODO change Connection so we can pass all the endpoints
          # instead of just the first one.
          endpoint = controller['api-endpoints'][0]
          account = self.jujudata.accounts().get(controller_name, {})
          models = self.jujudata.models().get(controller_name, {}).get('models',
                                                                       {})
          if model_name not in models:
              raise JujuConnectionError('Model not found: {}'.format(model_name))
  
          # TODO if there's no record for the required model name, connect
          # to the controller to find out the model's uuid, then connect
          # to that. This will let connect_model work with models that
          # haven't necessarily synced with the local juju data,
          # and also remove the need for base.CleanModel to
          # subclass JujuData.
          await self.connect(
              endpoint=endpoint,
              uuid=models[model_name]['uuid'],
              username=account.get('user'),
              password=account.get('password'),
              cacert=controller.get('ca-cert'),
              bakery_client=self.bakery_client_for_controller(controller_name),
          )
          self.controller_name = controller_name
          self.model_name = controller_name + ':' + model_name
docs: Connect to a model by name. If either controller or model
          parts of the name are empty, the current controller and/or model
          will be used.
  
          :param str model: <controller>:<model>