# Path: networking_vsphere/_i18n.py
# _LE = _translators.log_error


import time
from networking_vsphere._i18n import _LE
from oslo_log import log
from oslo_vmware import api
from oslo_vmware import vim

    @classmethod
    def create_connection(cls):
        cls.session = VMWareAPISession(cls.host_ip,
                                       cls.host_username,
                                       cls.host_password,
                                       cls.api_retry_count,
                                       cls.wsdl_url,
                                       scheme=cls.scheme,
                                       https_port=cls.https_port,
                                       create_session=cls.create_session,
                                       ca_cert=cls.ca_cert)
        return cls.session

    @classmethod
    def get_connection(cls, create=False):
        if not cls.session and create:
            return cls.create_connection()
        else:
            return cls.session

    @classmethod
    def try_connection(cls):
        while not cls.stopped:
            try:
                return cls.get_connection(create=True)
            except Exception as e:
                LOG.error(_LE("Connection to vCenter %(host_ip)s failed -"
                              "%(exception)s"), {"host_ip": cls.host_ip,
                                                 "exception": e})

# Path: networking_vsphere/_i18n.py
# _LE = _translators.log_error


# Path: networking_vsphere/utils/vim_session.py
import time
from networking_vsphere._i18n import _LE
from oslo_log import log
from oslo_vmware import api
from oslo_vmware import vim


    @classmethod
    def create_connection(cls):
        cls.session = VMWareAPISession(cls.host_ip,
                                       cls.host_username,
                                       cls.host_password,
                                       cls.api_retry_count,
                                       cls.wsdl_url,
                                       scheme=cls.scheme,
                                       https_port=cls.https_port,
                                       create_session=cls.create_session,
                                       ca_cert=cls.ca_cert)
        return cls.session

    @classmethod
    def get_connection(cls, create=False):
        if not cls.session and create:
            return cls.create_connection()
        else:
            return cls.session

    @classmethod
    def try_connection(cls):
        while not cls.stopped:
            try:
                return cls.get_connection(create=True)
            except Exception as e:
                LOG.error(_LE("Connection to vCenter %(host_ip)s failed -"
                              "%(exception)s"), {"host_ip": cls.host_ip,
                                                 "exception": e})

                LOG.error(_LE("Will retry after 60 secs"))