def _await_instance_rest_enabled(self):
     services_director = self._get_services_director()
     url = "%s/instance/%s/tm/3.5" % (
         services_director.connectivity_test_url,
         self.properties["hostname"]
     )
     vtm = vTM(url, self.config["username"], self.config["password"])
     for counter in xrange(15):
         try:
             if not vtm.test_connectivity():
                 raise Exception("")
             return vtm
         except Exception:
             pass
         sleep(10)
     raise Exception("Timeout waiting for vTM instance to become available")
 def __init__(self, plugin):
     self.openstack_connector = OpenStackInterface()
     # Build a list of all vTMs in the cluster
     self.vtms = [
         vTM(
             "https://%s:%s/api/tm/%s"
             % (server, cfg.CONF.vtm_settings.rest_port, cfg.CONF.vtm_settings.api_version),
             cfg.CONF.vtm_settings.username,
             cfg.CONF.vtm_settings.password,
         )
         for server in cfg.CONF.lbaas_settings.admin_servers
     ]
     LOG.error(
         _(
             "\nShared Brocade vTM LBaaS module initialized with %s " % len(self.vtms)
             + "cluster members.\nPlease restart the Neutron "
             "server if you manually add/remove any vTMs from the cluster."
         )
     )
 def _get_vtm(self, server_id):
     """
     Gets available instance of Brocade vTM from a Services Director.
     """
     services_director = self._get_services_director()
     url = "%s/instance/%s/tm/3.5" % (
         services_director.instance_url,
         server_id
     )
     for i in xrange(5):
         vtm = vTM(url, self.config["username"], self.config["password"],
                   connectivity_test_url="%s/instance/%s/tm/3.5" % (
                       services_director.connectivity_test_url, server_id
                   )
         )
         try:
             if not vtm.test_connectivity():
                 raise Exception("")
             return vtm
         except:
             pass
         sleep(i)
     raise Exception("Could not contact vTM instance '%s'" % server_id)