• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python guestagent_utils.build_file_path函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中trove.guestagent.common.guestagent_utils.build_file_path函数的典型用法代码示例。如果您正苦于以下问题:Python build_file_path函数的具体用法?Python build_file_path怎么用?Python build_file_path使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了build_file_path函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_build_file_path

    def test_build_file_path(self):
        self.assertEqual(
            'base_dir/base_name',
            guestagent_utils.build_file_path('base_dir', 'base_name'))

        self.assertEqual(
            'base_dir/base_name.ext1',
            guestagent_utils.build_file_path('base_dir', 'base_name', 'ext1'))

        self.assertEqual(
            'base_dir/base_name.ext1.ext2',
            guestagent_utils.build_file_path(
                'base_dir', 'base_name', 'ext1', 'ext2'))
开发者ID:zn-share,项目名称:trove,代码行数:13,代码来源:test_guestagent_utils.py


示例2: build_module_dir

 def build_module_dir(cls, module_type, module_id):
     sub_dir = os.path.join(module_type, module_id)
     module_dir = guestagent_utils.build_file_path(
         cls.MODULE_BASE_DIR, sub_dir)
     if not operating_system.exists(module_dir, is_directory=True):
         operating_system.create_directory(module_dir, force=True)
     return module_dir
开发者ID:Tesora,项目名称:tesora-trove,代码行数:7,代码来源:module_manager.py


示例3: __refresh_prepare_completed

 def __refresh_prepare_completed(self):
     # Set the value of __prepared_completed based on the existence of
     # the file.  This is required as the state is cached so this method
     # must be called any time the existence of the file changes.
     self.__prepare_completed = os.path.isfile(
         guestagent_utils.build_file_path(
             self.GUESTAGENT_DIR, self.PREPARE_END_FILENAME))
开发者ID:Hopebaytech,项目名称:trove,代码行数:7,代码来源:service.py


示例4: configure

    def configure(self, base_config_path, owner, group, codec, requires_root):
        """
        :param base_config_path     Path to the configuration file.
        :type base_config_path      string

        :param owner                Owner of the configuration and
                                    revision files.
        :type owner                 string

        :param group                Group of the configuration and
                                    revision files.
        :type group                 string

        :param codec                Codec for reading/writing of the particular
                                    configuration format.
        :type codec                 StreamCodec

        :param requires_root        Whether the strategy requires superuser
                                    privileges.
        :type requires_root         boolean
        """
        self._base_config_path = base_config_path
        self._owner = owner
        self._group = group
        self._codec = codec
        self._requires_root = requires_root
        self._base_revision_file = guestagent_utils.build_file_path(
            self._revision_dir, self.BASE_REVISION_NAME, self.REVISION_EXT)

        self._import_strategy.configure(
            base_config_path, owner, group, codec, requires_root)
开发者ID:Tesora-Release,项目名称:tesora-trove,代码行数:31,代码来源:configuration.py


示例5: prepare_completed

 def prepare_completed(self, value):
     # Set the value based on the existence of the file; 'value' is ignored
     # This is required as the value of prepare_completed is cached, so
     # this must be referenced any time the existence of the file changes
     self._prepare_completed = os.path.isfile(
         guestagent_utils.build_file_path(
             self.GUESTAGENT_DIR, self.PREPARE_END_FILENAME))
开发者ID:jjmob,项目名称:trove,代码行数:7,代码来源:service.py


示例6: __init__

    def __init__(self, state_change_wait_time=None):
        """
        Sets default status and state_change_wait_time
        """
        if state_change_wait_time:
            self.state_change_wait_time = state_change_wait_time
        else:
            self.state_change_wait_time = CONF.state_change_wait_time

        revision_dir = guestagent_utils.build_file_path(
            os.path.dirname(system.REDIS_CONFIG),
            ConfigurationManager.DEFAULT_STRATEGY_OVERRIDES_SUB_DIR)
        config_value_mappings = {'yes': True, 'no': False, "''": None}
        self._value_converter = StringConverter(config_value_mappings)
        self.configuration_manager = ConfigurationManager(
            system.REDIS_CONFIG,
            system.REDIS_OWNER, system.REDIS_OWNER,
            PropertiesCodec(
                unpack_singletons=False,
                string_mappings=config_value_mappings
            ), requires_root=True,
            override_strategy=OneFileOverrideStrategy(revision_dir))

        self.admin = self._build_admin_client()
        self.status = RedisAppStatus(self.admin)
