def test_download_resource_on_host(self):
     ctx = get_local_context()
     runner = FabricRunner(ctx)
     tasks.download_resource_on_host(
         ctx.logger, runner, AGENT_PACKAGE_URL, 'Ubuntu-agent.tar.gz')
     r = runner.exists('Ubuntu-agent.tar.gz')
     self.assertTrue(r)
Exemple #2
0
    def test_remove_worker(self):
        ctx = get_local_context()

        t.install(ctx)
        t.start(ctx)
        t.stop(ctx)
        t.uninstall(ctx)

        agent_config = ctx.properties['cloudify_agent']

        plugins = _extract_registered_plugins(agent_config['name'])
        # make sure the worker has stopped
        self.assertEqual(0, len(plugins))

        # make sure files are deleted
        service_file_path = "/etc/init.d/celeryd-{0}".format(
            agent_config['name'])
        defaults_file_path = "/etc/default/celeryd-{0}".format(
            agent_config['name'])
        worker_home = agent_config['base_dir']

        runner = FabricRunner(ctx, agent_config)

        self.assertFalse(runner.exists(service_file_path))
        self.assertFalse(runner.exists(defaults_file_path))
        self.assertFalse(runner.exists(worker_home))
 def test_download_resource_on_host(self):
     ctx = get_local_context()
     runner = FabricRunner(ctx)
     tasks.download_resource_on_host(ctx.logger, runner, AGENT_PACKAGE_URL,
                                     'Ubuntu-agent.tar.gz')
     r = runner.exists('Ubuntu-agent.tar.gz')
     self.assertTrue(r)
