def __init__(self, ip, platform, login='******', password='******', prompt='->'):
        self.switch_type = platform
        self.switch_ip = ip.strip()
        if len(self.switch_ip) == 0:
            LOG.info("Init Error! Must provide a valid IP address!!!")
            return

        self.switch_login = login.strip()
        if len(self.switch_login) == 0:
            self.switch_login = '******'

        self.switch_password = password.strip()
        if len(self.switch_password) == 0:
            self.switch_password = '******'

        self.switch_prompt = prompt.strip()
        if len(self.switch_prompt) == 0:
            self.switch_prompt = '->'

        self.aosapi = AOSAPI(AOSConnection(
            self.switch_login,
            self.switch_password,
            self.switch_ip,
            True,
            True,
            True,
            -1,
            None,
            0,
            False))

        self.threadLock = threading.Lock()
        self._init_done = True
class OmniSwitchRestfulDriver(object):

    """Name:        OmniSwitchRestfulDriver.
    Description: OmniSwitch device driver to communicate with OS6900 and OS10K devices which support
                 RESTful interface.
    Details:     It is used by OmniSwitchDevicePluginV2 to perform the necessary configuration on the physical
                 switches as response to OpenStack networking APIs. This driver is used only for OS6900, OS10K
                 and OS6860 devices which support RESTful APIs to configure them. This driver requires the following
                 minimum version of AOS SW to be running on these devices...
                        OS10K  : 732-R01-GA
                        OS6900 : 733-R01-GA
                        OS6860 : 811-R01-GA
                 It uses the "consumer.py" library provided as a reference implementation from the AOS/OmniSwitch
                 point of view. No changes is made as part of OmniSwitch plug-in or driver development. For
                 latest version of consumer.py, refer "//depot/7.3.3.R01/sw/management/web/consumer/consumer.py".
                 For any issues/bugs with the library, please contact AOS 7x WebService module owner
                 (Chris Ravanscoft).
    """
    def __init__(self, ip, platform, login='******', password='******', prompt='->'):
        self.switch_type = platform
        self.switch_ip = ip.strip()
        if len(self.switch_ip) == 0:
            LOG.info("Init Error! Must provide a valid IP address!!!")
            return

        self.switch_login = login.strip()
        if len(self.switch_login) == 0:
            self.switch_login = '******'

        self.switch_password = password.strip()
        if len(self.switch_password) == 0:
            self.switch_password = '******'

        self.switch_prompt = prompt.strip()
        if len(self.switch_prompt) == 0:
            self.switch_prompt = '->'

        self.aosapi = AOSAPI(AOSConnection(
            self.switch_login,
            self.switch_password,
            self.switch_ip,
            True,
            True,
            True,
            -1,
            None,
            0,
            False))

        self.threadLock = threading.Lock()
        self._init_done = True

    def get_switch_type(self):
        return self.switch_type

    def get_ip(self):
        return self.switch_ip

    def connect(self):
        if not self._init_done:
            LOG.info("Driver is not initialized!!!")
            return False
        try:
            results = self.aosapi.login()
            if not self.aosapi.success():
                LOG.info("Login error %s: %s", self.switch_ip, results)
                return False
            else:
                return True
        except urllib2.HTTPError, e:
            self.aosapi.logout()
            LOG.info("Connect Error %s: %s", self.switch_ip, e)
            return False