Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhifan huang
slapos
Commits
f9378e9b
Commit
f9378e9b
authored
Dec 03, 2012
by
Cédric de Saint Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
RequestOptional won't raise, only log, if request goes wrong
parent
eeda26cc
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
12 deletions
+15
-12
slapos/recipe/request.py
slapos/recipe/request.py
+15
-12
No files found.
slapos/recipe/request.py
View file @
f9378e9b
...
@@ -123,16 +123,16 @@ class Recipe(object):
...
@@ -123,16 +123,16 @@ class Recipe(object):
isSlave
=
options
.
get
(
'slave'
,
''
).
lower
()
in
\
isSlave
=
options
.
get
(
'slave'
,
''
).
lower
()
in
\
librecipe
.
GenericBaseRecipe
.
TRUE_VALUES
librecipe
.
GenericBaseRecipe
.
TRUE_VALUES
self
.
_raise_request_exception
=
None
try
:
self
.
instance
=
request
(
software_url
,
software_type
,
self
.
instance
=
request
(
software_url
,
software_type
,
name
,
partition_parameter_kw
=
partition_parameter_kw
,
name
,
partition_parameter_kw
=
partition_parameter_kw
,
filter_kw
=
filter_kw
,
shared
=
isSlave
)
filter_kw
=
filter_kw
,
shared
=
isSlave
)
self
.
_raise_resource_not_ready
=
None
try
:
# XXX what is the right way to get a global id?
# XXX what is the right way to get a global id?
options
[
'instance_guid'
]
=
self
.
instance
.
getId
()
options
[
'instance_guid'
]
=
self
.
instance
.
getId
()
except
slapmodule
.
ResourceNotReady
as
exc
:
except
(
slapmodule
.
NotFoundError
,
slapmodule
.
ServerError
,
slapmodule
.
ResourceNotReady
)
as
exc
:
self
.
_raise_resource_not_ready
=
exc
self
.
_raise_request_exception
=
exc
for
param
in
return_parameters
:
for
param
in
return_parameters
:
try
:
try
:
...
@@ -144,8 +144,8 @@ class Recipe(object):
...
@@ -144,8 +144,8 @@ class Recipe(object):
self
.
failed
=
param
self
.
failed
=
param
def
install
(
self
):
def
install
(
self
):
if
self
.
_raise_re
source_not_ready
:
if
self
.
_raise_re
quest_exception
:
raise
s
lapmodule
.
ResourceNotReady
(
self
.
_resource_not_ready
)
raise
s
elf
.
_raise_request_exception
if
self
.
failed
is
not
None
:
if
self
.
failed
is
not
None
:
# Check instance status to know if instance has been deployed
# Check instance status to know if instance has been deployed
...
@@ -169,11 +169,14 @@ class Recipe(object):
...
@@ -169,11 +169,14 @@ class Recipe(object):
class
RequestOptional
(
Recipe
):
class
RequestOptional
(
Recipe
):
"""
"""
Request a SlapOS instance. Won't fail if
instance
is not ready.
Request a SlapOS instance. Won't fail if
request failed or
is not ready.
Same as slapos.cookbook:request, but won't raise in case of problem.
Same as slapos.cookbook:request, but won't raise in case of problem.
"""
"""
def
install
(
self
):
def
install
(
self
):
if
self
.
failed
is
not
None
:
if
self
.
_raise_request_exception
:
self
.
logger
.
warning
(
'Optional request failed:'
)
self
.
logger
.
warning
(
self
.
_raise_request_exception
)
elif
self
.
failed
is
not
None
:
# Check instance status to know if instance has been deployed
# Check instance status to know if instance has been deployed
try
:
try
:
if
self
.
instance
.
_computer_id
is
not
None
:
if
self
.
instance
.
_computer_id
is
not
None
:
...
...
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