Function in novaclient from where we call api
def search(self, hypervisor_match, servers=False): >>>>>>>>>>>>>>.servers is False by default
"""
Get a list of matching hypervisors.
:param servers: If True, server information is also retrieved.
"""
target = 'servers' if servers else 'search'
url = ('/os-hypervisors/%s/%s' % (parse.quote(hypervisor_match, safe=''), target)) >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.
return self._list(url, 'hypervisors')
we are passing servers as true in these cli commands.
Servers = True
==============================================
1.
do_host_meta(cs, args):
"""Set or Delete metadata on all instances of a host."""
hypervisors = cs.hypervisors.search(args.host, servers=True)
2.
@utils.arg(
'hostname',
metavar='<hostname>',
help=_('The hypervisor hostname (or pattern) to search for.')) def do_hypervisor_servers(cs, args):
"""List servers belonging to specific hypervisors."""
hypers = cs.hypervisors.search(args.hostname, servers=True)
3.
def do_host_evacuate(cs, args):
"""Evacuate all instances from failed host."""
4.
def do_host_evacuate_live(cs, args):
"""Live migrate all instances of the specified host
to other available hosts.
"""
hypervisors = cs.hypervisors.search(args.host, servers=True)
response = []
5.
def do_host_servers_migrate(cs, args):
"""Cold migrate all instances off the specified host to other available
hosts.
"""
hypervisors = cs.hypervisors.search(args.host, servers=True)
response = []
for hyper in hypervisors:
2)We should introduce a new parameter in servers api which from cli which directs that exact match is to be
done in url. http://10.141.67.190:8774/v2.1/os-hypervisors/wipro/servers?exact_match=true
and query parameter then interpreted in server side code and behave as desired.
In this case we will have choice to not affect at undesired commands.
Hello Matt,
Kindly see analysis below and suggest.
When we execute OptiPlex- 3020:~/ openstack_ install/ devstack$ nova --debug host-evacuate wipro . 10.141. 67.190: 8774/v2. 1/os-hypervisor s/wipro/ servers -H "OpenStack- API-Version: compute 2.46" -H "User-Agent: python-novaclient" -H "Accept: application/json" -H "X-OpenStack- Nova-API- Version: 2.46" -H "X-Auth-Token: {SHA1}9e9230a54 eff2444ac32fa05 4c6bab3dbe446df 9" >>>>>>> >>>>>>> >>>>>>> >>>>>
stack@ubuntu14-
.
.
DEBUG (session:347) REQ: curl -g -i -X GET http://
nova api that's being called is this /developer. openstack. org/api- ref/compute/ ?expanded= search- hypervisor- detail, list-hypervisor -servers- detail# list-hypervisor -servers
https:/
Where it clearly states: "List all servers belong to each hypervisor whose host name is matching a given hypervisor host name or portion of it."
Another available api for hostname match is https:/ /developer. openstack. org/api- ref/compute/ ?expanded= search- hypervisor- detail, list-hypervisor -servers- detail# search- hypervisor
which states: "Search hypervisor by a given hypervisor host name or portion of it."
There is no api available at present where hostname is matched not as a pattern. PCMIIW.
Hence it can't be just fixed in client as it is.
Solution: I thought we can fix it by changing only http:// 10.141. 67.190: 8774/v2. 1/os-hypervisor s/wipro/ servers api to match hostname as exact so that https:/ /developer. openstack. org/api- ref/compute/ ?expanded= search- hypervisor- detail, list-hypervisor -servers- detail# search- hypervisor remains unaffected.
This I still have to change in nova server code, I will use an additional function parameter to specify if exact match is desired or a pattern match is desired.
But then http:// 10.141. 67.190: 8774/v2. 1/os-hypervisor s/wipro/ servers is being used by many other commands than just host-evacuate.
Which all will be affected.
Listing commands that will be affected are .
Function in novaclient from where we call api >>>>>>> .servers is False by default rs/%s/% s' %
(parse. quote(hyperviso r_match, safe=''), target)) >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>.
def search(self, hypervisor_match, servers=False): >>>>>>>
"""
Get a list of matching hypervisors.
:param servers: If True, server information is also retrieved.
"""
target = 'servers' if servers else 'search'
url = ('/os-hyperviso
return self._list(url, 'hypervisors')
we are passing servers as true in these cli commands.
Servers = True ======= ======= ======= ======= ======= ==== search( args.host, servers=True)
=======
1.
do_host_meta(cs, args):
"""Set or Delete metadata on all instances of a host."""
hypervisors = cs.hypervisors.
2. '<hostname> ', servers( cs, args): search( args.hostname, servers=True)
@utils.arg(
'hostname',
metavar=
help=_('The hypervisor hostname (or pattern) to search for.')) def do_hypervisor_
"""List servers belonging to specific hypervisors."""
hypers = cs.hypervisors.
3. evacuate( cs, args):
def do_host_
"""Evacuate all instances from failed host."""
hypervisors = cs.hypervisors. search( args.host, servers=True)
4. evacuate_ live(cs, args): search( args.host, servers=True)
def do_host_
"""Live migrate all instances of the specified host
to other available hosts.
"""
hypervisors = cs.hypervisors.
response = []
5. servers_ migrate( cs, args):
def do_host_
"""Cold migrate all instances off the specified host to other available
hosts.
"""
hypervisors = cs.hypervisors. search( args.host, servers=True)
response = []
for hyper in hypervisors:
Servers = false list(cs, matching=None, limit=None, marker=None):
utils. print_list( cs.hypervisors. search( matching) , columns)
===============
1.
def _do_hypervisor_
columns = ['ID', 'Hypervisor hostname', 'State', 'Status']
if matching:
Please suggest what is better solution?
1)Modifying http:// 10.141. 67.190: 8774/v2. 1/os-hypervisor s/wipro/ servers api code in nova server side code - to match hostname as exact not as a pattern 10.141. 67.190: 8774/v2. 1/os-hypervisor s/wipro/ search remains unaffected.
We can code so that http://
2)We should introduce a new parameter in servers api which from cli which directs that exact match is to be 10.141. 67.190: 8774/v2. 1/os-hypervisor s/wipro/ servers? exact_match= true
done in url.
http://
and query parameter then interpreted in server side code and behave as desired.
In this case we will have choice to not affect at undesired commands.
Thanks
Nidhi