コード例 #1
0
 def _update_hooks_config(self, new_config):
     with tempfile.NamedTemporaryFile() as f:
         yaml.dump(yaml.load(new_config), f, default_flow_style=False)
         f.flush()
         docl.copy_file_to_manager(source=f.name,
                                   target=self.HOOKS_CONFIG_PATH)
         docl.execute('chown cfyuser: {0}'.format(self.HOOKS_CONFIG_PATH))
コード例 #2
0
 def _restore_security_config(self):
     tmp_config_path = os.path.join(self.workdir, 'rest-security.conf')
     docl.copy_file_to_manager(tmp_config_path,
                               self.REST_SEC_CONFIG_PATH)
     docl.execute('chown cfyuser: {securityconf}'.format(
         securityconf=self.REST_SEC_CONFIG_PATH,
     ))
     self.restart_service('cloudify-restservice')
コード例 #3
0
    def copy_file_to_manager(source, target, owner=None):
        """
        Copy a file to the cloudify manager filesystem

        """
        ret_val = docl.copy_file_to_manager(source=source, target=target)
        if owner:
            BaseTestCase.env.chown(owner, target)
        return ret_val
コード例 #4
0
def prepare_reset_storage_script():
    reset_script = get_resource('scripts/reset_storage.py')
    copy_file_to_manager(reset_script, SCRIPT_PATH)
    with tempfile.NamedTemporaryFile(delete=False) as f:
        json.dump(
            {
                'config': {
                    '': constants.CONFIG_FILE_LOCATION,
                    'security': SECURITY_FILE_LOCATION,
                    'authorization': constants.AUTHORIZATION_FILE_LOCATION
                },
                'ip': utils.get_manager_ip(),
                'username': utils.get_manager_username(),
                'password': utils.get_manager_password(),
                'provider_context': PROVIDER_CONTEXT
            }, f)
    try:
        copy_file_to_manager(f.name, CONFIG_PATH)
    finally:
        os.unlink(f.name)
コード例 #5
0
ファイル: env.py プロジェクト: shadowlord666/cloudify-manager
    def _copy_docker_conf_file(self):
        # the docker_conf.json file is used to pass information
        # to the dockercompute plugin. (see
        # integration_tests_plugins/dockercompute)
        docl.execute('mkdir -p {0}'.format(constants.DOCKER_COMPUTE_DIR))
        with tempfile.NamedTemporaryFile() as f:
            json.dump({
                # The dockercompute plugin needs to know where to find the
                # docker host
                'docker_host': docl.docker_host(),

                # Used for cleanup purposes
                'env_label': self.env_label
            }, f)
            f.flush()
            docl.copy_file_to_manager(
                source=f.name,
                target=os.path.join(constants.DOCKER_COMPUTE_DIR,
                                    'docker_conf.json'))
        self.chown(constants.CLOUDIFY_USER, constants.DOCKER_COMPUTE_DIR)
コード例 #6
0
    def test_hook_config_invalid_yaml(self):
        new_config = """
        test_hook
            invalid: true
"""

        with tempfile.NamedTemporaryFile() as f:
            f.write(new_config)
            f.flush()
            docl.copy_file_to_manager(source=f.name,
                                      target=self.HOOKS_CONFIG_PATH)
            docl.execute('chown cfyuser: {0}'.format(self.HOOKS_CONFIG_PATH))

        self._start_a_workflow()
        workflow_started_error = "ERROR - The hook consumer received " \
                                 "`workflow_started` event but the hook " \
                                 "config file is invalid yaml"
        workflow_succeeded_error = "ERROR - The hook consumer received " \
                                   "`workflow_succeeded` event but the " \
                                   "hook config file is invalid yaml"
        self._assert_messages_in_log([workflow_started_error,
                                      workflow_succeeded_error])
コード例 #7
0
    def test_hook_config_invalid_yaml(self):
        new_config = """
        test_hook
            invalid: true
"""

        with tempfile.NamedTemporaryFile() as f:
            f.write(new_config)
            f.flush()
            docl.copy_file_to_manager(source=f.name,
                                      target=self.HOOKS_CONFIG_PATH)
            docl.execute('chown cfyuser: {0}'.format(self.HOOKS_CONFIG_PATH))

        self._start_a_workflow()
        workflow_started_error = "ERROR - The hook consumer received " \
                                 "`workflow_started` event but the hook " \
                                 "config file is invalid yaml"
        workflow_succeeded_error = "ERROR - The hook consumer received " \
                                   "`workflow_succeeded` event but the " \
                                   "hook config file is invalid yaml"
        self._assert_messages_in_log(
            [workflow_started_error, workflow_succeeded_error])
コード例 #8
0
ファイル: env.py プロジェクト: davidtranno1/cloudify-manager
    def _copy_docker_conf_file(self):
        # the docker_conf.json file is used to pass information
        # to the dockercompute plugin. (see
        # integration_tests_plugins/dockercompute)
        docl.execute('mkdir -p /root/dockercompute')
        with tempfile.NamedTemporaryFile() as f:
            json.dump(
                {
                    # The dockercompute plugin needs to know where to find the
                    # docker host
                    'docker_host': docl.docker_host(),

                    # Used to know from where to mount the plugins storage dir
                    # on dockercompute node instances containers
                    'plugins_storage_dir': self.plugins_storage_dir,

                    # Used for cleanup purposes
                    'env_label': self.env_label
                },
                f)
            f.flush()
            docl.copy_file_to_manager(
                source=f.name, target='/root/dockercompute/docker_conf.json')
コード例 #9
0
 def _restore_security_config(self):
     tmp_config_path = os.path.join(self.workdir, 'rest-security.conf')
     docl.copy_file_to_manager(tmp_config_path, self.REST_SEC_CONFIG_PATH)
     docl.execute('chown cfyuser: {securityconf}'.format(
         securityconf=self.REST_SEC_CONFIG_PATH, ))
     self.restart_service('cloudify-restservice')
コード例 #10
0
def _prepare_set_ldap_script():
    set_ldap_script = get_resource('scripts/set_ldap.py')
    copy_file_to_manager(set_ldap_script, '/tmp/set_ldap.py')
コード例 #11
0
    def copy_file_to_manager(source, target):
        """
        Copy a file to the cloudify manager filesystem

        """
        return docl.copy_file_to_manager(source=source, target=target)