本文整理汇总了Python中stratuslab.Util.gatewayIpFromNetAddress方法的典型用法代码示例。如果您正苦于以下问题:Python Util.gatewayIpFromNetAddress方法的具体用法?Python Util.gatewayIpFromNetAddress怎么用?Python Util.gatewayIpFromNetAddress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stratuslab.Util
的用法示例。
在下文中一共展示了Util.gatewayIpFromNetAddress方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _getConfSubnets
# 需要导入模块: from stratuslab import Util [as 别名]
# 或者: from stratuslab.Util import gatewayIpFromNetAddress [as 别名]
def _getConfSubnets():
subnetTemplate = """
subnet %(subnet)s netmask %(netmask)s {
option routers %(routers)s;
}
"""
subnet = ''
# All net types are defined together with NATing. Assuming NATing for
# Local net type. Need to create a shared network.
if Util.isTrueConfVal(self.nat) and _isAllDhcpGroupsDefined(dhcpGroups):
subnet = """
shared-network StratusLab-LAN {
"""
for _type in self.NET_TYPES_DHCP:
subnet += subnetTemplate % {
'subnet' : getattr(self, self._assembleDhcpAttributeName('%sSubnet' % _type)),
'netmask' : getattr(self, self._assembleDhcpAttributeName('%sNetmask' % _type)),
'routers' : getattr(self, self._assembleDhcpAttributeName('%sRouters' % _type))}
subnet += "}\n"
elif Util.isTrueConfVal(self.nat) and dhcpGroups['OneLocalNetwork']:
subnet = """
shared-network StratusLab-LAN {
"""
# main interface
subnet += """
subnet %(subnet)s netmask %(netmask)s {
}
""" % {'subnet' : self.dhcpSubnet,
'netmask' : self.dhcpNetmask}
# virtual interface
natGateway = getattr(self, 'natGateway', '')
if not natGateway:
natGateway = Util.gatewayIpFromNetAddress(self.natNetwork)
subnet += subnetTemplate % {'subnet' : self.natNetwork,
'netmask' : self.natNetmask,
'routers' : natGateway}
subnet += "}\n"
elif dhcpGroups['OnePublicNetwork']:
# main interface
subnet += """
subnet %(subnet)s netmask %(netmask)s {
}
""" % {'subnet' : self.dhcpSubnet,
'netmask' : self.dhcpNetmask}
elif dhcpGroups['OneLocalNetwork']:
# virtual interface
subnet = subnetTemplate % {
'subnet' : self.dhcpOneLocalNetworkSubnet,
'netmask' : self.dhcpOneLocalNetworkNetmask,
'routers' : self.dhcpOneLocalNetworkRouters}
else:
Util.printWarning('Invalid parameters combination to configure DHCP.')
return subnet
示例2: _configureFirewallNatNetworking
# 需要导入模块: from stratuslab import Util [as 别名]
# 或者: from stratuslab.Util import gatewayIpFromNetAddress [as 别名]
def _configureFirewallNatNetworking(self):
self._enableIpForwarding()
device = self.natNetworkInterface
ip = getattr(self, "natGateway", "")
if not ip:
ip = Util.gatewayIpFromNetAddress(self.natNetwork)
self._configureVirtualNetInterface(device, ip, self.natNetmask)
示例3: testGatewayIpFromNetAddress
# 需要导入模块: from stratuslab import Util [as 别名]
# 或者: from stratuslab.Util import gatewayIpFromNetAddress [as 别名]
def testGatewayIpFromNetAddress(self):
self.assertEqual(Util.gatewayIpFromNetAddress('0.0.0.0'), '0.0.0.1')