开发者ID:bhaskarduvvuri,项目名称:trove,代码行数:25,代码来源:service.py


示例7: post_restore

    def post_restore(self):
        try:
            # Root enabled for the backup
            pwd_file = guestagent_utils.build_file_path(
                system.COUCHBASE_DUMP_DIR, self.app.SECRET_KEY_FILE)
            if os.path.exists(pwd_file):
                with open(pwd_file, "r") as f:
                    pw = f.read().rstrip("\n")
                    self.app.reset_admin_credentials(password=pw)

            buckets_json = system.COUCHBASE_DUMP_DIR + system.BUCKETS_JSON
            buckets = self._parse_buckets(buckets_json)
            admin = self.app.build_admin()
            max_num_replicas = admin.get_num_cluster_nodes() - 1
            for bucket in buckets:
                bucket.bucket_replica_count = min(bucket.bucket_replica_count,
                                                  max_num_replicas)

            admin.create_buckets(buckets)
            for bucket in buckets:
                self.run_cbrestore(bucket.name)

        except exception.ProcessExecutionError as p:
            LOG.error(p)
            raise base.RestoreError("Couchbase restore failed.")
开发者ID:Tesora,项目名称:tesora-trove,代码行数:25,代码来源:couchbase_impl.py


示例8: assert_module_retrieve

 def assert_module_retrieve(
     self, client, instance_id, expected_count, expected_http_code=200, expected_results=None
 ):
     try:
         temp_dir = tempfile.mkdtemp()
         prefix = "contents"
         modretrieve_list = client.instances.module_retrieve(instance_id, directory=temp_dir, prefix=prefix)
         self.assert_client_code(expected_http_code, client)
         count = len(modretrieve_list)
         self.assert_equal(expected_count, count, "Wrong number of modules from retrieve")
         expected_results = expected_results or {}
         for module_name, filename in modretrieve_list.items():
             if module_name in expected_results:
                 expected = expected_results[module_name]
                 contents_name = "%s_%s_%s_%s" % (
                     prefix,
                     module_name,
                     expected["datastore"],
                     expected["datastore_version"],
                 )
                 expected_filename = guestagent_utils.build_file_path(temp_dir, contents_name, "dat")
                 self.assert_equal(expected_filename, filename, "Unexpected retrieve filename")
                 if "contents" in expected and expected["contents"]:
                     with open(filename, "rb") as fh:
                         contents = fh.read()
                     # convert contents into bytearray to work with py27
                     # and py34
                     contents = bytes([ord(item) for item in contents])
                     expected_contents = bytes([ord(item) for item in expected["contents"]])
                     self.assert_equal(expected_contents, contents, "Unexpected contents for %s" % module_name)
     finally:
         operating_system.remove(temp_dir)
开发者ID:mmasaki,项目名称:trove,代码行数:32,代码来源:module_runners.py


示例9: apply

    def apply(self, group_name, change_id, options):
        self._initialize_import_directory()
        revision_file = self._find_revision_file(group_name, change_id)
        if revision_file is None:
            # Create a new file.
            last_revision_index = self._get_last_file_index(group_name)
            revision_file = guestagent_utils.build_file_path(
                self._revision_dir,
                '%s-%03d-%s' % (group_name, last_revision_index + 1,
                                change_id),
                self._revision_ext)
        else:
            # Update the existing file.
            current = operating_system.read_file(
                revision_file, codec=self._codec, as_root=self._requires_root)
            options = guestagent_utils.update_dict(options, current)

        operating_system.write_file(
            revision_file, options, codec=self._codec,
            as_root=self._requires_root)
        operating_system.chown(
            revision_file, self._owner, self._group,
            as_root=self._requires_root)
        operating_system.chmod(
            revision_file, FileMode.ADD_READ_ALL, as_root=self._requires_root)
开发者ID:Tesora-Release,项目名称:tesora-trove,代码行数:25,代码来源:configuration.py


示例10: datastore_log_defs

    def datastore_log_defs(self):
        if not self.appStatus.is_running:
            # do nothing if Oracle is not running
            return {}
        owner = system.ORACLE_INSTANCE_OWNER
        group = system.ORACLE_GROUP_OWNER
        sid = self.admin.database_name
        diag_dest = self.admin.get_parameter('diagnostic_dest')
        dbname = sid.lower()
        # alert log path:
        # <diagnostic_dest>/diag/rdbms/<dbname>/<instname>/alert/log.xml
        alert_log_file = self.validate_log_file(
            guestagent_utils.build_file_path(
                path.join(diag_dest, 'diag', 'rdbms', dbname, sid, 'alert'),
                'log', 'xml'
            ), owner, group=group
        )

        return {
            'alert': {
                self.GUEST_LOG_TYPE_LABEL: guest_log.LogType.SYS,
                self.GUEST_LOG_USER_LABEL: owner,
                self.GUEST_LOG_FILE_LABEL: alert_log_file,
            },
        }
开发者ID:paramtech,项目名称:tesora-trove,代码行数:25,代码来源:manager.py


示例11: apply_next

 def apply_next(self, options):
     revision_num = self.count_revisions() + 1
     revision_file_path = guestagent_utils.build_file_path(
         self._revision_dir, self._base_config_name, str(revision_num), self._revision_ext
     )
     operating_system.write_file(revision_file_path, options, codec=self._codec, as_root=self._requires_root)
     operating_system.chown(revision_file_path, self._owner, self._group, as_root=self._requires_root)
     operating_system.chmod(revision_file_path, FileMode.ADD_READ_ALL, as_root=self._requires_root)
开发者ID:cretta,项目名称:trove,代码行数:8,代码来源:configuration.py


示例12: begin_install

    def begin_install(self):
        """First call of the DB prepare."""
        prepare_start_file = guestagent_utils.build_file_path(
            self.GUESTAGENT_DIR, self.PREPARE_START_FILENAME)
        operating_system.write_file(prepare_start_file, '')
        self.__refresh_prepare_completed()

        self.set_status(instance.ServiceStatuses.BUILDING, True)
开发者ID:Hopebaytech,项目名称:trove,代码行数:8,代码来源:service.py


示例13: begin_install

    def begin_install(self):
        """Called right before DB is prepared."""
        prepare_start_file = guestagent_utils.build_file_path(
            self.GUESTAGENT_DIR, self.PREPARE_START_FILENAME)
        operating_system.write_file(prepare_start_file, '')
        self.prepare_completed = False

        self.set_status(instance.ServiceStatuses.BUILDING, True)
开发者ID:paramtech,项目名称:tesora-trove,代码行数:8,代码来源:service.py


示例14: _remove_system_tables

    def _remove_system_tables(self):
        """
        Clean up the system keyspace.

        System tables are initialized on the first boot.
        They store certain properties, such as 'cluster_name',
        that cannot be easily changed once afterwards.
        The system keyspace needs to be cleaned up first. The
        tables will be regenerated on the next startup.
        Make sure to also cleanup the commitlog and caches to avoid
        startup errors due to inconsistencies.

        The service should not be running at this point.
        """
        if self.status.is_running:
            raise RuntimeError(_("Cannot remove system tables. "
                                 "The service is still running."))

        LOG.info(_('Removing existing system tables.'))
        system_keyspace_dir = guestagent_utils.build_file_path(
            self.cassandra_data_dir, 'system')
        commitlog_file = guestagent_utils.build_file_path(
            self.cassandra_working_dir, 'commitlog')
        chaches_dir = guestagent_utils.build_file_path(
            self.cassandra_working_dir, 'saved_caches')

        operating_system.remove(system_keyspace_dir,
                                force=True, recursive=True, as_root=True)
        operating_system.remove(commitlog_file,
                                force=True, recursive=True, as_root=True)
        operating_system.remove(chaches_dir,
                                force=True, recursive=True, as_root=True)

        operating_system.create_directory(
            system_keyspace_dir,
            user=self.cassandra_owner, group=self.cassandra_owner,
            force=True, as_root=True)
        operating_system.create_directory(
            commitlog_file,
            user=self.cassandra_owner, group=self.cassandra_owner,
            force=True, as_root=True)
        operating_system.create_directory(
            chaches_dir,
            user=self.cassandra_owner, group=self.cassandra_owner,
            force=True, as_root=True)
