-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathadd_host.py
More file actions
executable file
·40 lines (33 loc) · 1.14 KB
/
Copy pathadd_host.py
File metadata and controls
executable file
·40 lines (33 loc) · 1.14 KB
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
#! /usr/bin/python
from ovirtsdk.api import API
from ovirtsdk.xml import params
import time
VERSION = params.Version(major='3', minor='5')
URL = 'https://rhevm.example.com/ovirt-engine/api'
CA = '/etc/pki/ovirt-engine/ca.pem'
USERNAME = 'admin@internal'
PASSWORD = 'paSSwoRD'
DC_NAME = 'Default'
CLUSTER_NAME = 'Default'
HOST_NAME = 'rhevh1'
#
HOST_NAME = 'rhevh1'
HOST_ADDRESS = '192.168.100.11'
ROOT_PASSWORD = 'superSecret'
try:
api = API(url=URL, username=USERNAME, password=PASSWORD, ca_file=CA)
print "Connected to %s successfully!" % api.get_product_info().name
except Exception as err:
print "Connection failed: %s" % err
try:
if api.hosts.add(params.Host(name=HOST_NAME,
address=HOST_ADDRESS,
cluster=api.clusters.get(CLUSTER_NAME),
root_password=ROOT_PASSWORD)):
print 'Host was added successfully'
print 'Waiting for host to install and reach the Up status'
while api.hosts.get(HOST_NAME).status.state != 'up':
time.sleep(1)
print "Host is up"
except Exception as e:
print 'Failed to install Host:\n%s' % str(e)