-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathadd_label.py
More file actions
executable file
·30 lines (22 loc) · 797 Bytes
/
Copy pathadd_label.py
File metadata and controls
executable file
·30 lines (22 loc) · 797 Bytes
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
#! /usr/bin/python
from ovirtsdk.api import API
from ovirtsdk.xml import params
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'
HOST_NAME = 'rhevh1'
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:
host = api.hosts.get(HOST_NAME)
for nic in host.nics.list():
print nic.name
nic.labels.add(params.Label(id=nic.name))
host.nics.get('eth1').labels.add(params.Label(id='Test'))
except Exception as err:
print "Add Label failed: %s" % err