VOL-1437 : Fix display of devices in CLI
Renamed state field in image download proto which caused
json marshalling to fail.
other updates
- unmarshal data properly when pulling data from kv in watch
- do not update unecessarily if watch data matches data in memory
- added ofagent target to python Makefile
- fixed grpc path to update log level which interfered with getdevice
Change-Id: I4fceeb539c3325b6754efe2b68251d83b7367211
diff --git a/rw_core/core/device_agent.go b/rw_core/core/device_agent.go
index b50ca94..31720c1 100644
--- a/rw_core/core/device_agent.go
+++ b/rw_core/core/device_agent.go
@@ -316,7 +316,7 @@
}
// Save the image
clonedImg := proto.Clone(img).(*voltha.ImageDownload)
- clonedImg.State = voltha.ImageDownload_DOWNLOAD_REQUESTED
+ clonedImg.DownloadState = voltha.ImageDownload_DOWNLOAD_REQUESTED
cloned := proto.Clone(device).(*voltha.Device)
if cloned.ImageDownloads == nil {
cloned.ImageDownloads = []*voltha.ImageDownload{clonedImg}
@@ -363,7 +363,7 @@
cloned := proto.Clone(device).(*voltha.Device)
for _, image := range cloned.ImageDownloads {
if image.Id == img.Id && image.Name == img.Name {
- image.State = voltha.ImageDownload_DOWNLOAD_CANCELLED
+ image.DownloadState = voltha.ImageDownload_DOWNLOAD_CANCELLED
}
}
@@ -488,15 +488,15 @@
clonedImages := make([]*voltha.ImageDownload, len(cloned.ImageDownloads))
for _, image := range cloned.ImageDownloads {
if image.Id == img.Id && image.Name == img.Name {
- if image.State != voltha.ImageDownload_DOWNLOAD_CANCELLED {
+ if image.DownloadState != voltha.ImageDownload_DOWNLOAD_CANCELLED {
clonedImages = append(clonedImages, img)
}
}
}
cloned.ImageDownloads = clonedImages
// Set the Admin state to enabled if required
- if (img.State != voltha.ImageDownload_DOWNLOAD_REQUESTED &&
- img.State != voltha.ImageDownload_DOWNLOAD_STARTED) ||
+ if (img.DownloadState != voltha.ImageDownload_DOWNLOAD_REQUESTED &&
+ img.DownloadState != voltha.ImageDownload_DOWNLOAD_STARTED) ||
(img.ImageState != voltha.ImageDownload_IMAGE_ACTIVATING){
cloned.AdminState = voltha.AdminState_ENABLED
}
diff --git a/rw_core/core/grpc_nbi_api_handler.go b/rw_core/core/grpc_nbi_api_handler.go
index 4d88459..c65178d 100644
--- a/rw_core/core/grpc_nbi_api_handler.go
+++ b/rw_core/core/grpc_nbi_api_handler.go
@@ -521,11 +521,11 @@
func (handler *APIHandler) GetImageDownloadStatus(ctx context.Context, img *voltha.ImageDownload) (*voltha.ImageDownload, error) {
log.Debugw("getImageDownloadStatus-request", log.Fields{"img": *img})
if isTestMode(ctx) {
- resp := &voltha.ImageDownload{State: voltha.ImageDownload_DOWNLOAD_SUCCEEDED}
+ resp := &voltha.ImageDownload{DownloadState: voltha.ImageDownload_DOWNLOAD_SUCCEEDED}
return resp, nil
}
- failedresponse := &voltha.ImageDownload{State: voltha.ImageDownload_DOWNLOAD_UNKNOWN}
+ failedresponse := &voltha.ImageDownload{DownloadState: voltha.ImageDownload_DOWNLOAD_UNKNOWN}
if handler.competeForTransaction() {
if txn, err := handler.acquireTransaction(ctx); err != nil {
@@ -560,12 +560,12 @@
func (handler *APIHandler) GetImageDownload(ctx context.Context, img *voltha.ImageDownload) (*voltha.ImageDownload, error) {
log.Debugw("GetImageDownload-request", log.Fields{"img": *img})
if isTestMode(ctx) {
- resp := &voltha.ImageDownload{State: voltha.ImageDownload_DOWNLOAD_SUCCEEDED}
+ resp := &voltha.ImageDownload{DownloadState: voltha.ImageDownload_DOWNLOAD_SUCCEEDED}
return resp, nil
}
if download, err := handler.deviceMgr.getImageDownload(ctx, img); err != nil {
- return &voltha.ImageDownload{State: voltha.ImageDownload_DOWNLOAD_UNKNOWN}, err
+ return &voltha.ImageDownload{DownloadState: voltha.ImageDownload_DOWNLOAD_UNKNOWN}, err
} else {
return download, nil
}
@@ -581,7 +581,7 @@
if downloads, err := handler.deviceMgr.listImageDownloads(ctx, id.Id); err != nil {
failedResp := &voltha.ImageDownloads{
Items:[]*voltha.ImageDownload{
- &voltha.ImageDownload{State: voltha.ImageDownload_DOWNLOAD_UNKNOWN},
+ &voltha.ImageDownload{DownloadState: voltha.ImageDownload_DOWNLOAD_UNKNOWN},
},
}
return failedResp, err