def __init__(self, context):
     super(Plugin, self).__init__(context=context)
     self._interactive = False
     self.serv = None
     self.vdsClient = util.loadModule(
         path=ohostedcons.FileLocations.VDS_CLIENT_DIR,
         name='vdsClient'
     )
def run_vds_client_cmd(address, use_ssl, command, *args, **kwargs):
    """
    Run the passed in command name from the vdsClient library and either
    throw an exception with the error message or return the results.
    """
    # FIXME pass context to allow for shared or persistent vdsm connection
    log = logging.getLogger('SubmonitorUtil')
    log.debug("Connecting to vdsClient at %s with ssl=%r", address, use_ssl)
    vdsClient = util.loadModule(
        path=constants.VDS_CLIENT_DIR,
        name='vdsClient'
    )
    if vdsClient._glusterEnabled:
        serv = vdsClient.ge.GlusterService()
    else:
        serv = vdsClient.service()
    serv.useSSL = use_ssl

    if hasattr(vdscli, 'cannonizeAddrPort'):
        server, server_port = vdscli.cannonizeAddrPort(
            address
        ).split(':', 1)
        serv.do_connect(server, server_port)
    else:
        host_port = vdscli.cannonizeHostPort(address)
        serv.do_connect(host_port)

    log.debug("Connected, running %s, args %r, kwargs %r",
              command, args, kwargs)

    method = getattr(serv.s, command)
    retry = 0
    response = None
    new_args = list(args)
    # Add keyword args to argument list as a dict for vds api compatibility
    if kwargs:
        new_args.append(kwargs)
    while retry < constants.VDS_CLIENT_MAX_RETRY:
        try:
            response = method(*new_args)
            break
        except socket.error:
            log.debug("Error", exc_info=True)
            retry += 1
            time.sleep(1)

    log.debug("Response: %r", response)
    if retry >= constants.VDS_CLIENT_MAX_RETRY:
        raise Exception("VDSM initialization timeout")
    if response and response['status']['code'] != 0:
        raise DetailedError("Error {0} from {1}: {2}"
                            .format(response['status']['code'],
                                    command,
                                    response['status']['message']),
                            response['status']['message'])
    return response
 def __init__(self, context):
     super(Plugin, self).__init__(context=context)
     self.vdsClient = util.loadModule(
         path=ohostedcons.FileLocations.VDS_CLIENT_DIR,
         name='vdsClient'
     )
     self.serv = None
     self.waiter = None
     self.storageType = None
     self.protocol_version = None
     self.domain_exists = False
     self.pool_exists = False
     self._connected = False
     self._monitoring = False
示例#4
0
 def _getSupportedClusterLevels(self):
     self.logger.debug('Attempting to load the dsaversion vdsm module')
     savedPath = sys.path
     vSupportedClusterLevels = []
     raw_version_revision = ''
     try:
         sys.path.append(oenginecons.FileLocations.AIO_VDSM_PATH)
         dsaversion = util.loadModule(
             path=oenginecons.FileLocations.AIO_VDSM_PATH,
             name='dsaversion',
         )
         vSupportedClusterLevels = dsaversion.version_info['clusterLevels']
         raw_version_revision = dsaversion.raw_version_revision
     finally:
         sys.path = savedPath
     return vSupportedClusterLevels, raw_version_revision
示例#5
0
 def _getSupportedClusterLevels(self):
     self.logger.debug('Attempting to load the dsaversion vdsm module')
     savedPath = sys.path
     vSupportedClusterLevels = []
     raw_version_revision = ''
     try:
         sys.path.append(oenginecons.FileLocations.AIO_VDSM_PATH)
         dsaversion = util.loadModule(
             path=oenginecons.FileLocations.AIO_VDSM_PATH,
             name='dsaversion',
         )
         vSupportedClusterLevels = dsaversion.version_info['clusterLevels']
         raw_version_revision = dsaversion.raw_version_revision
     finally:
         sys.path = savedPath
     return vSupportedClusterLevels, raw_version_revision
示例#6
0
文件: cpu.py 项目: jtux270/translate
 def _getCompatibleCpuModels(self):
     self.logger.debug('Attempting to load the caps vdsm module')
     savedPath = sys.path
     ret = None
     try:
         sys.path.append(oenginecons.FileLocations.AIO_VDSM_PATH)
         caps = util.loadModule(
             path=oenginecons.FileLocations.AIO_VDSM_PATH,
             name='caps',
         )
         ret = (
             caps.CpuInfo().model(),
             caps._getCompatibleCpuModels(),
         )
     finally:
         sys.path = savedPath
     return ret
示例#7
0
 def _getCompatibleCpuModels(self):
     self.logger.debug('Attempting to load the caps vdsm module')
     savedPath = sys.path
     ret = None
     try:
         sys.path.append(ohostedcons.FileLocations.VDS_CLIENT_DIR)
         caps = util.loadModule(
             path=ohostedcons.FileLocations.VDS_CLIENT_DIR,
             name='caps',
         )
         ret = (
             caps.CpuInfo().model(),
             caps._getCompatibleCpuModels(),
         )
     finally:
         sys.path = savedPath
     return ret
    def _connect(self):
        vdsClient = util.loadModule(
            path=ohostedcons.FileLocations.VDS_CLIENT_DIR,
            name='vdsClient'
        )
        serv = None
        if vdsClient._glusterEnabled:
            serv = vdsClient.ge.GlusterService()
        else:
            serv = vdsClient.service()
        serv.useSSL = self.environment[ohostedcons.VDSMEnv.USE_SSL]
        if hasattr(vdscli, 'cannonizeAddrPort'):
            server, serverPort = vdscli.cannonizeAddrPort(
                'localhost'
            ).split(':', 1)
            serv.do_connect(server, serverPort)
        else:
            hostPort = vdscli.cannonizeHostPort('localhost')
            serv.do_connect(hostPort)

        self.environment[ohostedcons.VDSMEnv.VDS_CLI] = serv
        vdsmReady = False
        retry = 0
        while not vdsmReady and retry < self.MAX_RETRY:
            retry += 1
            try:
                hwinfo = serv.s.getVdsHardwareInfo()
                self.logger.debug(str(hwinfo))
                if hwinfo['status']['code'] == 0:
                    vdsmReady = True
                else:
                    self.logger.info(_('Waiting for VDSM hardware info'))
                    time.sleep(1)
            except socket.error:
                self.logger.info(_('Waiting for VDSM hardware info'))
                time.sleep(1)