def __connect_to_domain(model_context):
    """
    Connects WLST to the domain by either connecting to the Admin Server or reading the domain from disk.
    :param model_context: the model context
    :raises DiscoverException: if a WLST error occurs while connecting to or reading the domain
    """
    _method_name = '__connect_to_domain'

    __logger.entering(class_name=_class_name, method_name=_method_name)
    if __wlst_mode == WlstModes.ONLINE:
        try:
            wlst_helper.connect(model_context.get_admin_user(),
                                model_context.get_admin_password(),
                                model_context.get_admin_url())
        except PyWLSTException, wlst_ex:
            ex = exception_helper.create_discover_exception(
                'WLSDPLY-06001',
                model_context.get_admin_url(),
                model_context.get_admin_user(),
                wlst_ex.getLocalizedMessage(),
                error=wlst_ex)
            __logger.throwing(ex,
                              class_name=_class_name,
                              method_name=_method_name)
            raise ex
    def connect(self, admin_user, admin_pwd, admin_url):
        """
        Connects to the domain at the specified URL with the specified credentials.
        :raises: BundleAwareException of the specified type: if an error occurs
        """
        _method_name = 'connect'

        try:
            wlst_helper.connect(admin_user, admin_pwd, admin_url)
        except PyWLSTException, pwe:
            ex = exception_helper.create_exception(self.__exception_type, 'WLSDPLY-19127', admin_url, admin_user,
                                                   pwe.getLocalizedMessage(), error=pwe)
            self.__logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
            raise ex