[SEBA-854] Add new API and modify existing

Change-Id: Iea9fd003d122f58a4d45c79d806a2011087d1740
diff --git a/demo_test/Makefile b/demo_test/Makefile
index d2d3ced..533ef3a 100644
--- a/demo_test/Makefile
+++ b/demo_test/Makefile
@@ -24,6 +24,7 @@
 
 
 proto/importer.pb.go: ../proto/importer.proto
+	mkdir -p proto
 	protoc --proto_path=../proto \
 	-I${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
 	--go_out=plugins=grpc:proto/ \
diff --git a/demo_test/cmd_client/Note b/demo_test/cmd_client/Note
index 74b6916..ca0c094 100644
--- a/demo_test/cmd_client/Note
+++ b/demo_test/cmd_client/Note
@@ -52,44 +52,48 @@
 									attach:192.168.4.27:8888:edgecore:180
 									attach:192.168.3.34:8888:edgecore:180
 --------------------------------------------------------------------------------------
-UnSubscribe all events(ResourceAdded/ResourceRemoved/Alert)		unsub:add:rm:alert
+UnSubscribe all events(ResourceAdded/ResourceRemoved/Alert)		unsub:192.168.4.27:8888:add:rm:alert
 --------------------------------------------------------------------------------------
-Subscribe all events(ResourceAdded/ResourceRemoved/Alert) 		sub:add:rm:alert
+Subscribe all events(ResourceAdded/ResourceRemoved/Alert) 		sub:192.168.4.27:8888:add:rm:alert
 --------------------------------------------------------------------------------------
 Subscribe and unsubscribe an event					Example:	
 
-Subscribe ResourceAdded event 						sub:add
-Subscribe ResourceRemoved event						sub:rm
-Subscribe Alert event							sub:alert
-Unsubscribe ResourceAdded event						unsub:add
-Unsubscribe ResourceRemoved event					unsub:rm
-Unsubscribe Alert event							unsub:alert
+Subscribe ResourceAdded event 						sub:192.168.4.27:8888:add
+Subscribe ResourceRemoved event						sub:192.168.4.27:8888:rm
+Subscribe Alert event							sub:192.168.4.27:8888:alert
+Unsubscribe ResourceAdded event						unsub:192.168.4.27:8888:add
+Unsubscribe ResourceRemoved event					unsub:192.168.4.27:8888:rm
+Unsubscribe Alert event							unsub:192.168.4.27:8888:alert
 --------------------------------------------------------------------------------------
 Subscribe and unsubscribe multiple events, out of order			Use the above commands to do test.
 --------------------------------------------------------------------------------------
-Subscribe an unsupported event						sub:update
+Subscribe an unsupported event						sub:192.168.4.27:8888:update
 --------------------------------------------------------------------------------------
 Subscribe to an already subscribed event				Example:
 
-									sub:add
-									sub:add
+									sub:192.168.4.27:8888:add
+									sub:192.168.4.27:8888:add
 --------------------------------------------------------------------------------------
-Unsubscribe  an unsupported event					unsub:update
+Unsubscribe  an unsupported event					unsub:192.168.4.27:8888:update
 --------------------------------------------------------------------------------------
 Unsubscribe a supported but not-subscribed event			Example:
 
-									unsub:add:rm:alert
-									unsub:add
-									unsub:rm
-									unsub:alert
+									unsub:192.168.4.27:8888:add:rm:alert
+									unsub:192.168.4.27:8888:add
+									unsub:192.168.4.27:8888:rm
+									unsub:192.168.4.27:8888:alert
 --------------------------------------------------------------------------------------
 Change polling interval 						Example: 
 
 Set frequecny to 30 seconds
-									period:30
+									period:192.168.4.27:8888:30
 --------------------------------------------------------------------------------------
-Show support event list							showeventlist	
---------------------------------------------------------------------------------------
+Show support event list vendor						showeventlist:edgecore
+-----------------------------------------------------------------------------------------------
+Show current events subscribed by device                               showdeviceeventlist:192.168.4.27:8888
+------------------------------------------------------------------------------------------------------------ 
+Clear all current events subscribed by device                          cleardeviceeventlist:192.168.4.27:8888
+-------------------------------------------------------------------------------------------------------------
 * During and after each test, verify the list of events subscribed	wget --no-check-certificate  \
 									-qO- https://192.168.4.27:8888/redfish/v1/EventService/Subscriptions/ \
 									| python -m json.tool
diff --git a/demo_test/proto/importer.pb.go b/demo_test/proto/importer.pb.go
deleted file mode 100644
index 0e2fe6a..0000000
--- a/demo_test/proto/importer.pb.go
+++ /dev/null
@@ -1,432 +0,0 @@
-// Code generated by protoc-gen-go. DO NOT EDIT.
-// source: importer.proto
-
-package importer
-
-import (
-	context "context"
-	fmt "fmt"
-	proto "github.com/golang/protobuf/proto"
-	empty "github.com/golang/protobuf/ptypes/empty"
-	grpc "google.golang.org/grpc"
-	codes "google.golang.org/grpc/codes"
-	status "google.golang.org/grpc/status"
-	math "math"
-)
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the proto package it is being compiled against.
-// A compilation error at this line likely means your copy of the
-// proto package needs to be updated.
-const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
-
-type DeviceInfo struct {
-	IpAddress            string   `protobuf:"bytes,1,opt,name=ip_address,json=ipAddress,proto3" json:"ip_address,omitempty"`
-	Frequency            uint32   `protobuf:"varint,2,opt,name=frequency,proto3" json:"frequency,omitempty"`
-	Vendor               string   `protobuf:"bytes,3,opt,name=vendor,proto3" json:"vendor,omitempty"`
-	Protocol             string   `protobuf:"bytes,4,opt,name=protocol,proto3" json:"protocol,omitempty"`
-	XXX_NoUnkeyedLiteral struct{} `json:"-"`
-	XXX_unrecognized     []byte   `json:"-"`
-	XXX_sizecache        int32    `json:"-"`
-}
-
-func (m *DeviceInfo) Reset()         { *m = DeviceInfo{} }
-func (m *DeviceInfo) String() string { return proto.CompactTextString(m) }
-func (*DeviceInfo) ProtoMessage()    {}
-func (*DeviceInfo) Descriptor() ([]byte, []int) {
-	return fileDescriptor_394990ff89e0d02b, []int{0}
-}
-
-func (m *DeviceInfo) XXX_Unmarshal(b []byte) error {
-	return xxx_messageInfo_DeviceInfo.Unmarshal(m, b)
-}
-func (m *DeviceInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
-	return xxx_messageInfo_DeviceInfo.Marshal(b, m, deterministic)
-}
-func (m *DeviceInfo) XXX_Merge(src proto.Message) {
-	xxx_messageInfo_DeviceInfo.Merge(m, src)
-}
-func (m *DeviceInfo) XXX_Size() int {
-	return xxx_messageInfo_DeviceInfo.Size(m)
-}
-func (m *DeviceInfo) XXX_DiscardUnknown() {
-	xxx_messageInfo_DeviceInfo.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_DeviceInfo proto.InternalMessageInfo
-
-func (m *DeviceInfo) GetIpAddress() string {
-	if m != nil {
-		return m.IpAddress
-	}
-	return ""
-}
-
-func (m *DeviceInfo) GetFrequency() uint32 {
-	if m != nil {
-		return m.Frequency
-	}
-	return 0
-}
-
-func (m *DeviceInfo) GetVendor() string {
-	if m != nil {
-		return m.Vendor
-	}
-	return ""
-}
-
-func (m *DeviceInfo) GetProtocol() string {
-	if m != nil {
-		return m.Protocol
-	}
-	return ""
-}
-
-type EventList struct {
-	EventIpAddress       string   `protobuf:"bytes,1,opt,name=event_ip_address,json=eventIpAddress,proto3" json:"event_ip_address,omitempty"`
-	Events               []string `protobuf:"bytes,2,rep,name=events,proto3" json:"events,omitempty"`
-	XXX_NoUnkeyedLiteral struct{} `json:"-"`
-	XXX_unrecognized     []byte   `json:"-"`
-	XXX_sizecache        int32    `json:"-"`
-}
-
-func (m *EventList) Reset()         { *m = EventList{} }
-func (m *EventList) String() string { return proto.CompactTextString(m) }
-func (*EventList) ProtoMessage()    {}
-func (*EventList) Descriptor() ([]byte, []int) {
-	return fileDescriptor_394990ff89e0d02b, []int{1}
-}
-
-func (m *EventList) XXX_Unmarshal(b []byte) error {
-	return xxx_messageInfo_EventList.Unmarshal(m, b)
-}
-func (m *EventList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
-	return xxx_messageInfo_EventList.Marshal(b, m, deterministic)
-}
-func (m *EventList) XXX_Merge(src proto.Message) {
-	xxx_messageInfo_EventList.Merge(m, src)
-}
-func (m *EventList) XXX_Size() int {
-	return xxx_messageInfo_EventList.Size(m)
-}
-func (m *EventList) XXX_DiscardUnknown() {
-	xxx_messageInfo_EventList.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_EventList proto.InternalMessageInfo
-
-func (m *EventList) GetEventIpAddress() string {
-	if m != nil {
-		return m.EventIpAddress
-	}
-	return ""
-}
-
-func (m *EventList) GetEvents() []string {
-	if m != nil {
-		return m.Events
-	}
-	return nil
-}
-
-type SupportedEventList struct {
-	Events               []string `protobuf:"bytes,1,rep,name=events,proto3" json:"events,omitempty"`
-	XXX_NoUnkeyedLiteral struct{} `json:"-"`
-	XXX_unrecognized     []byte   `json:"-"`
-	XXX_sizecache        int32    `json:"-"`
-}
-
-func (m *SupportedEventList) Reset()         { *m = SupportedEventList{} }
-func (m *SupportedEventList) String() string { return proto.CompactTextString(m) }
-func (*SupportedEventList) ProtoMessage()    {}
-func (*SupportedEventList) Descriptor() ([]byte, []int) {
-	return fileDescriptor_394990ff89e0d02b, []int{2}
-}
-
-func (m *SupportedEventList) XXX_Unmarshal(b []byte) error {
-	return xxx_messageInfo_SupportedEventList.Unmarshal(m, b)
-}
-func (m *SupportedEventList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
-	return xxx_messageInfo_SupportedEventList.Marshal(b, m, deterministic)
-}
-func (m *SupportedEventList) XXX_Merge(src proto.Message) {
-	xxx_messageInfo_SupportedEventList.Merge(m, src)
-}
-func (m *SupportedEventList) XXX_Size() int {
-	return xxx_messageInfo_SupportedEventList.Size(m)
-}
-func (m *SupportedEventList) XXX_DiscardUnknown() {
-	xxx_messageInfo_SupportedEventList.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_SupportedEventList proto.InternalMessageInfo
-
-func (m *SupportedEventList) GetEvents() []string {
-	if m != nil {
-		return m.Events
-	}
-	return nil
-}
-
-func init() {
-	proto.RegisterType((*DeviceInfo)(nil), "importer.DeviceInfo")
-	proto.RegisterType((*EventList)(nil), "importer.EventList")
-	proto.RegisterType((*SupportedEventList)(nil), "importer.SupportedEventList")
-}
-
-func init() { proto.RegisterFile("importer.proto", fileDescriptor_394990ff89e0d02b) }
-
-var fileDescriptor_394990ff89e0d02b = []byte{
-	// 329 bytes of a gzipped FileDescriptorProto
-	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x90, 0xcf, 0x4a, 0xf3, 0x40,
-	0x14, 0xc5, 0x9b, 0xf6, 0xa3, 0x34, 0x97, 0x7e, 0x45, 0x47, 0xad, 0xa1, 0x56, 0x28, 0x59, 0x75,
-	0x21, 0x29, 0xe8, 0x5e, 0x14, 0xfa, 0xc7, 0x82, 0x6e, 0x1a, 0x5c, 0x97, 0x26, 0xb9, 0x2d, 0x03,
-	0xcd, 0xcc, 0x38, 0x33, 0x09, 0x74, 0xe1, 0x23, 0xfb, 0x0e, 0x92, 0x89, 0xcd, 0x14, 0x2a, 0x82,
-	0xe0, 0xf2, 0xfc, 0xe6, 0x9e, 0xb9, 0xe7, 0x1e, 0xe8, 0xd0, 0x54, 0x70, 0xa9, 0x51, 0x06, 0x42,
-	0x72, 0xcd, 0x49, 0x6b, 0xaf, 0x7b, 0x57, 0x1b, 0xce, 0x37, 0x5b, 0x1c, 0x19, 0x1e, 0x65, 0xeb,
-	0x11, 0xa6, 0x42, 0xef, 0xca, 0x31, 0xff, 0x1d, 0x60, 0x8c, 0x39, 0x8d, 0x71, 0xce, 0xd6, 0x9c,
-	0x5c, 0x03, 0x50, 0xb1, 0x5c, 0x25, 0x89, 0x44, 0xa5, 0x3c, 0x67, 0xe0, 0x0c, 0xdd, 0x85, 0x4b,
-	0xc5, 0x63, 0x09, 0x48, 0x1f, 0xdc, 0xb5, 0xc4, 0xb7, 0x0c, 0x59, 0xbc, 0xf3, 0xea, 0x03, 0x67,
-	0xf8, 0x7f, 0x61, 0x01, 0xe9, 0x42, 0x33, 0x47, 0x96, 0x70, 0xe9, 0x35, 0x8c, 0xf1, 0x4b, 0x91,
-	0x1e, 0xb4, 0xcc, 0xae, 0x98, 0x6f, 0xbd, 0x7f, 0xe6, 0xa5, 0xd2, 0xfe, 0x0b, 0xb8, 0x93, 0x1c,
-	0x99, 0x7e, 0xa6, 0x4a, 0x93, 0x21, 0x9c, 0x60, 0x21, 0x96, 0x47, 0x19, 0x3a, 0x86, 0xcf, 0xab,
-	0x20, 0x5d, 0x68, 0x1a, 0xa2, 0xbc, 0xfa, 0xa0, 0x51, 0xac, 0x2a, 0x95, 0x7f, 0x03, 0x24, 0xcc,
-	0x84, 0xb9, 0x3b, 0xb1, 0xff, 0xda, 0x69, 0xe7, 0x70, 0xfa, 0xf6, 0xa3, 0x0e, 0xa7, 0x89, 0x39,
-	0x7e, 0x99, 0xae, 0xd8, 0x6a, 0x83, 0x29, 0x32, 0x4d, 0x1e, 0xa0, 0x13, 0x22, 0x4b, 0x0e, 0x5a,
-	0x39, 0x0f, 0xaa, 0x6e, 0x2d, 0xed, 0x75, 0x83, 0xb2, 0xd7, 0x60, 0xdf, 0x6b, 0x30, 0x29, 0x7a,
-	0xf5, 0x6b, 0xe4, 0x1e, 0xda, 0x21, 0xea, 0x69, 0x55, 0xcc, 0x6f, 0xfd, 0x63, 0x68, 0xcf, 0x50,
-	0xdb, 0xfc, 0xdf, 0xfb, 0xfb, 0x96, 0x1e, 0xdf, 0xec, 0xd7, 0xc8, 0x14, 0x2e, 0xc2, 0x2c, 0x52,
-	0x32, 0x96, 0x34, 0xc2, 0x19, 0xcd, 0x91, 0x99, 0x57, 0x45, 0xce, 0xac, 0xb1, 0x9a, 0xff, 0x21,
-	0xcd, 0x13, 0x5c, 0xbe, 0xb2, 0xbf, 0xf8, 0x29, 0x6a, 0x1a, 0x72, 0xf7, 0x19, 0x00, 0x00, 0xff,
-	0xff, 0x79, 0x23, 0x4a, 0xc2, 0xab, 0x02, 0x00, 0x00,
-}
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ context.Context
-var _ grpc.ClientConn
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the grpc package it is being compiled against.
-const _ = grpc.SupportPackageIsVersion4
-
-// DeviceManagementClient is the client API for DeviceManagement service.
-//
-// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
-type DeviceManagementClient interface {
-	SendDeviceInfo(ctx context.Context, in *DeviceInfo, opts ...grpc.CallOption) (*empty.Empty, error)
-	SetFrequency(ctx context.Context, in *DeviceInfo, opts ...grpc.CallOption) (*empty.Empty, error)
-	GetEventList(ctx context.Context, in *DeviceInfo, opts ...grpc.CallOption) (*SupportedEventList, error)
-	SubsrcribeGivenEvents(ctx context.Context, in *EventList, opts ...grpc.CallOption) (*empty.Empty, error)
-	UnSubsrcribeGivenEvents(ctx context.Context, in *EventList, opts ...grpc.CallOption) (*empty.Empty, error)
-}
-
-type deviceManagementClient struct {
-	cc *grpc.ClientConn
-}
-
-func NewDeviceManagementClient(cc *grpc.ClientConn) DeviceManagementClient {
-	return &deviceManagementClient{cc}
-}
-
-func (c *deviceManagementClient) SendDeviceInfo(ctx context.Context, in *DeviceInfo, opts ...grpc.CallOption) (*empty.Empty, error) {
-	out := new(empty.Empty)
-	err := c.cc.Invoke(ctx, "/importer.device_management/SendDeviceInfo", in, out, opts...)
-	if err != nil {
-		return nil, err
-	}
-	return out, nil
-}
-
-func (c *deviceManagementClient) SetFrequency(ctx context.Context, in *DeviceInfo, opts ...grpc.CallOption) (*empty.Empty, error) {
-	out := new(empty.Empty)
-	err := c.cc.Invoke(ctx, "/importer.device_management/SetFrequency", in, out, opts...)
-	if err != nil {
-		return nil, err
-	}
-	return out, nil
-}
-
-func (c *deviceManagementClient) GetEventList(ctx context.Context, in *DeviceInfo, opts ...grpc.CallOption) (*SupportedEventList, error) {
-	out := new(SupportedEventList)
-	err := c.cc.Invoke(ctx, "/importer.device_management/GetEventList", in, out, opts...)
-	if err != nil {
-		return nil, err
-	}
-	return out, nil
-}
-
-func (c *deviceManagementClient) SubsrcribeGivenEvents(ctx context.Context, in *EventList, opts ...grpc.CallOption) (*empty.Empty, error) {
-	out := new(empty.Empty)
-	err := c.cc.Invoke(ctx, "/importer.device_management/SubsrcribeGivenEvents", in, out, opts...)
-	if err != nil {
-		return nil, err
-	}
-	return out, nil
-}
-
-func (c *deviceManagementClient) UnSubsrcribeGivenEvents(ctx context.Context, in *EventList, opts ...grpc.CallOption) (*empty.Empty, error) {
-	out := new(empty.Empty)
-	err := c.cc.Invoke(ctx, "/importer.device_management/UnSubsrcribeGivenEvents", in, out, opts...)
-	if err != nil {
-		return nil, err
-	}
-	return out, nil
-}
-
-// DeviceManagementServer is the server API for DeviceManagement service.
-type DeviceManagementServer interface {
-	SendDeviceInfo(context.Context, *DeviceInfo) (*empty.Empty, error)
-	SetFrequency(context.Context, *DeviceInfo) (*empty.Empty, error)
-	GetEventList(context.Context, *DeviceInfo) (*SupportedEventList, error)
-	SubsrcribeGivenEvents(context.Context, *EventList) (*empty.Empty, error)
-	UnSubsrcribeGivenEvents(context.Context, *EventList) (*empty.Empty, error)
-}
-
-// UnimplementedDeviceManagementServer can be embedded to have forward compatible implementations.
-type UnimplementedDeviceManagementServer struct {
-}
-
-func (*UnimplementedDeviceManagementServer) SendDeviceInfo(ctx context.Context, req *DeviceInfo) (*empty.Empty, error) {
-	return nil, status.Errorf(codes.Unimplemented, "method SendDeviceInfo not implemented")
-}
-func (*UnimplementedDeviceManagementServer) SetFrequency(ctx context.Context, req *DeviceInfo) (*empty.Empty, error) {
-	return nil, status.Errorf(codes.Unimplemented, "method SetFrequency not implemented")
-}
-func (*UnimplementedDeviceManagementServer) GetEventList(ctx context.Context, req *DeviceInfo) (*SupportedEventList, error) {
-	return nil, status.Errorf(codes.Unimplemented, "method GetEventList not implemented")
-}
-func (*UnimplementedDeviceManagementServer) SubsrcribeGivenEvents(ctx context.Context, req *EventList) (*empty.Empty, error) {
-	return nil, status.Errorf(codes.Unimplemented, "method SubsrcribeGivenEvents not implemented")
-}
-func (*UnimplementedDeviceManagementServer) UnSubsrcribeGivenEvents(ctx context.Context, req *EventList) (*empty.Empty, error) {
-	return nil, status.Errorf(codes.Unimplemented, "method UnSubsrcribeGivenEvents not implemented")
-}
-
-func RegisterDeviceManagementServer(s *grpc.Server, srv DeviceManagementServer) {
-	s.RegisterService(&_DeviceManagement_serviceDesc, srv)
-}
-
-func _DeviceManagement_SendDeviceInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
-	in := new(DeviceInfo)
-	if err := dec(in); err != nil {
-		return nil, err
-	}
-	if interceptor == nil {
-		return srv.(DeviceManagementServer).SendDeviceInfo(ctx, in)
-	}
-	info := &grpc.UnaryServerInfo{
-		Server:     srv,
-		FullMethod: "/importer.device_management/SendDeviceInfo",
-	}
-	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
-		return srv.(DeviceManagementServer).SendDeviceInfo(ctx, req.(*DeviceInfo))
-	}
-	return interceptor(ctx, in, info, handler)
-}
-
-func _DeviceManagement_SetFrequency_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
-	in := new(DeviceInfo)
-	if err := dec(in); err != nil {
-		return nil, err
-	}
-	if interceptor == nil {
-		return srv.(DeviceManagementServer).SetFrequency(ctx, in)
-	}
-	info := &grpc.UnaryServerInfo{
-		Server:     srv,
-		FullMethod: "/importer.device_management/SetFrequency",
-	}
-	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
-		return srv.(DeviceManagementServer).SetFrequency(ctx, req.(*DeviceInfo))
-	}
-	return interceptor(ctx, in, info, handler)
-}
-
-func _DeviceManagement_GetEventList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
-	in := new(DeviceInfo)
-	if err := dec(in); err != nil {
-		return nil, err
-	}
-	if interceptor == nil {
-		return srv.(DeviceManagementServer).GetEventList(ctx, in)
-	}
-	info := &grpc.UnaryServerInfo{
-		Server:     srv,
-		FullMethod: "/importer.device_management/GetEventList",
-	}
-	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
-		return srv.(DeviceManagementServer).GetEventList(ctx, req.(*DeviceInfo))
-	}
-	return interceptor(ctx, in, info, handler)
-}
-
-func _DeviceManagement_SubsrcribeGivenEvents_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
-	in := new(EventList)
-	if err := dec(in); err != nil {
-		return nil, err
-	}
-	if interceptor == nil {
-		return srv.(DeviceManagementServer).SubsrcribeGivenEvents(ctx, in)
-	}
-	info := &grpc.UnaryServerInfo{
-		Server:     srv,
-		FullMethod: "/importer.device_management/SubsrcribeGivenEvents",
-	}
-	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
-		return srv.(DeviceManagementServer).SubsrcribeGivenEvents(ctx, req.(*EventList))
-	}
-	return interceptor(ctx, in, info, handler)
-}
-
-func _DeviceManagement_UnSubsrcribeGivenEvents_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
-	in := new(EventList)
-	if err := dec(in); err != nil {
-		return nil, err
-	}
-	if interceptor == nil {
-		return srv.(DeviceManagementServer).UnSubsrcribeGivenEvents(ctx, in)
-	}
-	info := &grpc.UnaryServerInfo{
-		Server:     srv,
-		FullMethod: "/importer.device_management/UnSubsrcribeGivenEvents",
-	}
-	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
-		return srv.(DeviceManagementServer).UnSubsrcribeGivenEvents(ctx, req.(*EventList))
-	}
-	return interceptor(ctx, in, info, handler)
-}
-
-var _DeviceManagement_serviceDesc = grpc.ServiceDesc{
-	ServiceName: "importer.device_management",
-	HandlerType: (*DeviceManagementServer)(nil),
-	Methods: []grpc.MethodDesc{
-		{
-			MethodName: "SendDeviceInfo",
-			Handler:    _DeviceManagement_SendDeviceInfo_Handler,
-		},
-		{
-			MethodName: "SetFrequency",
-			Handler:    _DeviceManagement_SetFrequency_Handler,
-		},
-		{
-			MethodName: "GetEventList",
-			Handler:    _DeviceManagement_GetEventList_Handler,
-		},
-		{
-			MethodName: "SubsrcribeGivenEvents",
-			Handler:    _DeviceManagement_SubsrcribeGivenEvents_Handler,
-		},
-		{
-			MethodName: "UnSubsrcribeGivenEvents",
-			Handler:    _DeviceManagement_UnSubsrcribeGivenEvents_Handler,
-		},
-	},
-	Streams:  []grpc.StreamDesc{},
-	Metadata: "importer.proto",
-}
diff --git a/demo_test/test.go b/demo_test/test.go
index 70c2df6..05582ad 100644
--- a/demo_test/test.go
+++ b/demo_test/test.go
@@ -15,73 +15,61 @@
 package main
 
 import (
-        "fmt"
-        "net"
-        "bufio"
-        "os"
-        "os/signal"
-        "os/exec"
-        "github.com/Shopify/sarama"
-        "google.golang.org/grpc"
-        "golang.org/x/net/context"
-        importer "./proto"
-        log "github.com/Sirupsen/logrus"
+	importer "./proto"
+	"bufio"
 	"bytes"
+	"crypto/tls"
+	"fmt"
+	"github.com/Shopify/sarama"
+	log "github.com/Sirupsen/logrus"
+	"golang.org/x/net/context"
+	"google.golang.org/grpc"
+	"google.golang.org/grpc/status"
+	"net"
+	"net/http"
+	"os"
+	"os/exec"
+	"os/signal"
+	"strconv"
 	"strings"
-        "net/http"
-        "crypto/tls"
-        "strconv"
 )
 
