Question

I installed openstack. All services are running successfully.

[root@test ~]# nova-manage service list
Binary           Host                                 Zone             Status     State Updated_At
nova-cert        localhost.localdomain                nova             enabled    :-)   2012-11-06 04:25:36.396817
nova-scheduler   localhost.localdomain                nova             enabled    :-)   2012-11-06 04:25:41.735192
nova-network     compute                              nova             enabled    :-)   2012-11-06 04:25:42.109157
nova-compute     compute                              nova             enabled    :-)   2012-11-06 04:25:43.240902

After that I change HOSTNAME in /etc/sysconfig/network to myhost.mydomain. Then restart the services. Now I get the duplicate entry for the services.

[root@test ~]# nova-manage service list
Binary           Host                                 Zone             Status     State Updated_At
nova-cert        localhost.localdomain                nova             enabled    XXX   2012-11-06 04:25:36.396817
nova-cert        myhost.mydomain                      nova             enabled    :-)   2012-11-06 05:25:36.396817
nova-scheduler   localhost.localdomain                nova             enabled    XXX   2012-11-06 04:25:41.735192
nova-scheduler   myhost.mydomain                      nova             enabled    :-)   2012-11-06 05:25:41.735192
nova-network     compute                              nova             enabled    :-)   2012-11-06 04:25:42.109157
nova-compute     compute                              nova             enabled    :-)   2012-11-06 04:25:43.240902

From these services old services are not running.

I want to remove the services for host localhost.localdomain.

I check the nova-manage service --help but there is no option for the delete :(.

[root@test ~]# nova-manage service --help
--help does not match any options:
        describe_resource
        disable
        enable
        list
Was it helpful?

Solution

Looking at your example above, I suspect you're seeing a duplicate because you have two hosts with their hostnames set identically. If this is the case, the following code/answer isn't likely to help you out too much. There's an implicit assumption in that whole setup that hostnames of nodes upon which nova worker processes run will be unique.

In the latest branch, there isn't a command explicitly enabled for this, but the API exists underneath to do what you're after. Here's a snippet of code (untested!) that should do what you want; or at least point you to the relevant API if you're interested.

from nova import context
from nova import db

hostname = 'some_hostname'
service_name = 'nova_service_you_want_to_destroy'

ctxt = context.get_admin_context()
service = db.service_get_by_args(ctxt, hostname, service_name)
#... pick one of these services ... 
#... assign it to 'service'
db.service_destroy(ctxt, service[id])

NOTE: this will remove the service from the database, or raise an exception if it doesn't exist (or something else goes wrong). If the service is running, expect that it will just "show up" again, as the service list is populated by the various nova worker agents processes reporting in.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top