本文整理汇总了Python中pyvcloud.vcloudair.VCA.logout方法的典型用法代码示例。如果您正苦于以下问题:Python VCA.logout方法的具体用法?Python VCA.logout怎么用?Python VCA.logout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyvcloud.vcloudair.VCA
的用法示例。
在下文中一共展示了VCA.logout方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from pyvcloud.vcloudair import VCA [as 别名]
# 或者: from pyvcloud.vcloudair.VCA import logout [as 别名]
class TestVCASSO:
def __init__(self):
self.vca = None
self.instance = None
self.login_to_vcloud()
def login_to_vcloud(self):
"""Login to vCloud VCA"""
username = config["vcloud"]["username"]
password = config["vcloud"]["password"]
host = config["vcloud"]["host"]
version = config["vcloud"]["version"]
self.instance = config["vcloud"]["instance"]
self.vca = VCA(host=host, username=username, service_type="vca", version=version, verify=True, log=True)
assert self.vca
result = self.vca.login(password=password)
assert result
def logout_from_vcloud(self):
"""Logout from vCloud"""
print "logout"
self.vca.logout()
self.vca = None
assert self.vca is None
def test_0001(self):
"""Loggin in to vCloud"""
assert self.vca.token
def test_002(self):
"""Login to instance no password"""
result = self.vca.login_to_instance_sso(instance=self.instance)
assert result
示例2: __init__
# 需要导入模块: from pyvcloud.vcloudair import VCA [as 别名]
# 或者: from pyvcloud.vcloudair.VCA import logout [as 别名]
class TestVCAUser:
def __init__(self):
self.vca = None
self.instance = None
self.login_to_vcloud()
def login_to_vcloud(self):
"""Login to vCloud VCA"""
username = config['vcloud']['username']
password = config['vcloud']['password']
host = config['vcloud']['host']
version = config['vcloud']['version']
self.instance = config['vcloud']['instance']
self.vca = VCA(host=host, username=username, service_type='vca', version=version, verify=True, log=True)
assert self.vca
result = self.vca.login(password=password)
assert result
def logout_from_vcloud(self):
"""Logout from vCloud"""
print 'logout'
self.vca.logout()
self.vca = None
assert self.vca is None
def test_0001(self):
"""Loggin in to vCloud"""
assert self.vca.token
def test_002(self):
"""Get Users"""
result = self.vca.get_users()
assert result
print str(result)
示例3: __init__
# 需要导入模块: from pyvcloud.vcloudair import VCA [as 别名]
# 或者: from pyvcloud.vcloudair.VCA import logout [as 别名]
#.........这里部分代码省略.........
self.vca.token, self.vca.org))
org_url = None if self.vca.vcloud_session is None else \
self.vca.vcloud_session.org_url
result = self.vca.login(token=self.vca.token,
org=self.vca.org,
org_url=org_url)
if result:
Log.debug(self.logger, 'vca.login with token successful')
self.re_login_vcloud_session()
else:
Log.debug(self.logger, 'vca.login with token failed %s' %
self.vca.response.content)
raise Exception('login with token failed')
except Exception as e:
Log.error(self.logger, str(e))
tb = traceback.format_exc()
Log.error(self.logger, tb)
if self.password is not None and len(self.password) > 0:
try:
Log.debug(self.logger, 'about to re-login with password')
result = self.vca.login(password=self.password,
org=self.vca.org)
if result:
Log.debug(self.logger,
'about to re-login vcloud_session')
self.re_login_vcloud_session()
Log.debug(self.logger,
'after re-login vcloud_session')
self.save_config(self.profile, self.profile_file)
except Exception:
return False
return result
def logout(self):
assert self.vca is not None
self.vca.logout()
self.vca = None
self.password = None
self.instance = None
self.host = None
self.service_type = None
self.version = None
self.session_uri = None
self.host_score = None
self.save_config(self.profile, self.profile_file)
def org_to_table(self, vca):
links = (vca.vcloud_session.organization.Link if
vca.vcloud_session.organization else [])
org_name = (vca.vcloud_session.organization.name if
vca.vcloud_session.organization else [])
org_id = (vca.vcloud_session.organization.id if
vca.vcloud_session.organization else [])
table = [[details.get_type().split('.')[-1].split('+')[0],
details.get_name()] for details in
filter(lambda info: info.name, links)]
table.append(['Org Id', org_id[org_id.rfind(':') + 1:]])
table.append(['Org Name', org_name])
sorted_table = sorted(
table, key=operator.itemgetter(0), reverse=False)
return sorted_table
def vdc_to_table(self, vdc, gateways):
table = []
for entity in vdc.get_ResourceEntities().ResourceEntity:
table.append([entity.type_.split('.')[-1].split('+')[0],
示例4: __init__
# 需要导入模块: from pyvcloud.vcloudair import VCA [as 别名]
# 或者: from pyvcloud.vcloudair.VCA import logout [as 别名]
class TestVCloud:
def __init__(self):
self.vca = None
self.login_to_vcloud()
def login_to_vcloud(self):
"""Login to vCloud"""
username = config['vcloud']['username']
password = config['vcloud']['password']
service_type = config['vcloud']['service_type']
host = config['vcloud']['host']
version = config['vcloud']['version']
org = config['vcloud']['org']
service = config['vcloud']['service']
instance = config['vcloud']['instance']
self.vca = VCA(host=host, username=username, service_type=service_type, version=version, verify=True, log=True)
assert self.vca
if vcloudair.VCA_SERVICE_TYPE_STANDALONE == service_type:
result = self.vca.login(password=password, org=org)
assert result
result = self.vca.login(token=self.vca.token, org=org, org_url=self.vca.vcloud_session.org_url)
assert result
elif vcloudair.VCA_SERVICE_TYPE_SUBSCRIPTION == service_type:
result = self.vca.login(password=password)
assert result
result = self.vca.login(token=self.vca.token)
assert result
result = self.vca.login_to_org(service, org)
assert result
elif vcloudair.VCA_SERVICE_TYPE_ONDEMAND == service_type:
result = self.vca.login(password=password)
assert result
result = self.vca.login_to_instance(password=password, instance=instance, token=None, org_url=None)
assert result
result = self.vca.login_to_instance(password=None, instance=instance, token=self.vca.vcloud_session.token, org_url=self.vca.vcloud_session.org_url)
assert result
def logout_from_vcloud(self):
"""Logout from vCloud"""
print 'logout'
self.vca.logout()
self.vca = None
assert self.vca is None
def test_0001(self):
"""Loggin in to vCloud"""
assert self.vca.token
def test_0002(self):
"""Get VDC"""
vdc_name = config['vcloud']['vdc']
the_vdc = self.vca.get_vdc(vdc_name)
assert the_vdc
assert the_vdc.get_name() == vdc_name
def test_0003(self):
"""Create vApp"""
vdc_name = config['vcloud']['vdc']
vapp_name = config['vcloud']['vapp']
vm_name = config['vcloud']['vm']
catalog = config['vcloud']['catalog']
template = config['vcloud']['template']
network = config['vcloud']['network']
mode = config['vcloud']['mode']
the_vdc = self.vca.get_vdc(vdc_name)
assert the_vdc
assert the_vdc.get_name() == vdc_name
task = self.vca.create_vapp(vdc_name, vapp_name, template, catalog, vm_name=vm_name)
assert task
result = self.vca.block_until_completed(task)
assert result
the_vdc = self.vca.get_vdc(vdc_name)
the_vapp = self.vca.get_vapp(the_vdc, vapp_name)
assert the_vapp
assert the_vapp.name == vapp_name
def test_0004(self):
"""Disconnect vApp from pre-defined networks"""
vdc_name = config['vcloud']['vdc']
vapp_name = config['vcloud']['vapp']
the_vdc = self.vca.get_vdc(vdc_name)
assert the_vdc
assert the_vdc.get_name() == vdc_name
the_vapp = self.vca.get_vapp(the_vdc, vapp_name)
assert the_vapp
assert the_vapp.name == vapp_name
task = the_vapp.disconnect_from_networks()
assert task
result = self.vca.block_until_completed(task)
assert result
def test_0005(self):
"""Connect vApp to network"""
vdc_name = config['vcloud']['vdc']
vapp_name = config['vcloud']['vapp']
vm_name = config['vcloud']['vm']
network = config['vcloud']['network']
mode = config['vcloud']['mode']
the_vdc = self.vca.get_vdc(vdc_name)
#.........这里部分代码省略.........