Exemple #4
0
    def wrapper(*args, **kwargs):
        ctx = _find_type_in_kwargs(context.CloudifyContext,
                                   kwargs.values() + list(args))
        if not ctx:
            raise NonRecoverableError(
                'CloudifyContext not found in invocation args')
        if ctx.type == context.NODE_INSTANCE and \
                'cloudify_agent' in ctx.node.properties:
            agent_config = ctx.node.properties['cloudify_agent']
        else:
            agent_config = kwargs.get('cloudify_agent', {})
        prepare_configuration(ctx, agent_config)
        kwargs['agent_config'] = agent_config
        runner = FabricRunner(ctx, agent_config)
        kwargs['runner'] = runner

        try:
            if not (agent_config.get('distro') and
                    agent_config.get('distro_codename')):
                distro_info = get_machine_distro(runner)
                if not agent_config.get('distro'):
                    agent_config['distro'] = distro_info[0]
                if not agent_config.get('distro_codename'):
                    agent_config['distro_codename'] = distro_info[2]
            return func(*args, **kwargs)
        finally:
            # Fixes CFY-1741 (clear fabric connection cache)
            runner.close()
 def test_download_resource_on_host(self):
     properties = {
         'cloudify_agent': {
             'user': '******',
             'host': VAGRANT_MACHINE_IP,
             'key': '~/.vagrant.d/insecure_private_key',
             'port': 2222,
             'distro': 'Ubuntu',
             'distro_codename': 'trusty'
         }
     }
     ctx = get_remote_context(properties)
     runner = FabricRunner(ctx, ctx.node.properties['cloudify_agent'])
     tasks.download_resource_on_host(
         ctx.logger, runner, AGENT_PACKAGE_URL, 'Ubuntu-agent.tar.gz')
     r = runner.exists('Ubuntu-agent.tar.gz')
     self.assertTrue(r)
 def test_download_resource_on_host(self):
     properties = {
         'cloudify_agent': {
             'user': '******',
             'host': VAGRANT_MACHINE_IP,
             'key': '~/.vagrant.d/insecure_private_key',
             'port': 2222,
             'distro': 'Ubuntu',
             'distro_codename': 'trusty'
         }
     }
     ctx = get_remote_context(properties)
     runner = FabricRunner(ctx, ctx.node.properties['cloudify_agent'])
     tasks.download_resource_on_host(ctx.logger, runner, AGENT_PACKAGE_URL,
                                     'Ubuntu-agent.tar.gz')
     r = runner.exists('Ubuntu-agent.tar.gz')
     self.assertTrue(r)
    def wrapper(*args, **kwargs):
        ctx = _find_type_in_kwargs(context.CloudifyContext,
                                   kwargs.values() + list(args))
        if not ctx:
            raise NonRecoverableError(
                'CloudifyContext not found in invocation args')

        if 'cloudify_agent' in kwargs:
            if ctx.type == context.NODE_INSTANCE and \
                    ctx.node.properties.get('cloudify_agent'):
                raise NonRecoverableError("'cloudify_agent' is configured "
                                          "both as a node property and as an "
                                          "invocation input parameter for "
                                          "operation '{0}'"
                                          .format(ctx.operation.name))
            agent_config = kwargs['cloudify_agent']
        else:
            if ctx.type == context.NODE_INSTANCE and \
                    ctx.node.properties.get('cloudify_agent'):
                agent_config = ctx.node.properties['cloudify_agent']
            else:
                agent_config = {}
        prepare_connection_configuration(ctx, agent_config)
        runner = FabricRunner(ctx, agent_config)
        try:
            prepare_additional_configuration(ctx, agent_config, runner)

            kwargs['runner'] = runner
            kwargs['agent_config'] = agent_config

            if not (agent_config.get('distro') and
                    agent_config.get('distro_codename')):
                distro_info = get_machine_distro(runner)
                if not agent_config.get('distro'):
                    agent_config['distro'] = distro_info[0]
                if not agent_config.get('distro_codename'):
                    agent_config['distro_codename'] = distro_info[2]
            return func(*args, **kwargs)
        finally:
            # Fixes CFY-1741 (clear fabric connection cache)
            runner.close()
    def wrapper(*args, **kwargs):
        ctx = _find_type_in_kwargs(context.CloudifyContext,
                                   kwargs.values() + list(args))
        if not ctx:
            raise NonRecoverableError(
                'CloudifyContext not found in invocation args')

        if 'cloudify_agent' in kwargs:
            if ctx.type == context.NODE_INSTANCE and \
                    ctx.node.properties.get('cloudify_agent'):
                raise NonRecoverableError("'cloudify_agent' is configured "
                                          "both as a node property and as an "
                                          "invocation input parameter for "
                                          "operation '{0}'".format(
                                              ctx.operation.name))
            agent_config = kwargs['cloudify_agent']
        else:
            if ctx.type == context.NODE_INSTANCE and \
                    ctx.node.properties.get('cloudify_agent'):
                agent_config = ctx.node.properties['cloudify_agent']
            else:
                agent_config = {}
        prepare_connection_configuration(ctx, agent_config)
        runner = FabricRunner(ctx, agent_config)
        try:
            prepare_additional_configuration(ctx, agent_config, runner)

            kwargs['runner'] = runner
            kwargs['agent_config'] = agent_config

            if not (agent_config.get('distro')
                    and agent_config.get('distro_codename')):
                distro_info = get_machine_distro(runner)
                if not agent_config.get('distro'):
                    agent_config['distro'] = distro_info[0]
                if not agent_config.get('distro_codename'):
                    agent_config['distro_codename'] = distro_info[2]
            return func(*args, **kwargs)
        finally:
            # Fixes CFY-1741 (clear fabric connection cache)
            runner.close()
Exemple #9
0
 def wrapper(*args, **kwargs):
     ctx = _find_type_in_kwargs(cloudify.context.CloudifyContext,
                                kwargs.values() + list(args))
     if not ctx:
         raise NonRecoverableError(
             'CloudifyContext not found in invocation args')
     if ctx.properties and 'cloudify_agent' in ctx.properties:
         agent_config = ctx.properties['cloudify_agent']
     else:
         agent_config = kwargs.get('cloudify_agent', {})
     prepare_configuration(ctx, agent_config)
     kwargs['agent_config'] = agent_config
     kwargs['runner'] = FabricRunner(ctx, agent_config)
     if not agent_config.get('distro'):
         kwargs['agent_config']['distro'] = \
             get_machine_distro(kwargs['runner'])
     return func(*args, **kwargs)