本文整理汇总了Python中hackathon.RequiredFeature.get_assigned_endpoints方法的典型用法代码示例。如果您正苦于以下问题:Python RequiredFeature.get_assigned_endpoints方法的具体用法?Python RequiredFeature.get_assigned_endpoints怎么用?Python RequiredFeature.get_assigned_endpoints使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hackathon.RequiredFeature
的用法示例。
在下文中一共展示了RequiredFeature.get_assigned_endpoints方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_network_config
# 需要导入模块: from hackathon import RequiredFeature [as 别名]
# 或者: from hackathon.RequiredFeature import get_assigned_endpoints [as 别名]
def get_network_config(self, azure_key_id, update):
"""
Return None if image type is vm and not update
Public endpoint should be assigned in real time
:param service:
:return:
"""
azure_service = RequiredFeature("azure_service")
if self.is_vm_image() and not update:
return None
cs = self.virtual_environment[self.T_CLOUD_SERVICE]
nc = self.virtual_environment[self.T_NETWORK_CONFIG]
network_config = ConfigurationSet()
network_config.configuration_set_type = nc[self.T_CONFIGURATION_SET_TYPE]
input_endpoints = nc[self.T_INPUT_ENDPOINTS]
# avoid duplicate endpoint under same cloud service
assigned_endpoints = azure_service.get_assigned_endpoints(azure_key_id, cs[self.SERVICE_NAME])
endpoints = map(lambda i: i[self.T_LOCAL_PORT], input_endpoints)
unassigned_endpoints = map(str, find_unassigned_endpoints(endpoints, assigned_endpoints))
map(lambda (i, u): i.update({self.PORT: u}), zip(input_endpoints, unassigned_endpoints))
for input_endpoint in input_endpoints:
network_config.input_endpoints.input_endpoints.append(
ConfigurationSetInputEndpoint(
input_endpoint[self.NAME],
input_endpoint[self.PROTOCOL],
input_endpoint[self.PORT],
input_endpoint[self.T_LOCAL_PORT]
)
)
return network_config