本文整理汇总了Python中trove.guestagent.common.operating_system.create_directory函数的典型用法代码示例。如果您正苦于以下问题:Python create_directory函数的具体用法?Python create_directory怎么用?Python create_directory使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_directory函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: 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
示例2: __init__
def __init__(self):
self._admin_pwd = None
self._sys_pwd = None
self._db_name = None
self._db_unique_name = None
self.codec = stream_codecs.IniCodec()
if not os.path.isfile(self._CONF_FILE):
operating_system.create_directory(os.path.dirname(self._CONF_FILE),
as_root=True)
section = {self._CONF_ORA_SEC: {}}
operating_system.write_file(self._CONF_FILE, section,
codec=self.codec,
as_root=True)
else:
config = operating_system.read_file(self._CONF_FILE,
codec=self.codec,
as_root=True)
try:
if self._CONF_SYS_KEY in config[self._CONF_ORA_SEC]:
self._sys_pwd = config[self._CONF_ORA_SEC][self._CONF_SYS_KEY]
if self._CONF_ADMIN_KEY in config[self._CONF_ORA_SEC]:
self._admin_pwd = config[self._CONF_ORA_SEC][self._CONF_ADMIN_KEY]
if self._CONF_ROOT_ENABLED in config[self._CONF_ORA_SEC]:
self._root_enabled = config[self._CONF_ORA_SEC][self._CONF_ROOT_ENABLED]
if self._CONF_DB_NAME in config[self._CONF_ORA_SEC]:
self._db_name = config[self._CONF_ORA_SEC][self._CONF_DB_NAME]
if self._CONF_DB_UNIQUE_NAME in config[self._CONF_ORA_SEC]:
self._db_unique_name = config[self._CONF_ORA_SEC][self._CONF_DB_UNIQUE_NAME]
except KeyError:
# the ORACLE section does not exist, stop parsing
pass
开发者ID:cdelatte,项目名称:tesora-trove,代码行数:31,代码来源:service.py
示例3: _run_pre_backup
def _run_pre_backup(self):
"""Create archival contents in dump dir"""
try:
est_dump_size = self.estimate_dump_size()
avail = operating_system.get_bytes_free_on_fs(DB2_DBPATH)
if est_dump_size > avail:
self.cleanup()
raise OSError(_("Need more free space to backup db2 database,"
" estimated %(est_dump_size)s"
" and found %(avail)s bytes free ") %
{'est_dump_size': est_dump_size,
'avail': avail})
operating_system.create_directory(DB2_BACKUP_DIR,
system.DB2_INSTANCE_OWNER,
system.DB2_INSTANCE_OWNER,
as_root=True)
service.run_command(system.QUIESCE_DB2)
dbNames = self.list_dbnames()
for dbName in dbNames:
service.run_command(system.BACKUP_DB % {
'dbname': dbName, 'dir': DB2_BACKUP_DIR})
service.run_command(system.UNQUIESCE_DB2)
except exception.ProcessExecutionError as e:
LOG.debug("Caught exception when preparing the directory")
self.cleanup()
raise e
开发者ID:HoratiusTang,项目名称:trove,代码行数:29,代码来源:db2_impl.py
示例4: init_storage_structure
def init_storage_structure(self, mount_point):
try:
operating_system.create_directory(
mount_point, user=self.couchbase_owner,
group=self.couchbase_owner, as_root=True)
except exception.ProcessExecutionError:
LOG.exception(_("Error while initiating storage structure."))
开发者ID:paramtech,项目名称:tesora-trove,代码行数:7,代码来源:service.py
示例5: _initialize_import_directory
def _initialize_import_directory(self):
"""Lazy-initialize the directory for imported revision files.
"""
if not os.path.exists(self._revision_dir):
operating_system.create_directory(
self._revision_dir, user=self._owner, group=self._group,
force=True, as_root=self._requires_root)
开发者ID:Tesora-Release,项目名称:tesora-trove,代码行数:7,代码来源:configuration.py
示例6: _run_pre_backup
def _run_pre_backup(self):
"""Create archival contents in dump dir"""
try:
est_dump_size = self.estimate_dump_size()
avail = operating_system.get_bytes_free_on_fs(MONGODB_DBPATH)
if est_dump_size > avail:
self.cleanup()
# TODO(atomic77) Though we can fully recover from this error
# BackupRunner will leave the trove instance in a BACKUP state
raise OSError(_("Need more free space to run mongodump, "
"estimated %(est_dump_size)s"
" and found %(avail)s bytes free ") %
{'est_dump_size': est_dump_size,
'avail': avail})
operating_system.create_directory(MONGO_DUMP_DIR, as_root=True)
operating_system.chown(MONGO_DUMP_DIR, mongo_system.MONGO_USER,
mongo_system.MONGO_USER, as_root=True)
# high timeout here since mongodump can take a long time
utils.execute_with_timeout(
'mongodump', '--out', MONGO_DUMP_DIR,
*(self.app.admin_cmd_auth_params()),
run_as_root=True, root_helper='sudo',
timeout=LARGE_TIMEOUT
)
except exception.ProcessExecutionError as e:
LOG.debug("Caught exception when creating the dump")
self.cleanup()
raise e
开发者ID:HoratiusTang,项目名称:trove,代码行数:30,代码来源:mongo_impl.py
示例7: pre_upgrade
def pre_upgrade(self, context):
app = self.mysql_app(self.mysql_app_status.get())
data_dir = app.get_data_dir()
mount_point, _data = os.path.split(data_dir)
save_dir = "%s/etc_mysql" % mount_point
save_etc_dir = "%s/etc" % mount_point
home_save = "%s/trove_user" % mount_point
app.status.begin_restart()
app.stop_db()
if operating_system.exists("/etc/my.cnf", as_root=True):
operating_system.create_directory(save_etc_dir, as_root=True)
operating_system.copy("/etc/my.cnf", save_etc_dir,
preserve=True, as_root=True)
operating_system.copy("/etc/mysql/.", save_dir,
preserve=True, as_root=True)
operating_system.copy("%s/." % os.path.expanduser('~'), home_save,
preserve=True, as_root=True)
self.unmount_volume(context, mount_point=data_dir)
return {
'mount_point': mount_point,
'save_dir': save_dir,
'save_etc_dir': save_etc_dir,
'home_save': home_save
}
开发者ID:Tesora,项目名称:tesora-trove,代码行数:29,代码来源:manager.py
示例8: recreate_wal_archive_dir
def recreate_wal_archive_dir():
operating_system.remove(WAL_ARCHIVE_DIR, force=True, recursive=True,
as_root=True)
operating_system.create_directory(WAL_ARCHIVE_DIR,
user=PgSqlProcess.PGSQL_OWNER,
group=PgSqlProcess.PGSQL_OWNER,
force=True, as_root=True)
开发者ID:Hopebaytech,项目名称:trove,代码行数:7,代码来源:postgresql_impl.py
示例9: recreate_wal_archive_dir
def recreate_wal_archive_dir(self):
wal_archive_dir = self.wal_archive_location
operating_system.remove(wal_archive_dir, force=True, recursive=True,
as_root=True)
operating_system.create_directory(wal_archive_dir,
user=self.pgsql_owner,
group=self.pgsql_owner,
force=True, as_root=True)
开发者ID:Tesora-Release,项目名称:tesora-trove,代码行数:8,代码来源:service.py
示例10: recreate_wal_archive_dir
def recreate_wal_archive_dir(cls):
wal_archive_dir = CONF.postgresql.wal_archive_location
operating_system.remove(wal_archive_dir, force=True, recursive=True,
as_root=True)
operating_system.create_directory(wal_archive_dir,
user=cls.PGSQL_OWNER,
group=cls.PGSQL_OWNER,
force=True, as_root=True)
开发者ID:paramtech,项目名称:tesora-trove,代码行数:8,代码来源:process.py
示例11: pre_restore
def pre_restore(self):
self.stop_db(context=None)
PgBaseBackupUtil.recreate_wal_archive_dir()
datadir = self.pgsql_data_dir
operating_system.remove(datadir, force=True, recursive=True,
as_root=True)
operating_system.create_directory(datadir, user=self.PGSQL_OWNER,
group=self.PGSQL_OWNER, force=True,
as_root=True)
开发者ID:Hopebaytech,项目名称:trove,代码行数:9,代码来源:postgresql_impl.py
示例12: _initialize_writable_run_dir
def _initialize_writable_run_dir(self):
"""Create a writable directory for Mongodb's runtime data
(e.g. PID-file).
"""
mongodb_run_dir = os.path.dirname(system.MONGO_PID_FILE)
LOG.debug("Initializing a runtime directory: %s" % mongodb_run_dir)
operating_system.create_directory(
mongodb_run_dir, user=system.MONGO_USER, group=system.MONGO_USER,
force=True, as_root=True)
开发者ID:Hopebaytech,项目名称:trove,代码行数:9,代码来源:service.py
示例13: 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
示例14: pre_restore
def pre_restore(self):
self.app.stop_db()
LOG.info("Preparing WAL archive dir")
self.app.recreate_wal_archive_dir()
datadir = self.app.pgsql_data_dir
operating_system.remove(datadir, force=True, recursive=True,
as_root=True)
operating_system.create_directory(datadir, user=self.app.pgsql_owner,
group=self.app.pgsql_owner,
force=True, as_root=True)
开发者ID:Tesora-Release,项目名称:tesora-trove,代码行数:10,代码来源:postgresql_impl.py
示例15: pre_restore
def pre_restore(self):
self.stop_db(context=None)
LOG.info("Preparing WAL archive dir")
PgSqlProcess.recreate_wal_archive_dir()
datadir = self.pgsql_data_dir
operating_system.remove(datadir, force=True, recursive=True,
as_root=True)
operating_system.create_directory(datadir, user=self.PGSQL_OWNER,
group=self.PGSQL_OWNER, force=True,
as_root=True)
开发者ID:cdelatte,项目名称:tesora-trove,代码行数:10,代码来源:postgresql_impl.py
示例16: mount
def mount(self):
if not os.path.exists(self.mount_point):
operating_system.create_directory(self.mount_point, as_root=True)
LOG.debug("Mounting volume. Device path:{0}, mount_point:{1}, "
"volume_type:{2}, mount options:{3}".format(
self.device_path, self.mount_point, self.volume_fstype,
self.mount_options))
cmd = ("sudo mount -t %s -o %s %s %s" %
(self.volume_fstype, self.mount_options, self.device_path,
self.mount_point))
child = pexpect.spawn(cmd)
child.expect(pexpect.EOF)
开发者ID:openstacking,项目名称:trove,代码行数:12,代码来源:volume.py
示例17: _install_couchbase
def _install_couchbase(self, packages):
"""
Install the Couchbase Server.
"""
LOG.debug('Installing Couchbase Server. Creating %s' %
self.couchbase_conf_dir)
operating_system.create_directory(self.couchbase_conf_dir,
as_root=True)
pkg_opts = {}
packager.pkg_install(packages, pkg_opts, 1200)
self.start_db()
LOG.debug('Finished installing Couchbase Server.')
开发者ID:Tesora-Release,项目名称:tesora-trove,代码行数:12,代码来源:service.py
示例18: _install_couchbase
def _install_couchbase(self, packages):
"""
Install the Couchbase Server.
"""
LOG.debug('Installing Couchbase Server. Creating %s' %
system.COUCHBASE_CONF_DIR)
operating_system.create_directory(system.COUCHBASE_CONF_DIR,
as_root=True)
pkg_opts = {}
packager.pkg_install(packages, pkg_opts, system.TIME_OUT)
self.start_db()
LOG.debug('Finished installing Couchbase Server.')
开发者ID:HoratiusTang,项目名称:trove,代码行数:12,代码来源:service.py
示例19: __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
示例20: _install_redis
def _install_redis(self, packages):
"""
Install the redis server.
"""
LOG.debug('Installing redis server.')
msg = "Creating %s." % system.REDIS_CONF_DIR
LOG.debug(msg)
operating_system.create_directory(system.REDIS_CONF_DIR, as_root=True)
pkg_opts = {}
packager.pkg_install(packages, pkg_opts, TIME_OUT)
self.start_db()
LOG.debug('Finished installing redis server.')
开发者ID:bhaskarduvvuri,项目名称:trove,代码行数:12,代码来源:service.py
注:本文中的trove.guestagent.common.operating_system.create_directory函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论