Skip to content

Commit

Permalink
Remove PRIVATE_NET_AS_PUBLIC configuration variable and add PRIVATE_N…
Browse files Browse the repository at this point in the history
…ET_MASKS
  • Loading branch information
micafer committed Sep 11, 2015
1 parent 2c6761e commit 7c6d41d
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 19 deletions.
2 changes: 1 addition & 1 deletion IM/VirtualMachine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion IM/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
7 changes: 1 addition & 6 deletions IM/radl/radl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion changelog
Original file line number Diff line number Diff line change
Expand Up @@ -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
19 changes: 9 additions & 10 deletions doc/source/manual.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
5 changes: 5 additions & 0 deletions etc/im.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 7c6d41d

Please sign in to comment.