-var REDFISH_ROOT		= "/redfish/v1"
-var CONTENT_TYPE		= "application/json"
+var REDFISH_ROOT = "/redfish/v1"
+var CONTENT_TYPE = "application/json"
 var EVENTS_MAP = map[string]string{
-"add":"ResourceAdded",
-"rm":"ResourceRemoved",
-"alert":"Alert",
-"update":"Update"}
+	"add":    "ResourceAdded",
+	"rm":     "ResourceRemoved",
+	"alert":  "Alert",
+	"update": "Update"}
 
-var default_address string	= "localhost:31085"
-var default_port    string	= "8888"
-var default_vendor  string	= "edgecore"
-var default_freq    uint64	= 180
-var attach_device_ip string	= ""
-var importerTopic		= "importer"
+var default_address string = "localhost:31085"
+var default_port string = "8888"
+var default_vendor string = "edgecore"
+var default_freq uint64 = 180
+var attach_device_ip string = ""
+var importerTopic = "importer"
 var DataConsumer sarama.Consumer
 
-var cc	   importer.DeviceManagementClient
-var ctx	   context.Context
-var conn   * grpc.ClientConn
-
-type Device struct {
-	deviceinfo * importer.DeviceInfo
-	eventlist  * importer.EventList
-}
-
-var devicemap map[string]* Device
+var cc importer.DeviceManagementClient
+var ctx context.Context
+var conn *grpc.ClientConn
 
 /*///////////////////////////////////////////////////////////////////////*/
 // Allows user to register the device for data collection and frequency.
 //
 //
 /*///////////////////////////////////////////////////////////////////////*/
