本文整理汇总了Python中host.Host.list_ipinterfaces方法的典型用法代码示例。如果您正苦于以下问题:Python Host.list_ipinterfaces方法的具体用法?Python Host.list_ipinterfaces怎么用?Python Host.list_ipinterfaces使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类host.Host
的用法示例。
在下文中一共展示了Host.list_ipinterfaces方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: HostIPInterface
# 需要导入模块: from host import Host [as 别名]
# 或者: from host.Host import list_ipinterfaces [as 别名]
class HostIPInterface(object):
# Indentation START for the class
'''
/compute/ip-interfaces/search
/compute/ip-interfaces/{id}
/compute/ip-interfaces/{id}/deactivate
/compute/ip-interfaces/{id}/exports
'''
# All URIs for the Host ip-interface operations
URI_IPINTERFACE_DETAILS = "/compute/ip-interfaces/{0}"
URI_IPINTERFACE_DETAILS_BULK = "/compute/ip-interfaces/bulk"
URI_HOST_LIST_IPINTERFACES = "/compute/hosts/{0}/ip-interfaces"
URI_IPINTERFACE_DEACTIVATE = "/compute/ip-interfaces/{0}/deactivate"
IPINTERFACE_PROTOCOL_LIST = ['IPV4', 'IPV6']
__hostObject = None
def __init__(self, ipAddr, port):
'''
Constructor: takes IP address and port of the ViPR instance. These are
needed to make http requests for REST API
'''
self.__ipAddr = ipAddr
self.__port = port
self.__hostObject = Host(self.__ipAddr, self.__port)
'''
Returns the ip-interface URI for matching the name of the ip-interface
'''
def query_by_name(self, ipinterfaceName):
# Get the list of ip-interfaces
ipinterfaceList = self.list_all()
# Match the name and return uri
for ipinterface in ipinterfaceList:
if(ipinterface['name'] == ipinterfaceName):
return ipinterface['id']
raise SOSError(
SOSError.NOT_FOUND_ERR,
"Ip-interface with name '" +
ipinterfaceName +
"' not found")
'''
Returns the ip-interface URI for matching the name of the ip-interface
'''
def query_by_ipaddress(self, ipInterfaceIp, hostName, tenant):
# Get the list of ip-interfaces
hostUri = self.get_host_uri(hostName, tenant)
ipinterfaceList = self.get_host_object().list_ipinterfaces(hostUri)
# Match the name and return uri
for ipinterface in ipinterfaceList:
ipinterfaceDetails = self.show_by_uri(ipinterface['id'])
if(ipinterfaceDetails and
ipinterfaceDetails['ip_address'] == ipInterfaceIp):
return ipinterface['id']
raise SOSError(
SOSError.NOT_FOUND_ERR,
"Ip-interface with IP-Address '" +
ipInterfaceIp +
"' not found")
"""
ipinterface create operation
"""
def create(self, hostlabel, protocol, ipAddress,
netMask, prefixLength, scopeId, name, tenant):
hostUri = self.get_host_uri(hostlabel, tenant)
request = {'protocol': protocol,
'ip_address': ipAddress,
#'netmask ' : netMask,
#'prefix_length' :prefixLength,
#'scope_id' : scopeId
}
if(netMask):
request['netmask'] = netMask
if(prefixLength):
request['prefix_length'] = prefixLength
if(scopeId):
request['scopeid'] = scopeId
if(name):
request['name'] = name
body = json.dumps(request)
#.........这里部分代码省略.........