本文整理汇总了Python中eru.models.Host.get_by_addr方法的典型用法代码示例。如果您正苦于以下问题:Python Host.get_by_addr方法的具体用法?Python Host.get_by_addr怎么用?Python Host.get_by_addr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eru.models.Host
的用法示例。
在下文中一共展示了Host.get_by_addr方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: assign_host_to_group
# 需要导入模块: from eru.models import Host [as 别名]
# 或者: from eru.models.Host import get_by_addr [as 别名]
def assign_host_to_group(addr):
data = request.get_json()
group = Group.get_by_name(data['group_name'])
if not group:
raise EruAbortException(code.HTTP_BAD_REQUEST)
host = Host.get_by_addr(addr)
if not host:
raise EruAbortException(code.HTTP_BAD_REQUEST)
if not host.assigned_to_group(group):
raise EruAbortException(code.HTTP_BAD_REQUEST)
return {'r':0, 'msg': code.OK}
示例2: assign_host_to_group
# 需要导入模块: from eru.models import Host [as 别名]
# 或者: from eru.models.Host import get_by_addr [as 别名]
def assign_host_to_group(addr):
data = request.get_json()
group = Group.get_by_name(data['group_name'])
if not group:
raise EruAbortException(consts.HTTP_BAD_REQUEST, 'No group found')
host = Host.get_by_addr(addr)
if not host:
raise EruAbortException(consts.HTTP_BAD_REQUEST, 'No host found')
if not host.assigned_to_group(group):
raise EruAbortException(consts.HTTP_BAD_REQUEST, 'Assign failed')
current_app.logger.info('Host (addr=%s) assigned to group (name=%s)',
addr, data['group_name'])
return {'r':0, 'msg': consts.OK}
示例3: take_one
# 需要导入模块: from eru.models import Host [as 别名]
# 或者: from eru.models.Host import get_by_addr [as 别名]
def take_one(host_ip, netspace, vlan_ip):
host = Host.get_by_addr(host_ip + ':2376')
if not host:
print 'host %s not found' % host_ip
take_gateway(netspace, vlan_ip, host)