def logout(self): """ Simulate user logout. Note: "start" blocks until the "script" block completes. """ utils.start_service('shill-stop-user-session')
def main(): ctx.logger.info('Starting PostgreSQL Service...') utils.start_service(PS_SERVICE_NAME, append_prefix=False) utils.systemd.verify_alive(PS_SERVICE_NAME, append_prefix=False) if utils.is_upgrade or utils.is_rollback: # restore the 'provider_context' and 'snapshot' elements from file # created in the 'create.py' script. ctx.logger.error('NOT IMPLEMENTED - need to restore upgrade data')
def main(): if not ES_ENDPOINT_IP: ctx.logger.info('Starting Elasticsearch Service...') utils.start_service(ES_SERVICE_NAME, append_prefix=False) es_endpoint_ip = '127.0.0.1' utils.systemd.verify_alive(ES_SERVICE_NAME, append_prefix=False) else: es_endpoint_ip = ES_ENDPOINT_IP elasticsearch_url = 'http://{0}:{1}/'.format(es_endpoint_ip, ES_ENDPOINT_PORT) utils.verify_service_http(ES_SERVICE_NAME, elasticsearch_url, _examine_status_response) check_index_exists(elasticsearch_url) if utils.is_upgrade or utils.is_rollback: # restore the 'provider_context' and 'snapshot' elements from file # created in the 'create.py' script. es_upgrade_utils.restore_upgrade_data(es_endpoint_ip, ES_ENDPOINT_PORT)
#!/usr/bin/env python from os.path import join, dirname from cloudify import ctx ctx.download_resource( join('components', 'utils.py'), join(dirname(__file__), 'utils.py')) import utils # NOQA STAGE_SERVICE_NAME = 'stage' ctx.logger.info('Starting Stage (UI) Service...') utils.start_service(STAGE_SERVICE_NAME)
#!/usr/bin/env python from os.path import join, dirname from cloudify import ctx ctx.download_resource(join('components', 'utils.py'), join(dirname(__file__), 'utils.py')) import utils # NOQA runtime_props = ctx.instance.runtime_properties ctx.logger.info('Starting AMQP-Influx Broker Service...') utils.start_service(runtime_props['service_name'])
#!/usr/bin/env python from os.path import join, dirname from cloudify import ctx ctx.download_resource( join('components', 'utils.py'), join(dirname(__file__), 'utils.py')) import utils # NOQA WEBUI_SERVICE_NAME = 'webui' ctx.logger.info('Starting WebUI Service...') utils.start_service(WEBUI_SERVICE_NAME)
#!/usr/bin/env python from os.path import join, dirname from cloudify import ctx ctx.download_resource( join('components', 'utils.py'), join(dirname(__file__), 'utils.py')) import utils # NOQA runtime_props = ctx.instance.runtime_properties if 'skip_installation' not in runtime_props: ctx.logger.info('Starting Stage (UI) Service...') utils.start_service(runtime_props['service_name'])
req = urllib2.Request(blueprints_url, headers=headers) try: response = urllib2.urlopen(req) except urllib2.URLError as e: ctx.abort_operation('REST service returned an invalid response: {0}' .format(e)) if response.code == 401: ctx.abort_operation('Could not connect to the REST service: ' '401 unauthorized. Possible access control ' 'misconfiguration') if response.code != 200: ctx.abort_operation('REST service returned an unexpected response: {0}' .format(response.code)) try: json.load(response) except ValueError as e: ctx.abort_operation('REST service returned malformed JSON: {0}' .format(e)) ctx.logger.info('Starting Cloudify REST Service...') utils.start_service(REST_SERVICE_NAME) utils.systemd.verify_alive(REST_SERVICE_NAME) restservice_url = 'http://{0}:{1}'.format('127.0.0.1', 8100) utils.verify_service_http(REST_SERVICE_NAME, restservice_url) verify_restservice(restservice_url)
#!/usr/bin/env python from os.path import join, dirname from cloudify import ctx ctx.download_resource( join('components', 'utils.py'), join(dirname(__file__), 'utils.py')) import utils # NOQA RIEMANN_SERVICE_NAME = 'riemann' ctx.logger.info('Starting Riemann Service...') utils.start_service(RIEMANN_SERVICE_NAME) utils.systemd.verify_alive(RIEMANN_SERVICE_NAME)
name='events_queue_message_policy', expression='^cloudify-events$', policy=events_queue_message_policy ) set_rabbitmq_policy( name='metrics_queue_message_policy', expression='^amq\.gen.*$', policy=metrics_queue_message_policy ) set_rabbitmq_policy( name='riemann_deployment_queues_message_ttl', expression='^.*-riemann$', policy=riemann_deployment_queues_message_ttl ) # rabbitmq restart exits with 143 status code that is valid in this case. utils.start_service(RABBITMQ_SERVICE_NAME, ignore_restart_fail=True) rabbitmq_endpoint_ip = '127.0.0.1' utils.systemd.verify_alive(RABBITMQ_SERVICE_NAME) try: check_rabbit_running() except ValueError: ctx.abort_operation('Rabbitmq failed to start') try: check_port_accessible(rabbitmq_endpoint_ip, PORT) except ValueError: ctx.abort_operation('{0} error: port {1}:{2} was not open'.format( RABBITMQ_SERVICE_NAME, rabbitmq_endpoint_ip, PORT))
def start_shill(self): """ Starts a shill instance. """ utils.start_service('shill')
#!/usr/bin/env python from os.path import join, dirname from cloudify import ctx ctx.download_resource( join('components', 'utils.py'), join(dirname(__file__), 'utils.py')) import utils # NOQA AMQPINFLUX_SERVICE_NAME = 'amqpinflux' ctx.logger.info('Starting AMQP-Influx Broker Service...') utils.start_service(AMQPINFLUX_SERVICE_NAME)
def restart_system_processes(self): """ Restart vital system services at the end of the test. """ utils.start_service('shill', ignore_status=True) if self.recover_duts_stopped: utils.start_service('recover_duts', ignore_status=True)
#!/usr/bin/env python from os.path import join, dirname from cloudify import ctx ctx.download_resource(join('components', 'utils.py'), join(dirname(__file__), 'utils.py')) import utils # NOQA LOGSTASH_SERVICE_NAME = 'logstash' ctx.logger.info('Starting Logstash Service...') utils.start_service(LOGSTASH_SERVICE_NAME, append_prefix=False) utils.systemd.verify_alive(LOGSTASH_SERVICE_NAME, append_prefix=False)
#!/usr/bin/env python from os.path import join, dirname from cloudify import ctx ctx.download_resource(join('components', 'utils.py'), join(dirname(__file__), 'utils.py')) import utils # NOQA RIEMANN_SERVICE_NAME = 'riemann' ctx.logger.info('Starting Riemann Service...') utils.start_service(RIEMANN_SERVICE_NAME) utils.systemd.verify_alive(RIEMANN_SERVICE_NAME)
join('components', 'utils.py'), join(dirname(__file__), 'utils.py')) import utils # NOQA MGMT_WORKER_SERVICE_NAME = 'mgmtworker' CELERY_PATH = '/opt/mgmtworker/env/bin/celery' # also hardcoded in create @utils.retry(ValueError) def check_worker_running(): """Use `celery status` to check if the worker is running.""" result = utils.sudo([ 'CELERY_WORK_DIR=/opt/mgmtworker/work', CELERY_PATH, '--config=cloudify.broker_config', 'status' ], ignore_failures=True) if result.returncode != 0: raise ValueError('celery status: worker not running') ctx.logger.info('Starting Management Worker Service...') utils.start_service(MGMT_WORKER_SERVICE_NAME) utils.systemd.verify_alive(MGMT_WORKER_SERVICE_NAME) try: check_worker_running() except ValueError: ctx.abort_operation('Celery worker failed to start')
#!/usr/bin/env python from os.path import join, dirname from cloudify import ctx ctx.download_resource( join('components', 'utils.py'), join(dirname(__file__), 'utils.py')) import utils # NOQA runtime_props = ctx.instance.runtime_properties SERVICE_NAME = runtime_props['service_name'] ctx.logger.info('Starting Logstash Service...') utils.start_service(SERVICE_NAME, append_prefix=False) utils.systemd.verify_alive(SERVICE_NAME, append_prefix=False)
#!/usr/bin/env python from os.path import join, dirname from cloudify import ctx ctx.download_resource( join('components', 'utils.py'), join(dirname(__file__), 'utils.py')) import utils # NOQA LOGSTASH_SERVICE_NAME = 'logstash' ctx.logger.info('Starting Logstash Service...') utils.start_service(LOGSTASH_SERVICE_NAME, append_prefix=False) utils.systemd.verify_alive(LOGSTASH_SERVICE_NAME, append_prefix=False)
except urllib2.HTTPError as e: response = e except urllib2.URLError as e: ctx.abort_operation( 'REST service returned an invalid response: {0}'.format(e)) if response.code == 401: ctx.abort_operation('Could not connect to the REST service: ' '401 unauthorized. Possible access control ' 'misconfiguration') if response.code != 200: ctx.abort_operation( 'REST service returned an unexpected response: {0}'.format( response.code)) try: json.load(response) except ValueError as e: ctx.abort_operation( 'REST service returned malformed JSON: {0}'.format(e)) ctx.logger.info('Starting Cloudify REST Service...') utils.start_service(SERVICE_NAME) ctx.logger.info('Verifying Rest service is running...') utils.systemd.verify_alive(SERVICE_NAME) ctx.logger.info('Verifying Rest service is working as expected...') restservice_url = 'http://{0}:{1}'.format('127.0.0.1', 8100) verify_restservice(restservice_url)
ctx.download_resource(join('components', 'utils.py'), join(dirname(__file__), 'utils.py')) import utils # NOQA MGMT_WORKER_SERVICE_NAME = 'mgmtworker' CELERY_PATH = '/opt/mgmtworker/env/bin/celery' # also hardcoded in create @utils.retry(ValueError) def check_worker_running(): """Use `celery status` to check if the worker is running.""" result = utils.sudo([ 'CELERY_WORK_DIR=/opt/mgmtworker/work', CELERY_PATH, '--config=cloudify.broker_config', 'status' ], ignore_failures=True) if result.returncode != 0: raise ValueError('celery status: worker not running') ctx.logger.info('Starting Management Worker Service...') utils.start_service(MGMT_WORKER_SERVICE_NAME) utils.systemd.verify_alive(MGMT_WORKER_SERVICE_NAME) try: check_worker_running() except ValueError: ctx.abort_operation('Celery worker failed to start')
except urllib2.HTTPError as e: response = e except urllib2.URLError as e: ctx.abort_operation( 'REST service returned an invalid response: {0}'.format(e)) if response.code == 401: ctx.abort_operation('Could not connect to the REST service: ' '401 unauthorized. Possible access control ' 'misconfiguration') if response.code != 200: ctx.abort_operation( 'REST service returned an unexpected response: {0}'.format( response.code)) try: json.load(response) except ValueError as e: ctx.abort_operation( 'REST service returned malformed JSON: {0}'.format(e)) ctx.logger.info('Starting Cloudify REST Service...') utils.start_service(REST_SERVICE_NAME) ctx.logger.info('Verifying Rest service is running...') utils.systemd.verify_alive(REST_SERVICE_NAME) ctx.logger.info('Verifying Rest service is working as expected...') restservice_url = 'http://{0}:{1}'.format('127.0.0.1', 8100) verify_restservice(restservice_url)
ctx.logger.info("Setting RabbitMQ Policies...") set_rabbitmq_policy(name='logs_queue_message_policy', expression='^cloudify-logs$', policy=logs_queue_message_policy) set_rabbitmq_policy(name='events_queue_message_policy', expression='^cloudify-events$', policy=events_queue_message_policy) set_rabbitmq_policy(name='metrics_queue_message_policy', expression='^amq\.gen.*$', policy=metrics_queue_message_policy) set_rabbitmq_policy(name='riemann_deployment_queues_message_ttl', expression='^.*-riemann$', policy=riemann_deployment_queues_message_ttl) # rabbitmq restart exits with 143 status code that is valid in this case. utils.start_service(RABBITMQ_SERVICE_NAME, ignore_restart_fail=True) rabbitmq_endpoint_ip = '127.0.0.1' utils.systemd.verify_alive(RABBITMQ_SERVICE_NAME) try: check_rabbit_running() except ValueError: ctx.abort_operation('Rabbitmq failed to start') try: check_port_accessible(rabbitmq_endpoint_ip, PORT) except ValueError: ctx.abort_operation('{0} error: port {1}:{2} was not open'.format( RABBITMQ_SERVICE_NAME, rabbitmq_endpoint_ip, PORT))