Skip to content

Commit 237aa66

Browse files
Pramodh Pallapothueriknordmark
Pramodh Pallapothu
authored andcommitted
Addressed review comments
Signed-off-by: Pramodh Pallapothu <pramodh@zededa.com>
1 parent 0b9fa30 commit 237aa66

File tree

4 files changed

+24
-8
lines changed

4 files changed

+24
-8
lines changed

docs/ECO-METADATA.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,21 @@ The returned json contains
2121
- caller-ip: a string with the IP address and TCP port of the requesting app instance
2222
- external-ipv4: a string with the external IPv4 address
2323
- hostname: a string with the UUID hostname assigned to the app instance
24+
- app-instance-uuid: a string with the app instance UUID
25+
- device-uuid: a string with the device UUID
26+
- device-name: a string with the device name
27+
- project-uuid: a string with the UUID of the project the device is associated with
28+
- project-name: a string with the name of the project the device is associated with
29+
- enterprise-id: a string with the id of the enterprise the device is associated with
30+
- enterprise-name: a string with the name of the enterprise the device is associated with
2431

2532
Note that there is no need to specify the application instance identity since the meta-data server in EVE determines that from the virtual network adapter the application instance is using to communicate with EVE.
2633

2734
## Example usage
2835

2936
curl <http://169.254.169.254/eve/v1/network.json>
3037

31-
{"caller-ip":"10.1.0.2:39380","external-ipv4":"192.168.1.10","hostname":"afa43e51-56b7-4021-a5fa-4272b0381913", "app-instance-uuid":"afa43e51-56b7-4021-a5fa-4272b0381913","device-uuid":"6c6cb828-b0be-4166-9daf-ab353430dbc1","device-name":"test-system","project-name":"test-project","project-uuid":"4d12659e-6c9f-44bc-8e98-d525347afae6","enterprise-name":"testing","enterprise-uuid":"AAFlABBtJ0mP_lhJjIyVzjzgMXiR"}
38+
{"caller-ip":"10.1.0.2:39380","external-ipv4":"192.168.1.10","hostname":"afa43e51-56b7-4021-a5fa-4272b0381913", "app-instance-uuid":"afa43e51-56b7-4021-a5fa-4272b0381913","device-uuid":"6c6cb828-b0be-4166-9daf-ab353430dbc1","device-name":"test-system","project-name":"test-project","project-uuid":"4d12659e-6c9f-44bc-8e98-d525347afae6","enterprise-name":"testing","enterprise-id":"AAFlABBtJ0mP_lhJjIyVzjzgMXiR"}
3239

3340
## Application instances with multiple network interface adapters
3441

pkg/pillar/cmd/zedagent/parseedgenodeinfo.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package zedagent
66
import (
77
zconfig "github.com/lf-edge/eve/api/go/config"
88
"github.com/lf-edge/eve/pkg/pillar/types"
9+
uuid "github.com/satori/go.uuid"
910
)
1011

1112
// Get the node information
@@ -14,12 +15,14 @@ func parseEdgeNodeInfo(ctx *getconfigContext,
1415

1516
log.Tracef("Started parsing edge node information")
1617

18+
deviceID, _ := uuid.FromString(config.GetId().Uuid)
19+
projectID, _ := uuid.FromString(config.GetProjectId())
1720
enInfo := types.EdgeNodeInfo{}
1821
enInfo = types.EdgeNodeInfo{
1922
DeviceName: config.GetDeviceName(),
20-
DeviceID: config.GetId().Uuid,
23+
DeviceID: deviceID,
2124
ProjectName: config.GetProjectName(),
22-
ProjectID: config.GetProjectId(),
25+
ProjectID: projectID,
2326
EnterpriseName: config.GetEnterpriseName(),
2427
EnterpriseID: config.GetEnterpriseId(),
2528
}

pkg/pillar/cmd/zedrouter/server.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -446,13 +446,15 @@ func (hdl networkHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
446446

447447
enInfoObj, err := hdl.ctx.subEdgeNodeInfo.Get("global")
448448
if err != nil {
449-
http.Error(w, http.StatusText(http.StatusNoContent), http.StatusNoContent)
449+
errorLine := fmt.Sprintf("cannot fetch edge node information: %s", err)
450+
log.Error(errorLine)
451+
http.Error(w, errorLine, http.StatusInternalServerError)
450452
return
451453
}
452454
enInfo := enInfoObj.(types.EdgeNodeInfo)
453455
w.Header().Add("Content-Type", "application/json")
454456
w.WriteHeader(code)
455-
resp, _ := json.Marshal(map[string]string{
457+
resp, _ := json.Marshal(map[string]interface{}{
456458
"caller-ip": r.RemoteAddr,
457459
"external-ipv4": ipStr,
458460
"hostname": hostname, // Do not delete this line for backward compatibility
@@ -462,7 +464,7 @@ func (hdl networkHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
462464
"project-name": enInfo.ProjectName,
463465
"project-uuid": enInfo.ProjectID,
464466
"enterprise-name": enInfo.EnterpriseName,
465-
"enterprise-uuid": enInfo.EnterpriseID,
467+
"enterprise-id": enInfo.EnterpriseID,
466468
// TBD: add public-ipv4 when controller tells us
467469
})
468470
w.Write(resp)

pkg/pillar/types/edgenodetypes.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@
33

44
package types
55

6+
import (
7+
uuid "github.com/satori/go.uuid"
8+
)
9+
610
// EdgeNodeInfo - edge node info from controller
711
type EdgeNodeInfo struct {
812
DeviceName string
9-
DeviceID string
13+
DeviceID uuid.UUID
1014
ProjectName string
11-
ProjectID string
15+
ProjectID uuid.UUID
1216
EnterpriseName string
1317
EnterpriseID string
1418
}

0 commit comments

Comments
 (0)