コード例 #1
0
    def setUp(self):
        self.tmpdir = tempfile.mkdtemp()
        self.rest_service_log = tempfile.mkstemp()[1]
        self.securest_log_file = tempfile.mkstemp()[1]
        self.file_server = FileServer(self.tmpdir)
        self.addCleanup(self.cleanup)
        self.file_server.start()
        storage_manager.storage_manager_module_name = \
            STORAGE_MANAGER_MODULE_NAME

        # workaround for setting the rest service log path, since it's
        # needed when 'server' module is imported.
        # right after the import the log path is set normally like the rest
        # of the variables (used in the reset_state)
        tmp_conf_file = tempfile.mkstemp()[1]
        json.dump({'rest_service_log_path': self.rest_service_log,
                   'rest_service_log_file_size_MB': 1,
                   'rest_service_log_files_backup_count': 1,
                   'rest_service_log_level': 'DEBUG'},
                  open(tmp_conf_file, 'w'))
        os.environ['MANAGER_REST_CONFIG_PATH'] = tmp_conf_file
        try:
            from manager_rest import server
        finally:
            del(os.environ['MANAGER_REST_CONFIG_PATH'])

        server.reset_state(self.create_configuration())
        utils.copy_resources(config.instance().file_server_root)
        server.setup_app()
        server.app.config['Testing'] = True
        self.app = server.app.test_client()
        self.client = self.create_client()
        self.initialize_provider_context()
コード例 #2
0
 def _create_config_and_reset_app(self, server):
     """Create config, and reset Flask app
     :type server: module
     """
     self.server_configuration = self.create_configuration()
     utils.copy_resources(self.server_configuration.file_server_root)
     server.SQL_DIALECT = 'sqlite'
     server.reset_app(self.server_configuration)
コード例 #3
0
ファイル: base_test.py プロジェクト: post123/cloudify-manager
    def _create_config_and_reset_app(cls):
        """Create config, and reset Flask app
        """
        cls.server_configuration = cls.create_configuration()
        utils.copy_resources(cls.server_configuration.file_server_root)
        server.reset_app(cls.server_configuration)

        cls._set_hash_mechanism_to_plaintext()
コード例 #4
0
    def _create_config_and_reset_app(cls):
        """Create config, and reset Flask app
        """
        cls.server_configuration = cls.create_configuration()
        utils.copy_resources(cls.server_configuration.file_server_root)
        server.reset_app(cls.server_configuration)

        cls._set_hash_mechanism_to_plaintext()
コード例 #5
0
    def setUp(self):
        self.tmpdir = tempfile.mkdtemp(prefix='fileserver-')
        fd, self.rest_service_log = tempfile.mkstemp(prefix='rest-log-')
        os.close(fd)
        fd, self.sqlite_db_file = tempfile.mkstemp(prefix='sqlite-db-')
        os.close(fd)
        self.file_server = FileServer(self.tmpdir)
        self.maintenance_mode_dir = tempfile.mkdtemp(prefix='maintenance-')

        self.addCleanup(self.cleanup)
        self.file_server.start()

        # workaround for setting the rest service log path, since it's
        # needed when 'server' module is imported.
        # right after the import the log path is set normally like the rest
        # of the variables (used in the reset_state)
        fd, self.tmp_conf_file = tempfile.mkstemp(prefix='conf-file-')
        os.close(fd)
        with open(self.tmp_conf_file, 'w') as f:
            json.dump({'rest_service_log_path': self.rest_service_log,
                       'rest_service_log_file_size_MB': 1,
                       'rest_service_log_files_backup_count': 1,
                       'rest_service_log_level': 'DEBUG'},
                      f)
        os.environ['MANAGER_REST_CONFIG_PATH'] = self.tmp_conf_file
        try:
            from manager_rest import server
        finally:
            del(os.environ['MANAGER_REST_CONFIG_PATH'])

        self.server_configuration = self.create_configuration()
        server.SQL_DIALECT = 'sqlite'
        server.reset_app(self.server_configuration)
        utils.copy_resources(config.instance.file_server_root)

        self._flask_app_context = server.app.test_request_context()
        self._flask_app_context.push()
        self.addCleanup(self._flask_app_context.pop)

        self.app = self._get_app(server.app)
        self.client = self.create_client()
        server.db.create_all()
        default_tenant = self._init_default_tenant(server.db, server.app)
        self.sm = get_storage_manager()
        self._add_users_and_roles(server.user_datastore, default_tenant)
        self.initialize_provider_context()
