VOL-1761: Support for getting openolt and bal_core_dist version at agent
Change-Id: Ia059fd5a27005c87e7e1f0e91315b94f4d53a537
diff --git a/agent/common/main.cc b/agent/common/main.cc
index b211cfb..c4a0b53 100644
--- a/agent/common/main.cc
+++ b/agent/common/main.cc
@@ -20,8 +20,65 @@
#include "server.h"
#include "core.h"
+using namespace std;
+
+/*
+* This function displays openolt version, BAL version, openolt build date
+* and other VCS params like VCS url, VCS ref, commit date and exits.
+*
+* @param argc : number of arguments
+* @param argv : vector of arguments
+*/
+void display_version_info(int argc, char *argv[]) {
+
+ string version = "";
+ string bal_version = "";
+ string label_vcs_url = "";
+ string label_vcs_ref = "";
+ string label_build_date = "";
+ string label_commit_date = "";
+
+ #ifdef VERSION
+ version = VERSION;
+ #endif
+
+ #ifdef BAL_VER
+ bal_version = BAL_VER;
+ #endif
+
+ #ifdef LABEL_VCS_URL
+ label_vcs_url = LABEL_VCS_URL;
+ #endif
+
+ #ifdef LABEL_VCS_REF
+ label_vcs_ref = LABEL_VCS_REF;
+ #endif
+
+ #ifdef LABEL_BUILD_DATE
+ label_build_date = LABEL_BUILD_DATE;
+ #endif
+
+ #ifdef LABEL_COMMIT_DATE
+ label_commit_date = LABEL_COMMIT_DATE;
+ #endif
+
+ for (int i = 1; i < argc; ++i) {
+ if(strcmp(argv[i], "--version") == 0 || (strcmp(argv[i], "-v") == 0)) {
+ std::cout << "OpenOLT agent: " << version << "\n";
+ std::cout << "BAL version: " << bal_version << "\n";
+ std::cout << "Label VCS Url: " << label_vcs_url << "\n";
+ std::cout << "Label VCS Ref: " << label_vcs_ref << "\n";
+ std::cout << "Label build date: " << label_build_date << "\n";
+ std::cout << "Label commit date: " << label_commit_date << "\n";
+ exit(0);
+ }
+ }
+}
+
int main(int argc, char** argv) {
+ display_version_info(argc, argv);
+
Status status = Enable_(argc, argv);
if (!status.ok()) {
std::cout << "ERROR: Enable_ failed - "