From: agrawalgaurav Date: Mon, 11 May 2020 16:59:52 +0000 (+0530) Subject: GRPC client for broker X-Git-Url: https://gerrit.akraino.org/r/gitweb?a=commitdiff_plain;h=788ac3aa23fe22e53ec28d80dd2d00f03986b49a;p=ealt-edge.git GRPC client for broker Change-Id: I18230807610d3a2ca1be03bf6adf5b01f60abd10 --- diff --git a/mecm/mepm/applcm/broker/go.mod b/mecm/mepm/applcm/broker/go.mod new file mode 100644 index 0000000..235d5a0 --- /dev/null +++ b/mecm/mepm/applcm/broker/go.mod @@ -0,0 +1,19 @@ +module broker + +go 1.14 + +require ( + github.com/buger/jsonparser v0.0.0-20200322175846-f7e751efca13 + github.com/ghodss/yaml v1.0.0 + github.com/go-sql-driver/mysql v1.5.0 + github.com/golang/protobuf v1.4.0 + github.com/google/uuid v1.1.1 + github.com/gorilla/mux v1.7.4 + golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3 // indirect + golang.org/x/net v0.0.0-20200506145744-7e3656a0809f + golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135 // indirect + google.golang.org/grpc v1.29.1 + google.golang.org/protobuf v1.22.0 + gopkg.in/yaml.v2 v2.2.8 // indirect + honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc // indirect +) diff --git a/mecm/mepm/applcm/broker/go.sum b/mecm/mepm/applcm/broker/go.sum new file mode 100644 index 0000000..b43094c --- /dev/null +++ b/mecm/mepm/applcm/broker/go.sum @@ -0,0 +1,84 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/buger/jsonparser v0.0.0-20200322175846-f7e751efca13 h1:+qUNY4VRkEH46bLUwxCyUU+iOGJMQBVibAaYzWiwWcg= +github.com/buger/jsonparser v0.0.0-20200322175846-f7e751efca13/go.mod h1:tgcrVJ81GPSF0mz+0nu1Xaz0fazGPrmmJfJtxjbHhUQ= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= +github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs= +github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.3 h1:gyjaxf+svBWX08ZjK86iN9geUJF0H6gp2IRKX6Nf6/I= +github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0 h1:oOuy+ugB+P/kBdUnG5QaMXSIyJ1q38wWSojYCb3z5VQ= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= +github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/gorilla/mux v1.7.4 h1:VuZ8uybHlWmqV03+zRzdwKL4tUnIp1MAQtp1mIFE1bc= +github.com/gorilla/mux v1.7.4/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20200506145744-7e3656a0809f h1:QBjCr1Fz5kw158VqdE9JfI9cJnl/ymnJWAdMuinqL7Y= +golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd h1:xhmwyvizuTgC2qz7ZlMluP20uW+C3Rm0FD/WLDX8884= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55 h1:gSJIx1SDwno+2ElGhA4+qG2zF97qiUzTM+rQ0klBOcE= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.29.1 h1:EC2SB8S04d2r73uptxphDSUG+kTKVgjRPF+N3xpxRB4= +google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0 h1:cJv5/xdbk1NnMPR1VP9+HU6gupuG9MLBoH1r6RHZ2MY= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/mecm/mepm/applcm/broker/internal/lcmservice/lcmservice.pb.go b/mecm/mepm/applcm/broker/internal/lcmservice/lcmservice.pb.go new file mode 100644 index 0000000..9b505f3 --- /dev/null +++ b/mecm/mepm/applcm/broker/internal/lcmservice/lcmservice.pb.go @@ -0,0 +1,741 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.22.0-devel +// protoc v3.11.4 +// source: lcmservice.proto + +package lcmservice + +import ( + context "context" + proto "github.com/golang/protobuf/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// This is a compile-time assertion that a sufficiently up-to-date version +// of the legacy proto package is being used. +const _ = proto.ProtoPackageIsVersion4 + +type InstantiateRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to Data: + // *InstantiateRequest_HostIp + // *InstantiateRequest_Package + Data isInstantiateRequest_Data `protobuf_oneof:"data"` +} + +func (x *InstantiateRequest) Reset() { + *x = InstantiateRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_lcmservice_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *InstantiateRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*InstantiateRequest) ProtoMessage() {} + +func (x *InstantiateRequest) ProtoReflect() protoreflect.Message { + mi := &file_lcmservice_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use InstantiateRequest.ProtoReflect.Descriptor instead. +func (*InstantiateRequest) Descriptor() ([]byte, []int) { + return file_lcmservice_proto_rawDescGZIP(), []int{0} +} + +func (m *InstantiateRequest) GetData() isInstantiateRequest_Data { + if m != nil { + return m.Data + } + return nil +} + +func (x *InstantiateRequest) GetHostIp() string { + if x, ok := x.GetData().(*InstantiateRequest_HostIp); ok { + return x.HostIp + } + return "" +} + +func (x *InstantiateRequest) GetPackage() []byte { + if x, ok := x.GetData().(*InstantiateRequest_Package); ok { + return x.Package + } + return nil +} + +type isInstantiateRequest_Data interface { + isInstantiateRequest_Data() +} + +type InstantiateRequest_HostIp struct { + HostIp string `protobuf:"bytes,1,opt,name=hostIp,proto3,oneof"` +} + +type InstantiateRequest_Package struct { + Package []byte `protobuf:"bytes,2,opt,name=package,proto3,oneof"` +} + +func (*InstantiateRequest_HostIp) isInstantiateRequest_Data() {} + +func (*InstantiateRequest_Package) isInstantiateRequest_Data() {} + +type InstantiateResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + WorkloadId string `protobuf:"bytes,1,opt,name=workloadId,proto3" json:"workloadId,omitempty"` + Status string `protobuf:"bytes,2,opt,name=status,proto3" json:"status,omitempty"` +} + +func (x *InstantiateResponse) Reset() { + *x = InstantiateResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_lcmservice_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *InstantiateResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*InstantiateResponse) ProtoMessage() {} + +func (x *InstantiateResponse) ProtoReflect() protoreflect.Message { + mi := &file_lcmservice_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use InstantiateResponse.ProtoReflect.Descriptor instead. +func (*InstantiateResponse) Descriptor() ([]byte, []int) { + return file_lcmservice_proto_rawDescGZIP(), []int{1} +} + +func (x *InstantiateResponse) GetWorkloadId() string { + if x != nil { + return x.WorkloadId + } + return "" +} + +func (x *InstantiateResponse) GetStatus() string { + if x != nil { + return x.Status + } + return "" +} + +type TerminateRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + HostIp string `protobuf:"bytes,1,opt,name=hostIp,proto3" json:"hostIp,omitempty"` + WorkloadId string `protobuf:"bytes,2,opt,name=workloadId,proto3" json:"workloadId,omitempty"` +} + +func (x *TerminateRequest) Reset() { + *x = TerminateRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_lcmservice_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *TerminateRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TerminateRequest) ProtoMessage() {} + +func (x *TerminateRequest) ProtoReflect() protoreflect.Message { + mi := &file_lcmservice_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use TerminateRequest.ProtoReflect.Descriptor instead. +func (*TerminateRequest) Descriptor() ([]byte, []int) { + return file_lcmservice_proto_rawDescGZIP(), []int{2} +} + +func (x *TerminateRequest) GetHostIp() string { + if x != nil { + return x.HostIp + } + return "" +} + +func (x *TerminateRequest) GetWorkloadId() string { + if x != nil { + return x.WorkloadId + } + return "" +} + +type TerminateResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Status string `protobuf:"bytes,1,opt,name=status,proto3" json:"status,omitempty"` +} + +func (x *TerminateResponse) Reset() { + *x = TerminateResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_lcmservice_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *TerminateResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TerminateResponse) ProtoMessage() {} + +func (x *TerminateResponse) ProtoReflect() protoreflect.Message { + mi := &file_lcmservice_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use TerminateResponse.ProtoReflect.Descriptor instead. +func (*TerminateResponse) Descriptor() ([]byte, []int) { + return file_lcmservice_proto_rawDescGZIP(), []int{3} +} + +func (x *TerminateResponse) GetStatus() string { + if x != nil { + return x.Status + } + return "" +} + +type QueryRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + HostIp string `protobuf:"bytes,1,opt,name=hostIp,proto3" json:"hostIp,omitempty"` + WorkloadId string `protobuf:"bytes,2,opt,name=workloadId,proto3" json:"workloadId,omitempty"` +} + +func (x *QueryRequest) Reset() { + *x = QueryRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_lcmservice_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *QueryRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*QueryRequest) ProtoMessage() {} + +func (x *QueryRequest) ProtoReflect() protoreflect.Message { + mi := &file_lcmservice_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use QueryRequest.ProtoReflect.Descriptor instead. +func (*QueryRequest) Descriptor() ([]byte, []int) { + return file_lcmservice_proto_rawDescGZIP(), []int{4} +} + +func (x *QueryRequest) GetHostIp() string { + if x != nil { + return x.HostIp + } + return "" +} + +func (x *QueryRequest) GetWorkloadId() string { + if x != nil { + return x.WorkloadId + } + return "" +} + +type QueryResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Status string `protobuf:"bytes,1,opt,name=status,proto3" json:"status,omitempty"` +} + +func (x *QueryResponse) Reset() { + *x = QueryResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_lcmservice_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *QueryResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*QueryResponse) ProtoMessage() {} + +func (x *QueryResponse) ProtoReflect() protoreflect.Message { + mi := &file_lcmservice_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use QueryResponse.ProtoReflect.Descriptor instead. +func (*QueryResponse) Descriptor() ([]byte, []int) { + return file_lcmservice_proto_rawDescGZIP(), []int{5} +} + +func (x *QueryResponse) GetStatus() string { + if x != nil { + return x.Status + } + return "" +} + +var File_lcmservice_proto protoreflect.FileDescriptor + +var file_lcmservice_proto_rawDesc = []byte{ + 0x0a, 0x10, 0x6c, 0x63, 0x6d, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x12, 0x0a, 0x6c, 0x63, 0x6d, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x22, 0x52, + 0x0a, 0x12, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x69, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x06, 0x68, 0x6f, 0x73, 0x74, 0x49, 0x70, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x06, 0x68, 0x6f, 0x73, 0x74, 0x49, 0x70, 0x12, 0x1a, + 0x0a, 0x07, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x48, + 0x00, 0x52, 0x07, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x42, 0x06, 0x0a, 0x04, 0x64, 0x61, + 0x74, 0x61, 0x22, 0x4d, 0x0a, 0x13, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x69, 0x61, 0x74, + 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x77, 0x6f, 0x72, + 0x6b, 0x6c, 0x6f, 0x61, 0x64, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x77, + 0x6f, 0x72, 0x6b, 0x6c, 0x6f, 0x61, 0x64, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x22, 0x4a, 0x0a, 0x10, 0x54, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x74, 0x65, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x6f, 0x73, 0x74, 0x49, 0x70, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x68, 0x6f, 0x73, 0x74, 0x49, 0x70, 0x12, 0x1e, 0x0a, + 0x0a, 0x77, 0x6f, 0x72, 0x6b, 0x6c, 0x6f, 0x61, 0x64, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0a, 0x77, 0x6f, 0x72, 0x6b, 0x6c, 0x6f, 0x61, 0x64, 0x49, 0x64, 0x22, 0x2b, 0x0a, + 0x11, 0x54, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x46, 0x0a, 0x0c, 0x51, 0x75, + 0x65, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x6f, + 0x73, 0x74, 0x49, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x68, 0x6f, 0x73, 0x74, + 0x49, 0x70, 0x12, 0x1e, 0x0a, 0x0a, 0x77, 0x6f, 0x72, 0x6b, 0x6c, 0x6f, 0x61, 0x64, 0x49, 0x64, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x77, 0x6f, 0x72, 0x6b, 0x6c, 0x6f, 0x61, 0x64, + 0x49, 0x64, 0x22, 0x27, 0x0a, 0x0d, 0x51, 0x75, 0x65, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x32, 0xe8, 0x01, 0x0a, 0x06, + 0x41, 0x70, 0x70, 0x4c, 0x43, 0x4d, 0x12, 0x52, 0x0a, 0x0b, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, + 0x74, 0x69, 0x61, 0x74, 0x65, 0x12, 0x1e, 0x2e, 0x6c, 0x63, 0x6d, 0x73, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x69, 0x61, 0x74, 0x65, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x6c, 0x63, 0x6d, 0x73, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x69, 0x61, 0x74, 0x65, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x28, 0x01, 0x12, 0x4a, 0x0a, 0x09, 0x74, 0x65, + 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x74, 0x65, 0x12, 0x1c, 0x2e, 0x6c, 0x63, 0x6d, 0x73, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x2e, 0x54, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x74, 0x65, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x6c, 0x63, 0x6d, 0x73, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x2e, 0x54, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3e, 0x0a, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x12, + 0x18, 0x2e, 0x6c, 0x63, 0x6d, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x51, 0x75, 0x65, + 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x6c, 0x63, 0x6d, 0x73, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_lcmservice_proto_rawDescOnce sync.Once + file_lcmservice_proto_rawDescData = file_lcmservice_proto_rawDesc +) + +func file_lcmservice_proto_rawDescGZIP() []byte { + file_lcmservice_proto_rawDescOnce.Do(func() { + file_lcmservice_proto_rawDescData = protoimpl.X.CompressGZIP(file_lcmservice_proto_rawDescData) + }) + return file_lcmservice_proto_rawDescData +} + +var file_lcmservice_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_lcmservice_proto_goTypes = []interface{}{ + (*InstantiateRequest)(nil), // 0: lcmservice.InstantiateRequest + (*InstantiateResponse)(nil), // 1: lcmservice.InstantiateResponse + (*TerminateRequest)(nil), // 2: lcmservice.TerminateRequest + (*TerminateResponse)(nil), // 3: lcmservice.TerminateResponse + (*QueryRequest)(nil), // 4: lcmservice.QueryRequest + (*QueryResponse)(nil), // 5: lcmservice.QueryResponse +} +var file_lcmservice_proto_depIdxs = []int32{ + 0, // 0: lcmservice.AppLCM.instantiate:input_type -> lcmservice.InstantiateRequest + 2, // 1: lcmservice.AppLCM.terminate:input_type -> lcmservice.TerminateRequest + 4, // 2: lcmservice.AppLCM.query:input_type -> lcmservice.QueryRequest + 1, // 3: lcmservice.AppLCM.instantiate:output_type -> lcmservice.InstantiateResponse + 3, // 4: lcmservice.AppLCM.terminate:output_type -> lcmservice.TerminateResponse + 5, // 5: lcmservice.AppLCM.query:output_type -> lcmservice.QueryResponse + 3, // [3:6] is the sub-list for method output_type + 0, // [0:3] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_lcmservice_proto_init() } +func file_lcmservice_proto_init() { + if File_lcmservice_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_lcmservice_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*InstantiateRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_lcmservice_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*InstantiateResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_lcmservice_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TerminateRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_lcmservice_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TerminateResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_lcmservice_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*QueryRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_lcmservice_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*QueryResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + file_lcmservice_proto_msgTypes[0].OneofWrappers = []interface{}{ + (*InstantiateRequest_HostIp)(nil), + (*InstantiateRequest_Package)(nil), + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_lcmservice_proto_rawDesc, + NumEnums: 0, + NumMessages: 6, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_lcmservice_proto_goTypes, + DependencyIndexes: file_lcmservice_proto_depIdxs, + MessageInfos: file_lcmservice_proto_msgTypes, + }.Build() + File_lcmservice_proto = out.File + file_lcmservice_proto_rawDesc = nil + file_lcmservice_proto_goTypes = nil + file_lcmservice_proto_depIdxs = nil +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConnInterface + +// 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.SupportPackageIsVersion6 + +// AppLCMClient is the client API for AppLCM service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type AppLCMClient interface { + Instantiate(ctx context.Context, opts ...grpc.CallOption) (AppLCM_InstantiateClient, error) + Terminate(ctx context.Context, in *TerminateRequest, opts ...grpc.CallOption) (*TerminateResponse, error) + Query(ctx context.Context, in *QueryRequest, opts ...grpc.CallOption) (*QueryResponse, error) +} + +type appLCMClient struct { + cc grpc.ClientConnInterface +} + +func NewAppLCMClient(cc grpc.ClientConnInterface) AppLCMClient { + return &appLCMClient{cc} +} + +func (c *appLCMClient) Instantiate(ctx context.Context, opts ...grpc.CallOption) (AppLCM_InstantiateClient, error) { + stream, err := c.cc.NewStream(ctx, &_AppLCM_serviceDesc.Streams[0], "/lcmservice.AppLCM/instantiate", opts...) + if err != nil { + return nil, err + } + x := &appLCMInstantiateClient{stream} + return x, nil +} + +type AppLCM_InstantiateClient interface { + Send(*InstantiateRequest) error + CloseAndRecv() (*InstantiateResponse, error) + grpc.ClientStream +} + +type appLCMInstantiateClient struct { + grpc.ClientStream +} + +func (x *appLCMInstantiateClient) Send(m *InstantiateRequest) error { + return x.ClientStream.SendMsg(m) +} + +func (x *appLCMInstantiateClient) CloseAndRecv() (*InstantiateResponse, error) { + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + m := new(InstantiateResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *appLCMClient) Terminate(ctx context.Context, in *TerminateRequest, opts ...grpc.CallOption) (*TerminateResponse, error) { + out := new(TerminateResponse) + err := c.cc.Invoke(ctx, "/lcmservice.AppLCM/terminate", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *appLCMClient) Query(ctx context.Context, in *QueryRequest, opts ...grpc.CallOption) (*QueryResponse, error) { + out := new(QueryResponse) + err := c.cc.Invoke(ctx, "/lcmservice.AppLCM/query", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// AppLCMServer is the server API for AppLCM service. +type AppLCMServer interface { + Instantiate(AppLCM_InstantiateServer) error + Terminate(context.Context, *TerminateRequest) (*TerminateResponse, error) + Query(context.Context, *QueryRequest) (*QueryResponse, error) +} + +// UnimplementedAppLCMServer can be embedded to have forward compatible implementations. +type UnimplementedAppLCMServer struct { +} + +func (*UnimplementedAppLCMServer) Instantiate(AppLCM_InstantiateServer) error { + return status.Errorf(codes.Unimplemented, "method Instantiate not implemented") +} +func (*UnimplementedAppLCMServer) Terminate(context.Context, *TerminateRequest) (*TerminateResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Terminate not implemented") +} +func (*UnimplementedAppLCMServer) Query(context.Context, *QueryRequest) (*QueryResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Query not implemented") +} + +func RegisterAppLCMServer(s *grpc.Server, srv AppLCMServer) { + s.RegisterService(&_AppLCM_serviceDesc, srv) +} + +func _AppLCM_Instantiate_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(AppLCMServer).Instantiate(&appLCMInstantiateServer{stream}) +} + +type AppLCM_InstantiateServer interface { + SendAndClose(*InstantiateResponse) error + Recv() (*InstantiateRequest, error) + grpc.ServerStream +} + +type appLCMInstantiateServer struct { + grpc.ServerStream +} + +func (x *appLCMInstantiateServer) SendAndClose(m *InstantiateResponse) error { + return x.ServerStream.SendMsg(m) +} + +func (x *appLCMInstantiateServer) Recv() (*InstantiateRequest, error) { + m := new(InstantiateRequest) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func _AppLCM_Terminate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(TerminateRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AppLCMServer).Terminate(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/lcmservice.AppLCM/Terminate", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AppLCMServer).Terminate(ctx, req.(*TerminateRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _AppLCM_Query_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AppLCMServer).Query(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/lcmservice.AppLCM/Query", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AppLCMServer).Query(ctx, req.(*QueryRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _AppLCM_serviceDesc = grpc.ServiceDesc{ + ServiceName: "lcmservice.AppLCM", + HandlerType: (*AppLCMServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "terminate", + Handler: _AppLCM_Terminate_Handler, + }, + { + MethodName: "query", + Handler: _AppLCM_Query_Handler, + }, + }, + Streams: []grpc.StreamDesc{ + { + StreamName: "instantiate", + Handler: _AppLCM_Instantiate_Handler, + ClientStreams: true, + }, + }, + Metadata: "lcmservice.proto", +} diff --git a/mecm/mepm/applcm/broker/internal/lcmservice/lcmservice.proto b/mecm/mepm/applcm/broker/internal/lcmservice/lcmservice.proto new file mode 100644 index 0000000..bf8c39b --- /dev/null +++ b/mecm/mepm/applcm/broker/internal/lcmservice/lcmservice.proto @@ -0,0 +1,39 @@ +syntax = "proto3"; + +package lcmservice; + +message InstantiateRequest { + oneof data { + string hostIp = 1; + bytes package = 2; + }; +} + +message InstantiateResponse { + string workloadId = 1; + string status = 2; +} + +message TerminateRequest { + string hostIp = 1; + string workloadId = 2; +} + +message TerminateResponse { + string status = 1; +} + +message QueryRequest { + string hostIp = 1; + string workloadId = 2; +} + +message QueryResponse { + string status = 1; +} + +service AppLCM { + rpc instantiate (stream InstantiateRequest) returns (InstantiateResponse) {} + rpc terminate (TerminateRequest) returns (TerminateResponse) {} + rpc query (QueryRequest) returns (QueryResponse) {} +} \ No newline at end of file diff --git a/mecm/mepm/applcm/broker/pkg/plugin/grpcclient.go b/mecm/mepm/applcm/broker/pkg/plugin/grpcclient.go new file mode 100644 index 0000000..27402ed --- /dev/null +++ b/mecm/mepm/applcm/broker/pkg/plugin/grpcclient.go @@ -0,0 +1,175 @@ +package plugin + +import ( + "broker/internal/lcmservice" + "golang.org/x/net/context" + "google.golang.org/grpc" + "google.golang.org/grpc/credentials" + _ "google.golang.org/grpc/encoding/gzip" + "io" + "log" + "os" +) + +// ClientGRPC provides the implementation of a file +// uploader that streams chunks via protobuf-encoded +// messages. +type ClientGRPC struct { + conn *grpc.ClientConn + client lcmservice.AppLCMClient + chunkSize int +} + +type ClientGRPCConfig struct { + Address string + ChunkSize int + RootCertificate string +} + +func NewClientGRPC(cfg ClientGRPCConfig) (c ClientGRPC, err error) { + + logger := log.New(os.Stdout, "broker ", log.LstdFlags|log.Lshortfile) + + var ( + grpcOpts = []grpc.DialOption{} + grpcCreds credentials.TransportCredentials + ) + + if cfg.Address == "" { + logger.Fatalf("address must be specified: ", err) + } + + if cfg.RootCertificate != "" { + grpcCreds, err = credentials.NewClientTLSFromFile(cfg.RootCertificate, "localhost") + if err != nil { + logger.Fatalf("failed to create grpc tls client via root-cert: ", err) + } + + grpcOpts = append(grpcOpts, grpc.WithTransportCredentials(grpcCreds)) + } else { + grpcOpts = append(grpcOpts, grpc.WithInsecure()) + } + + switch { + case cfg.ChunkSize == 0: + logger.Fatalf("ChunkSize must be specified") + case cfg.ChunkSize > (1 << 22): + logger.Fatalf("ChunkSize must be < than 4MB") + default: + c.chunkSize = cfg.ChunkSize + } + + c.conn, err = grpc.Dial(cfg.Address, grpcOpts...) + if err != nil { + logger.Fatalf("failed to start grpc connection with address: ", cfg.Address) + } + + c.client = lcmservice.NewAppLCMClient(c.conn) + return +} + +func (c *ClientGRPC) Instantiate(ctx context.Context, f string, hostIP string) (workloadId string, status string) { + var ( + writing = true + buf []byte + n int + file *os.File + ) + log.Printf("hostIP: ", hostIP) + log.Printf("deployArtifact: ", f) + logger := log.New(os.Stdout, "broker ", log.LstdFlags|log.Lshortfile) + + // Get a file handle for the file we + // want to upload + file, err := os.Open(f) + if err != nil { + logger.Fatalf("failed to open file: ", err.Error()) + } + defer file.Close() + + // Open a stream-based connection with the + // gRPC server + stream, err := c.client.Instantiate(ctx) + + if err != nil { + logger.Fatalf("failed to create upload stream for file: ", err) + } + defer stream.CloseSend() + + //send metadata information + req := &lcmservice.InstantiateRequest{ + + Data: &lcmservice.InstantiateRequest_HostIp{ + HostIp: hostIP, + }, + } + + err = stream.Send(req) + if err != nil { + logger.Fatalf("failed to send metadata information: ", f) + } + + // Allocate a buffer with `chunkSize` as the capacity + // and length (making a 0 array of the size of `chunkSize`) + buf = make([]byte, c.chunkSize) + for writing { + // put as many bytes as `chunkSize` into the + // buf array. + n, err = file.Read(buf) + if err != nil { + // ... if `eof` --> `writing=false`... + if err == io.EOF { + writing = false + err = nil + continue + } + logger.Fatalf("errored while copying from file to buf: ", err) + } + + req := &lcmservice.InstantiateRequest { + Data: &lcmservice.InstantiateRequest_Package { + Package: buf[:n], + }, + } + + err = stream.Send(req) + + if err != nil { + logger.Fatalf("failed to send chunk via stream: ", err) + } + } + + res, err := stream.CloseAndRecv() + if err != nil { + logger.Fatalf("failed to receive upstream status response: ", err) + } + log.Printf("response", res) + return res.WorkloadId, res.Status +} + +func (c *ClientGRPC) Query(ctx context.Context, hostIP string, workloadId string) (status string) { + + req := &lcmservice.QueryRequest{ + HostIp: hostIP, + WorkloadId: workloadId, + } + resp, _ := c.client.Query(ctx, req) + return resp.Status +} + +func (c *ClientGRPC) Terminate(ctx context.Context, hostIP string, workloadId string) (status string) { + + req := &lcmservice.TerminateRequest{ + HostIp: hostIP, + WorkloadId: workloadId, + } + resp, _ := c.client.Terminate(ctx, req) + return resp.Status +} + +func (c *ClientGRPC) Close() { + if c.conn != nil { + c.conn.Close() + } +} + diff --git a/mecm/mepm/applcm/broker/version/version.go b/mecm/mepm/applcm/broker/version/version.go new file mode 100644 index 0000000..e3e130b --- /dev/null +++ b/mecm/mepm/applcm/broker/version/version.go @@ -0,0 +1,5 @@ +package version + +var ( + Version = "0.0.1" +)