Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
zoe
main
Commits
8b28147c
Commit
8b28147c
authored
May 23, 2016
by
Daniele Venzano
Browse files
Add more validation checks to the new fields
parent
894f5045
Changes
1
Hide whitespace changes
Inline
Side-by-side
zoe_master/state/application.py
View file @
8b28147c
...
...
@@ -180,7 +180,7 @@ class ServiceDescription:
return
d
def
from_dict
(
self
,
data
):
required_keys
=
[
'name'
,
'docker_image'
,
'monitor'
]
required_keys
=
[
'name'
,
'docker_image'
,
'monitor'
,
'total_count'
,
'essential_count'
,
'startup_order'
]
for
k
in
required_keys
:
try
:
setattr
(
self
,
k
,
data
[
k
])
...
...
@@ -194,18 +194,22 @@ class ServiceDescription:
try
:
self
.
total_count
=
int
(
data
[
'total_count'
])
if
self
.
total_count
<
1
:
raise
InvalidApplicationDescription
(
msg
=
"total_count must be bigger than zero"
)
except
ValueError
:
raise
InvalidApplicationDescription
(
msg
=
"total_count field should be an int"
)
try
:
self
.
essential_count
=
int
(
data
[
'essential_count'
])
if
self
.
essential_count
<
0
or
self
.
essential_count
>
self
.
total_count
:
raise
InvalidApplicationDescription
(
msg
=
"essential_count must be between zero and total_count"
)
except
ValueError
:
raise
InvalidApplicationDescription
(
msg
=
"essential_count field should be an int"
)
try
:
self
.
startup_order
=
int
(
data
[
'start_order'
])
self
.
startup_order
=
int
(
data
[
'start
up
_order'
])
except
ValueError
:
raise
InvalidApplicationDescription
(
msg
=
"start_order field should be an int"
)
raise
InvalidApplicationDescription
(
msg
=
"start
up
_order field should be an int"
)
if
'ports'
not
in
data
:
raise
InvalidApplicationDescription
(
msg
=
"Missing required key: ports"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment