当前位置: 首页>>代码示例>>Python>>正文


Python Util.gatewayIpFromNetAddress方法代码示例

本文整理汇总了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
开发者ID:remyd1,项目名称:client,代码行数:59,代码来源:BaseSystem.py

示例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)
开发者ID:StratusLab,项目名称:client,代码行数:11,代码来源:BaseSystem.py

示例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')
开发者ID:StratusLab,项目名称:client,代码行数:4,代码来源:UtilTest.py


注:本文中的stratuslab.Util.gatewayIpFromNetAddress方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。