コード例 #6
0
    def setUp(self):
        self.tmpdir = tempfile.mkdtemp(prefix='fileserver-')
        fd, self.rest_service_log = tempfile.mkstemp(prefix='rest-log-')
        os.close(fd)
        fd, self.securest_log_file = tempfile.mkstemp(prefix='securest-log-')
        os.close(fd)
        self.file_server = FileServer(self.tmpdir)
        self.maintenance_mode_dir = tempfile.mkdtemp(prefix='maintenance-')

        self.addCleanup(self.cleanup)
        self.file_server.start()

        storage_manager.storage_manager_module_name = \
            STORAGE_MANAGER_MODULE_NAME

        # workaround for setting the rest service log path, since it's
        # needed when 'server' module is imported.
        # right after the import the log path is set normally like the rest
        # of the variables (used in the reset_state)
        fd, self.tmp_conf_file = tempfile.mkstemp(prefix='conf-file-')
        os.close(fd)
        with open(self.tmp_conf_file, 'w') as f:
            json.dump(
                {
                    'rest_service_log_path': self.rest_service_log,
                    'rest_service_log_file_size_MB': 1,
                    'rest_service_log_files_backup_count': 1,
                    'rest_service_log_level': 'DEBUG'
                }, f)
        os.environ['MANAGER_REST_CONFIG_PATH'] = self.tmp_conf_file
        try:
            from manager_rest import server
        finally:
            del (os.environ['MANAGER_REST_CONFIG_PATH'])

        self.server_configuration = self.create_configuration()
        server.reset_state(self.server_configuration)
        utils.copy_resources(config.instance().file_server_root)
        self.flask_app = server.setup_app()
        server.app.config['Testing'] = True
        self.app = server.app.test_client()
        self.client = self.create_client()
        self.initialize_provider_context()
コード例 #7
0
    def start_fileserver(self):

        # workaround to update path
        manager_rest_path = path.dirname(path.dirname(path.dirname(__file__)))
        manager_rest_path = path.join(manager_rest_path, "rest-service")
        sys.path.append(manager_rest_path)
        os.mkdir(self.fileserver_dir)
        from manager_rest.file_server import FileServer
        from manager_rest.utils import copy_resources

        self.file_server_process = FileServer(self.fileserver_dir)
        self.file_server_process.start()

        # copy resources (base yaml etc)
        resources_path = path.abspath(__file__)
        resources_path = path.dirname(resources_path)
        resources_path = path.dirname(resources_path)
        resources_path = path.dirname(resources_path)
        resources_path = path.join(resources_path, "resources")
        copy_resources(self.fileserver_dir, resources_path)

        self.patch_source_urls(self.fileserver_dir)
コード例 #8
0
    def start_fileserver(self):

        # workaround to update path
        manager_rest_path = \
            path.dirname(path.dirname(path.dirname(__file__)))
        manager_rest_path = path.join(manager_rest_path, 'rest-service')
        sys.path.append(manager_rest_path)
        os.mkdir(self.fileserver_dir)
        from manager_rest.file_server import FileServer
        from manager_rest.utils import copy_resources

        self.file_server_process = FileServer(self.fileserver_dir)
        self.file_server_process.start()

        # copy resources (base yaml etc)
        resources_path = path.abspath(__file__)
        resources_path = path.dirname(resources_path)
        resources_path = path.dirname(resources_path)
        resources_path = path.dirname(resources_path)
        resources_path = path.join(resources_path, 'resources')
        copy_resources(self.fileserver_dir, resources_path)

        self.patch_source_urls(self.fileserver_dir)