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 -*-
|
||||
|
||||
import netaddr
|
||||
import os
|
||||
|
||||
from .utils import ScriptRunner, force_ip
|
||||
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):
|
||||
|
@ -6,8 +6,7 @@ import os
|
||||
import uuid
|
||||
import logging
|
||||
|
||||
from packstack.installer import validators
|
||||
from packstack.installer import utils
|
||||
from packstack.installer import processors, utils, validators
|
||||
from packstack.installer.exceptions import ScriptRuntimeError
|
||||
|
||||
from packstack.modules.ospluginutils import NovaConfig, getManifestTemplate, appendManifestFile, manifestfiles
|
||||
@ -203,6 +202,7 @@ def initConfig(controllerObject):
|
||||
"USAGE" : "IP Range for Flat DHCP",
|
||||
"PROMPT" : "Enter the IP Range for Flat DHCP",
|
||||
"OPTION_LIST" : ["^([\d]{1,3}\.){3}[\d]{1,3}/\d\d?$"],
|
||||
"PROCESSORS" : [processors.process_cidr],
|
||||
"VALIDATORS" : [validators.validate_regexp],
|
||||
"DEFAULT_VALUE" : "192.168.32.0/22",
|
||||
"MASK_INPUT" : False,
|
||||
@ -215,6 +215,7 @@ def initConfig(controllerObject):
|
||||
"USAGE" : "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?$"],
|
||||
"PROCESSORS" : [processors.process_cidr],
|
||||
"VALIDATORS" : [validators.validate_regexp],
|
||||
"DEFAULT_VALUE" : "10.3.4.0/22",
|
||||
"MASK_INPUT" : False,
|
||||
|
1
requirements.txt
Normal file
1
requirements.txt
Normal file
@ -0,0 +1 @@
|
||||
netaddr>=0.7.6
|
Loading…
x
Reference in New Issue
Block a user