本文整理匯總了Python中ovirtsdk4.Connection方法的典型用法代碼示例。如果您正苦於以下問題:Python ovirtsdk4.Connection方法的具體用法?Python ovirtsdk4.Connection怎麽用?Python ovirtsdk4.Connection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ovirtsdk4
的用法示例。
在下文中一共展示了ovirtsdk4.Connection方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _connect_sdk
# 需要導入模塊: import ovirtsdk4 [as 別名]
# 或者: from ovirtsdk4 import Connection [as 別名]
def _connect_sdk(self, url, username, password, ca):
connection = sdk.Connection(
url=url,
username=username,
password=password,
ca_file=ca,
)
return connection
示例2: _connect_sdk
# 需要導入模塊: import ovirtsdk4 [as 別名]
# 或者: from ovirtsdk4 import Connection [as 別名]
def _connect_sdk(url, username, password, ca, log_):
connection = sdk.Connection(
url=url,
username=username,
password=password,
ca_file=ca,
debug=True,
log=log_,
)
return connection
示例3: _validate_connection
# 需要導入模塊: import ovirtsdk4 [as 別名]
# 或者: from ovirtsdk4 import Connection [as 別名]
def _validate_connection(self,
log,
url,
username,
password,
ca):
conn = None
try:
conn = self._connect_sdk(url,
username,
password,
ca)
dcs_service = conn.system_service().data_centers_service()
dcs_service.list()
except Exception as e:
msg = "Connection to setup has failed. " \
"Please check your cradentials: " \
"\n URL: " + url \
+ "\n USER: " + username \
+ "\n CA file: " + ca
log.error(msg)
print("%s%s%s%s" % (FAIL, PREFIX, msg, END))
log.error("Error: %s", e)
if conn:
conn.close()
return False
return True