Skip to content

Commit

Permalink
[backend] AIP Get/List/Create/Update/Delete rename
Browse files Browse the repository at this point in the history
Resource-oriented design https://google.aip.dev/121

for word in Get List Create Update Delete; do
  for i in AioController NullDebug NVMfRemoteController; do
    sed -i "s/${i}${word}/${word}${i}/g" v1alpha1/backend_*.proto ;
  done;
done

See opiproject/opi-api#217

Signed-off-by: Boris Glimcher <[email protected]>
  • Loading branch information
glimchb committed Dec 7, 2022
1 parent a8c4c84 commit 430e5d8
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 103 deletions.
18 changes: 12 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,21 +84,27 @@ docker run --network=host --rm -it namely/grpc-cli call --json_input --json_outp
and netwok-facing APIs:

```bash
docker run --network=host --rm -it namely/grpc-cli call --json_input --json_output 10.10.10.1:50051 NVMfRemoteControllerConnect "{ctrl : {id: '12', traddr:'11.11.11.2', subnqn:'nqn.2016-06.com.opi.spdk.target0', trsvcid:'4444', trtype:'NVME_TRANSPORT_TCP', adrfam:'NVMF_ADRFAM_IPV4', hostnqn:'nqn.2014-08.org.nvmexpress:uuid:feb98abe-d51f-40c8-b348-2753f3571d3c'}}"
docker run --network=host --rm -it namely/grpc-cli call --json_input --json_output 10.10.10.1:50051 CreateNVMfRemoteController "{ctrl : {id: { value : 'OpiNvme12' }, traddr:'11.11.11.2', subnqn:'nqn.2016-06.com.opi.spdk.target0', trsvcid:'4444', trtype:'NVME_TRANSPORT_TCP', adrfam:'NVMF_ADRFAM_IPV4', hostnqn:'nqn.2014-08.org.nvmexpress:uuid:feb98abe-d51f-40c8-b348-2753f3571d3c'}}"
connecting to 10.10.10.1:50051
{}
Rpc succeeded with OK status

docker run --network=host --rm -it namely/grpc-cli call --json_input --json_output 10.10.10.1:50051 NVMfRemoteControllerGet "{'id': '12'}"
docker run --network=host --rm -it namely/grpc-cli call --json_input --json_output 10.10.10.1:50051 GetNVMfRemoteController "{id: {value : 'OpiNvme12' }}"
connecting to 10.10.10.1:50051
{
"ctrl": {
"subnqn": "OpiNvme12"
}
"id": {
"value": "OpiNvme12"
},
"trtype": "NVME_TRANSPORT_TCP",
"adrfam": "NVMF_ADRFAM_IPV4",
"traddr": "11.11.11.2",
"trsvcid": "4444",
"subnqn": "nqn.2016-06.io.spdk:cnode1",
"hostnqn": "nqn.2014-08.org.nvmexpress:uuid:feb98abe-d51f-40c8-b348-2753f3571d3c"
}
Rpc succeeded with OK status

docker run --network=host --rm -it namely/grpc-cli call --json_input --json_output 10.10.10.1:50051 NVMfRemoteControllerDisconnect "{'id': '12'}"
docker run --network=host --rm -it namely/grpc-cli call --json_input --json_output 10.10.10.1:50051 DeleteNVMfRemoteController "{id: {value : 'OpiNvme12' }}"
connecting to 10.10.10.1:50051
{}
Rpc succeeded with OK status
Expand Down
36 changes: 18 additions & 18 deletions client/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ func doBackend(ctx context.Context, conn grpc.ClientConnInterface) {
if err != nil {
log.Fatalf("could not find SPDK IP address")
}
rr0, err := c4.NVMfRemoteControllerConnect(ctx, &pb.NVMfRemoteControllerConnectRequest{
rr0, err := c4.CreateNVMfRemoteController(ctx, &pb.CreateNVMfRemoteControllerRequest{
Ctrl: &pb.NVMfRemoteController{
Id: 8,
Id: &pc.ObjectKey{Value: "OpiNvme8"},
Trtype: pb.NvmeTransportType_NVME_TRANSPORT_TCP,
Adrfam: pb.NvmeAddressFamily_NVMF_ADRFAM_IPV4,
Traddr: addr[0].String(),
Expand All @@ -31,27 +31,27 @@ func doBackend(ctx context.Context, conn grpc.ClientConnInterface) {
log.Fatalf("could not connect to Remote NVMf controller: %v", err)
}
log.Printf("Connected: %v", rr0)
rr2, err := c4.NVMfRemoteControllerReset(ctx, &pb.NVMfRemoteControllerResetRequest{Id: 8})
rr2, err := c4.NVMfRemoteControllerReset(ctx, &pb.NVMfRemoteControllerResetRequest{Id: &pc.ObjectKey{Value: "OpiNvme8"}})
if err != nil {
log.Fatalf("could not reset Remote NVMf controller: %v", err)
}
log.Printf("Reset: %v", rr2)
rr3, err := c4.NVMfRemoteControllerList(ctx, &pb.NVMfRemoteControllerListRequest{Id: 8})
rr3, err := c4.ListNVMfRemoteController(ctx, &pb.ListNVMfRemoteControllerRequest{})
if err != nil {
log.Fatalf("could not list Remote NVMf controllerd: %v", err)
}
log.Printf("List: %v", rr3)
rr4, err := c4.NVMfRemoteControllerGet(ctx, &pb.NVMfRemoteControllerGetRequest{Id: 8})
rr4, err := c4.GetNVMfRemoteController(ctx, &pb.GetNVMfRemoteControllerRequest{Id: &pc.ObjectKey{Value: "OpiNvme8"}})
if err != nil {
log.Fatalf("could not get Remote NVMf controller: %v", err)
}
log.Printf("Got: %v", rr4)
rr5, err := c4.NVMfRemoteControllerStats(ctx, &pb.NVMfRemoteControllerStatsRequest{Id: 8})
rr5, err := c4.NVMfRemoteControllerStats(ctx, &pb.NVMfRemoteControllerStatsRequest{Id: &pc.ObjectKey{Value: "OpiNvme8"}})
if err != nil {
log.Fatalf("could not stats from Remote NVMf controller: %v", err)
}
log.Printf("Stats: %v", rr5)
rr1, err := c4.NVMfRemoteControllerDisconnect(ctx, &pb.NVMfRemoteControllerDisconnectRequest{Id: 8})
rr1, err := c4.DeleteNVMfRemoteController(ctx, &pb.DeleteNVMfRemoteControllerRequest{Id: &pc.ObjectKey{Value: "OpiNvme8"}})
if err != nil {
log.Fatalf("could not disconnect from Remote NVMf controller: %v", err)
}
Expand All @@ -60,22 +60,22 @@ func doBackend(ctx context.Context, conn grpc.ClientConnInterface) {
// NullDebug
c1 := pb.NewNullDebugServiceClient(conn)
log.Printf("Testing NewNullDebugServiceClient")
rs1, err := c1.NullDebugCreate(ctx, &pb.NullDebugCreateRequest{Device: &pb.NullDebug{Handle: &pc.ObjectKey{Value: "OpiNull9"}}})
rs1, err := c1.CreateNullDebug(ctx, &pb.CreateNullDebugRequest{Device: &pb.NullDebug{Handle: &pc.ObjectKey{Value: "OpiNull9"}}})
if err != nil {
log.Fatalf("could not create NULL device: %v", err)
}
log.Printf("Added: %v", rs1)
rs3, err := c1.NullDebugUpdate(ctx, &pb.NullDebugUpdateRequest{Device: &pb.NullDebug{Handle: &pc.ObjectKey{Value: "OpiNull9"}}})
rs3, err := c1.UpdateNullDebug(ctx, &pb.UpdateNullDebugRequest{Device: &pb.NullDebug{Handle: &pc.ObjectKey{Value: "OpiNull9"}}})
if err != nil {
log.Fatalf("could not update NULL device: %v", err)
}
log.Printf("Updated: %v", rs3)
rs4, err := c1.NullDebugList(ctx, &pb.NullDebugListRequest{})
rs4, err := c1.ListNullDebug(ctx, &pb.ListNullDebugRequest{})
if err != nil {
log.Fatalf("could not list NULL device: %v", err)
}
log.Printf("Listed: %v", rs4)
rs5, err := c1.NullDebugGet(ctx, &pb.NullDebugGetRequest{Handle: &pc.ObjectKey{Value: "OpiNull9"}})
rs5, err := c1.GetNullDebug(ctx, &pb.GetNullDebugRequest{Handle: &pc.ObjectKey{Value: "OpiNull9"}})
if err != nil {
log.Fatalf("could not get NULL device: %v", err)
}
Expand All @@ -85,7 +85,7 @@ func doBackend(ctx context.Context, conn grpc.ClientConnInterface) {
log.Fatalf("could not stats NULL device: %v", err)
}
log.Printf("Stats: %s", rs6.Stats)
rs2, err := c1.NullDebugDelete(ctx, &pb.NullDebugDeleteRequest{Handle: &pc.ObjectKey{Value: "OpiNull9"}})
rs2, err := c1.DeleteNullDebug(ctx, &pb.DeleteNullDebugRequest{Handle: &pc.ObjectKey{Value: "OpiNull9"}})
if err != nil {
log.Fatalf("could not delete NULL device: %v", err)
}
Expand All @@ -94,32 +94,32 @@ func doBackend(ctx context.Context, conn grpc.ClientConnInterface) {
// Aio
c2 := pb.NewAioControllerServiceClient(conn)
log.Printf("Testing NewAioControllerServiceClient")
ra1, err := c2.AioControllerCreate(ctx, &pb.AioControllerCreateRequest{Device: &pb.AioController{Handle: &pc.ObjectKey{Value: "OpiAio4"}, Filename: "/tmp/aio_bdev_file"}})
ra1, err := c2.CreateAioController(ctx, &pb.CreateAioControllerRequest{Device: &pb.AioController{Handle: &pc.ObjectKey{Value: "OpiAio4"}, Filename: "/tmp/aio_bdev_file"}})
if err != nil {
log.Fatalf("could not create Aio device: %v", err)
}
log.Printf("Added: %v", ra1)
ra3, err := c2.AioControllerUpdate(ctx, &pb.AioControllerUpdateRequest{Device: &pb.AioController{Handle: &pc.ObjectKey{Value: "OpiAio4"}, Filename: "/tmp/aio_bdev_file"}})
ra3, err := c2.UpdateAioController(ctx, &pb.UpdateAioControllerRequest{Device: &pb.AioController{Handle: &pc.ObjectKey{Value: "OpiAio4"}, Filename: "/tmp/aio_bdev_file"}})
if err != nil {
log.Fatalf("could not update Aio device: %v", err)
}
log.Printf("Updated: %v", ra3)
ra4, err := c2.AioControllerGetList(ctx, &pb.AioControllerGetListRequest{})
ra4, err := c2.ListAioController(ctx, &pb.ListAioControllerRequest{})
if err != nil {
log.Fatalf("could not list Aio device: %v", err)
}
log.Printf("Listed: %v", ra4)
ra5, err := c2.AioControllerGet(ctx, &pb.AioControllerGetRequest{Handle: &pc.ObjectKey{Value: "OpiAio4"}})
ra5, err := c2.GetAioController(ctx, &pb.GetAioControllerRequest{Handle: &pc.ObjectKey{Value: "OpiAio4"}})
if err != nil {
log.Fatalf("could not get Aio device: %v", err)
}
log.Printf("Got: %s", ra5.Handle.Value)
ra6, err := c2.AioControllerGetStats(ctx, &pb.AioControllerGetStatsRequest{Handle: &pc.ObjectKey{Value: "OpiAio4"}})
ra6, err := c2.AioControllerStats(ctx, &pb.AioControllerStatsRequest{Handle: &pc.ObjectKey{Value: "OpiAio4"}})
if err != nil {
log.Fatalf("could not stats Aio device: %v", err)
}
log.Printf("Stats: %s", ra6.Stats)
ra2, err := c2.AioControllerDelete(ctx, &pb.AioControllerDeleteRequest{Handle: &pc.ObjectKey{Value: "OpiAio4"}})
ra2, err := c2.DeleteAioController(ctx, &pb.DeleteAioControllerRequest{Handle: &pc.ObjectKey{Value: "OpiAio4"}})
if err != nil {
log.Fatalf("could not delete Aio device: %v", err)
}
Expand Down
10 changes: 5 additions & 5 deletions client/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ module opi.storage.v1
go 1.19

require (
github.com/opiproject/opi-api v0.0.0-20221129180238-b10361a9c119
github.com/opiproject/opi-api v0.0.0-20221207164013-fd93b840b575
google.golang.org/grpc v1.51.0
)

require (
github.com/golang/protobuf v1.5.2 // indirect
golang.org/x/net v0.1.0 // indirect
golang.org/x/sys v0.1.0 // indirect
golang.org/x/text v0.4.0 // indirect
google.golang.org/genproto v0.0.0-20221027153422-115e99e71e1c // indirect
golang.org/x/net v0.4.0 // indirect
golang.org/x/sys v0.3.0 // indirect
golang.org/x/text v0.5.0 // indirect
google.golang.org/genproto v0.0.0-20221206210731-b1a01be3a5f6 // indirect
google.golang.org/protobuf v1.28.1 // indirect
)
22 changes: 10 additions & 12 deletions client/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,18 @@ github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
github.com/opiproject/opi-api v0.0.0-20221121200811-5d2289de810a h1:dFFDDQez4aCsKEkvEnQ+yFnMu5/yZ/VWBxbIRmAvgd4=
github.com/opiproject/opi-api v0.0.0-20221121200811-5d2289de810a/go.mod h1:92pv4ulvvPMuxCJ9ND3aYbmBfEMLx0VCjpkiR7ZTqPY=
github.com/opiproject/opi-api v0.0.0-20221129180238-b10361a9c119 h1:exwxNwGuwQtA9IRs2I/Eh22IWeeReAf3uzExgblLytY=
github.com/opiproject/opi-api v0.0.0-20221129180238-b10361a9c119/go.mod h1:92pv4ulvvPMuxCJ9ND3aYbmBfEMLx0VCjpkiR7ZTqPY=
golang.org/x/net v0.1.0 h1:hZ/3BUoy5aId7sCpA/Tc5lt8DkFgdVS2onTpJsZ/fl0=
golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco=
golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U=
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
github.com/opiproject/opi-api v0.0.0-20221207164013-fd93b840b575 h1:qUuLJp4bRKxC21El2bg6rhlBLjD/HBta7ALSZLD2pMY=
github.com/opiproject/opi-api v0.0.0-20221207164013-fd93b840b575/go.mod h1:92pv4ulvvPMuxCJ9ND3aYbmBfEMLx0VCjpkiR7ZTqPY=
golang.org/x/net v0.4.0 h1:Q5QPcMlvfxFTAPV0+07Xz/MpK9NTXu2VDUuy0FeMfaU=
golang.org/x/net v0.4.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE=
golang.org/x/sys v0.3.0 h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ=
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.5.0 h1:OLmvp0KP+FVG99Ct/qFiL/Fhk4zp4QQnZ7b2U+5piUM=
golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
google.golang.org/genproto v0.0.0-20221027153422-115e99e71e1c h1:QgY/XxIAIeccR+Ca/rDdKubLIU9rcJ3xfy1DC/Wd2Oo=
google.golang.org/genproto v0.0.0-20221027153422-115e99e71e1c/go.mod h1:CGI5F/G+E5bKwmfYo09AXuVN4dD894kIKUFmVbP2/Fo=
google.golang.org/genproto v0.0.0-20221206210731-b1a01be3a5f6 h1:AGXp12e/9rItf6/4QymU7WsAUwCf+ICW75cuR91nJIc=
google.golang.org/genproto v0.0.0-20221206210731-b1a01be3a5f6/go.mod h1:1dOng4TWOomJrDGhpXjfCD35wQC6jnC7HpRmOFRqEV0=
google.golang.org/grpc v1.51.0 h1:E1eGv1FTqoLIdnBCZufiSHgKjlqG6fKFf6pPWtMTh8U=
google.golang.org/grpc v1.51.0/go.mod h1:wgNDFcnuBGmxLKI/qn4T+m5BtEBYXJPvibbUPsAIPww=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
Expand Down
Loading

0 comments on commit 430e5d8

Please sign in to comment.