VOL-4011:Initial commit changes for opendm-agnt
Added test target
building the opendm-agent inside the docker for jenkins

Change-Id: Id27be99dd1770404a94a49b357229a8b97f8a629
diff --git a/inc/dmi_common.h b/inc/dmi_common.h
new file mode 100644
index 0000000..a8a6261
--- /dev/null
+++ b/inc/dmi_common.h
@@ -0,0 +1,34 @@
+ /*
+ * Copyright 2021-present Open Networking Foundation
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DMI_COMMON_H_
+#define DMI_COMMON_H_
+
+#include <iostream>
+#include <string>
+#include <memory>
+#include <vector>
+#include <grpc/grpc.h>
+#include <grpc++/server.h>
+#include <grpc++/server_builder.h>
+#include <grpc++/server_context.h>
+#include <grpcpp/grpcpp.h>
+
+using grpc::Server;
+using grpc::ServerBuilder;
+using grpc::ServerContext;
+using grpc::ServerWriter;
+using grpc::Status;
+using grpc::ResourceQuota;
+
+#endif
diff --git a/inc/dmi_events_mgmt.h b/inc/dmi_events_mgmt.h
new file mode 100644
index 0000000..6a275dd
--- /dev/null
+++ b/inc/dmi_events_mgmt.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2021-present Open Networking Foundation
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DMI_HW_MGMT_H_
+#define DMI_HH_MGMT_H_
+
+#include "hw_events_mgmt_service.grpc.pb.h"
+#include "hw_events_mgmt_service.pb.h"
+#include "dmi_common.h"
+
+class HWEventsMgmtService final : public dmi::NativeEventsManagementService::Service
+{
+    public:
+        static HWEventsMgmtService& getHwEventMgmtInstance()
+        {
+            static HWEventsMgmtService HwEventInstance;
+            return HwEventInstance;
+        }
+
+        grpc::Status ListEvents(
+                ServerContext* context,
+                const dmi::HardwareID* request,
+                dmi::ListEventsResponse* response)
+        {
+            //TODO write an internal API to handle the request
+            return Status(grpc::StatusCode::UNIMPLEMENTED, "RPC not implemented");
+        }
+
+        grpc::Status UpdateEventsConfiguration(
+                ServerContext* context,
+                const dmi::EventsConfigurationRequest* request,
+                dmi::EventsConfigurationResponse* response )
+        {
+            //TODO write an internal API to handle the request
+            return Status(grpc::StatusCode::UNIMPLEMENTED, "RPC not implemented");
+        }
+
+    private:
+        HWEventsMgmtService()
+        {
+        }
+
+        ~HWEventsMgmtService()
+        {
+        }
+};
+
+#endif
diff --git a/inc/dmi_hw_mgmt.h b/inc/dmi_hw_mgmt.h
new file mode 100644
index 0000000..2ff29ab
--- /dev/null
+++ b/inc/dmi_hw_mgmt.h
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2021-present Open Networking Foundation
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DMI_HW_MGMT_H_
+#define DMI_HH_MGMT_H_
+
+#include "hw_management_service.grpc.pb.h"
+#include "hw_management_service.pb.h"
+#include "dmi_common.h"
+
+using grpc::ServerWriter;
+
+grpc::Status StartManagingDevice_(
+             const dmi::ModifiableComponent* request,
+             ServerWriter<dmi::StartManagingDeviceResponse>* writer
+             );
+grpc::Status StopManagingDevice_(dmi::StopManagingDeviceResponse* response);
+grpc::Status GetManagedDevices_(dmi::ManagedDevicesResponse* response);
+grpc::Status GetPhysicalInventory_(dmi::PhysicalInventoryResponse* response);
+
+class HWMgmtService final : public dmi::NativeHWManagementService::Service
+{
+    public:
+        static HWMgmtService& getHWInstance()
+        {
+            static HWMgmtService hwinstance;
+            return hwinstance;
+        }
+
+        grpc::Status StartManagingDevice(
+                ServerContext* context,
+                const dmi::ModifiableComponent* request,
+                ServerWriter<dmi::StartManagingDeviceResponse>* writer
+                )
+        {
+            return StartManagingDevice_(request, writer);
+        }
+
+        grpc::Status StopManagingDevice(
+                ServerContext* context,
+                const dmi::StopManagingDeviceRequest* request,
+                dmi::StopManagingDeviceResponse* response
+                )
+        {
+            return StopManagingDevice_(response);
+        }
+
+        grpc::Status GetManagedDevices(
+                ServerContext* context,
+                const google::protobuf::Empty* request,
+                dmi::ManagedDevicesResponse* response
+                )
+        {
+            return GetManagedDevices_(response);
+        }
+
+        grpc::Status GetPhysicalInventory(
+                ServerContext* context,
+                const dmi::PhysicalInventoryRequest* request,
+                dmi::PhysicalInventoryResponse* response
+                )
+        {
+            return GetPhysicalInventory_(response);
+        }
+
+    private:
+        HWMgmtService()
+        {
+        }
+
+        ~HWMgmtService()
+        {
+        }
+};
+
+#endif
diff --git a/inc/dmi_metrics_mgmt.h b/inc/dmi_metrics_mgmt.h
new file mode 100644
index 0000000..a60e21d
--- /dev/null
+++ b/inc/dmi_metrics_mgmt.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2021-present Open Networking Foundation
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DMI_HW_MGMT_H_
+#define DMI_HH_MGMT_H_
+
+#include "hw_metrics_mgmt_service.grpc.pb.h"
+#include "hw_metrics_mgmt_service.pb.h"
+#include "dmi_common.h"
+
+using grpc::ServerWriter;
+
+
+class HWMetricsMgmtService final : public dmi::NativeMetricsManagementService::Service
+{
+    public:
+        static HWMetricsMgmtService& getHwMetricMgmtInstance()
+        {
+            static HWMetricsMgmtService HwMetrictInstance;
+            return HwMetrictInstance;
+        }
+
+        grpc::Status ListMetrics(
+                ServerContext* context,
+                const dmi::HardwareID* request,
+                dmi::ListMetricsResponse* response )
+        {
+            //TODO write an internal API to handle the request
+            return Status(grpc::StatusCode::UNIMPLEMENTED, "RPC not implemented");
+        }
+
+        grpc::Status UpdateMetricsConfiguration(
+                ServerContext* context,
+                const dmi::MetricsConfigurationRequest* request,
+                dmi::MetricsConfigurationResponse* response )
+        {
+            //TODO write an internal API to handle the request
+            return Status(grpc::StatusCode::UNIMPLEMENTED, "RPC not implemented");
+        }
+
+        grpc::Status GetMetric(
+                ServerContext* context,
+                const dmi::GetMetricRequest* request,
+                dmi::GetMetricResponse* response )
+        {
+            //TODO write an internal API to handle the request
+            return Status(grpc::StatusCode::UNIMPLEMENTED, "RPC not implemented");
+        }
+
+    private:
+        HWMetricsMgmtService()
+        {
+        }
+
+        ~HWMetricsMgmtService()
+        {
+        }
+};
+
+#endif
diff --git a/inc/dmi_phycomp_factory.h b/inc/dmi_phycomp_factory.h
new file mode 100644
index 0000000..e3711eb
--- /dev/null
+++ b/inc/dmi_phycomp_factory.h
@@ -0,0 +1,224 @@
+/*
+ * Copyright 2021-present Open Networking Foundation
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef DMI_PHYCOMP_FACTORY_H_
+#define DMI_PHYCOMP_FACTORY_H_
+
+#include "hw_management_service.grpc.pb.h"
+#include "hw_management_service.pb.h"
+#include <iostream>
+#include <string>
+/*
+ * PhyComponent
+ * PhyComponent implement the same interface so that the classes can refer
+ * to the interface not the concrete Component
+ */
+class PhyComponent
+{
+    public:
+        dmi::Component comp;
+        uint8_t comp_number;
+
+        /*Interfaces where each subclasses implements thier specific details*/
+        virtual uint8_t UpdateComp(uint8_t comp_number) = 0;
+        virtual uint8_t SetModifiableCompFields(dmi::ModifiableComponent mod_fields) = 0;
+
+        virtual ~PhyComponent() {}
+};
+
+
+/*
+ * Concrete Component
+ * define Component to be created
+ */
+class FanComp : public PhyComponent
+{
+	public:
+  	FanComp()
+  	{
+        /*Fill the default/common parameters here*/
+		this->comp.set_class_( dmi::ComponentType::COMPONENT_TYPE_FAN);
+		this->comp.set_is_fru( 1 );
+  	}
+
+	uint8_t UpdateComp(uint8_t comp_number);
+	uint8_t SetModifiableCompFields(dmi::ModifiableComponent mod_fields);
+	~FanComp() {}
+};
+
+
+
+/*
+ * Concrete Component
+ * define Component to be created
+ */
+class DiskComp : public PhyComponent
+{
+    public:
+        DiskComp()
+        {
+            this->comp.set_class_( dmi::ComponentType::COMPONENT_TYPE_STORAGE);
+            this->comp.set_is_fru( 0 );
+        }
+
+        uint8_t UpdateComp(uint8_t comp_number);
+        uint8_t SetModifiableCompFields(dmi::ModifiableComponent mod_fields);
+        ~DiskComp() {}
+};
+
+
+/*
+ * Concrete Component
+ * define Component to be created
+ */
+class ContainerComp : public PhyComponent
+{
+    public:
+        ContainerComp()
+        {
+            this->comp.set_class_( dmi::ComponentType::COMPONENT_TYPE_CONTAINER);
+            this->comp.set_is_fru( 0 );
+            //set the container attribute
+        }
+
+        uint8_t UpdateComp(uint8_t comp_number);
+        uint8_t SetModifiableCompFields(dmi::ModifiableComponent mod_fields);
+        ~ContainerComp() {}
+};
+
+
+
+/*
+ * Concrete Component
+ * define Component to be created
+ */
+class PortComp : public PhyComponent
+{
+    public:
+        PortComp()
+        {
+            this->comp.set_class_( dmi::ComponentType::COMPONENT_TYPE_PORT );
+            this->comp.set_is_fru( 0 );
+        }
+
+        uint8_t UpdateComp(uint8_t comp_number);
+        uint8_t SetModifiableCompFields(dmi::ModifiableComponent mod_fields);
+        ~PortComp() {}
+};
+
+
+/*
+ * Concrete Component
+ * define Component to be created
+ */
+class CPUComp : public PhyComponent
+{
+    public:
+        CPUComp()
+        {
+            this->comp.set_class_( dmi::ComponentType::COMPONENT_TYPE_CPU );
+            this->comp.set_is_fru( 0 );
+        }
+
+        uint8_t UpdateComp(uint8_t comp_number);
+        uint8_t SetModifiableCompFields(dmi::ModifiableComponent mod_fields);
+        ~CPUComp() {}
+};
+
+/*
+ * Concrete Component
+ * define Component to be created
+ */
+class TransceiverComp : public PhyComponent
+{
+    public:
+        TransceiverComp()
+        {
+            this->comp.set_class_( dmi::ComponentType::COMPONENT_TYPE_TRANSCEIVER );
+            this->comp.set_is_fru ( 1 );
+        }
+
+        uint8_t UpdateComp(uint8_t comp_number);
+        uint8_t SetModifiableCompFields(dmi::ModifiableComponent mod_fields);
+        ~TransceiverComp() {}
+};
+
+
+/*
+ * Creator
+ * contains the implementation for all of the methods
+ * to manipulate products except for the factory method
+ */
+class Creator
+{
+    public:
+
+        virtual PhyComponent* CreateFanCompInst()         = 0;
+        virtual PhyComponent* CreateDiskCompInst()        = 0;
+        virtual PhyComponent* CreateContainerCompInst()   = 0;
+        virtual PhyComponent* CreatePortCompInst()        = 0;
+        virtual PhyComponent* CreateCPUCompInst()         = 0;
+        virtual PhyComponent* CreateTransceiverCompInst() = 0;
+        virtual void removeComponent( PhyComponent *comp ) = 0;
+        virtual ~Creator() {}
+};
+
+/*
+ * Concrete Creator
+ * implements factory method that is responsible for creating
+ * one or more concrete products ie. it is class that has
+ * the knowledge of how to create the products
+ */
+class ConcreteComp : public Creator
+{
+    public:
+        ~ConcreteComp() {}
+
+        PhyComponent* CreateFanCompInst()
+        {
+            return new FanComp();
+        }
+
+        PhyComponent* CreateDiskCompInst()
+        {
+            return new DiskComp();
+        }
+
+        PhyComponent* CreateContainerCompInst()
+        {
+            return new ContainerComp();
+        }
+
+        PhyComponent* CreatePortCompInst()
+        {
+            return new PortComp();
+        }
+
+        PhyComponent* CreateCPUCompInst()
+        {
+            return new CPUComp();
+        }
+
+        PhyComponent* CreateTransceiverCompInst()
+        {
+            return new TransceiverComp();
+        }
+
+        void removeComponent( PhyComponent *comp )
+        {
+            delete comp;
+        }
+};
+#endif
+
diff --git a/inc/dmi_server.h b/inc/dmi_server.h
new file mode 100644
index 0000000..5e79bb0
--- /dev/null
+++ b/inc/dmi_server.h
@@ -0,0 +1,21 @@
+ /*
+ * Copyright 2021-present Open Networking Foundation
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef DMI_SERVER_H_
+#define DMI_SERVER_H_
+
+extern void RunGrpcServer();
+
+#endif
+
diff --git a/inc/dmi_sw_mgmt.h b/inc/dmi_sw_mgmt.h
new file mode 100644
index 0000000..b699157
--- /dev/null
+++ b/inc/dmi_sw_mgmt.h
@@ -0,0 +1,96 @@
+ /*
+ * Copyright 2021-present Open Networking Foundation
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DMI_SW_MGMT_H_
+#define DMI_SW_MGMT_H_
+
+#include "sw_management_service.grpc.pb.h"
+#include "sw_management_service.pb.h"
+#include "dmi_common.h"
+
+using grpc::ServerWriter;
+
+grpc::Status GetSoftwareVersion_(const dmi::HardwareID* request,
+             dmi::GetSoftwareVersionInformationResponse* response);
+
+class SWMgmtService final : public dmi::NativeSoftwareManagementService::Service
+{
+    public:
+        static SWMgmtService& getSWInstance()
+        {
+            static SWMgmtService swinstance;
+            return swinstance;
+        }
+
+        grpc::Status GetSoftwareVersion(
+                ServerContext* context,
+                const dmi::HardwareID* request,
+                dmi::GetSoftwareVersionInformationResponse* response )
+        {
+            return GetSoftwareVersion_(request, response);
+        }
+
+        grpc::Status DownloadImage(
+                ServerContext* context,
+                const dmi::DownloadImageRequest* request,
+                ServerWriter<dmi::ImageStatus>* writer )
+        {
+            //TODO write an internal API to handle the request
+            return Status(grpc::StatusCode::UNIMPLEMENTED, "RPC not implemented");
+        }
+
+        grpc::Status ActivateImage(
+                ServerContext* context,
+                const dmi::HardwareID* request,
+                ServerWriter<dmi::ImageStatus>* writer )
+        {
+            //TODO write an internal API to handle the request
+            return Status(grpc::StatusCode::UNIMPLEMENTED, "RPC not implemented");
+        }
+
+        grpc::Status RevertToStandbyImage(
+                ServerContext* context,
+                const dmi::HardwareID* request,
+                ServerWriter<dmi::ImageStatus>* writer )
+        {
+            //TODO write an internal API to handle the request
+            return Status(grpc::StatusCode::UNIMPLEMENTED, "RPC not implemented");
+        }
+
+        grpc::Status UpdateStartupConfiguration(
+                ServerContext* context,
+                const dmi::ConfigRequest* request,
+                ServerWriter<dmi::ConfigResponse>* writer )
+        {
+            //TODO write an internal API to handle the request
+            return Status(grpc::StatusCode::UNIMPLEMENTED, "RPC not implemented");
+        }
+
+        grpc::Status GetStartupConfigurationInfo(
+                ServerContext* context,
+                const dmi::StartupConfigInfoRequest* request,
+                dmi::StartupConfigInfoResponse* response )
+        {
+            //TODO write an internal API to handle the request
+            return Status(grpc::StatusCode::UNIMPLEMENTED, "RPC not implemented");
+        }
+    private:
+        SWMgmtService()
+        {
+        }
+
+        ~SWMgmtService()
+        {
+        }
+};
+#endif
diff --git a/inc/dmi_utils.h b/inc/dmi_utils.h
new file mode 100644
index 0000000..e806ca9
--- /dev/null
+++ b/inc/dmi_utils.h
@@ -0,0 +1,12 @@
+ /*
+ * Copyright 2021-present Open Networking Foundation
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */