Пример #1
0
 def validate(self):
     if not isalphadashscore(self.name):
         self.logger.error('bad subnet name %s \n' % (self.name))
         exit(1)
     try:
         IPNetwork(self.mask)
     except ValueError:
         self.logger.error('bad ip subnet %s for subnet %s\n' % (self.mask, self.name))
         exit(1)
     if not IPAddress(self.gateway) in IPNetwork(self.mask):
         self.logger.error('network: %s Gateway IP (%s) not in subnet for SUBNET line(%s)!\n' % 
             (self.name, self.gateway, self.mask))
         exit(1)
Пример #2
0
def checkFirewall(clientip):
    try:
        clientinrange = any([
            IPAddress(clientip) in IPNetwork(i)
            for i in AceConfig.firewallnetranges
        ])
    except:
        logger.error('Check firewall netranges settings !')
        return False
    return not ((AceConfig.firewallblacklistmode and clientinrange) or
                (not AceConfig.firewallblacklistmode and not clientinrange))
import re
import yaml

from ipaddress import ip_address as IPAddress
from ipaddress import ip_network as IPNetwork

LOG = logging.getLogger(__name__)

ROLES = [
    'ControllerDeployedServer',
    'ComputeDeployedServer',
    'NetworkerDeployedServer',
]

NETWORKS = {
    'internal_api': IPNetwork('172.16.32.0/19'),
    'storage': IPNetwork('192.168.0.0/19'),
    'tenant': IPNetwork('172.16.64.0/19'),
    'external': IPNetwork('129.10.5.0/24'),
    'ctlplane': IPNetwork('172.16.0.0/19'),
}

re_ip = re.compile(r'[^\d](\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})[^\d]')


def find_existing_ips(config):
    addresses = []
    allocated = {k: set() for k in NETWORKS}

    defaults = config['parameter_defaults']