mirror of
https://git.rwth-aachen.de/acs/public/villas/web-backend-go/
synced 2025-03-30 00:00:12 +01:00
use properties of existing IC for duplication
This commit is contained in:
parent
3a0da86d92
commit
d596c8a4bf
1 changed files with 38 additions and 24 deletions
|
@ -47,6 +47,23 @@ type Action struct {
|
||||||
Results json.RawMessage `json:"results,omitempty"`
|
Results json.RawMessage `json:"results,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ICPropertiesToCopy struct {
|
||||||
|
Job json.RawMessage `json:"job"`
|
||||||
|
UUID string `json:"uuid"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Description string `json:"description"`
|
||||||
|
Location string `json:"location"`
|
||||||
|
Owner string `json:"owner"`
|
||||||
|
Category string `json:"category"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ICUpdateToCopy struct {
|
||||||
|
Properties ICPropertiesToCopy `json:"properties"`
|
||||||
|
Status json.RawMessage `json:"status"`
|
||||||
|
Schema json.RawMessage `json:"schema"`
|
||||||
|
}
|
||||||
|
|
||||||
var client AMQPclient
|
var client AMQPclient
|
||||||
|
|
||||||
const VILLAS_EXCHANGE = "villas"
|
const VILLAS_EXCHANGE = "villas"
|
||||||
|
@ -225,31 +242,28 @@ func CheckConnection() error {
|
||||||
|
|
||||||
func RequestICcreateAMQP(ic *database.InfrastructureComponent, managerUUID string) (string, error) {
|
func RequestICcreateAMQP(ic *database.InfrastructureComponent, managerUUID string) (string, error) {
|
||||||
newUUID := uuid.New().String()
|
newUUID := uuid.New().String()
|
||||||
// TODO: where to get the properties part from?
|
|
||||||
msg := `{"name": "` + ic.Name + `",` +
|
var lastUpdate ICUpdateToCopy
|
||||||
`"location": "` + ic.Location + `",` +
|
err := json.Unmarshal(ic.StatusUpdateRaw.RawMessage, &lastUpdate)
|
||||||
`"category": "` + ic.Category + `",` +
|
if err != nil {
|
||||||
`"type": "` + ic.Type + `",` +
|
return newUUID, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var jobdef string
|
||||||
|
err = json.Unmarshal(lastUpdate.Properties.Job, &jobdef)
|
||||||
|
if err != nil {
|
||||||
|
return newUUID, err
|
||||||
|
}
|
||||||
|
|
||||||
|
msg := `{"name": "` + lastUpdate.Properties.Name + `",` +
|
||||||
|
`"description": "` + lastUpdate.Properties.Description + `",` +
|
||||||
|
`"location": "` + lastUpdate.Properties.Location + `",` +
|
||||||
|
`"category": "` + lastUpdate.Properties.Category + `",` +
|
||||||
|
`"type": "` + lastUpdate.Properties.Type + `",` +
|
||||||
`"uuid": "` + newUUID + `",` +
|
`"uuid": "` + newUUID + `",` +
|
||||||
`"realm": "de.rwth-aachen.eonerc.acs",` +
|
|
||||||
`"properties": {` +
|
`"properties": {` +
|
||||||
`"job": {` +
|
`"job": "` + jobdef + `",` +
|
||||||
`"apiVersion": "batch/v1",` +
|
`}}`
|
||||||
`"kind": "Job",` +
|
|
||||||
`"metadata": {` +
|
|
||||||
`"name": "dpsim"` +
|
|
||||||
`},` +
|
|
||||||
`"spec": {` +
|
|
||||||
`"activeDeadlineSeconds": 3600,` +
|
|
||||||
`"backoffLimit": 1,` +
|
|
||||||
`"ttlSecondsAfterFinished": 3600,` +
|
|
||||||
`"template": {` +
|
|
||||||
`"spec": {` +
|
|
||||||
`"restartPolicy": "Never",` +
|
|
||||||
`"containers": [{` +
|
|
||||||
`"image": "dpsimrwth/slew-villas",` +
|
|
||||||
`"name": "slew-dpsim"` +
|
|
||||||
`}]}}}}}}`
|
|
||||||
|
|
||||||
log.Print(msg)
|
log.Print(msg)
|
||||||
|
|
||||||
|
@ -259,7 +273,7 @@ func RequestICcreateAMQP(ic *database.InfrastructureComponent, managerUUID strin
|
||||||
Parameters: json.RawMessage(msg),
|
Parameters: json.RawMessage(msg),
|
||||||
}
|
}
|
||||||
|
|
||||||
err := SendActionAMQP(actionCreate, managerUUID)
|
err = SendActionAMQP(actionCreate, managerUUID)
|
||||||
|
|
||||||
return newUUID, err
|
return newUUID, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue