当前位置: 首页>>代码示例>>Python>>正文


Python guestagent_utils.build_file_path函数代码示例

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


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


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