-func (s * Device) Attach(aip string, avendor string, afreq uint32) (error, string) {
-        fmt.Println("Received Attach\n")
-	var default_protocol string	= "https"
+func Attach(aip string, avendor string, afreq uint32) error {
+	fmt.Println("Received Attach\n")
+	var default_protocol string = "https"
+	deviceinfo := new(importer.DeviceInfo)
+	deviceinfo.IpAddress = aip
+	deviceinfo.Vendor = avendor
+	deviceinfo.Frequency = afreq
+	deviceinfo.Protocol = default_protocol
+	_, err := cc.SendDeviceInfo(ctx, deviceinfo)
 
-	s.deviceinfo = new(importer.DeviceInfo)
-	s.eventlist  = new(importer.EventList)
-	s.deviceinfo.IpAddress  = aip
-	s.deviceinfo.Vendor     = avendor
-	s.deviceinfo.Frequency  = afreq
-	s.deviceinfo.Protocol   = default_protocol
-	_, err := cc.SendDeviceInfo(ctx, s.deviceinfo)
-
-	if err != nil {
-		return err ,"attach error!!"
-	}else{
-		return nil,""
-	}
+	return err
 }
 
 /*///////////////////////////////////////////////////////////////////////*/
@@ -89,16 +77,14 @@
 //
 //
 /*///////////////////////////////////////////////////////////////////////*/
-func (s * Device) UpdateFreq(wd uint32)(error, string) {
-        fmt.Println("Received Period\n")
-	s.deviceinfo.Frequency  = wd
-	_, err := cc.SetFrequency(ctx, s.deviceinfo)
+func UpdateFreq(ip_address string, wd uint32) error {
+	fmt.Println("Received Period\n")
+	freqinfo := new(importer.FreqInfo)
+	freqinfo.Frequency = wd
+	freqinfo.IpAddress = ip_address
+	_, err := cc.SetFrequency(ctx, freqinfo)
 
-	if err != nil {
-		return err, "period error!!"
-	}else{
-		return nil,""
-	}
+	return err
 }
 
 /*///////////////////////////////////////////////////////////////////////*/
@@ -106,17 +92,14 @@
 //
 //
 /*///////////////////////////////////////////////////////////////////////*/
-func (s * Device) Subscribe(eventlist []string) (error, string) {
-        fmt.Println("Received Subscribe\n")
-	s.eventlist.Events = eventlist
-	s.eventlist.EventIpAddress = s.deviceinfo.IpAddress
-	_, err := cc.SubsrcribeGivenEvents(ctx, s.eventlist)
+func Subscribe(ip_address string, Giveneventlist []string) error {
+	fmt.Println("Received Subscribe\n")
+	giveneventlist := new(importer.GivenEventList)
+	giveneventlist.Events = Giveneventlist
+	giveneventlist.EventIpAddress = ip_address
+	_, err := cc.SubsrcribeGivenEvents(ctx, giveneventlist)
 
-	if err != nil {
-		return err, "sub error!!"
-	}else{
-		return nil,""
-	}
+	return err
 }
 
 /*///////////////////////////////////////////////////////////////////////*/
@@ -124,17 +107,14 @@
 //
 //
 /*///////////////////////////////////////////////////////////////////////*/
-func (s * Device) UnSubscribe(eventlist []string) (error, string) {
-        fmt.Println("Received UnSubscribe\n")
-	s.eventlist.Events = eventlist
-	s.eventlist.EventIpAddress = s.deviceinfo.IpAddress
-	_, err := cc.UnSubsrcribeGivenEvents(ctx, s.eventlist)
+func UnSubscribe(ip_address string, Giveneventlist []string) error {
+	fmt.Println("Received UnSubscribe\n")
+	giveneventlist := new(importer.GivenEventList)
+	giveneventlist.Events = Giveneventlist
+	giveneventlist.EventIpAddress = ip_address
+	_, err := cc.UnSubsrcribeGivenEvents(ctx, giveneventlist)
 
-	if err != nil {
-		return err, "unsub error!!"
-	}else{
-		return nil,""
-	}
+	return err
 }
 
 /*///////////////////////////////////////////////////////////////////////*/
@@ -142,23 +122,50 @@
 //
 //
 /*///////////////////////////////////////////////////////////////////////*/
-func (s * Device) GetEventSupportList() (error, []string) {
-        fmt.Println("Received GetEventSupportList\n")
-	var ret_msg * importer.SupportedEventList
-	ret_msg, err :=cc.GetEventList(ctx, devicemap[s.deviceinfo.IpAddress].deviceinfo);
-	if err != nil {
-		return err,ret_msg.Events
-	}else{
-		fmt.Println("show all event subs:", ret_msg)
-		return nil , ret_msg.Events
-	}
+func GetEventSupportList(vendor string) (error, []string) {
+	fmt.Println("Received GetEventSupportList\n")
+	vendorinfo := new(importer.VendorInfo)
+	vendorinfo.Vendor = vendor
+	var ret_msg *importer.EventList
+	ret_msg, err := cc.GetEventList(ctx, vendorinfo)
+
+	return err, ret_msg.Events
+}
+
+/*///////////////////////////////////////////////////////////////////////*/
+// Allows user to get the current events subscribed by device
+//
+//
+/*///////////////////////////////////////////////////////////////////////*/
+func GetEventCurrentDeviceList(ip_address string) (error, []string) {
+	fmt.Println("Received GetEventCurrentDeviceList\n")
+	currentdeviceinfo := new(importer.Device)
+	currentdeviceinfo.IpAddress = ip_address
+	var ret_msg *importer.EventList
+	ret_msg, err := cc.GetCurrentEventList(ctx, currentdeviceinfo)
+
+	return err, ret_msg.Events
+}
+
+/*///////////////////////////////////////////////////////////////////////*/
+// Allows user to get the current events subscribed by device
+//
+//
+/*///////////////////////////////////////////////////////////////////////*/
+func ClearCurrentDeviceEventList(ip_address string) error {
+	fmt.Println("Received ClearCurrentDeviceEventList\n")
+	currentdeviceinfo := new(importer.Device)
+	currentdeviceinfo.IpAddress = ip_address
+	_, err := cc.ClearCurrentEventList(ctx, currentdeviceinfo)
+
+	return err
 }
 
 func init() {
-        Formatter := new(log.TextFormatter)
-        Formatter.TimestampFormat = "02-01-2006 15:04:05"
-        Formatter.FullTimestamp = true
-        log.SetFormatter(Formatter)
+	Formatter := new(log.TextFormatter)
+	Formatter.TimestampFormat = "02-01-2006 15:04:05"
+	Formatter.FullTimestamp = true
+	log.SetFormatter(Formatter)
 }
 
 func topicListener(topic *string, master sarama.Consumer) {
@@ -180,7 +187,7 @@
 				log.Info("Got message on topic=[%s]: %s", *topic, string(msg.Value))
 			case <-signals:
 				log.Warn("Interrupt is detected")
-		                os.Exit(1)
+				os.Exit(1)
 			}
 		}
 	}()
@@ -188,7 +195,7 @@
 }
 
 func kafkainit() {
-	cmd := exec.Command("/bin/sh","kafka_ip.sh")
+	cmd := exec.Command("/bin/sh", "kafka_ip.sh")
 	var kafkaIP string
 	var out bytes.Buffer
 	cmd.Stdout = &out
@@ -200,8 +207,8 @@
 
 	kafkaIP = out.String()
 	kafkaIP = strings.TrimSuffix(kafkaIP, "\n")
-	kafkaIP = kafkaIP +":9092"
-	fmt.Println("IP address of kafka-cord-0:",kafkaIP)
+	kafkaIP = kafkaIP + ":9092"
+	fmt.Println("IP address of kafka-cord-0:", kafkaIP)
 	config := sarama.NewConfig()
 	config.Consumer.Return.Errors = true
 	master, err := sarama.NewConsumer([]string{kafkaIP}, config)
@@ -219,21 +226,21 @@
 	kafkainit()
 
 	ln, err := net.Listen("tcp", ":9999")
-        if err != nil {
-                fmt.Println("could not listen")
-                log.Fatal("did not listen: %v", err)
-        }
+	if err != nil {
+		fmt.Println("could not listen")
+		log.Fatal("did not listen: %v", err)
+	}
 	defer ln.Close()
 
 	connS, err := ln.Accept()
 	if err != nil {
-                fmt.Println("Accept error")
-                log.Fatal("Accept error: %v", err)
-	}else{
+		fmt.Println("Accept error")
+		log.Fatal("Accept error: %v", err)
+	} else {
 
 		conn, err = grpc.Dial(default_address, grpc.WithInsecure())
 		if err != nil {
-		        fmt.Println("could not connect")
+			fmt.Println("could not connect")
 			log.Fatal("did not connect: %v", err)
 		}
 		defer conn.Close()
@@ -241,7 +248,6 @@
 		cc = importer.NewDeviceManagementClient(conn)
 		ctx = context.Background()
 
-		devicemap = make(map[string] *Device)
 		loop := true
 
 		for loop == true {
@@ -254,153 +260,193 @@
 
 			switch string(cmd) {
 
-			case "attach" :
+			case "attach":
 				cmd_size := len(s)
-				var err	error
-				var aport   string = default_port
-				var avendor string = default_vendor
-				var uafreq  uint64 = default_freq
+				var err error
+				var uafreq uint64
+				if cmd_size == 5 {
+					aip := s[1]
+					aport := s[2]
+					avendor := s[3]
+					afreq := s[4]
+					uafreq, err = strconv.ParseUint(afreq, 10, 64)
 
-				if (cmd_size == 2 || cmd_size == 5){
-					aip    := s[1]
-					if(cmd_size == 5){
-						aport	= s[2]
-						avendor	= s[3]
-						afreq	:= s[4]
-						uafreq, err = strconv.ParseUint(afreq, 10, 64)
-
-						if err != nil {
-							fmt.Print("ParseUint error!!")
-						}
-
-						attach_device_ip = aip + ":" + aport
-					}else{
-						attach_device_ip = aip + ":" + default_port
+					if err != nil {
+						fmt.Print("ParseUint error!!\n")
 					}
 
-					if (devicemap[attach_device_ip] == nil){
-						dev := new (Device)
-						err, newmessage = dev.Attach(attach_device_ip, avendor, uint32(uafreq))
-						if err != nil {
-							fmt.Print("attach error!!")
-						}else{
-							fmt.Print("attatch IP:", attach_device_ip)
-							newmessage = attach_device_ip
-							devicemap[attach_device_ip] = dev
-						}
-					}else{
-						fmt.Print("Change attach IP to %v", attach_device_ip)
+					attach_device_ip = aip + ":" + aport
+
+					err = Attach(attach_device_ip, avendor, uint32(uafreq))
+					if err != nil {
+						errStatus, _ := status.FromError(err)
+						fmt.Println(errStatus.Message())
+						fmt.Println(errStatus.Code())
+						fmt.Print("attach error!!\n")
+						newmessage = errStatus.Message()
+
+					} else {
+						fmt.Print("attatch IP:\n", attach_device_ip)
 						newmessage = attach_device_ip
 					}
-				}else{
-					fmt.Print("Need IP address !!")
+				} else {
+					fmt.Print("Need IP addres,port,vendor,freqs !!\n")
 					newmessage = "Need IP address !!"
 
 				}
-			break
 
-			case "period" :
+			case "period":
 				cmd_size := len(s)
-				if (cmd_size == 2 ){
-					if (devicemap[attach_device_ip] != nil){
-						pv  := s[1]
-						fmt.Print("pv:", pv)
-						u, err := strconv.ParseUint(pv, 10, 64)
+				fmt.Print("cmd_size period %d", cmd_size)
+				if cmd_size == 4 {
+					fip := s[1]
+					fport := s[2]
+					pv := s[3]
+					fmt.Print("pv:", pv)
+					u, err := strconv.ParseUint(pv, 10, 64)
+
+					if err != nil {
+						fmt.Print("ParseUint error!!\n")
+					} else {
+						wd := uint32(u)
+						ip_address := fip + ":" + fport
+						err = UpdateFreq(ip_address, wd)
 
 						if err != nil {
-							fmt.Print("ParseUint error!!")
-						}else{
-							wd := uint32(u)
-							dev := devicemap[attach_device_ip]
-							err, newmessage =  dev.UpdateFreq(wd)
-
-							if err != nil {
-								fmt.Print("period error!!")
-							}else{
-								newmessage = strings.ToUpper(cmd)
-							}
+							errStatus, _ := status.FromError(err)
+							fmt.Println(errStatus.Message())
+							fmt.Println(errStatus.Code())
+							newmessage = errStatus.Message()
+							fmt.Print("period error!!\n")
+						} else {
+							newmessage = strings.ToUpper(cmd)
 						}
-					}else{
-						fmt.Print("need attach first!!")
-						newmessage = "need attach first!!"
 					}
-				}else{
-					fmt.Print("Need period value !!")
+				} else {
+					fmt.Print("Need period value !!\n")
 					newmessage = "Need period value !!"
 				}
 
-			break
-
-			case "sub","unsub" :
+			case "sub", "unsub":
 				cmd_size := len(s)
-				fmt.Print("cmd is :", cmd)
-				if(cmd_size > 4 || cmd_size <0){
+				fmt.Print("cmd is :", cmd, cmd_size)
+				if cmd_size > 6 || cmd_size < 0 {
 					fmt.Print("error event !!")
 					newmessage = "error event !!"
-				}else{
+				} else {
+					ip := s[1]
+					port := s[2]
+					ip_address := ip + ":" + port
 					var events_list []string
-					for i := 1; i < cmd_size; i++ {
+					for i := 3; i < cmd_size; i++ {
 						if value, ok := EVENTS_MAP[s[i]]; ok {
-							events_list = append(events_list,value)
+							events_list = append(events_list, value)
 						} else {
 							fmt.Println("key not found")
 						}
 					}
 
-					if (devicemap[attach_device_ip] != nil){
-						dev := devicemap[attach_device_ip]
-						if(string(cmd) == "sub"){
-							err, newmessage =  dev.Subscribe(events_list)
-							if err != nil {
-								fmt.Print("sub error!!")
-								newmessage = "sub error!!"
-							}else{
-								newmessage = strings.ToUpper(cmd)
-							}
-						}else{
-							err, newmessage =  dev.UnSubscribe(events_list)
-							if err != nil {
-								fmt.Print("unsub error!!")
-								newmessage = "unsub error!!"
-							}else{
-								newmessage = strings.ToUpper(cmd)
-							}
+					if string(cmd) == "sub" {
+						err = Subscribe(ip_address, events_list)
+						if err != nil {
+							errStatus, _ := status.FromError(err)
+							fmt.Println(errStatus.Message())
+							fmt.Println(errStatus.Code())
+							newmessage = errStatus.Message()
+							fmt.Print("sub error!!")
+						} else {
+							newmessage = strings.ToUpper(cmd)
 						}
-					}else{
-						fmt.Print("need attach first !!")
-						newmessage = "need attach first !!"
+					} else {
+						err = UnSubscribe(ip_address, events_list)
+						if err != nil {
+							errStatus, _ := status.FromError(err)
+							fmt.Println(errStatus.Message())
+							fmt.Println(errStatus.Code())
+							newmessage = errStatus.Message()
+							fmt.Print("unsub error!!")
+						} else {
+							newmessage = strings.ToUpper(cmd)
+						}
 					}
 				}
-			break
 
-			case "showeventlist" :
-				if (devicemap[attach_device_ip] != nil){
-					dev := devicemap[attach_device_ip]
-					err, supportlist :=  dev.GetEventSupportList()
+			case "showeventlist":
+				cmd_size := len(s)
+				fmt.Print("cmd is :", cmd, cmd_size)
+				if cmd_size > 3 || cmd_size < 0 {
+					fmt.Print("error event !!")
+					newmessage = "error event !!"
+				} else {
+					vendor := s[1]
+					err, supportlist := GetEventSupportList(vendor)
 
 					if err != nil {
+						errStatus, _ := status.FromError(err)
+						fmt.Println(errStatus.Message())
+						fmt.Println(errStatus.Code())
+						newmessage = errStatus.Message()
 						fmt.Print("showeventlist error!!")
-					}else{
+					} else {
 						fmt.Print("showeventlist ", supportlist)
-						newmessage = strings.Join(supportlist[:],",")
+						newmessage = strings.Join(supportlist[:], ",")
 					}
-				}else{
-					fmt.Print("need attach first !!")
-					newmessage = "need attach first !!"
 				}
 
-			break
+			case "showdeviceeventlist":
+				cmd_size := len(s)
+				fmt.Print("cmd is :", cmd, cmd_size)
+				if cmd_size > 4 || cmd_size < 0 {
+					fmt.Print("error event !!")
+					newmessage = "error event !!"
+				} else {
+					eip := s[1]
+					eport := s[2]
+					ip_address := eip + ":" + eport
+					err, currentlist := GetEventCurrentDeviceList(ip_address)
 
-			case "QUIT" :
+					if err != nil {
+						errStatus, _ := status.FromError(err)
+						fmt.Println(errStatus.Message())
+						fmt.Println(errStatus.Code())
+						newmessage = errStatus.Message()
+						fmt.Print("showdeviceeventlist error!!")
+					} else {
+						fmt.Print("showeventlist ", currentlist)
+						newmessage = strings.Join(currentlist[:], ",")
+					}
+				}
+
+			case "cleardeviceeventlist":
+				cmd_size := len(s)
+				fmt.Print("cmd is :", cmd, cmd_size)
+				if cmd_size > 4 || cmd_size < 0 {
+					fmt.Print("error event !!")
+					newmessage = "error event !!"
+				} else {
+					clip := s[1]
+					clport := s[2]
+					ip_address := clip + ":" + clport
+					err = ClearCurrentDeviceEventList(ip_address)
+					if err != nil {
+						errStatus, _ := status.FromError(err)
+						fmt.Println(errStatus.Message())
+						fmt.Println(errStatus.Code())
+						newmessage = errStatus.Message()
+						fmt.Print("cleardeviceeventlist  error!!")
+					} else {
+						newmessage = strings.ToUpper(cmd)
+					}
+				}
+
+			case "QUIT":
 				loop = false
-	                        newmessage="QUIT"
-			break
+				newmessage = "QUIT"
 
-			default :
-			break
+			default:
 			}
 			// send string back to client
 			connS.Write([]byte(newmessage + "\n"))
-	        }
+		}
 	}
 }
diff --git a/event_subscriber.go b/event_subscriber.go
index 9fe0308..973a765 100644
--- a/event_subscriber.go
+++ b/event_subscriber.go
@@ -15,12 +15,12 @@
 package main
 
 import (
+	"bytes"
 	"encoding/json"
 	"fmt"
 	"net/http"
-	"bytes"
-	"regexp"
 	"os"
+	"regexp"
 )
 
 const RF_SUBSCRIPTION = "/EventService/Subscriptions/"
@@ -29,7 +29,7 @@
 	rtn = false
 
 	destip := os.Getenv("EVENT_NOTIFICATION_DESTIP") + ":" + os.Getenv("DEVICE_MANAGEMENT_DESTPORT")
-	subscrpt_info := map[string]interface{}{"Context":"TBD","Protocol":"Redfish"}
+	subscrpt_info := map[string]interface{}{"Context": "TBD-" + destip, "Protocol": "Redfish"}
 	subscrpt_info["Name"] = event + " event subscription"
 	subscrpt_info["Destination"] = "https://" + destip
 	subscrpt_info["EventTypes"] = []string{event}
@@ -48,7 +48,7 @@
 		json.NewDecoder(resp.Body).Decode(&result)
 		fmt.Println(result)
 		fmt.Println(result["data"])
-		fmt.Println("Add ", event, " subscription failed. HTTP response status: ",  resp.Status)
+		fmt.Println("Add ", event, " subscription failed. HTTP response status: ", resp.Status)
 		return
 	}
 	rtn = true
@@ -119,4 +119,3 @@
 	fmt.Println("Subscription id", id, "was successfully removed")
 	return true
 }
-
diff --git a/main.go b/main.go
index c0d7346..bc0e3ba 100644
--- a/main.go
+++ b/main.go
@@ -15,22 +15,24 @@
 package main
 
 import (
+	importer "./proto"
+	"crypto/tls"
+	"encoding/json"
 	"fmt"
+	"github.com/Shopify/sarama"
+	log "github.com/Sirupsen/logrus"
+	empty "github.com/golang/protobuf/ptypes/empty"
+	"golang.org/x/net/context"
+	"google.golang.org/grpc"
+	"google.golang.org/grpc/codes"
+	"google.golang.org/grpc/status"
+	"io/ioutil"
 	"net"
 	"net/http"
 	"os"
 	"os/signal"
-	"io/ioutil"
-	"github.com/Shopify/sarama"
-	"google.golang.org/grpc"
-	"golang.org/x/net/context"
-	"crypto/tls"
-	empty "github.com/golang/protobuf/ptypes/empty"
-        importer "./proto"
-        log "github.com/Sirupsen/logrus"
-	"time"
-	"encoding/json"
 	"path"
+	"time"
 )
 
 //globals
@@ -43,83 +45,156 @@
 
 var DataProducer sarama.AsyncProducer
 
-var    vendor_default_events = map[string][]string{
-        "edgecore": {"ResourceAdded","ResourceRemoved","Alert"},
-    }
-var redfish_services = [...]string{"/Chassis", "/Systems","/EthernetSwitches"}
+var vendor_default_events = map[string][]string{
+	"edgecore": {"ResourceAdded", "ResourceRemoved", "Alert"},
+}
+var redfish_services = [...]string{"/Chassis", "/Systems", "/EthernetSwitches"}
 var pvmount = os.Getenv("DEVICE_MANAGEMENT_PVMOUNT")
 var subscriptionListPath string
 
-type scheduler struct  {
-	getdata time.Ticker
-	quit chan bool
+type scheduler struct {
+	getdata *time.Ticker
+	quit    chan bool
 }
 
-type device struct  {
-	Subscriptions	map[string]string	`json:"ss"`
-	Freq		uint32			`json:"freq"`
-	Datacollector	scheduler		`json:"-"`
-	Freqchan	chan uint32		`json:"-"`
-	Vendor		string			`json:"vendor"`
-	Protocol	string			`json:"protocol"`
+type device struct {
+	Subscriptions map[string]string `json:"ss"`
+	Freq          uint32            `json:"freq"`
+	Datacollector scheduler         `json:"-"`
+	Freqchan      chan uint32       `json:"-"`
+	Vendor        string            `json:"vendor"`
+	Protocol      string            `json:"protocol"`
 }
 
 type Server struct {
-	devicemap	map[string]*device
-	gRPCserver	*grpc.Server
-	dataproducer	sarama.AsyncProducer
-	httpclient	*http.Client
-	devicechan	chan *importer.DeviceInfo
+	devicemap    map[string]*device
+	gRPCserver   *grpc.Server
+	dataproducer sarama.AsyncProducer
+	httpclient   *http.Client
+	devicechan   chan *importer.DeviceInfo
 }
 
-func (s *Server) GetEventList(c context.Context, info *importer.DeviceInfo) (*importer.SupportedEventList, error) {
+func (s *Server) ClearCurrentEventList(c context.Context, info *importer.Device) (*empty.Empty, error) {
+	fmt.Println("Received GetCurrentEventList\n")
+	ip_address := info.IpAddress
+	_, found := s.devicemap[ip_address]
+	if !found {
+		return nil, status.Errorf(codes.NotFound, "Device not registered")
+	}
+	f := get_subscription_list(ip_address)
+	for event, _ := range s.devicemap[ip_address].Subscriptions {
+		rtn := s.remove_subscription(ip_address, event, f)
+		if !rtn {
+			log.WithFields(log.Fields{
+				"Event": event,
+			}).Info("Error removing event")
+		}
+	}
+	if f != nil {
+		f.Close()
+	}
+	return &empty.Empty{}, nil
+}
+
+func (s *Server) GetCurrentEventList(c context.Context, info *importer.Device) (*importer.EventList, error) {
+	fmt.Println("Received ClearCurrentEventList\n")
+	_, found := s.devicemap[info.IpAddress]
+	if !found {
+		return nil, status.Errorf(codes.NotFound, "Device not registered")
+	}
+	currentevents := new(importer.EventList)
+	for event, _ := range s.devicemap[info.IpAddress].Subscriptions {
+		currentevents.Events = append(currentevents.Events, event)
+	}
+	return currentevents, nil
+}
+
+func (s *Server) GetEventList(c context.Context, info *importer.VendorInfo) (*importer.EventList, error) {
 	fmt.Println("Received GetEventList\n")
-	eventstobesubscribed:= new(importer.SupportedEventList)
+	_, found := vendor_default_events[info.Vendor]
+	if !found {
+		return nil, status.Errorf(codes.NotFound, "Invalid Vendor Provided")
+	}
+	eventstobesubscribed := new(importer.EventList)
 	eventstobesubscribed.Events = vendor_default_events[info.Vendor]
 	return eventstobesubscribed, nil
 }
 
-func (s *Server) SetFrequency(c context.Context,  info *importer.DeviceInfo) (*empty.Empty, error) {
+func (s *Server) SetFrequency(c context.Context, info *importer.FreqInfo) (*empty.Empty, error) {
 	fmt.Println("Received SetFrequency")
+	_, found := s.devicemap[info.IpAddress]
+	if !found {
+		return nil, status.Errorf(codes.NotFound, "Device not registered")
+	}
+
 	s.devicemap[info.IpAddress].Freqchan <- info.Frequency
 	return &empty.Empty{}, nil
 }
 
-func (s *Server) SubsrcribeGivenEvents(c context.Context,  subeventlist *importer.EventList) (*empty.Empty, error) {
+func (s *Server) SubsrcribeGivenEvents(c context.Context, subeventlist *importer.GivenEventList) (*empty.Empty, error) {
 	fmt.Println("Received SubsrcribeEvents\n")
 	//Call API to subscribe events
 	ip_address := subeventlist.EventIpAddress
+	_, found := s.devicemap[ip_address]
+	if !found {
+		return nil, status.Errorf(codes.NotFound, "Device not registered")
+	}
+	if len(subeventlist.Events) <= 0 {
+		return nil, status.Errorf(codes.InvalidArgument, "Event list is empty")
+	}
 	f := get_subscription_list(ip_address)
 	for _, event := range subeventlist.Events {
 		if _, ok := s.devicemap[ip_address].Subscriptions[event]; !ok {
-			s.add_subscription(ip_address, event, f)
+			rtn := s.add_subscription(ip_address, event, f)
+			if !rtn {
+				log.WithFields(log.Fields{
+					"Event": event,
+				}).Info("Error adding  event")
+			}
 		} else {
 			log.WithFields(log.Fields{
 				"Event": event,
-				}).Info("Already Subscribed")
+			}).Info("Already Subscribed")
 		}
 	}
-	if f != nil { f.Close() }
+	if f != nil {
+		f.Close()
+	}
 	return &empty.Empty{}, nil
 }
 
-func (s *Server) UnSubsrcribeGivenEvents(c context.Context,  unsubeventlist *importer.EventList) (*empty.Empty, error) {
+func (s *Server) UnSubsrcribeGivenEvents(c context.Context, unsubeventlist *importer.GivenEventList) (*empty.Empty, error) {
 	fmt.Println("Received UnSubsrcribeEvents\n")
 	ip_address := unsubeventlist.EventIpAddress
+	_, found := s.devicemap[ip_address]
+	if !found {
+		return nil, status.Errorf(codes.NotFound, "Device not registered")
+	}
+
+	if len(unsubeventlist.Events) <= 0 {
+		return nil, status.Errorf(codes.InvalidArgument, "Event list is empty")
+	}
 	//Call API to unsubscribe events
 	f := get_subscription_list(ip_address)
 	for _, event := range unsubeventlist.Events {
 		if _, ok := s.devicemap[ip_address].Subscriptions[event]; ok {
-			s.remove_subscription(ip_address, event, f)
-                } else {
-                                log.WithFields(log.Fields{
-                                  "Event": event,
-                                }).Info("was not Subscribed")
-                        }
-        }
-	if f != nil { f.Close() }
+			rtn := s.remove_subscription(ip_address, event, f)
+			if !rtn {
+				log.WithFields(log.Fields{
+					"Event": event,
+				}).Info("Error removing event")
+			}
+		} else {
+			log.WithFields(log.Fields{
+				"Event": event,
+			}).Info("was not Subscribed")
+		}
+	}
+	if f != nil {
+		f.Close()
+	}
 
-       return &empty.Empty{}, nil
+	return &empty.Empty{}, nil
 }
 
 func (s *Server) collect_data(ip_address string) {
@@ -130,8 +205,10 @@
 		select {
 		case freq := <-freqchan:
 			ticker.Stop()
-			ticker = *time.NewTicker(time.Duration(freq) * time.Second)
-		case  err := <-s.dataproducer.Errors():
+			if freq > 0 {
+				ticker = time.NewTicker(time.Duration(freq) * time.Second)
+			}
+		case err := <-s.dataproducer.Errors():
 			fmt.Println("Failed to produce message:", err)
 		case <-ticker.C:
 			for _, service := range redfish_services {
@@ -143,9 +220,9 @@
 						b := []byte(str)
 						msg := &sarama.ProducerMessage{Topic: importerTopic, Value: sarama.StringEncoder(b)}
 						select {
-						// TODO: this is blocking, maybe a timer?
-						case  s.dataproducer.Input() <- msg:
+						case s.dataproducer.Input() <- msg:
 							fmt.Println("Produce message")
+						default:
 						}
 					}
 				}
@@ -158,22 +235,32 @@
 	}
 }
 
-func (s *Server) SendDeviceInfo(c context.Context,  info *importer.DeviceInfo) (*empty.Empty, error) {
-	d := device {
+func (s *Server) SendDeviceInfo(c context.Context, info *importer.DeviceInfo) (*empty.Empty, error) {
+	d := device{
 		Subscriptions: make(map[string]string),
-		Freq: info.Frequency,
+		Freq:          info.Frequency,
 		Datacollector: scheduler{
-			getdata: *time.NewTicker(time.Duration(info.Frequency) * time.Second),
-			quit: make(chan bool),
+			getdata: time.NewTicker(time.Duration(info.Frequency) * time.Second),
+			quit:    make(chan bool),
 		},
 		Freqchan: make(chan uint32),
-		Vendor: info.Vendor,
+		Vendor:   info.Vendor,
 		Protocol: info.Protocol,
 	}
-        //default_events := [...]string{}
+	_, found := s.devicemap[info.IpAddress]
+	if found {
+		return nil, status.Errorf(codes.AlreadyExists, "Device Already registered")
+	}
+
+	_, vendorfound := vendor_default_events[info.Vendor]
+	if !vendorfound {
+		return nil, status.Errorf(codes.NotFound, "Vendor Not Found")
+	}
+
+	//default_events := [...]string{}
 	s.devicemap[info.IpAddress] = &d
 	fmt.Printf("size of devicemap %d\n", len(s.devicemap))
-	ip_address:= info.IpAddress
+	ip_address := info.IpAddress
 	fmt.Printf("Configuring  %s\n", ip_address)
 	// call subscription function with info.IpAddress
 
@@ -183,18 +270,20 @@
 	for _, event := range default_events {
 		s.add_subscription(ip_address, event, f)
 	}
-	if f != nil { f.Close() }
+	if f != nil {
+		f.Close()
+	}
 	go s.collect_data(ip_address)
 	return &empty.Empty{}, nil
 }
 
 func NewGrpcServer(grpcport string) (l net.Listener, g *grpc.Server, e error) {
-        fmt.Printf("Listening %s\n", grpcport)
-        g = grpc.NewServer()
-        l, e = net.Listen("tcp", grpcport)
-        return
+	fmt.Printf("Listening %s\n", grpcport)
+	g = grpc.NewServer()
+	l, e = net.Listen("tcp", grpcport)
+	return
 }
-func (s *Server) startgrpcserver()error {
+func (s *Server) startgrpcserver() error {
 	fmt.Println("starting gRPC Server")
 	grpcport := ":50051"
 	listener, gserver, err := NewGrpcServer(grpcport)
@@ -211,8 +300,8 @@
 	return nil
 
 }
-func (s *Server) kafkaCloseProducer(){
-	if err :=s.dataproducer.Close(); err != nil {
+func (s *Server) kafkaCloseProducer() {
+	if err := s.dataproducer.Close(); err != nil {
 		panic(err)
 	}
 
@@ -220,7 +309,7 @@
 func (s *Server) kafkaInit() {
 	fmt.Println("Starting kafka init to Connect to broker: ")
 	config := sarama.NewConfig()
-        config.Producer.RequiredAcks = sarama.WaitForAll
+	config.Producer.RequiredAcks = sarama.WaitForAll
 	config.Producer.Retry.Max = 10
 	producer, err := sarama.NewAsyncProducer([]string{"cord-kafka.default.svc.cluster.local:9092"}, config)
 	if err != nil {
@@ -233,19 +322,19 @@
 	signals := make(chan os.Signal, 1)
 	signal.Notify(signals, os.Interrupt)
 
-        fmt.Println(" IN Handle Event  ")
-	if(r.Method ==  "POST"){
+	fmt.Println(" IN Handle Event  ")
+	if r.Method == "POST" {
 		Body, err := ioutil.ReadAll(r.Body)
 		if err != nil {
-			fmt.Println("Error getting HTTP data",err)
+			fmt.Println("Error getting HTTP data", err)
 		}
-		defer  r.Body.Close()
+		defer r.Body.Close()
 		fmt.Println("Received Event Message ")
-		fmt.Printf("%s\n",Body)
-		message :=&sarama.ProducerMessage{
-                        Topic: importerTopic,
-                        Value: sarama.StringEncoder(Body),
-                }
+		fmt.Printf("%s\n", Body)
+		message := &sarama.ProducerMessage{
+			Topic: importerTopic,
+			Value: sarama.StringEncoder(Body),
+		}
 		s.dataproducer.Input() <- message
 	}
 }
@@ -274,7 +363,7 @@
 					d := device{}
 					json.Unmarshal(b, &d)
 					s.devicemap[ip] = &d
-					s.devicemap[ip].Datacollector.getdata = *time.NewTicker(time.Duration(s.devicemap[ip].Freq) * time.Second)
+					s.devicemap[ip].Datacollector.getdata = time.NewTicker(time.Duration(s.devicemap[ip].Freq) * time.Second)
 					s.devicemap[ip].Datacollector.quit = make(chan bool)
 					s.devicemap[ip].Freqchan = make(chan uint32)
 					go s.collect_data(ip)
@@ -285,14 +374,14 @@
 }
 
 func init() {
-        Formatter := new(log.TextFormatter)
-        Formatter.TimestampFormat = "02-01-2006 15:04:05"
-        Formatter.FullTimestamp = true
-        log.SetFormatter(Formatter)
+	Formatter := new(log.TextFormatter)
+	Formatter.TimestampFormat = "02-01-2006 15:04:05"
+	Formatter.FullTimestamp = true
+	log.SetFormatter(Formatter)
 	fmt.Println("Connecting to broker: ")
 	fmt.Println("Listening to  http server")
-        log.Info("log Connecting to broker:")
-        log.Info("log Listening to  http server ")
+	log.Info("log Connecting to broker:")
+	log.Info("log Listening to  http server ")
 	//sarama.Logger = log.New()
 }
 
@@ -300,7 +389,7 @@
 	if pvmount == "" {
 		return nil
 	}
-	f, err := os.OpenFile(subscriptionListPath + "/" + ip, os.O_CREATE|os.O_RDWR, 0664)
+	f, err := os.OpenFile(subscriptionListPath+"/"+ip, os.O_CREATE|os.O_RDWR, 0664)
 	if err != nil {
 		fmt.Println(err)
 	}
@@ -313,16 +402,15 @@
 	http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
 	client := &http.Client{
 		Timeout: 10 * time.Second,
-		}
+	}
 
-	s := Server {
-		devicemap:	make(map[string]*device),
-		devicechan:	make(chan *importer.DeviceInfo),
-		httpclient:	client,
+	s := Server{
+		devicemap:  make(map[string]*device),
+		devicechan: make(chan *importer.DeviceInfo),
+		httpclient: client,
 	}
 
 	s.kafkaInit()
-//TODO: check if we should keep this as goroutines?
 	go s.runServer()
 	go s.startgrpcserver()
 
diff --git a/proto/importer.proto b/proto/importer.proto
index 1ec491b..dd85cd1 100644
--- a/proto/importer.proto
+++ b/proto/importer.proto
@@ -14,25 +14,45 @@
 	string protocol = 4;
 }
 
-message EventList {
+message GivenEventList {
 	string event_ip_address = 1;
         repeated string events = 2;
 }
 
-message SupportedEventList {
+message EventList {
         repeated string events = 1;
 }
 
+message FreqInfo {
+	string IpAddress = 1;
+	uint32 Frequency = 2;
+}
+
+message VendorInfo {
+	string Vendor = 1;
+}
+
+message Device {
+	string IpAddress = 1;
+}
+
+
+message Empty {}
 service device_management {
     rpc SendDeviceInfo(DeviceInfo) returns (google.protobuf.Empty) {}
 
-    rpc SetFrequency(DeviceInfo) returns (google.protobuf.Empty) {}
+    rpc SetFrequency(FreqInfo) returns (google.protobuf.Empty) {}
 
-    rpc GetEventList(DeviceInfo) returns (SupportedEventList) {}
+    rpc GetEventList(VendorInfo) returns (EventList) {}
 
-    rpc SubsrcribeGivenEvents(EventList)  returns (google.protobuf.Empty) {}
+    rpc SubsrcribeGivenEvents(GivenEventList)  returns (google.protobuf.Empty) {}
 
-    rpc UnSubsrcribeGivenEvents(EventList) returns (google.protobuf.Empty) {}
+    rpc UnSubsrcribeGivenEvents(GivenEventList) returns (google.protobuf.Empty) {}
+
+    rpc GetCurrentEventList(Device) returns (EventList) {}
+
+    rpc ClearCurrentEventList(Device) returns (google.protobuf.Empty) {}
+
 }