[ovirt-users] Details of the host

Juan Hernández jhernand at redhat.com
Fri Jan 23 08:16:13 UTC 2015


On 01/21/2015 02:27 PM, ChandraShekar Shastri wrote:
> Hi All,
> 
> I want to get the details of the Host without activating is there a way
> to do it. 
> I want to query the RHEV-Manager and would like to get the details of
> MAC address without activating it. 
> 
> Do you have the script to do this.
> 
> Thanks,
> Chandrashekar 
> 

Assuming that the host has already been added to the system then you can
get the details with a Python script like this:

#!/usr/bin/python

from ovirtsdk.api import API
from ovirtsdk.xml import params

api = API(
  url='https://ovirt.example.com/ovirt-engine/api',
  username='admin at internal',
  password='******',
  insecure=True
)

host = api.hosts.get(name="myhost")
nics = host.nics.list()
for nic in nics:
    print("%s: %s" % (nic.get_name(), nic.get_mac().get_address()))

api.disconnect()

This will print something like this:

eth0: 52:54:00:9d:a7:26

If the host hasn't been added you can add it, without activating it:

#!/usr/bin/python

from ovirtsdk.api import API
from ovirtsdk.xml import params

api = API(
  url='https://rhevm35.example.com/ovirt-engine/api',
  username='admin at internal',
  password='******',
  insecure=True,
)

api.hosts.add(
  host = params.Host(
    name="myhost",
    address="myhost.example.com",
    root_password="******"
  )
)

api.disconnect()

-- 
Dirección Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta
3ºD, 28016 Madrid, Spain
Inscrita en el Reg. Mercantil de Madrid – C.I.F. B82657941 - Red Hat S.L.



More information about the Users mailing list