开发者ID:gongwayne,项目名称:Openstack,代码行数:45,代码来源:service.py


示例15: init_config

    def init_config(self):
        if not operating_system.exists(MOUNT_POINT, True):
            operating_system.create_directory(MOUNT_POINT,
                                              system.DB2_INSTANCE_OWNER,
                                              system.DB2_INSTANCE_OWNER,
                                              as_root=True)
        """
        The database manager configuration file - db2systm is stored  under the
        /home/db2inst1/sqllib directory. To update the configuration
        parameters, DB2 recommends using the command - UPDATE DBM CONFIGURATION
        commands instead of directly updating the config file.

        The existing PropertiesCodec implementation has been reused to handle
        text-file operations. Configuration overrides are implemented using
        the ImportOverrideStrategy of the guestagent configuration manager.
        """
        LOG.debug("Initialize DB2 configuration")
        revision_dir = (
            guestagent_utils.build_file_path(
                os.path.join(MOUNT_POINT,
                             os.path.dirname(system.DB2_INSTANCE_OWNER)),
                ConfigurationManager.DEFAULT_STRATEGY_OVERRIDES_SUB_DIR)
        )
        if not operating_system.exists(FAKE_CFG):
            operating_system.write_file(FAKE_CFG, '', as_root=True)
            operating_system.chown(FAKE_CFG, system.DB2_INSTANCE_OWNER,
                                   system.DB2_INSTANCE_OWNER, as_root=True)
        self.configuration_manager = (
            ConfigurationManager(FAKE_CFG, system.DB2_INSTANCE_OWNER,
                                 system.DB2_INSTANCE_OWNER,
                                 PropertiesCodec(delimiter='='),
                                 requires_root=True,
                                 override_strategy=ImportOverrideStrategy(
                                     revision_dir, "cnf"))
        )
        '''
        Below we are getting the database manager default configuration and
        saving it to the DB2_DEFAULT_CFG file. This is done to help with
        correctly resetting the configurations to the original values when
        user wants to detach a user-defined configuration group from an
        instance. DB2 provides a command to reset the database manager
        configuration parameters (RESET DBM CONFIGURATION) but this command
        resets all the configuration parameters to the system defaults. When
        we build a DB2 guest image there are certain configurations
        parameters like SVCENAME which we set so that the instance can start
        correctly. Hence resetting this value to the system default will
        render the instance in an unstable state. Instead, the recommended
        way for resetting a subset of configuration parameters is to save
        the output of GET DBM CONFIGURATION of the original configuration
        and then call UPDATE DBM CONFIGURATION to reset the value.
          http://www.ibm.com/support/knowledgecenter/SSEPGG_10.5.0/
        com.ibm.db2.luw.admin.cmd.doc/doc/r0001970.html
        '''
        if not operating_system.exists(DB2_DEFAULT_CFG):
            run_command(system.GET_DBM_CONFIGURATION % {
                "dbm_config": DB2_DEFAULT_CFG})
        self.process_default_dbm_config()
开发者ID:Tesora,项目名称:tesora-trove,代码行数:57,代码来源:service.py


示例16: build_log_file_name

    def build_log_file_name(self, log_name, owner, datastore_dir=None):
        """Build a log file name based on the log_name and make sure the
        directories exist and are accessible by owner.
        """
        if datastore_dir is None:
            base_dir = self.GUEST_LOG_BASE_DIR
            if not operating_system.exists(base_dir, is_directory=True):
                operating_system.create_directory(
                    base_dir, user=owner, group=owner, force=True,
                    as_root=True)
            datastore_dir = guestagent_utils.build_file_path(
                base_dir, self.GUEST_LOG_DATASTORE_DIRNAME)

        if not operating_system.exists(datastore_dir, is_directory=True):
            operating_system.create_directory(
                datastore_dir, user=owner, group=owner, force=True,
                as_root=True)
        log_file_name = guestagent_utils.build_file_path(
            datastore_dir, '%s-%s.log' % (self.manager, log_name))

        return self.validate_log_file(log_file_name, owner)
开发者ID:HoratiusTang,项目名称:trove,代码行数:21,代码来源:manager.py


