예제 #1
0
def update_provider_context(data):
    ip = data['ip']
    username = data['rest_username']
    password = data['rest_password']
    rest_port = data['rest_port']
    rest_protocol = data['rest_protocol']
    print 'Updating provider context with broker_ip: {}'.format(ip)
    os.environ.update({
        'REST_HOST': ip,
        'REST_PORT': str(rest_port),
        'REST_PROTOCOL': rest_protocol,
        'SECURITY_ENABLED': str(password is not None),
        'VERIFY_REST_CERTIFICATE': '',
    })
    ctx = CloudifyContext({
        'rest_username': username,
        'rest_password': password
    })
    with current_ctx.push(ctx):
        client = get_rest_client()
    for _ in range(1800):
        try:
            context_obj = client.manager.get_context()
            break
        except:
            time.sleep(0.1)
    else:
        raise
    name = context_obj['name']
    context = context_obj['context']
    context['cloudify']['cloudify_agent']['broker_ip'] = ip
    client.manager.update_context(name, context)
예제 #2
0
 def _request_handler(self):
     request = bottle.request.body.read()
     with current_ctx.push(self.ctx):
         response = self.process(request)
         return bottle.LocalResponse(
             body=response,
             status=200,
             headers={'content-type': 'application/json'})
 def _request_handler(self):
     request = bottle.request.body.read()
     with current_ctx.push(self.ctx):
         response = self.process(request)
         return bottle.LocalResponse(
             body=response,
             status=200,
             headers={'content-type': 'application/json'})
예제 #4
0
    def uninstall_plugin_task(self,
                              plugin,
                              rest_token,
                              tenant,
                              rest_host,
                              target=None,
                              bypass_maintenance=False):

        if target:
            # target was provided, so this is to be installed only on the
            # specified workers, but might have been received by us because
            # it was sent to a fanout exchange.
            # This only matters for mgmtworkers, because agents have no
            # fanout exchanges.
            if get_manager_name() not in target:
                return

        class _EmptyID(object):
            id = None

        class PluginUninstallCloudifyContext(object):
            """A CloudifyContext that has just enough data to uninstall plugins
            """
            def __init__(self):
                self.rest_host = rest_host
                self.tenant_name = tenant['name']
                self.rest_token = rest_token
                self.execution_token = None
                self.logger = logging.getLogger('plugin')
                # deployment/blueprint are not defined for force-installs,
                # but the ctx demands they be objects with an .id
                self.deployment = _EmptyID()
                self.blueprint = _EmptyID()
                self.bypass_maintenance = bypass_maintenance

        with current_ctx.push(PluginUninstallCloudifyContext()):
            uninstall_plugins([plugin])
예제 #5
0
 def installer_func(dep_id='__system__'):
     with current_ctx.push(ctx_obj):
         installer.install(plugins.plugin_struct(file_server), dep_id)
예제 #6
0
 def consume_output(self):
     if self.ctx is not None:
         with current_ctx.push(self.ctx):
             self._do_consume()
     else:
         self._do_consume()