Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
feudal
feudalBackend
Commits
762f7dd8
Commit
762f7dd8
authored
Jun 18, 2018
by
Lukas Burgey
Browse files
Rename ..Task to ..State
parent
ca3d7553
Changes
7
Hide whitespace changes
Inline
Side-by-side
django_backend/backend/clientapi/serializers.py
View file @
762f7dd8
...
...
@@ -40,7 +40,7 @@ class DeploymentsSerializer(serializers.Serializer):
)
class
Deployment
Task
Serializer
(
serializers
.
Serializer
):
class
Deployment
State
Serializer
(
serializers
.
Serializer
):
id
=
serializers
.
IntegerField
()
action
=
serializers
.
CharField
()
user
=
UserSerializer
()
...
...
@@ -49,7 +49,7 @@ class DeploymentTaskSerializer(serializers.Serializer):
class
SiteSerializer
(
serializers
.
Serializer
):
ta
sk
s
=
Deployment
Task
Serializer
(
many
=
True
)
s
ta
te
s
=
Deployment
State
Serializer
(
many
=
True
)
class
RabbitMQInstanceSerializer
(
serializers
.
ModelSerializer
):
...
...
django_backend/backend/clientapi/urls.py
View file @
762f7dd8
...
...
@@ -4,6 +4,6 @@ from . import views
URLPATTERNS
=
[
url
(
r
'^deployments'
,
views
.
DeploymentsView
.
as_view
()),
url
(
r
'^config'
,
views
.
ConfigurationView
.
as_view
()),
url
(
r
'^ack/(?P<ta
sk
_id>\d+)'
,
views
.
AckView
.
as_view
()),
url
(
r
'^ack/(?P<
s
ta
te
_id>\d+)'
,
views
.
AckView
.
as_view
()),
url
(
r
'^response'
,
views
.
ResponseView
.
as_view
()),
]
django_backend/backend/clientapi/views.py
View file @
762f7dd8
...
...
@@ -3,7 +3,7 @@ import logging
from
rest_framework
import
generics
,
views
from
rest_framework.authentication
import
BasicAuthentication
from
rest_framework.response
import
Response
from
.serializers
import
Deployment
Task
Serializer
,
ServiceSerializer
,
RabbitMQInstanceSerializer
from
.serializers
import
Deployment
State
Serializer
,
ServiceSerializer
,
RabbitMQInstanceSerializer
from
..models
import
RabbitMQInstance
LOGGER
=
logging
.
getLogger
(
__name__
)
...
...
@@ -15,10 +15,10 @@ AUTHENTICATION_CLASSES = (BasicAuthentication, )
class
DeploymentsView
(
generics
.
ListAPIView
):
authentication_classes
=
AUTHENTICATION_CLASSES
serializer_class
=
Deployment
Task
Serializer
serializer_class
=
Deployment
State
Serializer
def
get_queryset
(
self
):
return
self
.
request
.
user
.
site
.
ta
sk
s
return
self
.
request
.
user
.
site
.
s
ta
te
s
# the client has to fetch the configuration (like services etc.) here
...
...
@@ -42,15 +42,15 @@ class ConfigurationView(views.APIView):
class
AckView
(
views
.
APIView
):
authentication_classes
=
AUTHENTICATION_CLASSES
def
delete
(
self
,
request
,
ta
sk
_id
=
None
):
# find the corresponding ta
sk
for this item
for
item
in
request
.
user
.
site
.
ta
sk
_items
.
all
():
if
item
.
ta
sk
.
id
==
int
(
ta
sk
_id
):
def
delete
(
self
,
request
,
s
ta
te
_id
=
None
):
# find the corresponding
s
ta
te
for this item
for
item
in
request
.
user
.
site
.
s
ta
te
_items
.
all
():
if
item
.
s
ta
te
.
id
==
int
(
s
ta
te
_id
):
item
.
success
()
return
Response
({
'ok'
:
True
})
# this is no critical
LOGGER
.
info
(
'%s executed the obsolete ta
sk
#%s'
,
request
.
user
,
ta
sk
_id
)
LOGGER
.
info
(
'%s executed the obsolete
s
ta
te
#%s'
,
request
.
user
,
s
ta
te
_id
)
return
Response
({
'ok'
:
True
})
...
...
@@ -60,33 +60,33 @@ class ResponseView(views.APIView):
def
post
(
self
,
request
):
output
=
request
.
data
[
'output'
]
status
=
output
[
'status'
]
ta
sk
_id
=
request
.
data
[
'id'
]
s
ta
te
_id
=
request
.
data
[
'id'
]
LOGGER
.
debug
(
'%s responded to ta
sk
%s:
\n
%s'
,
request
.
user
,
ta
sk
_id
,
request
.
data
)
LOGGER
.
debug
(
'%s responded to
s
ta
te
%s:
\n
%s'
,
request
.
user
,
s
ta
te
_id
,
request
.
data
)
# find the corresponding ta
sk
for this item
ta
sk
_item
=
None
for
item
in
request
.
user
.
site
.
ta
sk
_items
.
all
():
if
item
.
ta
sk
.
id
==
int
(
ta
sk
_id
):
ta
sk
_item
=
item
# find the corresponding
s
ta
te
for this item
s
ta
te
_item
=
None
for
item
in
request
.
user
.
site
.
s
ta
te
_items
.
all
():
if
item
.
s
ta
te
.
id
==
int
(
s
ta
te
_id
):
s
ta
te
_item
=
item
if
ta
sk
_item
is
not
None
:
if
s
ta
te
_item
is
not
None
:
if
status
==
'success'
:
ta
sk
_item
.
success
(
s
ta
te
_item
.
success
(
credentials
=
request
.
data
.
output
.
get
(
'credentials'
,
None
),
)
return
Response
({})
elif
status
==
'fail'
:
ta
sk
_item
.
failed
()
s
ta
te
_item
.
failed
()
return
Response
({})
elif
status
==
'reject'
:
ta
sk
_item
.
rejected
(
output
[
'questionnaire'
])
s
ta
te
_item
.
rejected
(
output
[
'questionnaire'
])
return
Response
({})
LOGGER
.
info
(
'%s executed the obsolete ta
sk
#%s'
,
request
.
user
,
ta
sk
_id
)
LOGGER
.
info
(
'%s executed the obsolete
s
ta
te
#%s'
,
request
.
user
,
s
ta
te
_id
)
return
Response
(
data
=
{
'error'
:
'obsolete_ta
sk
'
},
data
=
{
'error'
:
'obsolete_
s
ta
te
'
},
status
=
500
,
)
django_backend/backend/frontend/serializers.py
View file @
762f7dd8
...
...
@@ -20,14 +20,14 @@ class ServiceSerializer(serializers.ModelSerializer):
exclude
=
[]
class
Deployment
Task
ItemSerializer
(
serializers
.
ModelSerializer
):
class
Deployment
State
ItemSerializer
(
serializers
.
ModelSerializer
):
service
=
ServiceSerializer
()
key
=
backend_serializers
.
SSHPublicKeySerializerB
()
site
=
SiteSerializer
()
questionnaire
=
serializers
.
JSONField
()
class
Meta
:
model
=
models
.
Deployment
Task
Item
model
=
models
.
Deployment
State
Item
fields
=
[
'action'
,
'key'
,
...
...
@@ -39,11 +39,11 @@ class DeploymentTaskItemSerializer(serializers.ModelSerializer):
]
class
Deployment
Task
Serializer
(
serializers
.
ModelSerializer
):
class
Deployment
State
Serializer
(
serializers
.
ModelSerializer
):
key
=
backend_serializers
.
SSHPublicKeySerializerB
()
service
=
ServiceSerializer
()
class
Meta
:
model
=
models
.
Deployment
Task
model
=
models
.
Deployment
State
fields
=
[
'action'
,
'key'
,
...
...
@@ -56,8 +56,8 @@ class DeploymentSerializer(serializers.Serializer):
service
=
ServiceSerializer
()
ssh_keys
=
backend_serializers
.
SSHPublicKeySerializer
(
many
=
True
)
ssh_keys_to_withdraw
=
backend_serializers
.
SSHPublicKeySerializer
(
many
=
True
)
deploys
=
Deployment
Task
Serializer
(
many
=
True
)
withdrawals
=
Deployment
Task
Serializer
(
many
=
True
)
deploys
=
Deployment
State
Serializer
(
many
=
True
)
withdrawals
=
Deployment
State
Serializer
(
many
=
True
)
class
Meta
:
model
=
models
.
Deployment
...
...
@@ -76,8 +76,8 @@ class UserSerializer(serializers.ModelSerializer):
ssh_keys
=
backend_serializers
.
SSHPublicKeySerializer
(
many
=
True
)
deployments
=
DeploymentSerializer
(
many
=
True
)
auth_groups
=
backend_serializers
.
AuthGroupSerializer
(
many
=
True
)
deployment_ta
sk
s
=
Deployment
Task
Serializer
(
many
=
True
)
deployment_ta
sk
_items
=
Deployment
Task
ItemSerializer
(
many
=
True
)
deployment_
s
ta
te
s
=
Deployment
State
Serializer
(
many
=
True
)
deployment_
s
ta
te
_items
=
Deployment
State
ItemSerializer
(
many
=
True
)
class
Meta
:
model
=
models
.
User
...
...
@@ -89,8 +89,8 @@ class UserSerializer(serializers.ModelSerializer):
'groups'
,
'deployments'
,
'auth_groups'
,
'deployment_ta
sk
s'
,
'deployment_ta
sk
_items'
,
'deployment_
s
ta
te
s'
,
'deployment_
s
ta
te
_items'
,
]
...
...
django_backend/backend/frontend/views.py
View file @
762f7dd8
...
...
@@ -131,9 +131,9 @@ class DeploymentView(views.APIView):
class
QuestionnaireView
(
views
.
APIView
):
def
post
(
self
,
request
):
ta
sk
_item_id
=
request
.
query_params
.
get
(
'id'
,
''
)
if
ta
sk
_item_id
!=
''
:
item
=
models
.
Deployment
Task
Item
.
objects
.
filter
(
id
=
int
(
ta
sk
_item_id
))
s
ta
te
_item_id
=
request
.
query_params
.
get
(
'id'
,
''
)
if
s
ta
te
_item_id
!=
''
:
item
=
models
.
Deployment
State
Item
.
objects
.
filter
(
id
=
int
(
s
ta
te
_item_id
))
if
item
.
exists
():
item
.
first
().
questionnaire_answered
(
answers
=
request
.
data
,
...
...
django_backend/backend/models.py
View file @
762f7dd8
...
...
@@ -330,7 +330,7 @@ class User(AbstractUser):
self
.
deactivate
()
# FIXME: deleting the user brings problems:
# the deletion cascades down to Deployment
Task
and Deployment
Task
Item
# the deletion cascades down to Deployment
State
and Deployment
State
Item
# but these need to be conserved so all clients withdrawals can be tracked
LOGGER
.
info
(
self
.
msg
(
'Deleting'
))
self
.
delete
()
...
...
@@ -399,15 +399,15 @@ class Site(models.Model):
def
__str__
(
self
):
return
self
.
name
# ta
sk
s which are still to be executed on this site
#
s
ta
te
s which are still to be executed on this site
@
property
def
ta
sk
s
(
self
):
ta
sk
_items
=
self
.
ta
sk
_items
.
filter
(
state
=
'pending'
)
\
|
self
.
ta
sk
_items
.
filter
(
state
=
'failed'
)
\
|
self
.
ta
sk
_items
.
filter
(
state
=
'answered'
)
return
[
item
.
ta
sk
def
s
ta
te
s
(
self
):
s
ta
te
_items
=
self
.
s
ta
te
_items
.
filter
(
state
=
'pending'
)
\
|
self
.
s
ta
te
_items
.
filter
(
state
=
'failed'
)
\
|
self
.
s
ta
te
_items
.
filter
(
state
=
'answered'
)
return
[
item
.
s
ta
te
for
item
in
ta
sk
_items
]
in
s
ta
te
_items
]
class
Service
(
models
.
Model
):
...
...
@@ -458,7 +458,7 @@ class SSHPublicKey(models.Model):
# somewhere
# the receiver 'delete_withdrawn_ssh_key' does the actual deletion
def
delete_key
(
self
):
if
(
not
self
.
ta
sk
s
.
exists
()
and
not
self
.
deployments
.
exists
()):
if
(
not
self
.
s
ta
te
s
.
exists
()
and
not
self
.
deployments
.
exists
()):
LOGGER
.
info
(
self
.
msg
(
'Direct deletion of key'
))
self
.
delete
()
return
...
...
@@ -473,7 +473,7 @@ class SSHPublicKey(models.Model):
# when a key is withdrawn by a client we try to finally delete it
def
try_final_deletion
(
self
):
if
(
self
.
deleted
and
not
self
.
ta
sk
s
.
exists
()):
if
(
self
.
deleted
and
not
self
.
s
ta
te
s
.
exists
()):
LOGGER
.
info
(
self
.
msg
(
'All clients have withdrawn this key. Final deletion'
))
self
.
delete
()
...
...
@@ -490,8 +490,8 @@ class SSHPublicKey(models.Model):
# (exception: if is_active=False the ssh_keys contain the keys to be deployed
# if the deployment is reactivated)
#
# Deployment
Task
is what is sent to the clients via rabbitmq
# The Deployment
Task
Item track the acknowledgements from the clients
# Deployment
State
is what is sent to the clients via rabbitmq
# The Deployment
State
Item track the acknowledgements from the clients
class
Deployment
(
models
.
Model
):
user
=
models
.
ForeignKey
(
User
,
...
...
@@ -539,11 +539,11 @@ class Deployment(models.Model):
@
property
def
withdrawals
(
self
):
return
self
.
ta
sk
s
.
filter
(
action
=
'withdraw'
)
return
self
.
s
ta
te
s
.
filter
(
action
=
'withdraw'
)
@
property
def
deploys
(
self
):
return
self
.
ta
sk
s
.
filter
(
action
=
'deploy'
)
return
self
.
s
ta
te
s
.
filter
(
action
=
'deploy'
)
def
__str__
(
self
):
return
'{}:{}'
.
format
(
self
.
service
,
self
.
user
)
...
...
@@ -581,21 +581,21 @@ class Deployment(models.Model):
# only deploy the key
def
_deploy_key
(
self
,
key
):
ta
sk
=
Deployment
Task
.
construct_deployment_ta
sk
(
s
ta
te
=
Deployment
State
.
construct_deployment_
s
ta
te
(
deployment
=
self
,
key
=
key
,
)
# publish the ta
sk
ta
sk
.
publish
()
# publish the
s
ta
te
s
ta
te
.
publish
()
def
_withdraw_key
(
self
,
key
):
ta
sk
=
Deployment
Task
.
construct_withdrawal_ta
sk
(
s
ta
te
=
Deployment
State
.
construct_withdrawal_
s
ta
te
(
deployment
=
self
,
key
=
key
,
)
# publish the ta
sk
ta
sk
.
publish
()
# publish the
s
ta
te
s
ta
te
.
publish
()
# deploy key and track changes in the key lists
def
deploy_key
(
self
,
key
):
...
...
@@ -633,9 +633,9 @@ def invert_action(action):
return
'deploy'
# Deployment
Task
: knows:
# Deployment
State
: knows:
# user, service, key, action
class
Deployment
Task
(
models
.
Model
):
class
Deployment
State
(
models
.
Model
):
ACTION_CHOICES
=
(
(
'deploy'
,
'deploy'
),
(
'withdraw'
,
'withdraw'
),
...
...
@@ -646,38 +646,38 @@ class DeploymentTask(models.Model):
)
key
=
models
.
ForeignKey
(
SSHPublicKey
,
related_name
=
'ta
sk
s'
,
related_name
=
'
s
ta
te
s'
,
on_delete
=
models
.
CASCADE
,
)
deployment
=
models
.
ForeignKey
(
Deployment
,
related_name
=
'ta
sk
s'
,
related_name
=
'
s
ta
te
s'
,
on_delete
=
models
.
CASCADE
,
)
user
=
models
.
ForeignKey
(
User
,
related_name
=
'deployment_ta
sk
s'
,
related_name
=
'deployment_
s
ta
te
s'
,
on_delete
=
models
.
CASCADE
,
)
# the inverse action of this ta
sk
is requirred
# so we invert the ta
sk
and manage its ta
sk
_items accordingly
def
invert_ta
sk
(
self
):
# the inverse action of this
s
ta
te
is requirred
# so we invert the
s
ta
te
and manage its
s
ta
te
_items accordingly
def
invert_
s
ta
te
(
self
):
LOGGER
.
debug
(
self
.
msg
(
'inverting'
))
previous_action
=
self
.
action
self
.
action
=
invert_action
(
previous_action
)
self
.
save
()
pending_sites
=
[
ta
sk
.
site
for
ta
sk
in
self
.
ta
sk
_items
.
all
()]
pending_sites
=
[
s
ta
te
.
site
for
s
ta
te
in
self
.
s
ta
te
_items
.
all
()]
self
.
chancel_items
()
# sites which already executed the ta
sk
# sites which already executed the
s
ta
te
# we have to send them an order to rollback the changes
for
site
in
self
.
deployment
.
service
.
site
.
all
():
if
site
not
in
pending_sites
:
deploy
=
Deployment
Task
Item
(
ta
sk
=
self
,
deploy
=
Deployment
State
Item
(
s
ta
te
=
self
,
site
=
site
,
user
=
self
.
deployment
.
user
)
...
...
@@ -685,83 +685,83 @@ class DeploymentTask(models.Model):
LOGGER
.
debug
(
deploy
.
msg
(
'pending'
))
@
classmethod
def
construct_deployment_ta
sk
(
cls
,
deployment
,
key
):
# does a ta
sk
exist for this key?
query
=
deployment
.
ta
sk
s
.
filter
(
key
=
key
)
def
construct_deployment_
s
ta
te
(
cls
,
deployment
,
key
):
# does a
s
ta
te
exist for this key?
query
=
deployment
.
s
ta
te
s
.
filter
(
key
=
key
)
if
query
.
exists
():
if
len
(
query
)
>
1
:
raise
Exception
(
'Unexpected query result'
)
ta
sk
=
query
.
first
()
if
ta
sk
.
action
==
'deploy'
:
raise
Exception
(
'Constructing deployment ta
sk
when one already exists'
)
s
ta
te
=
query
.
first
()
if
s
ta
te
.
action
==
'deploy'
:
raise
Exception
(
'Constructing deployment
s
ta
te
when one already exists'
)
ta
sk
.
invert_ta
sk
()
return
ta
sk
s
ta
te
.
invert_
s
ta
te
()
return
s
ta
te
else
:
#create new ta
sk
ta
sk
=
cls
(
#create new
s
ta
te
s
ta
te
=
cls
(
action
=
'deploy'
,
deployment
=
deployment
,
key
=
key
,
user
=
deployment
.
user
,
)
ta
sk
.
save
()
LOGGER
.
debug
(
ta
sk
.
msg
(
'pending'
))
s
ta
te
.
save
()
LOGGER
.
debug
(
s
ta
te
.
msg
(
'pending'
))
# generate ta
sk
items
# generate
s
ta
te
items
for
site
in
deployment
.
service
.
site
.
all
():
deploy
=
Deployment
Task
Item
(
ta
sk
=
task
,
deploy
=
Deployment
State
Item
(
s
ta
te
=
state
,
site
=
site
,
user
=
deployment
.
user
)
deploy
.
save
()
LOGGER
.
debug
(
deploy
.
msg
(
'pending'
))
return
ta
sk
return
s
ta
te
@
classmethod
def
construct_withdrawal_ta
sk
(
cls
,
deployment
,
key
):
# does a ta
sk
exist for this key?
query
=
deployment
.
ta
sk
s
.
filter
(
key
=
key
)
def
construct_withdrawal_
s
ta
te
(
cls
,
deployment
,
key
):
# does a
s
ta
te
exist for this key?
query
=
deployment
.
s
ta
te
s
.
filter
(
key
=
key
)
if
query
.
exists
():
if
len
(
query
)
>
1
:
raise
Exception
(
'Unexpected query result'
)
ta
sk
=
query
.
first
()
if
ta
sk
.
action
==
'withdraw'
:
raise
Exception
(
'Constructing deployment ta
sk
when one already exists'
)
s
ta
te
=
query
.
first
()
if
s
ta
te
.
action
==
'withdraw'
:
raise
Exception
(
'Constructing deployment
s
ta
te
when one already exists'
)
ta
sk
.
invert_ta
sk
()
return
ta
sk
s
ta
te
.
invert_
s
ta
te
()
return
s
ta
te
else
:
# create a new ta
sk
ta
sk
=
cls
(
# create a new
s
ta
te
s
ta
te
=
cls
(
action
=
'withdraw'
,
deployment
=
deployment
,
key
=
key
,
user
=
deployment
.
user
,
)
ta
sk
.
save
()
LOGGER
.
debug
(
ta
sk
.
msg
(
'pending'
))
s
ta
te
.
save
()
LOGGER
.
debug
(
s
ta
te
.
msg
(
'pending'
))
# generate ta
sk
items
# generate
s
ta
te
items
for
site
in
deployment
.
service
.
site
.
all
():
deploy
=
Deployment
Task
Item
(
ta
sk
=
task
,
deploy
=
Deployment
State
Item
(
s
ta
te
=
state
,
site
=
site
,
user
=
deployment
.
user
)
deploy
.
save
()
LOGGER
.
debug
(
deploy
.
msg
(
'pending'
))
return
ta
sk
return
s
ta
te
def
chancel_items
(
self
):
for
item
in
self
.
ta
sk
_items
.
all
():
for
item
in
self
.
s
ta
te
_items
.
all
():
item
.
chancel
()
def
chancel
(
self
):
...
...
@@ -781,12 +781,12 @@ class DeploymentTask(models.Model):
)
def
msg
(
self
,
msg
):
return
'[D
eploymentTask
:{}] {}'
.
format
(
self
,
msg
)
return
'[D
State
:{}] {}'
.
format
(
self
,
msg
)
def
publish
(
self
):
# mitigating circular dependencies here
from
.clientapi.serializers
import
Deployment
Task
Serializer
msg
=
json
.
dumps
(
Deployment
Task
Serializer
(
self
).
data
)
from
.clientapi.serializers
import
Deployment
State
Serializer
msg
=
json
.
dumps
(
Deployment
State
Serializer
(
self
).
data
)
RabbitMQInstance
.
load
().
publish_by_service
(
self
.
service
,
...
...
@@ -805,11 +805,11 @@ class DeploymentTask(models.Model):
)
def
try_finished
(
self
):
if
not
self
.
ta
sk
_items
.
exists
():
if
not
self
.
s
ta
te
_items
.
exists
():
# finished sends its own message
self
.
_finished
()
# maintenance after all ta
sk
items are done
# maintenance after all
s
ta
te
items are done
def
_finished
(
self
):
LOGGER
.
info
(
self
.
msg
(
'done'
))
...
...
@@ -842,22 +842,22 @@ def questionnaire_default():
def
credential_default
():
return
{}
# Deployment
Task
Item: knows:
# Deployment
State
Item: knows:
# user, service, key, action, _and_ site
class
Deployment
Task
Item
(
models
.
Model
):
ta
sk
=
models
.
ForeignKey
(
Deployment
Task
,
related_name
=
'ta
sk
_items'
,
class
Deployment
State
Item
(
models
.
Model
):
s
ta
te
=
models
.
ForeignKey
(
Deployment
State
,
related_name
=
'
s
ta
te
_items'
,
on_delete
=
models
.
CASCADE
,
)
site
=
models
.
ForeignKey
(
Site
,
related_name
=
'ta
sk
_items'
,
related_name
=
'
s
ta
te
_items'
,
on_delete
=
models
.
CASCADE
,
)
user
=
models
.
ForeignKey
(
User
,
related_name
=
'deployment_ta
sk
_items'
,
related_name
=
'deployment_
s
ta
te
_items'
,
on_delete
=
models
.
CASCADE
,
)
STATE_CHOICES
=
(
...
...
@@ -888,40 +888,40 @@ class DeploymentTaskItem(models.Model):
@
property
def
service
(
self
):
return
self
.
ta
sk
.
service
return
self
.
s
ta
te
.
service
@
property
def
key
(
self
):
return
self
.
ta
sk
.
key
return
self
.
s
ta
te
.
key
@
property
def
action
(
self
):
return
self
.
deployment
.
key
# the client acked the receipt and execution of the ta
sk
for his site
# the client acked the receipt and execution of the
s
ta
te
for his site
def
success
(
self
,
credentials
=
None
):
ta
sk
=
self
.
ta
sk
s
ta
te
=
self
.
s
ta
te
self
.
credentials
=
credentials
self
.
save
()
LOGGER
.
debug
(
self
.
msg
(
'success'
))
# TODO test: does not deleting the ta
sk
item work?
# TODO test: does not deleting the
s
ta
te
item work?
# self.delete()
ta
sk
.
send_state_update
()
s
ta
te
.
send_state_update
()
# TODO test: does not deleting the ta
sk
work?
#ta
sk
.try_finished()
# TODO test: does not deleting the
s
ta
te
work?
#
s
ta
te
.try_finished()
# the user changed the deployment
# chancel (delete) this ta
sk
item
# chancel (delete) this
s
ta
te
item
def
chancel
(
self
):
LOGGER
.
debug
(
self
.
msg
(
'chanceled'
))
self
.
delete
()
# no update on chancel
# the next ta
sk
will send an update
#ta
sk
.send_state_update()
# the next
s
ta
te
will send an update
#
s
ta
te
.send_state_update()
# the client failed to execute the item
# the client can try again later
...
...
@@ -931,7 +931,7 @@ class DeploymentTaskItem(models.Model):
self
.
state
=
'failed'
self
.
save
()
self
.
ta
sk
.
send_state_update
()
self
.
s
ta
te
.
send_state_update
()
# the client failed to execute the item
# the client needs additional information from the user to try again
...
...
@@ -942,7 +942,7 @@ class DeploymentTaskItem(models.Model):
self
.
questionnaire
=
questionnaire
self
.
save
()
self
.
ta
sk
.
send_state_update
()
self
.
s
ta
te
.
send_state_update
()
def
questionnaire_answered
(
self
,
answers
=
None
):
LOGGER
.
debug
(
'%s %s'
,
self
.
msg
(
'answers'
),
answers
)
...
...
@@ -950,14 +950,14 @@ class DeploymentTaskItem(models.Model):
self
.
questionnaire
=
answers
self
.
save
()
# publish the ta
sk
item
# publish the
s
ta
te
item
self
.
publish
()