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


Python Misc.get_aws_yaml方法代碼示例

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


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

示例1: info_all

# 需要導入模塊: from misc import Misc [as 別名]
# 或者: from misc.Misc import get_aws_yaml [as 別名]
 def info_all(self):
     elbs = self.get_all_elbs()
     result = []
     yaml = Misc.get_aws_yaml(yaml_file="elb")
     V = Vpc()
     for lb in elbs:
         tmp = lb['LoadBalancerName'].split('-')
         if len(tmp) >= 3:
             elb_env = tmp.pop(0)
             short_env = tmp.pop(0)
             elb_stack = "-".join(tmp)
         elb_facing = lb['Scheme']
         if elb_stack in yaml and elb_facing in yaml[elb_stack]:
             yaml_info = yaml[elb_stack][elb_facing]
             v = V.get_vpc_from_env(env=elb_env)
             domain = Misc.get_value_from_array_hash(dictlist=v.get('Tags'), key="Domain")
             if elb_facing == "internet-facing":
                 elb_dns_name = yaml_info['dns'] + "." + Misc.change_domain_to_local(domain=domain)
             elif elb_facing == "internal":
                 elb_dns_name = yaml_info['dns'] + "." + Misc.change_domain_to_local(domain=domain)
         else:
             elb_dns_name = None
         info = {}
         if elb_dns_name is not None:
             info['DNS cname'] = elb_dns_name
         else:
             info['DNS cname'] = "This elb is not in automatisation framework. Will be decomissioned"
         info['Xively_service'] = Misc.get_value_from_array_hash(dictlist=lb.get('Tags'), key="Xively_service")
         info['Puppet_role'] = Misc.get_value_from_array_hash(dictlist=lb.get('Tags'), key="Puppet_role")
         info['Env'] = Misc.get_value_from_array_hash(dictlist=lb.get('Tags'), key="Environment")
         info['Real endpoint'] = lb['DNSName']
         info['Vpcid'] = lb['VPCId']
         info['Name'] = lb['LoadBalancerName']
         info['CreateTime'] = lb['CreatedTime'].strftime("%Y-%m-%d %H:%M")
         info['Facing'] = elb_facing
         info['Availability Zones'] = lb['AvailabilityZones']
         info['Securitygroups'] = lb['SecurityGroups']
         instance = []
         for i in lb['Instances']:
             instance.append(i['InstanceId'])
         info['InstanceIds'] = instance
         listen = []
         for listener in lb['ListenerDescriptions']:
             listener = listener['Listener']
             listen.append(
                 "%s-%s-%s" % (listener['LoadBalancerPort'], listener['InstancePort'], listener['Protocol']))
         info['From-To-Protocol'] = listen
         result.append(info)
     return result
開發者ID:s4mur4i,項目名稱:char-libv2,代碼行數:51,代碼來源:elb.py


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