Add more stronger validation for fixed_network_range

Remove all '!' from examples
Change format for param netboot_enabled from string to integer
This commit is contained in:
Vladmir Sharhsov(warpc) 2013-08-16 12:34:29 +04:00
parent cf7d7c8ee4
commit 4d82febc78
3 changed files with 20 additions and 14 deletions

View File

@ -9,14 +9,14 @@ engine:
# These parameters can be overridden in the specification of a particular node
common_node_settings:
name_servers: ! '"10.20.0.2"'
name_servers: "10.20.0.2"
# These parameters can be overridden in the specification of a particular node
common_power_info:
power_type: ssh
power_user: root
power_pass: /root/.ssh/bootstrap.rsa
netboot_enabled: '1'
netboot_enabled: 1
# These parameters can be overridden in the specification of a particular node
common_ks_meta:
@ -30,7 +30,7 @@ common_ks_meta:
puppet_auto_setup: 1
puppet_master: fuel.domain.tld
mco_auto_setup: 1
auth_key: ! '""'
auth_key: '""'
puppet_version: 2.7.19
mco_connector: rabbitmq
mco_host: 10.20.0.2

View File

@ -32,10 +32,10 @@ mapping:
required: true
desc: Password/credentials for cobbler to manage power of this machine
"netboot_enabled":
type: text
type: int
required: true
desc: Disable/enable netboot for this node.
enum: ['0', '1']
range: { min: 0, max: 1 }
"common_node_settings":
type: map
mapping:

View File

@ -50,18 +50,19 @@ module Astute
require_field(value, path, errors, 'quantum', true, 'fixed_network_range')
require_field(value, path, errors, 'quantum', true, 'quantum_access')
#require_field(value, path, errors, 'quantum', false, 'floating_network_range')
floating_network_range = value['floating_network_range']
quantum = value['quantum']
if quantum
cidr = Regexp.new(CIDR_REGEXP)
if cidr.match(floating_network_range).nil?
msg = "'floating_network_range' is required CIDR notation when quantum is 'true'"
errors << Kwalify::ValidationError.new(msg, path)
end
if value['quantum']
is_cidr_notation?(value['floating_network_range'])
msg = "'floating_network_range' is required CIDR notation when quantum is 'true'"
errors << Kwalify::ValidationError.new(msg, path)
elsif !floating_network_range.is_a?(Array)
msg = "'floating_network_range' is required array of IPs when quantum is 'false'"
errors << Kwalify::ValidationError.new(msg, path)
end
if !is_cidr_notation?(value['fixed_network_range'])
msg = "'floating_network_range' is required CIDR notation"
errors << Kwalify::ValidationError.new(msg, path)
end
when 'Nodes'
#require_field(value, path, errors, 'quantum', true, 'public_br')
#require_field(value, path, errors, 'quantum', true, 'internal_br')
@ -69,7 +70,12 @@ module Astute
end
private
def is_cidr_notation?(value)
cidr = Regexp.new(CIDR_REGEXP)
!cidr.match(value).nil?
end
def require_field(value, path, errors, condition_key, condition_value, key)
return if value[condition_key] != condition_value
field_value = value[key]