code: def connect(self, region, **kw_params):
          
          self.ec2 = boto.ec2.connect_to_region(region, **kw_params)
          if not self.ec2:
              raise EC2ManagerException('Unable to connect to region "%s"' % region)
          self.remote_images.clear()
  
          if self.images and any(('image_name' in img and 'image_id' not in img) for img in self.images.values()):
              for img in self.images.values():
                  if 'image_name' in img and 'image_id' not in img:
                      img['image_id'] = self.resolve_image_name(img.pop('image_name'))
docs: Connect to a EC2.
  
          :param region: The name of the region to connect to.
          :type region: str
          :param kw_params:
          :type kw_params: dict