本文整理汇总了Python中cloud.aws.CloudHost.create_new_volume方法的典型用法代码示例。如果您正苦于以下问题:Python CloudHost.create_new_volume方法的具体用法?Python CloudHost.create_new_volume怎么用?Python CloudHost.create_new_volume使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cloud.aws.CloudHost
的用法示例。
在下文中一共展示了CloudHost.create_new_volume方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_disk_for_user
# 需要导入模块: from cloud.aws import CloudHost [as 别名]
# 或者: from cloud.aws.CloudHost import create_new_volume [as 别名]
def get_disk_for_user(user_email):
JBoxEBSVol.log_debug("creating EBS volume for %s", user_email)
if not JBoxEBSVol.HAS_EBS:
raise Exception("EBS disks not enabled")
disk_id = JBoxEBSVol._reserve_disk_id()
if disk_id is None:
raise Exception("No free disk available")
sess_id = unique_sessname(user_email)
sess_props = JBoxSessionProps(sess_id, create=True, user_id=user_email)
if sess_props.is_new:
sess_props.save()
snap_id = sess_props.get_snapshot_id()
if snap_id is None:
snap_id = JBoxEBSVol.DISK_TEMPLATE_SNAPSHOT
JBoxEBSVol.log_debug("will use snapshot id %s for %s", snap_id, user_email)
_dev_path, mnt_path = CloudHost.create_new_volume(snap_id, disk_id, JBoxEBSVol.FS_LOC, tag=user_email)
ebsvol = JBoxEBSVol(mnt_path, user_email=user_email)
if snap_id == JBoxEBSVol.DISK_TEMPLATE_SNAPSHOT:
JBoxEBSVol.log_debug("creating home folder on blank volume for %s", user_email)
ebsvol.restore_user_home()
ebsvol.restore()
#else:
# snap_age_days = CloudHost.get_snapshot_age(snap_id).total_seconds()/(60*60*24)
# if snap_age_days > 7:
# ebsvol.restore_user_home()
JBoxEBSVol.log_debug("setting up instance configuration on disk for %s", user_email)
ebsvol.setup_instance_config()
return ebsvol