-
Notifications
You must be signed in to change notification settings - Fork 2
/
test_api.py
52 lines (40 loc) · 1.23 KB
/
test_api.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from __future__ import print_function
import sys
import os
from time import sleep
from progress.spinner import Spinner
from functions_ovirt import connect, read_config
path = os.path.dirname(os.path.abspath(__file__))
config = read_config(file_config=path + '/config.yml')
manager = config['manager']
url_manager = 'https://' + manager
username = 'admin@internal'
password = 'S0p0rt32015.'
api = connect(url_manager,password,username)
clusters = api.clusters.list()
hosts = api.hosts.list()
#for data_center in data_centers:
# print("DataCenter Name: %s Status: %s" % (data_center.name, data_center.get_status().get_state()))
for cluster in clusters:
print("Cluster Name: %s " % (cluster.name))
def spm_status(host):
if host.storage_manager.valueOf_ == 'true':
return 1
else:
return 0
spinner = Spinner("Waiting ")
terminate = 0
while terminate != '1':
data_centers = api.datacenters.list()
count = 0
for data_center in data_centers:
if data_center.get_status().get_state() == 'up':
count += 1
if count == len(data_centers):
terminate = 1
if terminate == 1:
break
spinner.next()
sys.stdout.flush()
api.disconnect()
print("\nFinished...")