Correct CIDR values in case of invalid is given
Change-Id: I4f2a18acb2f5a0c17e7154368b767c70fd166e8c Fixes: rhbz#969977
This commit is contained in:
parent
eb64ccf8ae
commit
1265f9b608
@ -1,12 +1,24 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import netaddr
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from .utils import ScriptRunner, force_ip
|
from .utils import ScriptRunner, force_ip
|
||||||
from .exceptions import ParamProcessingError, NetworkError
|
from .exceptions import ParamProcessingError, NetworkError
|
||||||
|
|
||||||
|
|
||||||
__all__ = ('ParamProcessingError', 'process_host', 'process_ssh_key')
|
__all__ = ('ParamProcessingError', 'process_cidr', 'process_host',
|
||||||
|
'process_ssh_key')
|
||||||
|
|
||||||
|
|
||||||
|
def process_cidr(param, process_args=None):
|
||||||
|
"""
|
||||||
|
Corrects given CIDR if necessary.
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
return str(netaddr.IPNetwork(param).cidr)
|
||||||
|
except Exception, ex:
|
||||||
|
raise ParamProcessingError(str(ex))
|
||||||
|
|
||||||
|
|
||||||
def process_host(param, process_args=None):
|
def process_host(param, process_args=None):
|
||||||
|
@ -6,8 +6,7 @@ import os
|
|||||||
import uuid
|
import uuid
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from packstack.installer import validators
|
from packstack.installer import processors, utils, validators
|
||||||
from packstack.installer import utils
|
|
||||||
from packstack.installer.exceptions import ScriptRuntimeError
|
from packstack.installer.exceptions import ScriptRuntimeError
|
||||||
|
|
||||||
from packstack.modules.ospluginutils import NovaConfig, getManifestTemplate, appendManifestFile, manifestfiles
|
from packstack.modules.ospluginutils import NovaConfig, getManifestTemplate, appendManifestFile, manifestfiles
|
||||||
@ -203,6 +202,7 @@ def initConfig(controllerObject):
|
|||||||
"USAGE" : "IP Range for Flat DHCP",
|
"USAGE" : "IP Range for Flat DHCP",
|
||||||
"PROMPT" : "Enter the IP Range for Flat DHCP",
|
"PROMPT" : "Enter the IP Range for Flat DHCP",
|
||||||
"OPTION_LIST" : ["^([\d]{1,3}\.){3}[\d]{1,3}/\d\d?$"],
|
"OPTION_LIST" : ["^([\d]{1,3}\.){3}[\d]{1,3}/\d\d?$"],
|
||||||
|
"PROCESSORS" : [processors.process_cidr],
|
||||||
"VALIDATORS" : [validators.validate_regexp],
|
"VALIDATORS" : [validators.validate_regexp],
|
||||||
"DEFAULT_VALUE" : "192.168.32.0/22",
|
"DEFAULT_VALUE" : "192.168.32.0/22",
|
||||||
"MASK_INPUT" : False,
|
"MASK_INPUT" : False,
|
||||||
@ -215,6 +215,7 @@ def initConfig(controllerObject):
|
|||||||
"USAGE" : "IP Range for Floating IP's",
|
"USAGE" : "IP Range for Floating IP's",
|
||||||
"PROMPT" : "Enter the IP Range for Floating IP's",
|
"PROMPT" : "Enter the IP Range for Floating IP's",
|
||||||
"OPTION_LIST" : ["^([\d]{1,3}\.){3}[\d]{1,3}/\d\d?$"],
|
"OPTION_LIST" : ["^([\d]{1,3}\.){3}[\d]{1,3}/\d\d?$"],
|
||||||
|
"PROCESSORS" : [processors.process_cidr],
|
||||||
"VALIDATORS" : [validators.validate_regexp],
|
"VALIDATORS" : [validators.validate_regexp],
|
||||||
"DEFAULT_VALUE" : "10.3.4.0/22",
|
"DEFAULT_VALUE" : "10.3.4.0/22",
|
||||||
"MASK_INPUT" : False,
|
"MASK_INPUT" : False,
|
||||||
|
1
requirements.txt
Normal file
1
requirements.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
netaddr>=0.7.6
|
1
setup.py
1
setup.py
@ -24,6 +24,7 @@ setup(
|
|||||||
include_package_data=True,
|
include_package_data=True,
|
||||||
long_description=read('README'),
|
long_description=read('README'),
|
||||||
zip_safe=False,
|
zip_safe=False,
|
||||||
|
install_requires=['netaddr'],
|
||||||
classifiers=[
|
classifiers=[
|
||||||
"Development Status :: 3 - Alpha",
|
"Development Status :: 3 - Alpha",
|
||||||
"Topic :: Utilities",
|
"Topic :: Utilities",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user