Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ACS
Public
VILLASframework
VILLASweb-backend-go
Commits
e2bebbc6
Commit
e2bebbc6
authored
Oct 30, 2020
by
Sonja Happ
Browse files
Do not create ICs with state gone, add some logging info for AMQP-related actions
#31
#41
parent
fb757b11
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
routes/infrastructure-component/ic_methods.go
View file @
e2bebbc6
...
...
@@ -110,7 +110,11 @@ func createNewICviaAMQP(payload ICUpdate) error {
}
else
{
newICReq
.
InfrastructureComponent
.
State
=
"unknown"
}
// TODO check if state is "gone" and abort creation of IC in this case
if
newICReq
.
InfrastructureComponent
.
State
==
"gone"
{
// Check if state is "gone" and abort creation of IC in this case
log
.
Println
(
"########## AMQP: Aborting creation of IC with state gone"
)
return
nil
}
if
payload
.
Properties
.
WS_url
!=
nil
{
newICReq
.
InfrastructureComponent
.
WebsocketURL
=
*
payload
.
Properties
.
WS_url
...
...
@@ -151,17 +155,19 @@ func createNewICviaAMQP(payload ICUpdate) error {
}
func
(
s
*
InfrastructureComponent
)
updateICviaAMQP
(
payload
ICUpdate
)
error
{
var
updatedICReq
UpdateICRequest
if
payload
.
State
!=
nil
{
updatedICReq
.
InfrastructureComponent
.
State
=
*
payload
.
State
if
*
payload
.
State
==
"gone"
{
// remove IC from DB
log
.
Println
(
"########## AMQP: Deleting IC with state gone"
)
err
:=
s
.
delete
(
true
)
if
err
!=
nil
{
// if component could not be deleted there are still configurations using it in the DB
// continue with the update to save the new state of the component and get back to the deletion later
log
.
Println
(
"
Could not delete IC because there is a config using it, deletion postponed
"
)
log
.
Println
(
"
########## AMQP: Deletion of IC postponed (config(s) associated to it)
"
)
}
}
...
...
routes/infrastructure-component/ic_validators.go
View file @
e2bebbc6
...
...
@@ -28,6 +28,7 @@ import (
"github.com/jinzhu/gorm/dialects/postgres"
"github.com/nsf/jsondiff"
"gopkg.in/go-playground/validator.v9"
"log"
"time"
)
...
...
@@ -131,6 +132,7 @@ func (r *AddICRequest) createIC(receivedViaAMQP bool) (InfrastructureComponent,
*
action
.
Properties
.
UUID
=
r
.
InfrastructureComponent
.
UUID
}
log
.
Println
(
"########## AMQP: Sending request to create new IC"
)
err
=
sendActionAMQP
(
action
)
// s remains empty
...
...
Write
Preview
Supports
Markdown
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