Remove brackets from Service.GREP variables
This patch makes content of GREP variables more readable and clear. Also it helps to protect users/developers from missing brackets in GREP variables. * Use `grep -v grep` to to filter grep from ps output. Change-Id: I8455a347912d853b5245e654781f8f117d340298
This commit is contained in:
parent
3ddf8dda85
commit
7eb1f4a038
@ -28,6 +28,7 @@ def main():
|
||||
cmd = ('bash -c "tf=$(mktemp /tmp/script.XXXXXX);'
|
||||
'echo -n \'#!\' > $tf; '
|
||||
'echo -en \'/bin/bash\\npids=`ps ax | '
|
||||
'grep -v grep | '
|
||||
'grep %s | awk {{\\047print $1\\047}}`; '
|
||||
'echo $pids | xargs kill -19; sleep %s; '
|
||||
'echo $pids | xargs kill -18; rm \' >> $tf; '
|
||||
|
@ -25,7 +25,7 @@ def main():
|
||||
grep = module.params['grep']
|
||||
sig = module.params['sig']
|
||||
|
||||
cmd = ('bash -c "ps ax | grep \'%s\' | awk {\'print $1\'} '
|
||||
cmd = ('bash -c "ps ax | grep -v grep | grep \'%s\' | awk {\'print $1\'} '
|
||||
'| xargs kill -%s"') % (grep, sig)
|
||||
rc, stdout, stderr = module.run_command(cmd, check_rc=True)
|
||||
module.exit_json(cmd=cmd, rc=rc, stderr=stderr, stdout=stdout)
|
||||
|
@ -47,7 +47,7 @@ class ServiceAsProcess(service.Service):
|
||||
def get_nodes(self):
|
||||
nodes = self.cloud_management.get_nodes()
|
||||
ips = nodes.get_ips()
|
||||
cmd = 'bash -c "ps ax | grep \'{}\'"'.format(self.GREP)
|
||||
cmd = 'bash -c "ps ax | grep -v grep | grep \'{}\'"'.format(self.GREP)
|
||||
results = self.cloud_management.execute_on_cloud(
|
||||
ips, {'command': cmd}, False)
|
||||
success_ips = [r.host for r in results
|
||||
|
@ -59,7 +59,7 @@ class ServiceInScreen(service.ServiceAsProcess):
|
||||
|
||||
class KeystoneService(service.ServiceAsProcess):
|
||||
SERVICE_NAME = 'keystone'
|
||||
GREP = '[k]eystone-'
|
||||
GREP = 'keystone-'
|
||||
RESTART_CMD = 'sudo service apache2 restart'
|
||||
TERMINATE_CMD = 'sudo service apache2 stop'
|
||||
START_CMD = 'sudo service apache2 start'
|
||||
@ -67,7 +67,7 @@ class KeystoneService(service.ServiceAsProcess):
|
||||
|
||||
class MySQLService(service.ServiceAsProcess):
|
||||
SERVICE_NAME = 'mysql'
|
||||
GREP = '[m]ysqld'
|
||||
GREP = 'mysqld'
|
||||
RESTART_CMD = 'sudo service mysql restart'
|
||||
TERMINATE_CMD = 'sudo service mysql stop'
|
||||
START_CMD = 'sudo service mysql start'
|
||||
@ -76,7 +76,7 @@ class MySQLService(service.ServiceAsProcess):
|
||||
|
||||
class RabbitMQService(service.ServiceAsProcess):
|
||||
SERVICE_NAME = 'rabbitmq'
|
||||
GREP = '[r]abbitmq-server'
|
||||
GREP = 'rabbitmq-server'
|
||||
RESTART_CMD = 'sudo service rabbitmq-server restart'
|
||||
TERMINATE_CMD = 'sudo service rabbitmq-server stop'
|
||||
START_CMD = 'sudo service rabbitmq-server start'
|
||||
@ -84,37 +84,37 @@ class RabbitMQService(service.ServiceAsProcess):
|
||||
|
||||
class NovaAPIService(ServiceInScreen):
|
||||
SERVICE_NAME = 'nova-api'
|
||||
GREP = '[n]ova-api'
|
||||
GREP = 'nova-api'
|
||||
WINDOW_NAME = 'n-api'
|
||||
|
||||
|
||||
class GlanceAPIService(ServiceInScreen):
|
||||
SERVICE_NAME = 'glance-api'
|
||||
GREP = '[g]lance-api'
|
||||
GREP = 'glance-api'
|
||||
WINDOW_NAME = 'g-api'
|
||||
|
||||
|
||||
class NovaComputeService(ServiceInScreen):
|
||||
SERVICE_NAME = 'nova-compute'
|
||||
GREP = '[n]ova-compute'
|
||||
GREP = 'nova-compute'
|
||||
WINDOW_NAME = 'n-cpu'
|
||||
|
||||
|
||||
class NovaSchedulerService(ServiceInScreen):
|
||||
SERVICE_NAME = 'nova-scheduler'
|
||||
GREP = '[n]ova-scheduler'
|
||||
GREP = 'nova-scheduler'
|
||||
WINDOW_NAME = 'n-sch'
|
||||
|
||||
|
||||
class IronicApiService(ServiceInScreen):
|
||||
SERVICE_NAME = 'ironic-api'
|
||||
GREP = '[i]ronic-api'
|
||||
GREP = 'ironic-api'
|
||||
WINDOW_NAME = 'ir-api'
|
||||
|
||||
|
||||
class IronicConductorService(ServiceInScreen):
|
||||
SERVICE_NAME = 'ironic-conductor'
|
||||
GREP = '[i]ronic-conductor'
|
||||
GREP = 'ironic-conductor'
|
||||
WINDOW_NAME = 'ir-cond'
|
||||
|
||||
|
||||
|
@ -86,257 +86,257 @@ class PcsOrLinuxService(service.ServiceAsProcess):
|
||||
|
||||
class KeystoneService(service.LinuxService):
|
||||
SERVICE_NAME = 'keystone'
|
||||
GREP = '[k]eystone'
|
||||
GREP = 'keystone'
|
||||
LINUX_SERVICE = 'apache2'
|
||||
|
||||
|
||||
class HorizonService(service.LinuxService):
|
||||
SERVICE_NAME = 'horizon'
|
||||
GREP = '[a]pache2'
|
||||
GREP = 'apache2'
|
||||
LINUX_SERVICE = 'apache2'
|
||||
|
||||
|
||||
class MemcachedService(service.LinuxService):
|
||||
SERVICE_NAME = 'memcached'
|
||||
GREP = '[m]emcached'
|
||||
GREP = 'memcached'
|
||||
LINUX_SERVICE = 'memcached'
|
||||
|
||||
|
||||
class MySQLService(PcsService):
|
||||
SERVICE_NAME = 'mysql'
|
||||
GREP = '[m]ysqld'
|
||||
GREP = 'mysqld'
|
||||
PCS_SERVICE = 'p_mysqld'
|
||||
PORT = ('tcp', 3307)
|
||||
|
||||
|
||||
class RabbitMQService(PcsService):
|
||||
SERVICE_NAME = 'rabbitmq'
|
||||
GREP = '[r]abbit tcp_listeners'
|
||||
GREP = 'rabbit tcp_listeners'
|
||||
PCS_SERVICE = 'p_rabbitmq-server'
|
||||
|
||||
|
||||
class GlanceAPIService(service.LinuxService):
|
||||
SERVICE_NAME = 'glance-api'
|
||||
GREP = '[g]lance-api'
|
||||
GREP = 'glance-api'
|
||||
LINUX_SERVICE = 'glance-api'
|
||||
|
||||
|
||||
class GlanceGlareService(service.LinuxService):
|
||||
SERVICE_NAME = 'glance-glare'
|
||||
GREP = '[g]lance-glare'
|
||||
GREP = 'glance-glare'
|
||||
LINUX_SERVICE = 'glance-glare'
|
||||
|
||||
|
||||
class GlanceRegistryService(service.LinuxService):
|
||||
SERVICE_NAME = 'glance-registry'
|
||||
GREP = '[g]lance-registry'
|
||||
GREP = 'glance-registry'
|
||||
LINUX_SERVICE = 'glance-registry'
|
||||
|
||||
|
||||
class NovaAPIService(service.LinuxService):
|
||||
SERVICE_NAME = 'nova-api'
|
||||
GREP = '[n]ova-api'
|
||||
GREP = 'nova-api'
|
||||
LINUX_SERVICE = 'nova-api'
|
||||
|
||||
|
||||
class NovaComputeService(service.LinuxService):
|
||||
SERVICE_NAME = 'nova-compute'
|
||||
GREP = '[n]ova-compute'
|
||||
GREP = 'nova-compute'
|
||||
LINUX_SERVICE = 'nova-compute'
|
||||
|
||||
|
||||
class NovaSchedulerService(service.LinuxService):
|
||||
SERVICE_NAME = 'nova-scheduler'
|
||||
GREP = '[n]ova-scheduler'
|
||||
GREP = 'nova-scheduler'
|
||||
LINUX_SERVICE = 'nova-scheduler'
|
||||
|
||||
|
||||
class NovaCertService(service.LinuxService):
|
||||
SERVICE_NAME = 'nova-cert'
|
||||
GREP = '[n]ova-cert'
|
||||
GREP = 'nova-cert'
|
||||
LINUX_SERVICE = 'nova-cert'
|
||||
|
||||
|
||||
class NovaConductorService(service.LinuxService):
|
||||
SERVICE_NAME = 'nova-conductor'
|
||||
GREP = '[n]ova-conductor'
|
||||
GREP = 'nova-conductor'
|
||||
LINUX_SERVICE = 'nova-conductor'
|
||||
|
||||
|
||||
class NovaConsoleAuthService(service.LinuxService):
|
||||
SERVICE_NAME = 'nova-consoleauth'
|
||||
GREP = '[n]ova-consoleauth'
|
||||
GREP = 'nova-consoleauth'
|
||||
LINUX_SERVICE = 'nova-consoleauth'
|
||||
|
||||
|
||||
class NovaNoVNCProxyService(service.LinuxService):
|
||||
SERVICE_NAME = 'nova-novncproxy'
|
||||
GREP = '[n]ova-novncproxy'
|
||||
GREP = 'nova-novncproxy'
|
||||
LINUX_SERVICE = 'nova-novncproxy'
|
||||
|
||||
|
||||
class NeutronServerService(service.LinuxService):
|
||||
SERVICE_NAME = 'neutron-server'
|
||||
GREP = '[n]eutron-server'
|
||||
GREP = 'neutron-server'
|
||||
LINUX_SERVICE = 'neutron-server'
|
||||
|
||||
|
||||
class NeutronDhcpAgentService(PcsService):
|
||||
SERVICE_NAME = 'neutron-dhcp-agent'
|
||||
GREP = '[n]eutron-dhcp-agent'
|
||||
GREP = 'neutron-dhcp-agent'
|
||||
PCS_SERVICE = 'neutron-dhcp-agent'
|
||||
|
||||
|
||||
class NeutronMetadataAgentService(PcsOrLinuxService):
|
||||
SERVICE_NAME = 'neutron-metadata-agent'
|
||||
GREP = '[n]eutron-metadata-agent'
|
||||
GREP = 'neutron-metadata-agent'
|
||||
PCS_SERVICE = 'neutron-metadata-agent'
|
||||
LINUX_SERVICE = 'neutron-metadata-agent'
|
||||
|
||||
|
||||
class NeutronOpenvswitchAgentService(PcsOrLinuxService):
|
||||
SERVICE_NAME = 'neutron-openvswitch-agent'
|
||||
GREP = '[n]eutron-openvswitch-agent'
|
||||
GREP = 'neutron-openvswitch-agent'
|
||||
PCS_SERVICE = 'neutron-openvswitch-agent'
|
||||
LINUX_SERVICE = 'neutron-openvswitch-agent'
|
||||
|
||||
|
||||
class NeutronL3AgentService(PcsOrLinuxService):
|
||||
SERVICE_NAME = 'neutron-l3-agent'
|
||||
GREP = '[n]eutron-l3-agent'
|
||||
GREP = 'neutron-l3-agent'
|
||||
PCS_SERVICE = 'neutron-l3-agent'
|
||||
LINUX_SERVICE = 'neutron-l3-agent'
|
||||
|
||||
|
||||
class HeatAPIService(service.LinuxService):
|
||||
SERVICE_NAME = 'heat-api'
|
||||
GREP = '[h]eat-api'
|
||||
GREP = 'heat-api'
|
||||
LINUX_SERVICE = 'heat-api'
|
||||
|
||||
|
||||
class HeatEngineService(PcsService):
|
||||
SERVICE_NAME = 'heat-engine'
|
||||
GREP = '[h]eat-engine'
|
||||
GREP = 'heat-engine'
|
||||
PCS_SERVICE = 'p_heat-engine'
|
||||
|
||||
|
||||
class CinderAPIService(service.LinuxService):
|
||||
SERVICE_NAME = 'cinder-api'
|
||||
GREP = '[c]inder-api'
|
||||
GREP = 'cinder-api'
|
||||
LINUX_SERVICE = 'cinder-api'
|
||||
|
||||
|
||||
class CinderSchedulerService(service.LinuxService):
|
||||
SERVICE_NAME = 'cinder-scheduler'
|
||||
GREP = '[c]inder-scheduler'
|
||||
GREP = 'cinder-scheduler'
|
||||
LINUX_SERVICE = 'cinder-scheduler'
|
||||
|
||||
|
||||
class CinderVolumeService(service.LinuxService):
|
||||
SERVICE_NAME = 'cinder-volume'
|
||||
GREP = '[c]inder-volume'
|
||||
GREP = 'cinder-volume'
|
||||
LINUX_SERVICE = 'cinder-volume'
|
||||
|
||||
|
||||
class CinderBackupService(service.LinuxService):
|
||||
SERVICE_NAME = 'cinder-backup'
|
||||
GREP = '[c]inder-backup'
|
||||
GREP = 'cinder-backup'
|
||||
LINUX_SERVICE = 'cinder-backup'
|
||||
|
||||
|
||||
class IronicApiService(service.LinuxService):
|
||||
SERVICE_NAME = 'ironic-api'
|
||||
GREP = '[i]ronic-api'
|
||||
GREP = 'ironic-api'
|
||||
LINUX_SERVICE = 'ironic-api'
|
||||
|
||||
|
||||
class IronicConductorService(service.LinuxService):
|
||||
SERVICE_NAME = 'ironic-conductor'
|
||||
GREP = '[i]ronic-conductor'
|
||||
GREP = 'ironic-conductor'
|
||||
LINUX_SERVICE = 'ironic-conductor'
|
||||
|
||||
|
||||
class SwiftAccountService(service.LinuxService):
|
||||
SERVICE_NAME = 'swift-account'
|
||||
GREP = '[s]wift-account'
|
||||
GREP = 'swift-account'
|
||||
LINUX_SERVICE = 'swift-account'
|
||||
|
||||
|
||||
class SwiftAccountAuditorService(service.LinuxService):
|
||||
SERVICE_NAME = 'swift-account-auditor'
|
||||
GREP = '[s]wift-account-auditor'
|
||||
GREP = 'swift-account-auditor'
|
||||
LINUX_SERVICE = 'swift-account-auditor'
|
||||
|
||||
|
||||
class SwiftAccountReaperService(service.LinuxService):
|
||||
SERVICE_NAME = 'swift-account-reaper'
|
||||
GREP = '[s]wift-account-reaper'
|
||||
GREP = 'swift-account-reaper'
|
||||
LINUX_SERVICE = 'swift-account-reaper'
|
||||
|
||||
|
||||
class SwiftAccountReplicatorService(service.LinuxService):
|
||||
SERVICE_NAME = 'swift-account-replicator'
|
||||
GREP = '[s]wift-account-replicator'
|
||||
GREP = 'swift-account-replicator'
|
||||
LINUX_SERVICE = 'swift-account-replicator'
|
||||
|
||||
|
||||
class SwiftContainerService(service.LinuxService):
|
||||
SERVICE_NAME = 'swift-container'
|
||||
GREP = '[s]wift-container'
|
||||
GREP = 'swift-container'
|
||||
LINUX_SERVICE = 'swift-container'
|
||||
|
||||
|
||||
class SwiftContainerAuditorService(service.LinuxService):
|
||||
SERVICE_NAME = 'swift-container-auditor'
|
||||
GREP = '[s]wift-container-auditor'
|
||||
GREP = 'swift-container-auditor'
|
||||
LINUX_SERVICE = 'swift-container-auditor'
|
||||
|
||||
|
||||
class SwiftContainerReplicatorService(service.LinuxService):
|
||||
SERVICE_NAME = 'swift-container-replicator'
|
||||
GREP = '[s]wift-container-replicator'
|
||||
GREP = 'swift-container-replicator'
|
||||
LINUX_SERVICE = 'swift-container-replicator'
|
||||
|
||||
|
||||
class SwiftContainerSyncService(service.LinuxService):
|
||||
SERVICE_NAME = 'swift-container-sync'
|
||||
GREP = '[s]wift-container-sync'
|
||||
GREP = 'swift-container-sync'
|
||||
LINUX_SERVICE = 'swift-container-sync'
|
||||
|
||||
|
||||
class SwiftContainerUpdaterService(service.LinuxService):
|
||||
SERVICE_NAME = 'swift-container-updater'
|
||||
GREP = '[s]wift-container-updater'
|
||||
GREP = 'swift-container-updater'
|
||||
LINUX_SERVICE = 'swift-container-updater'
|
||||
|
||||
|
||||
class SwiftObjectService(service.LinuxService):
|
||||
SERVICE_NAME = 'swift-object'
|
||||
GREP = '[s]wift-object'
|
||||
GREP = 'swift-object'
|
||||
LINUX_SERVICE = 'swift-object'
|
||||
|
||||
|
||||
class SwiftObjectAuditorService(service.LinuxService):
|
||||
SERVICE_NAME = 'swift-object-auditor'
|
||||
GREP = '[s]wift-object-auditor'
|
||||
GREP = 'swift-object-auditor'
|
||||
LINUX_SERVICE = 'swift-object-auditor'
|
||||
|
||||
|
||||
class SwiftObjectReplicatorService(service.LinuxService):
|
||||
SERVICE_NAME = 'swift-object-replicator'
|
||||
GREP = '[s]wift-object-replicator'
|
||||
GREP = 'swift-object-replicator'
|
||||
LINUX_SERVICE = 'swift-object-replicator'
|
||||
|
||||
|
||||
class SwiftObjectUpdaterService(service.LinuxService):
|
||||
SERVICE_NAME = 'swift-object-updater'
|
||||
GREP = '[s]wift-object-updater'
|
||||
GREP = 'swift-object-updater'
|
||||
LINUX_SERVICE = 'swift-object-updater'
|
||||
|
||||
|
||||
class SwiftProxyService(service.LinuxService):
|
||||
SERVICE_NAME = 'swift-proxy'
|
||||
GREP = '[s]wift-proxy'
|
||||
GREP = 'swift-proxy'
|
||||
LINUX_SERVICE = 'swift-proxy'
|
||||
|
||||
|
||||
|
@ -54,25 +54,25 @@ class SaltService(service.ServiceAsProcess):
|
||||
|
||||
class KeystoneService(SaltService):
|
||||
SERVICE_NAME = 'keystone'
|
||||
GREP = '[k]eystone-all'
|
||||
GREP = 'keystone-all'
|
||||
SALT_SERVICE = 'keystone'
|
||||
|
||||
|
||||
class HorizonService(SaltService):
|
||||
SERVICE_NAME = 'horizon'
|
||||
GREP = '[a]pache2'
|
||||
GREP = 'apache2'
|
||||
SALT_SERVICE = 'apache2'
|
||||
|
||||
|
||||
class MemcachedService(SaltService):
|
||||
SERVICE_NAME = 'memcached'
|
||||
GREP = '[m]emcached'
|
||||
GREP = 'memcached'
|
||||
SALT_SERVICE = 'memcached'
|
||||
|
||||
|
||||
class MySQLService(SaltService):
|
||||
SERVICE_NAME = 'mysql'
|
||||
GREP = '[m]ysqld'
|
||||
GREP = 'mysqld'
|
||||
SALT_SERVICE = 'mysql'
|
||||
PORT = ('tcp', 3307)
|
||||
|
||||
@ -85,121 +85,121 @@ class RabbitMQService(SaltService):
|
||||
|
||||
class GlanceAPIService(SaltService):
|
||||
SERVICE_NAME = 'glance-api'
|
||||
GREP = '[g]lance-api'
|
||||
GREP = 'glance-api'
|
||||
SALT_SERVICE = 'glance-api'
|
||||
|
||||
|
||||
class GlanceRegistryService(SaltService):
|
||||
SERVICE_NAME = 'glance-registry'
|
||||
GREP = '[g]lance-registry'
|
||||
GREP = 'glance-registry'
|
||||
SALT_SERVICE = 'glance-registry'
|
||||
|
||||
|
||||
class NovaAPIService(SaltService):
|
||||
SERVICE_NAME = 'nova-api'
|
||||
GREP = '[n]ova-api'
|
||||
GREP = 'nova-api'
|
||||
SALT_SERVICE = 'nova-api'
|
||||
|
||||
|
||||
class NovaComputeService(SaltService):
|
||||
SERVICE_NAME = 'nova-compute'
|
||||
GREP = '[n]ova-compute'
|
||||
GREP = 'nova-compute'
|
||||
SALT_SERVICE = 'nova-compute'
|
||||
|
||||
|
||||
class NovaSchedulerService(SaltService):
|
||||
SERVICE_NAME = 'nova-scheduler'
|
||||
GREP = '[n]ova-scheduler'
|
||||
GREP = 'nova-scheduler'
|
||||
SALT_SERVICE = 'nova-scheduler'
|
||||
|
||||
|
||||
class NovaCertService(SaltService):
|
||||
SERVICE_NAME = 'nova-cert'
|
||||
GREP = '[n]ova-cert'
|
||||
GREP = 'nova-cert'
|
||||
SALT_SERVICE = 'nova-cert'
|
||||
|
||||
|
||||
class NovaConductorService(SaltService):
|
||||
SERVICE_NAME = 'nova-conductor'
|
||||
GREP = '[n]ova-conductor'
|
||||
GREP = 'nova-conductor'
|
||||
SALT_SERVICE = 'nova-conductor'
|
||||
|
||||
|
||||
class NovaConsoleAuthService(SaltService):
|
||||
SERVICE_NAME = 'nova-consoleauth'
|
||||
GREP = '[n]ova-consoleauth'
|
||||
GREP = 'nova-consoleauth'
|
||||
SALT_SERVICE = 'nova-consoleauth'
|
||||
|
||||
|
||||
class NovaNoVNCProxyService(SaltService):
|
||||
SERVICE_NAME = 'nova-novncproxy'
|
||||
GREP = '[n]ova-novncproxy'
|
||||
GREP = 'nova-novncproxy'
|
||||
SALT_SERVICE = 'nova-novncproxy'
|
||||
|
||||
|
||||
class NeutronServerService(SaltService):
|
||||
SERVICE_NAME = 'neutron-server'
|
||||
GREP = '[n]eutron-server'
|
||||
GREP = 'neutron-server'
|
||||
SALT_SERVICE = 'neutron-server'
|
||||
|
||||
|
||||
class NeutronDhcpAgentService(SaltService):
|
||||
SERVICE_NAME = 'neutron-dhcp-agent'
|
||||
GREP = '[n]eutron-dhcp-agent'
|
||||
GREP = 'neutron-dhcp-agent'
|
||||
SALT_SERVICE = 'neutron-dhcp-agent'
|
||||
|
||||
|
||||
class NeutronMetadataAgentService(SaltService):
|
||||
SERVICE_NAME = 'neutron-metadata-agent'
|
||||
GREP = '[n]eutron-metadata-agent'
|
||||
GREP = 'neutron-metadata-agent'
|
||||
SALT_SERVICE = 'neutron-metadata-agent'
|
||||
|
||||
|
||||
class NeutronOpenvswitchAgentService(SaltService):
|
||||
SERVICE_NAME = 'neutron-openvswitch-agent'
|
||||
GREP = '[n]eutron-openvswitch-agent'
|
||||
GREP = 'neutron-openvswitch-agent'
|
||||
SALT_SERVICE = 'neutron-openvswitch-agent'
|
||||
|
||||
|
||||
class NeutronL3AgentService(SaltService):
|
||||
SERVICE_NAME = 'neutron-l3-agent'
|
||||
GREP = '[n]eutron-l3-agent'
|
||||
GREP = 'neutron-l3-agent'
|
||||
SALT_SERVICE = 'neutron-l3-agent'
|
||||
|
||||
|
||||
class HeatAPIService(SaltService):
|
||||
SERVICE_NAME = 'heat-api'
|
||||
GREP = '[h]eat-api '
|
||||
GREP = 'heat-api ' # space at the end filters heat-api-* services
|
||||
SALT_SERVICE = 'heat-api'
|
||||
|
||||
|
||||
class HeatEngineService(SaltService):
|
||||
SERVICE_NAME = 'heat-engine'
|
||||
GREP = '[h]eat-engine'
|
||||
GREP = 'heat-engine'
|
||||
SALT_SERVICE = 'heat-engine'
|
||||
|
||||
|
||||
class CinderAPIService(SaltService):
|
||||
SERVICE_NAME = 'cinder-api'
|
||||
GREP = '[c]inder-api'
|
||||
GREP = 'cinder-api'
|
||||
SALT_SERVICE = 'cinder-api'
|
||||
|
||||
|
||||
class CinderSchedulerService(SaltService):
|
||||
SERVICE_NAME = 'cinder-scheduler'
|
||||
GREP = '[c]inder-scheduler'
|
||||
GREP = 'cinder-scheduler'
|
||||
SALT_SERVICE = 'cinder-scheduler'
|
||||
|
||||
|
||||
class CinderVolumeService(SaltService):
|
||||
SERVICE_NAME = 'cinder-volume'
|
||||
GREP = '[c]inder-volume'
|
||||
GREP = 'cinder-volume'
|
||||
SALT_SERVICE = 'cinder-volume'
|
||||
|
||||
|
||||
class CinderBackupService(SaltService):
|
||||
SERVICE_NAME = 'cinder-backup'
|
||||
GREP = '[c]inder-backup'
|
||||
GREP = 'cinder-backup'
|
||||
SALT_SERVICE = 'cinder-backup'
|
||||
|
||||
|
||||
|
@ -33,6 +33,7 @@ class FreezeTestCase(test.TestCase):
|
||||
cmd = ('bash -c "tf=$(mktemp /tmp/script.XXXXXX);'
|
||||
'echo -n \'#!\' > $tf; '
|
||||
'echo -en \'/bin/bash\\npids=`ps ax | '
|
||||
'grep -v grep | '
|
||||
'grep foo | awk {{\\047print $1\\047}}`; '
|
||||
'echo $pids | xargs kill -19; sleep 15; '
|
||||
'echo $pids | xargs kill -18; rm \' >> $tf; '
|
||||
|
@ -22,9 +22,9 @@ from os_faults.tests.unit import test
|
||||
@ddt.ddt
|
||||
class KillTestCase(test.TestCase):
|
||||
|
||||
@ddt.data(['foo', 9, 'bash -c "ps ax | grep \'foo\' '
|
||||
@ddt.data(['foo', 9, 'bash -c "ps ax | grep -v grep | grep \'foo\' '
|
||||
'| awk {\'print $1\'} | xargs kill -9"'],
|
||||
['bar', 3, 'bash -c "ps ax | grep \'bar\' '
|
||||
['bar', 3, 'bash -c "ps ax | grep -v grep | grep \'bar\' '
|
||||
'| awk {\'print $1\'} | xargs kill -3"'])
|
||||
@ddt.unpack
|
||||
@mock.patch("os_faults.ansible.modules.kill.AnsibleModule")
|
||||
|
@ -181,7 +181,8 @@ class DevStackManagementTestCase(test.TestCase):
|
||||
|
||||
nodes = service.get_nodes()
|
||||
|
||||
cmd = 'bash -c "ps ax | grep \'{}\'"'.format(service_cls.GREP)
|
||||
cmd = 'bash -c "ps ax | grep -v grep | grep \'{}\'"'.format(
|
||||
service_cls.GREP)
|
||||
ansible_runner_inst.execute.assert_has_calls([
|
||||
mock.call(
|
||||
['10.0.0.2'], {'command': 'cat /sys/class/net/eth0/address'}),
|
||||
@ -219,7 +220,8 @@ class DevStackServiceTestCase(test.TestCase):
|
||||
|
||||
service.restart()
|
||||
|
||||
cmd = 'bash -c "ps ax | grep \'{}\'"'.format(service_cls.GREP)
|
||||
cmd = 'bash -c "ps ax | grep -v grep | grep \'{}\'"'.format(
|
||||
service_cls.GREP)
|
||||
ansible_runner_inst.execute.assert_has_calls([
|
||||
mock.call(
|
||||
['10.0.0.2'], {'command': 'cat /sys/class/net/eth0/address'}),
|
||||
@ -246,7 +248,8 @@ class DevStackServiceTestCase(test.TestCase):
|
||||
|
||||
service.terminate()
|
||||
|
||||
cmd = 'bash -c "ps ax | grep \'{}\'"'.format(service_cls.GREP)
|
||||
cmd = 'bash -c "ps ax | grep -v grep | grep \'{}\'"'.format(
|
||||
service_cls.GREP)
|
||||
ansible_runner_inst.execute.assert_has_calls([
|
||||
mock.call(
|
||||
['10.0.0.2'], {'command': 'cat /sys/class/net/eth0/address'}),
|
||||
@ -273,7 +276,8 @@ class DevStackServiceTestCase(test.TestCase):
|
||||
|
||||
service.start()
|
||||
|
||||
cmd = 'bash -c "ps ax | grep \'{}\'"'.format(service_cls.GREP)
|
||||
cmd = 'bash -c "ps ax | grep -v grep | grep \'{}\'"'.format(
|
||||
service_cls.GREP)
|
||||
ansible_runner_inst.execute.assert_has_calls([
|
||||
mock.call(
|
||||
['10.0.0.2'], {'command': 'cat /sys/class/net/eth0/address'}),
|
||||
|
@ -158,7 +158,8 @@ class FuelManagementTestCase(test.TestCase):
|
||||
self.assertIsInstance(service, service_cls)
|
||||
|
||||
nodes = service.get_nodes()
|
||||
cmd = 'bash -c "ps ax | grep \'{}\'"'.format(service_cls.GREP)
|
||||
cmd = 'bash -c "ps ax | grep -v grep | grep \'{}\'"'.format(
|
||||
service_cls.GREP)
|
||||
ansible_runner_inst.execute.assert_has_calls([
|
||||
mock.call(['fuel.local'], {'command': 'fuel node --json'}),
|
||||
mock.call(['10.0.0.2', '10.0.0.3'],
|
||||
|
@ -57,7 +57,7 @@ class FuelServiceTestCase(test.TestCase):
|
||||
|
||||
service.kill()
|
||||
|
||||
get_nodes_cmd = 'bash -c "ps ax | grep \'{}\'"'.format(
|
||||
get_nodes_cmd = 'bash -c "ps ax | grep -v grep | grep \'{}\'"'.format(
|
||||
service_cls.GREP)
|
||||
ansible_runner_inst.execute.assert_has_calls([
|
||||
mock.call(['fuel.local'], {'command': 'fuel node --json'}),
|
||||
@ -91,7 +91,7 @@ class FuelServiceTestCase(test.TestCase):
|
||||
|
||||
service.freeze()
|
||||
|
||||
get_nodes_cmd = 'bash -c "ps ax | grep \'{}\'"'.format(
|
||||
get_nodes_cmd = 'bash -c "ps ax | grep -v grep | grep \'{}\'"'.format(
|
||||
service_cls.GREP)
|
||||
ansible_runner_inst.execute.assert_has_calls([
|
||||
mock.call(['fuel.local'], {'command': 'fuel node --json'}),
|
||||
@ -126,7 +126,7 @@ class FuelServiceTestCase(test.TestCase):
|
||||
delay_sec = 10
|
||||
service.freeze(nodes=None, sec=delay_sec)
|
||||
|
||||
get_nodes_cmd = 'bash -c "ps ax | grep \'{}\'"'.format(
|
||||
get_nodes_cmd = 'bash -c "ps ax | grep -v grep | grep \'{}\'"'.format(
|
||||
service_cls.GREP)
|
||||
ansible_runner_inst.execute.assert_has_calls([
|
||||
mock.call(['fuel.local'], {'command': 'fuel node --json'}),
|
||||
@ -161,7 +161,7 @@ class FuelServiceTestCase(test.TestCase):
|
||||
|
||||
service.unfreeze()
|
||||
|
||||
get_nodes_cmd = 'bash -c "ps ax | grep \'{}\'"'.format(
|
||||
get_nodes_cmd = 'bash -c "ps ax | grep -v grep | grep \'{}\'"'.format(
|
||||
service_cls.GREP)
|
||||
ansible_runner_inst.execute.assert_has_calls([
|
||||
mock.call(['fuel.local'], {'command': 'fuel node --json'}),
|
||||
@ -195,7 +195,7 @@ class FuelServiceTestCase(test.TestCase):
|
||||
|
||||
service.unplug()
|
||||
|
||||
get_nodes_cmd = 'bash -c "ps ax | grep \'{}\'"'.format(
|
||||
get_nodes_cmd = 'bash -c "ps ax | grep -v grep | grep \'{}\'"'.format(
|
||||
service_cls.GREP)
|
||||
ansible_runner_inst.execute.assert_has_calls([
|
||||
mock.call(['fuel.local'], {'command': 'fuel node --json'}),
|
||||
@ -232,7 +232,7 @@ class FuelServiceTestCase(test.TestCase):
|
||||
|
||||
service.plug()
|
||||
|
||||
get_nodes_cmd = 'bash -c "ps ax | grep \'{}\'"'.format(
|
||||
get_nodes_cmd = 'bash -c "ps ax | grep -v grep | grep \'{}\'"'.format(
|
||||
service_cls.GREP)
|
||||
ansible_runner_inst.execute.assert_has_calls([
|
||||
mock.call(['fuel.local'], {'command': 'fuel node --json'}),
|
||||
@ -269,8 +269,8 @@ class FuelServiceTestCase(test.TestCase):
|
||||
|
||||
service.restart()
|
||||
|
||||
get_nodes_cmd = 'bash -c "ps ax | grep \'{}\'"'.format(
|
||||
service.GREP)
|
||||
get_nodes_cmd = 'bash -c "ps ax | grep -v grep | grep \'{}\'"'.format(
|
||||
service_cls.GREP)
|
||||
ansible_runner_inst.execute.assert_has_calls([
|
||||
mock.call(['fuel.local'], {'command': 'fuel node --json'}),
|
||||
mock.call(['10.0.0.2', '10.0.0.3'],
|
||||
@ -303,8 +303,8 @@ class FuelServiceTestCase(test.TestCase):
|
||||
|
||||
service.terminate()
|
||||
|
||||
get_nodes_cmd = 'bash -c "ps ax | grep \'{}\'"'.format(
|
||||
service.GREP)
|
||||
get_nodes_cmd = 'bash -c "ps ax | grep -v grep | grep \'{}\'"'.format(
|
||||
service_cls.GREP)
|
||||
ansible_runner_inst.execute.assert_has_calls([
|
||||
mock.call(['fuel.local'], {'command': 'fuel node --json'}),
|
||||
mock.call(['10.0.0.2', '10.0.0.3'],
|
||||
@ -337,8 +337,8 @@ class FuelServiceTestCase(test.TestCase):
|
||||
|
||||
service.start()
|
||||
|
||||
get_nodes_cmd = 'bash -c "ps ax | grep \'{}\'"'.format(
|
||||
service.GREP)
|
||||
get_nodes_cmd = 'bash -c "ps ax | grep -v grep | grep \'{}\'"'.format(
|
||||
service_cls.GREP)
|
||||
ansible_runner_inst.execute.assert_has_calls([
|
||||
mock.call(['fuel.local'], {'command': 'fuel node --json'}),
|
||||
mock.call(['10.0.0.2', '10.0.0.3'],
|
||||
@ -369,7 +369,7 @@ class FuelServiceTestCase(test.TestCase):
|
||||
exception = self.assertRaises(error.ServiceError, service.restart)
|
||||
self.assertEqual('Task failed on some nodes', str(exception))
|
||||
|
||||
get_nodes_cmd = 'bash -c "ps ax | grep \'{}\'"'.format(
|
||||
get_nodes_cmd = 'bash -c "ps ax | grep -v grep | grep \'{}\'"'.format(
|
||||
service.GREP)
|
||||
ansible_runner_inst.execute.assert_has_calls([
|
||||
mock.call(['fuel.local'], {'command': 'fuel node --json'}),
|
||||
@ -398,7 +398,7 @@ class FuelServiceTestCase(test.TestCase):
|
||||
exception = self.assertRaises(error.ServiceError, service.restart)
|
||||
self.assertEqual('Node collection is empty', str(exception))
|
||||
|
||||
get_nodes_cmd = 'bash -c "ps ax | grep \'{}\'"'.format(
|
||||
get_nodes_cmd = 'bash -c "ps ax | grep -v grep | grep \'{}\'"'.format(
|
||||
service.GREP)
|
||||
ansible_runner_inst.execute.assert_has_calls([
|
||||
mock.call(['fuel.local'], {'command': 'fuel node --json'}),
|
||||
|
@ -251,7 +251,8 @@ class TCPCloudManagementTestCase(test.TestCase):
|
||||
self.assertIsInstance(service, service_cls)
|
||||
|
||||
nodes = service.get_nodes()
|
||||
cmd = 'bash -c "ps ax | grep \'{}\'"'.format(service_cls.GREP)
|
||||
cmd = 'bash -c "ps ax | grep -v grep | grep \'{}\'"'.format(
|
||||
service_cls.GREP)
|
||||
ansible_runner_inst.execute.assert_has_calls([
|
||||
mock.call(['tcp.local'], {'command': self.get_nodes_cmd}),
|
||||
mock.call(['tcp.local'], {'command': self.get_ips_cmd}),
|
||||
@ -327,7 +328,8 @@ class TcpServiceTestCase(test.TestCase):
|
||||
|
||||
service.restart()
|
||||
|
||||
cmd = 'bash -c "ps ax | grep \'{}\'"'.format(service_cls.GREP)
|
||||
cmd = 'bash -c "ps ax | grep -v grep | grep \'{}\'"'.format(
|
||||
service_cls.GREP)
|
||||
ansible_runner_inst.execute.assert_has_calls([
|
||||
mock.call(['tcp.local'], {'command': self.get_nodes_cmd}),
|
||||
mock.call(['tcp.local'], {'command': self.get_ips_cmd}),
|
||||
@ -362,7 +364,8 @@ class TcpServiceTestCase(test.TestCase):
|
||||
|
||||
service.terminate()
|
||||
|
||||
cmd = 'bash -c "ps ax | grep \'{}\'"'.format(service_cls.GREP)
|
||||
cmd = 'bash -c "ps ax | grep -v grep | grep \'{}\'"'.format(
|
||||
service_cls.GREP)
|
||||
ansible_runner_inst.execute.assert_has_calls([
|
||||
mock.call(['tcp.local'], {'command': self.get_nodes_cmd}),
|
||||
mock.call(['tcp.local'], {'command': self.get_ips_cmd}),
|
||||
@ -397,7 +400,8 @@ class TcpServiceTestCase(test.TestCase):
|
||||
|
||||
service.start()
|
||||
|
||||
cmd = 'bash -c "ps ax | grep \'{}\'"'.format(service_cls.GREP)
|
||||
cmd = 'bash -c "ps ax | grep -v grep | grep \'{}\'"'.format(
|
||||
service_cls.GREP)
|
||||
ansible_runner_inst.execute.assert_has_calls([
|
||||
mock.call(['tcp.local'], {'command': self.get_nodes_cmd}),
|
||||
mock.call(['tcp.local'], {'command': self.get_ips_cmd}),
|
||||
|
Loading…
Reference in New Issue
Block a user