diff --git a/IM/VirtualMachine.py b/IM/VirtualMachine.py index a7c8aa1ba..13b92a823 100644 --- a/IM/VirtualMachine.py +++ b/IM/VirtualMachine.py @@ -461,7 +461,7 @@ def setIps(self,public_ips,private_ips): private_net_mask = None # Get the private network mask - for mask in network.private_net_masks: + for mask in Config.PRIVATE_NET_MASKS: if IPAddress(private_ip) in IPNetwork(mask): private_net_mask = mask break diff --git a/IM/config.py b/IM/config.py index e0b2f3b04..1a7145a10 100644 --- a/IM/config.py +++ b/IM/config.py @@ -27,6 +27,9 @@ def parse_options(config, section_name, config_class): config_class.__dict__[option] = config.getboolean(section_name, option) elif isinstance(config_class.__dict__[option], int): config_class.__dict__[option] = config.getint(section_name, option) + elif isinstance(config_class.__dict__[option], list): + str_value = config.get(section_name, option) + config_class.__dict__[option] = str_value.split(',') else: config_class.__dict__[option] = config.get(section_name, option) else: @@ -76,7 +79,7 @@ class Config: VM_INFO_UPDATE_ERROR_GRACE_PERIOD = 120 # This value must be always higher than VM_INFO_UPDATE_FREQUENCY REMOTE_CONF_DIR = "/tmp/.im" MAX_SSH_ERRORS = 5 - PRIVATE_NET_AS_PUBLIC = '' + PRIVATE_NET_MASKS = ["10.0.0.0/8","172.16.0.0/12","192.168.0.0/16","169.254.0.0/16","100.64.0.0/10","192.0.0.0/24","198.18.0.0/15"] CHECK_CTXT_PROCESS_INTERVAL = 5 CONFMAMAGER_CHECK_STATE_INTERVAL = 5 UPDATE_CTXT_LOG_INTERVAL = 20 diff --git a/IM/radl/radl.py b/IM/radl/radl.py index 03323bb5b..1ff2082d1 100644 --- a/IM/radl/radl.py +++ b/IM/radl/radl.py @@ -660,10 +660,6 @@ def check(self, radl): class network(Features, Aspect): """Store a RADL ``network``.""" - - private_net_masks = ["10.0.0.0/8","172.16.0.0/12","192.168.0.0/16","169.254.0.0/16","100.64.0.0/10","192.0.0.0/24","198.18.0.0/15"] - if Config.PRIVATE_NET_AS_PUBLIC in private_net_masks: - private_net_masks.remove(Config.PRIVATE_NET_AS_PUBLIC) def __init__(self, name, features=None, reference=False, line=None): self.id = name @@ -678,8 +674,7 @@ def isPrivateIP(ip): """ Check if an IP address is private """ - - for mask in network.private_net_masks: + for mask in Config.PRIVATE_NET_MASKS: if IPAddress(ip) in IPNetwork(mask): return True return False diff --git a/changelog b/changelog index 47dde98c5..fa93bceae 100644 --- a/changelog +++ b/changelog @@ -140,4 +140,4 @@ IM 1.3.2 * Bugfix in ConfManager formatting volumes * Change Ansible version to 1.9.2 * Improve documentation - + * Remove PRIVATE_NET_AS_PUBLIC configuration variable and add PRIVATE_NET_MASKS diff --git a/doc/source/manual.rst b/doc/source/manual.rst index 8d43d1785..9330da12e 100644 --- a/doc/source/manual.rst +++ b/doc/source/manual.rst @@ -413,19 +413,18 @@ GANGLIA INTEGRATION Maximum frequency to update the Ganglia info (in secs). The default value is ``30``. -IM IN LOCAL INSTALLATIONS -^^^^^^^^^^^^^^^^^^^^^^^^^ +NETWORK OPTIONS +^^^^^^^^^^^^^^^ -.. confval:: PRIVATE_NET_AS_PUBLIC +.. confval:: PRIVATE_NET_MASKS - Private network that IM will detect as public enabling to use - the IM service in installations of only one private Cloud provider. - It must be one of this values: 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, 169.254.0.0/16 - If this feature is not needed undefine or use an empty string. - The default value is ``''``. + List of networks assumed as private. The IM use it to distinguish private from public networks. + IM considers IPs not in these subnets as Public IPs. + It must be a coma separated string of the network definitions (using CIDR) (without spaces). + The default value is ``'10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,192.0.0.0/24,169.254.0.0/16,100.64.0.0/10,198.18.0.0/15'``. -OpenNebula Options -^^^^^^^^^^^^^^^^^^ +OpenNebula connector Options +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The configuration values under the ``OpenNebula`` section: diff --git a/etc/im.cfg b/etc/im.cfg index 65eaf969b..f7fe593c0 100644 --- a/etc/im.cfg +++ b/etc/im.cfg @@ -97,6 +97,11 @@ GANGLIA_INFO_UPDATE_FREQUENCY = 30 # Number of retries of the Ansible playbooks in case of failure PLAYBOOK_RETRIES = 3 +# List of networks assumed as private +# It must be a coma separated string of the network definitions (without spaces) +# This are the default values: +# PRIVATE_NET_MASKS = "10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,169.254.0.0/16,100.64.0.0/10,192.0.0.0/24,198.18.0.0/15" + [OpenNebula] # OpenNebula connector configuration values