def test_put_blueprint_archive_from_url(self):
        port = 53230
        blueprint_id = 'new_blueprint_id'

        archive_path = self.archive_mock_blueprint(
            archive_func=archiving.make_tarbz2file)
        archive_filename = os.path.basename(archive_path)
        archive_dir = os.path.dirname(archive_path)

        archive_url = 'http://localhost:{0}/{1}'.format(
            port, archive_filename)

        fs = FileServer(archive_dir, False, port)
        fs.start()
        try:
            self.wait_for_url(archive_url)

            blueprint_id = self.client.blueprints.publish_archive(
                archive_url,
                blueprint_id).id
            # verifying blueprint exists
            result = self.client.blueprints.get(blueprint_id)
            self.assertEqual(blueprint_id, result.id)
        finally:
            fs.stop()
Пример #2
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()
Пример #3
0
 def test_publish_archive_blueprint_main_file_name(self):
     port = 53230
     blueprint_id = 'publish_archive_blueprint_main_file_name'
     main_file_name = 'blueprint_with_workflows.yaml'
     archive_path = self.archive_mock_blueprint()
     archive_filename = os.path.basename(archive_path)
     archive_dir = os.path.dirname(archive_path)
     fs = FileServer(archive_dir, False, port)
     fs.start()
     try:
         archive_url = 'http://localhost:{0}/{1}'.format(
             port, archive_filename)
         self.wait_for_url(archive_url)
         response = self.client.blueprints.publish_archive(
             archive_url, blueprint_id, main_file_name)
     finally:
         fs.stop()
     self.assertEqual(blueprint_id, response.id)
     self.assertEqual(main_file_name, response.main_file_name)
Пример #4
0
 def _init_file_server(self):
     self.file_server = FileServer(self.tmpdir)
     self.file_server.start()
     self.addCleanup(self.cleanup)
Пример #5
0
 def _init_file_server(cls):
     cls.file_server = FileServer(cls.tmpdir)
     cls.file_server.start()