print(*args, file=sys.stderr, **kwargs) if os.environ.get('CLUSTERDN'): CLUSTERDN = os.environ.get('CLUSTERDN') else: eprint(red('An instance endpoint has to be provided using the CLUSTERDN environment variable')) sys.exit(2) if os.environ.get('REGISTRY'): REGISTRY = os.environ.get('REGISTRY') else: REGISTRY = 'http://consul.service.int.cesga.es:8500/v1/kv' # Retrieve info from the registry registry.connect(REGISTRY) cluster = registry.Cluster(CLUSTERDN) nodes = cluster.nodes services = cluster.services def wait_until_node_is_running(node): """Wait until node is in status running: i.e. docker-executor finished""" name = node.name retry = 0 while not node.status == 'running': retry += 1 if retry > MAX_RETRIES: sys.exit(3) print('Waiting for node {}: {}/{}'.format(name, retry, MAX_RETRIES)) time.sleep(DELAY)
if os.environ.get('CLUSTERDN'): CLUSTERDN = os.environ.get('CLUSTERDN') else: eprint( red('An instance endpoint has to be provided using the CLUSTERDN environment variable' )) sys.exit(2) if os.environ.get('REGISTRY'): REGISTRY = os.environ.get('REGISTRY') else: REGISTRY = 'http://consul.service.int.cesga.es:8500/v1/kv' # Retrieve info from the registry registry.connect(REGISTRY) cluster = registry.Cluster(CLUSTERDN) nodes = cluster.nodes services = cluster.services def wait_until_node_is_running(node): """Wait until node is in status running: i.e. docker-executor finished""" name = node.name retry = 0 while not node.status == 'running': retry += 1 if retry > MAX_RETRIES: sys.exit(3) print('Waiting for node {}: {}/{}'.format(name, retry, MAX_RETRIES)) time.sleep(DELAY)
""" from __future__ import print_function import logging import sys import click import registry from . import docker # we need the config module to load the logging configuration logging.basicConfig(stream=sys.stdout, level=logging.DEBUG, format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s') logger = logging.getLogger(__name__) # For debugging use global endpoint instead of localhost connection registry.connect('http://10.112.0.101:8500/v1/kv') @click.group(chain=True) def cli(): """Run docker containers Example: docker-executor run instances/jlopez/cdh/5.7.0/9/nodes/slave1 """ pass @cli.command('run') @click.option('--pipework/--no-pipework', default=True, help="Add network connectivity")
def setUp(self): registry.connect(URL) self.PREFIX = registry.TMPLPREFIX self.servicename = "__unittests__" self.start_time = time.time()
from flask import jsonify from . import api, app import registry import subprocess import os from tempfile import NamedTemporaryFile import threading CONSUL_ENDPOINT = app.config.get('CONSUL_ENDPOINT') registry.connect(CONSUL_ENDPOINT) @api.route('/clusters/<clusterid>', methods=['POST']) #@asynchronous def run_orchestrator(clusterid): app.logger.info('Request to launch orchestrator for cluster {}' .format(clusterid)) clusterdn = registry.dn_from(clusterid) cluster = registry.get_cluster(dn=clusterdn) product_str = clusterdn.split('/')[2] version_str = clusterdn.split('/')[3] product = registry.get_product(product_str, version_str) orchestrator = product.orchestrator def configure_cluster(): with NamedTemporaryFile(suffix='.py') as fabfile: fabfile.write(orchestrator) fabfile.flush() cluster.status = 'configuring' env = os.environ.copy() env['CLUSTERDN'] = clusterdn
def __init__(self, executor): self.executor = executor self.queue = utils.JobQueue() registry.connect(ENDPOINT)
from __future__ import print_function import logging import copy import requests import registry from registry import id_from ENDPOINT = 'http://consul:8500/v1/kv' DISKS_ENDPOINT = 'http://disks.service.int.cesga.es:5000/resources/disks/v1' registry.connect(ENDPOINT) class DiskServiceError(Exception): pass def update_cluster_progress(node): """Update cluster launching progress""" cluster = node.cluster step = int(cluster.step) + 1 total = len(cluster.nodes) cluster.step = step cluster.progress = int(float(step) / total * 100) if step == total: cluster.status = 'scheduled'