當前位置: 首頁>>代碼示例>>Python>>正文


Python DiscoAWS.hostclass_option_default方法代碼示例

本文整理匯總了Python中disco_aws_automation.DiscoAWS.hostclass_option_default方法的典型用法代碼示例。如果您正苦於以下問題:Python DiscoAWS.hostclass_option_default方法的具體用法?Python DiscoAWS.hostclass_option_default怎麽用?Python DiscoAWS.hostclass_option_default使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在disco_aws_automation.DiscoAWS的用法示例。


在下文中一共展示了DiscoAWS.hostclass_option_default方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: run

# 需要導入模塊: from disco_aws_automation import DiscoAWS [as 別名]
# 或者: from disco_aws_automation.DiscoAWS import hostclass_option_default [as 別名]
def run():
    """Parses command line and dispatches the commands"""
    config = read_config()
    parser = get_parser()
    args = parser.parse_args()
    configure_logging(args.debug)

    environment_name = args.env or config.get("disco_aws", "default_environment")

    aws = DiscoAWS(config, environment_name=environment_name)
    if args.mode == "create":
        product_line = aws.hostclass_option_default(args.hostclass, 'product_line', 'unknown')
        aws.disco_storage.create_ebs_snapshot(args.hostclass, args.size, product_line, not args.unencrypted)
    elif args.mode == "list":
        for snapshot in aws.disco_storage.get_snapshots(args.hostclasses):
            print("{0:26} {1:13} {2:9} {3} {4:4}".format(
                snapshot.tags['hostclass'], snapshot.id, snapshot.status,
                snapshot.start_time, snapshot.volume_size))
    elif args.mode == "cleanup":
        aws.disco_storage.cleanup_ebs_snapshots(args.keep)
    elif args.mode == "capture":
        if args.volume_id:
            extra_snapshot_tags = None
            if args.tags:
                extra_snapshot_tags = dict(tag_item.split(':') for tag_item in args.tags)
            snapshot_id = aws.disco_storage.take_snapshot(args.volume_id, snapshot_tags=extra_snapshot_tags)
            print("Successfully created snapshot: {0}".format(snapshot_id))
        else:
            instances = instances_from_args(aws, args)
            if not instances:
                print("No instances found")
            for instance in instances:
                return_code, output = aws.remotecmd(
                    instance, ["sudo /opt/wgen/bin/take_snapshot.sh"], user="snapshot")
                if return_code:
                    raise Exception("Failed to snapshot instance {0}:\n {1}\n".format(instance, output))
                print("Successfully snapshotted {0}".format(instance))
    elif args.mode == "delete":
        for snapshot_id in args.snapshots:
            aws.disco_storage.delete_snapshot(snapshot_id)
    elif args.mode == "update":
        if args.snapshot_id:
            snapshot = aws.disco_storage.get_snapshot_from_id(args.snapshot_id)
        else:
            snapshot = aws.disco_storage.get_latest_snapshot(args.hostclass)
        aws.discogroup.update_snapshot(snapshot.id, snapshot.volume_size, hostclass=args.hostclass)
開發者ID:amplifylitco,項目名稱:asiaq,代碼行數:48,代碼來源:disco_snapshot.py


注:本文中的disco_aws_automation.DiscoAWS.hostclass_option_default方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。