本文整理汇总了Python中cattle.Config.container_state_dir方法的典型用法代码示例。如果您正苦于以下问题:Python Config.container_state_dir方法的具体用法?Python Config.container_state_dir怎么用?Python Config.container_state_dir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cattle.Config
的用法示例。
在下文中一共展示了Config.container_state_dir方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _record_state
# 需要导入模块: from cattle import Config [as 别名]
# 或者: from cattle.Config import container_state_dir [as 别名]
def _record_state(self, client, instance, docker_id=None):
if docker_id is None:
container = self.get_container(client, instance)
if container is not None:
docker_id = container['Id']
if docker_id is None:
return
cont_dir = Config.container_state_dir()
tmp_file_path = path.join(cont_dir, 'tmp-%s' % docker_id)
if path.exists(tmp_file_path):
remove(tmp_file_path)
file_path = path.join(cont_dir, docker_id)
if path.exists(file_path):
remove(file_path)
if not path.exists(cont_dir):
makedirs(cont_dir)
with open(tmp_file_path, 'w') as outfile:
marshaller = get_type(MARSHALLER)
data = marshaller.to_string(instance)
outfile.write(data)
rename(tmp_file_path, file_path)
示例2: state_file_exists
# 需要导入模块: from cattle import Config [as 别名]
# 或者: from cattle.Config import container_state_dir [as 别名]
def state_file_exists(docker_id):
try:
cont_dir = Config.container_state_dir()
file_path = path.join(cont_dir, docker_id)
return os.path.exists(file_path)
except:
return False
示例3: remove_state_file
# 需要导入模块: from cattle import Config [as 别名]
# 或者: from cattle.Config import container_state_dir [as 别名]
def remove_state_file(container):
if container:
try:
cont_dir = Config.container_state_dir()
file_path = path.join(cont_dir, container['Id'])
if os.path.exists(file_path):
os.remove(file_path)
except:
pass
示例4: purge_state
# 需要导入模块: from cattle import Config [as 别名]
# 或者: from cattle.Config import container_state_dir [as 别名]
def purge_state(self, client, instance):
container = self.get_container(client, instance)
if container is None:
return
docker_id = container["Id"]
cont_dir = Config.container_state_dir()
files = [path.join(cont_dir, "tmp-%s" % docker_id), path.join(cont_dir, docker_id)]
for f in files:
if path.exists(f):
remove(f)
示例5: on_startup
# 需要导入模块: from cattle import Config [as 别名]
# 或者: from cattle.Config import container_state_dir [as 别名]
def on_startup(self):
env = dict(os.environ)
env['HOST_API_CATTLE_ACCESS_KEY'] = Config.access_key()
env['HOST_API_CATTLE_SECRET_KEY'] = Config.secret_key()
url = 'http://{0}:{1}'.format(Config.cadvisor_ip(),
Config.cadvisor_port())
background(['host-api',
'-cadvisor-url', url,
'-logtostderr=true',
'-ip', Config.host_api_ip(),
'-port', str(Config.host_api_port()),
'-auth=true',
'-host-uuid', DockerConfig.docker_uuid(),
'-public-key', Config.jwt_public_key_file(),
'-cattle-url', Config.api_url(),
'-cattle-state-dir', Config.container_state_dir()],
env=env)