code: def login(self, registry, docker_secret_path):
          
          logger.info("logging in: registry '%s', secret path '%s'", registry, docker_secret_path)
          # Docker-py needs username
          dockercfg = Dockercfg(docker_secret_path)
          credentials = dockercfg.get_credentials(registry)
          unpacked_auth = dockercfg.unpack_auth_b64(registry)
          username = credentials.get('username')
          if unpacked_auth:
              username = unpacked_auth.username
          if not username:
              raise RuntimeError("Failed to extract a username from '%s'" % dockercfg)
  
          logger.info("found username %s for registry %s", username, registry)
  
          response = self.d.login(registry=registry, username=username,
                                  dockercfg_path=dockercfg.json_secret_path)
          if not response:
              raise RuntimeError("Failed to login to '%s' with config '%s'" % (registry, dockercfg))
          if u'Status' in response and response[u'Status'] == u'Login Succeeded':
              logger.info("login succeeded")
          else:
              if not(isinstance(response, dict) and 'password' in response.keys()):
                  # for some reason docker-py returns the contents of the dockercfg - we shouldn't
                  # be displaying that
                  logger.debug("response: %r", response)
docs: login to docker registry
  
          :param registry: registry name
          :param docker_secret_path: path to docker config directory