示例17: __init__

    def __init__(self):
        self.state_change_wait_time = CONF.state_change_wait_time
        self.status = CassandraAppStatus(self.get_current_superuser())

        revision_dir = guestagent_utils.build_file_path(
            os.path.dirname(self.cassandra_conf),
            ConfigurationManager.DEFAULT_STRATEGY_OVERRIDES_SUB_DIR)
        self.configuration_manager = ConfigurationManager(
            self.cassandra_conf,
            self.cassandra_owner, self.cassandra_owner,
            SafeYamlCodec(default_flow_style=False), requires_root=True,
            override_strategy=OneFileOverrideStrategy(revision_dir))
开发者ID:gongwayne,项目名称:Openstack,代码行数:12,代码来源:service.py


示例18: __init__

    def __init__(self, base_config_path, owner, group, codec,
                 requires_root=False, override_strategy=None):
        """
        :param base_config_path     Path to the configuration file.
        :type base_config_path      string

        :param owner                Owner of the configuration files.
        :type owner                 string

        :param group                Group of the configuration files.
        :type group                 string

        :param codec                Codec for reading/writing of the particular
                                    configuration format.
        :type codec                 StreamCodec

        :param requires_root        Whether the manager requires superuser
                                    privileges.
        :type requires_root         boolean

        :param override_strategy    Strategy used to manage configuration
                                    overrides (e.g. ImportOverrideStrategy).
                                    Defaults to OneFileOverrideStrategy
                                    if None. This strategy should be
                                    compatible with very much any datastore.
                                    It is recommended each datastore defines
                                    its strategy explicitly to avoid upgrade
                                    compatibility issues in case the default
                                    implementation changes in the future.
        :type override_strategy     ConfigurationOverrideStrategy
        """
        self._base_config_path = base_config_path
        self._owner = owner
        self._group = group
        self._codec = codec
        self._requires_root = requires_root
        self._value_cache = None

        if not override_strategy:
            # Use OneFile strategy by default. Store the revisions in a
            # sub-directory at the location of the configuration file.
            revision_dir = guestagent_utils.build_file_path(
                os.path.dirname(base_config_path),
                self.DEFAULT_STRATEGY_OVERRIDES_SUB_DIR)
            operating_system.create_directory(
                revision_dir, user=owner, group=group, force=True,
                as_root=requires_root)
            self._override_strategy = OneFileOverrideStrategy(revision_dir)
        else:
            self._override_strategy = override_strategy

        self._override_strategy.configure(
            base_config_path, owner, group, codec, requires_root)
开发者ID:cp16net,项目名称:trove,代码行数:53,代码来源:configuration.py


示例19: __init__

    def __init__(self, *args, **kwargs):
        super(PgSqlConfig, self).__init__(*args, **kwargs)

        revision_dir = guestagent_utils.build_file_path(
            os.path.dirname(self.pgsql_config),
            ConfigurationManager.DEFAULT_STRATEGY_OVERRIDES_SUB_DIR)
        self._configuration_manager = ConfigurationManager(
            self.pgsql_config, self.PGSQL_OWNER, self.PGSQL_OWNER,
            PropertiesCodec(
                delimiter='=',
                string_mappings={'on': True, 'off': False, "''": None}),
            requires_root=True,
            override_strategy=OneFileOverrideStrategy(revision_dir))
开发者ID:HoratiusTang,项目名称:trove,代码行数:13,代码来源:config.py


示例20: _init_overrides_dir

    def _init_overrides_dir(cls):
        """Initialize a directory for configuration overrides.
        """
        revision_dir = guestagent_utils.build_file_path(
            os.path.dirname(CONFIG_FILE), ConfigurationManager.DEFAULT_STRATEGY_OVERRIDES_SUB_DIR
        )

        if not os.path.exists(revision_dir):
            operating_system.create_directory(
                revision_dir, user=system.MONGO_USER, group=system.MONGO_USER, force=True, as_root=True
            )

        return revision_dir
开发者ID:bbgw,项目名称:trove,代码行数:13,代码来源:service.py



注:本文中的trove.guestagent.common.guestagent_utils.build_file_path函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python guestagent_utils.update_dict函数代码示例发布时间:2022-05-27
下一篇:
Python configuration.ConfigurationManager类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap