本文整理汇总了Python中vdsm.vdscli.connect函数的典型用法代码示例。如果您正苦于以下问题:Python connect函数的具体用法?Python connect怎么用?Python connect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了connect函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _boot_from_hd
def _boot_from_hd(self):
# Temporary attach cloud-init no-cloud iso if we have to
if (
self.environment[ohostedcons.VMEnv.BOOT] == 'disk' and
self.environment[ohostedcons.VMEnv.CDROM]
):
self.environment[
ohostedcons.VMEnv.SUBST
]['@[email protected]'] = self.environment[
ohostedcons.VMEnv.CDROM
]
created = False
while not created:
try:
self._create_vm()
created = True
except socket.error as e:
self.logger.debug(
'Error talking with VDSM (%s), reconnecting.' % str(e),
exc_info=True
)
cli = vdscli.connect(
timeout=ohostedcons.Const.VDSCLI_SSL_TIMEOUT
)
self.environment[ohostedcons.VDSMEnv.VDS_CLI] = cli
示例2: _setupVdsConnection
def _setupVdsConnection(self):
if self.hibernating:
return
hostPort = vdscli.cannonizeHostPort(
self._dst,
config.getint('addresses', 'management_port'))
self.remoteHost, port = hostPort.rsplit(':', 1)
try:
client = self._createClient(port)
requestQueues = config.get('addresses', 'request_queues')
requestQueue = requestQueues.split(",")[0]
self._destServer = jsonrpcvdscli.connect(requestQueue, client)
self.log.debug('Initiating connection with destination')
self._destServer.ping()
except (JsonRpcBindingsError, JsonRpcNoResponseError):
if config.getboolean('vars', 'ssl'):
self._destServer = vdscli.connect(
hostPort,
useSSL=True,
TransportClass=kaxmlrpclib.TcpkeepSafeTransport)
else:
self._destServer = kaxmlrpclib.Server('http://' + hostPort)
self.log.debug('Destination server is: ' + hostPort)
示例3: start
def start(self):
self.vdscli = vdscli.connect()
self.netinfo = self._get_netinfo()
if config.get('vars', 'net_persistence') == 'unified':
self.config = RunningConfig()
else:
self.config = None
示例4: _setupVdsConnection
def _setupVdsConnection(self):
if self.hibernating:
return
# FIXME: The port will depend on the binding being used.
# This assumes xmlrpc
hostPort = vdscli.cannonizeHostPort(
self._dst,
config.getint('addresses', 'management_port'))
self.remoteHost, _ = hostPort.rsplit(':', 1)
if config.getboolean('vars', 'ssl'):
self._destServer = vdscli.connect(
hostPort,
useSSL=True,
TransportClass=kaxmlrpclib.TcpkeepSafeTransport)
else:
self._destServer = kaxmlrpclib.Server('http://' + hostPort)
self.log.debug('Destination server is: ' + hostPort)
try:
self.log.debug('Initiating connection with destination')
status = self._destServer.getVmStats(self._vm.id)
if not status['status']['code']:
self.log.error("Machine already exists on the destination")
self.status = errCode['exist']
except Exception:
self.log.exception("Error initiating connection")
self.status = errCode['noConPeer']
示例5: get_domain_path
def get_domain_path(config_):
"""
Return path of storage domain holding engine vm
"""
vdsm = vdscli.connect()
sd_uuid = config_.get(config.ENGINE, config.SD_UUID)
dom_type = config_.get(config.ENGINE, config.DOMAIN_TYPE)
parent = constants.SD_MOUNT_PARENT
if dom_type == "glusterfs":
parent = os.path.join(parent, "glusterSD")
if dom_type.startswith("nfs"):
response = vdsm.getStorageDomainInfo(sd_uuid)
if response["status"]["code"] == 0:
try:
local_path = response["info"]["remotePath"].replace("/", "_")
path = os.path.join(parent, local_path, sd_uuid)
if os.access(path, os.F_OK):
return path
# don't have remotePath? so fallback to old logic
except KeyError:
pass
# fallback in case of getStorageDomainInfo call fails
# please note that this code will get stuck if some of
# the storage domains is not accessible rhbz#1140824
for dname in os.listdir(parent):
path = os.path.join(parent, dname, sd_uuid)
if os.access(path, os.F_OK):
return path
raise Exception("path to storage domain {0} not found in {1}".format(sd_uuid, parent))
示例6: get_fc_lun_tuple_list
def get_fc_lun_tuple_list(self):
# workaround for vdsm check before use vdscli:
if os.system("service vdsmd status|grep 'active (running)' &>/dev/null"):
os.system("service sanlock stop")
os.system("service libvirtd stop")
os.system("service supervdsmd stop")
os.system("vdsm-tool configure")
os.system("service vdsmd restart")
# workaround for imageio-daemon start success
os.system("service ovirt-imageio-daemon restart")
connecting = True
fc_lun_list = []
FC_DOMAIN = 2
while connecting:
try:
cli = vdscli.connect(timeout=900)
devices = cli.getDeviceList(FC_DOMAIN)
connecting = False
except socket_error as serr:
if serr.errno == errno.ECONNREFUSED:
time.sleep(2)
else:
raise serr
if devices['status']['code']:
raise RuntimeError(devices['status']['message'])
for device in devices['devList']:
device_info = "%s %sGiB\n%s %s status: %s" % (
device["GUID"], int(device['capacity']) / pow(2, 30),
device['vendorID'], device['productID'], device["status"],
)
fc_lun_list.append((device_info, None))
return fc_lun_list
示例7: _setupVdsConnection
def _setupVdsConnection(self):
if self._mode == 'file': return
self.remoteHost = self._dst.split(':')[0]
# FIXME: The port will depend on the binding being used.
# This assumes xmlrpc
self.remotePort = self._vm.cif.bindings['xmlrpc'].serverPort
try:
self.remotePort = self._dst.split(':')[1]
except:
pass
serverAddress = self.remoteHost + ':' + self.remotePort
if config.getboolean('vars', 'ssl'):
self.destServer = vdscli.connect(serverAddress, useSSL=True,
TransportClass=kaxmlrpclib.TcpkeepSafeTransport)
else:
self.destServer = kaxmlrpclib.Server('http://' + serverAddress)
self.log.debug('Destination server is: ' + serverAddress)
try:
self.log.debug('Initiating connection with destination')
status = self.destServer.getVmStats(self._vm.id)
if not status['status']['code']:
self.log.error("Machine already exists on the destination")
self.status = errCode['exist']
except:
self.log.error("Error initiating connection", exc_info=True)
self.status = errCode['noConPeer']
示例8: __init__
def __init__(self):
self.vdscli = vdscli.connect()
self.netinfo = \
netinfo.NetInfo(self.vdscli.getVdsCapabilities()['info'])
if config.get('vars', 'net_persistence') == 'unified':
self.config = RunningConfig()
else:
self.config = None
示例9: _connect_to_server
def _connect_to_server(host, port, use_ssl):
host_port = "%s:%s" % (host, port)
try:
return vdscli.connect(host_port, use_ssl)
except socket.error as e:
if e[0] == errno.ECONNREFUSED:
raise ConnectionRefusedError(
"Connection to %s refused" % (host_port,))
raise
示例10: __init__
def __init__(self):
super(XmlRpcVdsmInterface, self).__init__()
try:
self.vdsm_api = vdscli.connect()
response = self.vdsm_api.ping()
self._check_status(response)
except socket.error as e:
self.handle_connection_error(e)
except vdsmException, e:
e.handle_exception()
示例11: start
def start(self):
if _JSONRPC_ENABLED:
requestQueues = config.get('addresses', 'request_queues')
requestQueue = requestQueues.split(",")[0]
self.vdscli = jsonrpcvdscli.connect(requestQueue, xml_compat=False)
else:
self.vdscli = vdscli.connect()
self.netinfo = self._get_netinfo()
if config.get('vars', 'net_persistence') == 'unified':
self.config = RunningConfig()
else:
self.config = None
示例12: _misc
def _misc(self):
self.logger.info(_('Configuring the management bridge'))
conn = vdscli.connect()
networks = {
self.environment[ohostedcons.NetworkEnv.BRIDGE_NAME]:
vds_info.network(
vds_info.capabilities(conn),
self.environment[ohostedcons.NetworkEnv.BRIDGE_IF]
)
}
_setupNetworks(conn, networks, {}, {'connectivityCheck': False})
_setSafeNetworkConfig(conn)
示例13: setupclient
def setupclient(useSSL, tsPath,
timeout=sslutils.SOCKET_DEFAULT_TIMEOUT):
server = TestServer(useSSL, tsPath)
server.start()
hostPort = '0:' + str(server.port)
client = vdscli.connect(hostPort=hostPort,
useSSL=useSSL,
tsPath=tsPath,
timeout=timeout)
try:
yield client
finally:
server.stop()
示例14: get_fc_lun_tuple_list
def get_fc_lun_tuple_list(self):
cli = vdscli.connect(timeout=900)
fc_lun_list = []
FC_DOMAIN = 2
devices = cli.getDeviceList(FC_DOMAIN)
if devices['status']['code'] != 0:
raise RuntimeError(devices['status']['message'])
for device in devices['devList']:
device_info = "%s %sGiB\n%s %s status: %s" % (
device["GUID"], int(device['capacity']) / pow(2, 30),
device['vendorID'], device['productID'], device["status"],
)
fc_lun_list.append((device_info, None))
return fc_lun_list
示例15: _connect
def _connect(self):
cli = vdscli.connect(timeout=ohostedcons.Const.VDSCLI_SSL_TIMEOUT)
self.environment[ohostedcons.VDSMEnv.VDS_CLI] = cli
vdsmReady = False
retry = 0
while not vdsmReady and retry < self.MAX_RETRY:
retry += 1
try:
hwinfo = cli.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)