本文整理汇总了Python中ovs.extensions.services.service.ServiceManager.has_service方法的典型用法代码示例。如果您正苦于以下问题:Python ServiceManager.has_service方法的具体用法?Python ServiceManager.has_service怎么用?Python ServiceManager.has_service使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ovs.extensions.services.service.ServiceManager
的用法示例。
在下文中一共展示了ServiceManager.has_service方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: restart_framework_and_memcache_services
# 需要导入模块: from ovs.extensions.services.service import ServiceManager [as 别名]
# 或者: from ovs.extensions.services.service.ServiceManager import has_service [as 别名]
def restart_framework_and_memcache_services(clients, logger, offline_node_ips=None):
"""
Restart framework and Memcached services
:param clients: Clients on which to restart these services
:type clients: dict
:param logger: Logger object used for logging
:type logger: ovs.log.log_handler.LogHandler
:param offline_node_ips: IP addresses of offline nodes in the cluster
:type offline_node_ips: list
:return: None
"""
from ovs.dal.lists.storagerouterlist import StorageRouterList
master_ips = [sr.ip for sr in StorageRouterList.get_masters()]
slave_ips = [sr.ip for sr in StorageRouterList.get_slaves()]
if offline_node_ips is None:
offline_node_ips = []
memcached = 'memcached'
watcher = 'watcher-framework'
support_agent = 'support-agent'
for ip in master_ips + slave_ips:
if ip not in offline_node_ips:
if ServiceManager.has_service(watcher, clients[ip]):
Toolbox.change_service_state(clients[ip], watcher, 'stop', logger)
for ip in master_ips:
if ip not in offline_node_ips:
Toolbox.change_service_state(clients[ip], memcached, 'restart', logger)
for ip in master_ips + slave_ips:
if ip not in offline_node_ips:
if ServiceManager.has_service(watcher, clients[ip]):
Toolbox.change_service_state(clients[ip], watcher, 'start', logger)
if ServiceManager.has_service(support_agent, clients[ip]):
Toolbox.change_service_state(clients[ip], support_agent, 'restart', logger)
VolatileFactory.store = None
示例2: __init__
# 需要导入模块: from ovs.extensions.services.service import ServiceManager [as 别名]
# 或者: from ovs.extensions.services.service.ServiceManager import has_service [as 别名]
def __init__(self, cinder_client):
self.client = SSHClient('127.0.0.1', username='root')
self.cinder_client = cinder_client
self._NOVA_CONF = '/etc/nova/nova.conf'
self._CINDER_CONF = '/etc/cinder/cinder.conf'
self._is_openstack = ServiceManager.has_service(OSManager.get_openstack_cinder_service_name(), self.client)
self._nova_installed = self.client.file_exists(self._NOVA_CONF)
self._cinder_installed = self.client.file_exists(self._CINDER_CONF)
self._driver_location = OSManager.get_openstack_package_base_path()
self._openstack_users = OSManager.get_openstack_users()
self._devstack_driver = '/opt/stack/cinder/cinder/volume/drivers/openvstorage.py'
try:
self._is_devstack = 'stack' in str(self.client.run('ps aux | grep SCREEN | grep stack | grep -v grep || true'))
except SystemExit: # ssh client raises system exit 1
self._is_devstack = False
except Exception:
self._is_devstack = False
try:
from cinder import version
version_string = version.version_string()
if version_string.startswith('2015.2') or version_string.startswith('7.0'):
self._stack_version = 'liberty'
elif version_string.startswith('2015.1'):
self._stack_version = 'kilo'
elif version_string.startswith('2014.2'):
self._stack_version = 'juno'
else:
raise ValueError('Unsupported cinder version: {0}'.format(version_string))
except Exception as ex:
raise ValueError('Cannot determine cinder version: {0}'.format(ex))
示例3: on_demote
# 需要导入模块: from ovs.extensions.services.service import ServiceManager [as 别名]
# 或者: from ovs.extensions.services.service.ServiceManager import has_service [as 别名]
def on_demote(cluster_ip, master_ip, offline_node_ips=None):
"""
Handles the demote for the StorageDrivers
:param cluster_ip: IP of the node to demote
:param master_ip: IP of the master node
:param offline_node_ips: IPs of nodes which are offline
"""
if offline_node_ips is None:
offline_node_ips = []
client = SSHClient(cluster_ip, username='root') if cluster_ip not in offline_node_ips else None
servicetype = ServiceTypeList.get_by_name('Arakoon')
current_service = None
remaining_ips = []
for service in servicetype.services:
if service.name == 'arakoon-voldrv':
if service.storagerouter.ip == cluster_ip:
current_service = service
elif service.storagerouter.ip not in offline_node_ips:
remaining_ips.append(service.storagerouter.ip)
if current_service is not None:
print '* Shrink StorageDriver cluster'
ArakoonInstaller.shrink_cluster(master_ip, cluster_ip, 'voldrv', offline_node_ips)
if client is not None and ServiceManager.has_service(current_service.name, client=client) is True:
ServiceManager.stop_service(current_service.name, client=client)
ServiceManager.remove_service(current_service.name, client=client)
ArakoonInstaller.restart_cluster_remove('voldrv', remaining_ips)
current_service.delete()
StorageDriverController._configure_arakoon_to_volumedriver(offline_node_ips)
示例4: remove_services
# 需要导入模块: from ovs.extensions.services.service import ServiceManager [as 别名]
# 或者: from ovs.extensions.services.service.ServiceManager import has_service [as 别名]
def remove_services(client, node_type, logger):
"""
Remove all services managed by OVS
:param client: Client on which to remove the services
:type client: ovs.extensions.generic.sshclient.SSHClient
:param node_type: Type of node, can be 'master' or 'extra'
:type node_type: str
:param logger: Logger object used for logging
:type logger: ovs.log.log_handler.LogHandler
:return: None
"""
Toolbox.log(logger=logger, messages="Removing services")
stop_only = ["rabbitmq-server", "memcached"]
services = ["workers", "support-agent", "watcher-framework"]
if node_type == "master":
services += ["scheduled-tasks", "webapp-api", "volumerouter-consumer"]
if Toolbox.is_service_internally_managed(service="rabbitmq") is True:
services.append("rabbitmq-server")
if Toolbox.is_service_internally_managed(service="memcached") is True:
services.append("memcached")
for service in services:
if ServiceManager.has_service(service, client=client):
Toolbox.log(
logger=logger,
messages="{0} service {1}".format("Removing" if service not in stop_only else "Stopping", service),
)
ServiceManager.stop_service(service, client=client)
if service not in stop_only:
ServiceManager.remove_service(service, client=client)
示例5: stop
# 需要导入模块: from ovs.extensions.services.service import ServiceManager [as 别名]
# 或者: from ovs.extensions.services.service.ServiceManager import has_service [as 别名]
def stop(cluster_name, client):
"""
Stops an arakoon service
"""
if ServiceManager.has_service('arakoon-{0}'.format(cluster_name), client=client) is True and \
ServiceManager.get_service_status('arakoon-{0}'.format(cluster_name), client=client) is True:
ServiceManager.stop_service('arakoon-{0}'.format(cluster_name), client=client)
示例6: _setup_proxy
# 需要导入模块: from ovs.extensions.services.service import ServiceManager [as 别名]
# 或者: from ovs.extensions.services.service.ServiceManager import has_service [as 别名]
def _setup_proxy(initial_cluster, slave_client, cluster_name, force=False):
base_name = 'ovs-etcd-proxy'
target_name = 'ovs-etcd-{0}'.format(cluster_name)
if force is False and ServiceManager.has_service(target_name, slave_client) and \
ServiceManager.get_service_status(target_name, slave_client) is True:
logger.info('Service {0} already configured and running'.format(target_name))
return
EtcdInstaller.stop(cluster_name, slave_client)
data_dir = EtcdInstaller.DATA_DIR.format(EtcdInstaller.DB_DIR, cluster_name)
wal_dir = EtcdInstaller.WAL_DIR.format(EtcdInstaller.DB_DIR, cluster_name)
abs_paths = [data_dir, wal_dir]
slave_client.dir_delete(abs_paths)
slave_client.dir_create(data_dir)
slave_client.dir_chmod(data_dir, 0755, recursive=True)
slave_client.dir_chown(data_dir, 'ovs', 'ovs', recursive=True)
ServiceManager.add_service(base_name, slave_client,
params={'CLUSTER': cluster_name,
'DATA_DIR': data_dir,
'LOCAL_CLIENT_URL': EtcdInstaller.CLIENT_URL.format('127.0.0.1'),
'INITIAL_CLUSTER': initial_cluster},
target_name=target_name)
EtcdInstaller.start(cluster_name, slave_client)
EtcdInstaller.wait_for_cluster(cluster_name, slave_client)
示例7: on_demote
# 需要导入模块: from ovs.extensions.services.service import ServiceManager [as 别名]
# 或者: from ovs.extensions.services.service.ServiceManager import has_service [as 别名]
def on_demote(cluster_ip, master_ip):
"""
Handles the demote for the StorageDrivers
:param cluster_ip: IP of the node to demote
:param master_ip: IP of the master node
"""
client = SSHClient(cluster_ip, username='root')
servicetype = ServiceTypeList.get_by_name('Arakoon')
current_service = None
remaining_ips = []
for service in servicetype.services:
if service.name == 'arakoon-voldrv':
if service.storagerouter.ip == cluster_ip:
current_service = service
else:
remaining_ips.append(service.storagerouter.ip)
if current_service is not None:
print '* Shrink StorageDriver cluster'
ArakoonInstaller.shrink_cluster(master_ip, cluster_ip, 'voldrv')
if ServiceManager.has_service(current_service.name, client=client) is True:
ServiceManager.stop_service(current_service.name, client=client)
ServiceManager.remove_service(current_service.name, client=client)
ArakoonInstaller.restart_cluster_remove('voldrv', remaining_ips)
current_service.delete()
for storagerouter in StorageRouterList.get_storagerouters():
ArakoonInstaller.deploy_to_slave(master_ip, storagerouter.ip, 'voldrv')
StorageDriverController._configure_arakoon_to_volumedriver()
示例8: add_services
# 需要导入模块: from ovs.extensions.services.service import ServiceManager [as 别名]
# 或者: from ovs.extensions.services.service.ServiceManager import has_service [as 别名]
def add_services(client, node_type, logger):
"""
Add the services required by the OVS cluster
:param client: Client on which to add the services
:type client: ovs.extensions.generic.sshclient.SSHClient
:param node_type: Type of node ('master' or 'extra')
:type node_type: str
:param logger: Logger object used for logging
:type logger: ovs.log.log_handler.LogHandler
:return: None
"""
Toolbox.log(logger=logger, messages='Adding services')
services = {}
worker_queue = System.get_my_machine_id(client=client)
if node_type == 'master':
worker_queue += ',ovs_masters'
services.update({'memcached': {'MEMCACHE_NODE_IP': client.ip, 'WORKER_QUEUE': worker_queue},
'rabbitmq-server': {'MEMCACHE_NODE_IP': client.ip, 'WORKER_QUEUE': worker_queue},
'scheduled-tasks': {},
'webapp-api': {},
'volumerouter-consumer': {}})
services.update({'workers': {'WORKER_QUEUE': worker_queue},
'watcher-framework': {}})
for service_name, params in services.iteritems():
if not ServiceManager.has_service(service_name, client):
Toolbox.log(logger=logger, messages='Adding service {0}'.format(service_name))
ServiceManager.add_service(name=service_name, params=params, client=client)
示例9: has_service
# 需要导入模块: from ovs.extensions.services.service import ServiceManager [as 别名]
# 或者: from ovs.extensions.services.service.ServiceManager import has_service [as 别名]
def has_service(name, client):
"""
Validate if the node has the service configured
:param name: Name of the service
:param client: SSHClient object
:return: True if service is configured
"""
return ServiceManager.has_service(name, client)
示例10: remove
# 需要导入模块: from ovs.extensions.services.service import ServiceManager [as 别名]
# 或者: from ovs.extensions.services.service.ServiceManager import has_service [as 别名]
def remove(cluster_name, client):
"""
Removes an etcd service
:param client: Client on which to remove the service
:param cluster_name: The name of the cluster service to remove
"""
if ServiceManager.has_service('etcd-{0}'.format(cluster_name), client=client) is True:
ServiceManager.remove_service('etcd-{0}'.format(cluster_name), client=client)
示例11: stop
# 需要导入模块: from ovs.extensions.services.service import ServiceManager [as 别名]
# 或者: from ovs.extensions.services.service.ServiceManager import has_service [as 别名]
def stop(cluster_name, client):
"""
Stops an etcd service
:param client: Client on which to stop the service
:param cluster_name: The name of the cluster service to stop
"""
if ServiceManager.has_service('etcd-{0}'.format(cluster_name), client=client) is True:
ServiceManager.stop_service('etcd-{0}'.format(cluster_name), client=client)
示例12: start
# 需要导入模块: from ovs.extensions.services.service import ServiceManager [as 别名]
# 或者: from ovs.extensions.services.service.ServiceManager import has_service [as 别名]
def start(cluster_name, client):
"""
Starts an arakoon cluster
:param client: Client on which to start the service
:param cluster_name: The name of the cluster service to start
"""
if ServiceManager.has_service('arakoon-{0}'.format(cluster_name), client=client) is True:
ServiceManager.start_service('arakoon-{0}'.format(cluster_name), client=client)
示例13: is_running
# 需要导入模块: from ovs.extensions.services.service import ServiceManager [as 别名]
# 或者: from ovs.extensions.services.service.ServiceManager import has_service [as 别名]
def is_running(cluster_name, client):
"""
Checks if arakoon service is running
:param client: Client on which to stop the service
:param cluster_name: The name of the cluster service to stop
"""
if ServiceManager.has_service('arakoon-{0}'.format(cluster_name), client=client):
return ServiceManager.get_service_status('arakoon-{0}'.format(cluster_name), client=client)
return False
示例14: stop
# 需要导入模块: from ovs.extensions.services.service import ServiceManager [as 别名]
# 或者: from ovs.extensions.services.service.ServiceManager import has_service [as 别名]
def stop(cluster_name, client):
"""
Stops an arakoon service
:param client: Client on which to stop the service
:param cluster_name: The name of the cluster service to stop
"""
if ServiceManager.has_service('arakoon-{0}'.format(cluster_name), client=client) is True and \
ServiceManager.get_service_status('arakoon-{0}'.format(cluster_name), client=client) is True:
ServiceManager.stop_service('arakoon-{0}'.format(cluster_name), client=client)
示例15: start
# 需要导入模块: from ovs.extensions.services.service import ServiceManager [as 别名]
# 或者: from ovs.extensions.services.service.ServiceManager import has_service [as 别名]
def start(cluster_name, client):
"""
Starts an etcd cluster
:param client: Client on which to start the service
:param cluster_name: The name of the cluster service to start
"""
if ServiceManager.has_service('etcd-{0}'.format(cluster_name), client=client) is True and \
ServiceManager.get_service_status('etcd-{0}'.format(cluster_name), client=client) is False:
ServiceManager.start_service('etcd-{0}'.format(cluster_name), client=client)