diff --git a/go.sum b/go.sum index 076a1b4..ad861da 100644 --- a/go.sum +++ b/go.sum @@ -7,17 +7,11 @@ github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaS 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/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/lithammer/fuzzysearch v1.1.5 h1:Ag7aKU08wp0R9QCfF4GoGST9HbmAIeLP7xwMrOBEp1c= github.com/lithammer/fuzzysearch v1.1.5/go.mod h1:1R1LRNk7yKid1BaQkmuLQaHruxcC4HmAH30Dh61Ih1Q= -github.com/opiproject/opi-api v0.0.0-20221220003855-844775ae0e14 h1:ZjzswIdvCpehv/QI86y5fdAf3YLrYEZGz13butIcYS0= -github.com/opiproject/opi-api v0.0.0-20221220003855-844775ae0e14/go.mod h1:92pv4ulvvPMuxCJ9ND3aYbmBfEMLx0VCjpkiR7ZTqPY= -github.com/opiproject/opi-api v0.0.0-20230105195424-f410dd418885 h1:hjPymbqTQ68BHMpjZmEhpQer0R3hB+4XcjLw6rwzmyU= -github.com/opiproject/opi-api v0.0.0-20230105195424-f410dd418885/go.mod h1:92pv4ulvvPMuxCJ9ND3aYbmBfEMLx0VCjpkiR7ZTqPY= -github.com/opiproject/opi-api v0.0.0-20230109175516-18c8c629ed6f h1:14E/5ukEHq6zGGjZE0qkI8vE+PucGT3t5vR6X6/wK5I= -github.com/opiproject/opi-api v0.0.0-20230109175516-18c8c629ed6f/go.mod h1:92pv4ulvvPMuxCJ9ND3aYbmBfEMLx0VCjpkiR7ZTqPY= github.com/opiproject/opi-api v0.0.0-20230111150933-e4b3480e8ee9 h1:Y/0Ku5yIfnLEnLa9jzYCK/7l85CHQVefs0PnaXFX+v0= github.com/opiproject/opi-api v0.0.0-20230111150933-e4b3480e8ee9/go.mod h1:92pv4ulvvPMuxCJ9ND3aYbmBfEMLx0VCjpkiR7ZTqPY= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -38,13 +32,8 @@ golang.org/x/text v0.6.0 h1:3XmdazWV+ubf7QgHSTWeykHOci5oeekaGJBLkrkaw4k= golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 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-20220930163606-c98284e70a91 h1:Ezh2cpcnP5Rq60sLensUsFnxh7P6513NLvNtCm9iyJ4= -google.golang.org/genproto v0.0.0-20220930163606-c98284e70a91/go.mod h1:3526vdqwhZAwq4wsRUaVG555sVgsNmIjRtO7t/JH29U= google.golang.org/genproto v0.0.0-20221118155620-16455021b5e6 h1:a2S6M0+660BgMNl++4JPlcAO/CjkqYItDEZwkoDQK7c= google.golang.org/genproto v0.0.0-20221118155620-16455021b5e6/go.mod h1:rZS5c/ZVYMaOGBfO68GWtjOw/eLaZM1X6iVtgjZ+EWg= -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/grpc v1.52.0 h1:kd48UiU7EHsV4rnLyOJRuP/Il/UHE7gdDAQ+SZI7nZk= google.golang.org/grpc v1.52.0/go.mod h1:pu6fVzoFb+NBYNAvQL08ic+lvB2IojljRYuun5vorUY= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= diff --git a/goopicsi.go b/goopicsi.go index c6f2287..e1c6fe9 100644 --- a/goopicsi.go +++ b/goopicsi.go @@ -7,7 +7,6 @@ package goopicsi import ( "context" "errors" - "flag" "fmt" "log" "strings" @@ -33,77 +32,6 @@ type NVMeConnection struct { traddr string } -// ConnectToRemoteAndExpose connects to the remote storage over NVMe/TCP and exposes it as a local NVMe/PCIe device -func ConnectToRemoteAndExpose(addr string) error { - flag.Parse() - // Set up a connection to the server. - conn, err := grpc.Dial(addr, grpc.WithTransportCredentials(insecure.NewCredentials())) - if err != nil { - log.Printf("did not connect: %v", err) - return err - } - defer func(conn *grpc.ClientConn) { - err := conn.Close() - if err != nil { - log.Fatalf("Failed to close connection: %v", err) - } - }(conn) - - // Contact the server and print out its response. - ctx, cancel := context.WithTimeout(context.Background(), time.Second) - defer cancel() - - // Connect to remote NVMe target from xPU - c4 := pb.NewNVMfRemoteControllerServiceClient(conn) - rr0, err := c4.CreateNVMfRemoteController(ctx, &pb.CreateNVMfRemoteControllerRequest{NvMfRemoteController: &pb.NVMfRemoteController{ - Id: &pbc.ObjectKey{Value: "nvme-remote-connect"}}}) - if err != nil { - log.Printf("could not connect to Remote NVMf controller: %v", err) - return err - } - log.Printf("Connected: %v", rr0) - - // Expose emulated NVMe device to the Host (Step 1: Subsystem) - c1 := pb.NewFrontendNvmeServiceClient(conn) - rs1, err := c1.CreateNVMeSubsystem(ctx, &pb.CreateNVMeSubsystemRequest{ - NvMeSubsystem: &pb.NVMeSubsystem{ - Spec: &pb.NVMeSubsystemSpec{ - Id: &pbc.ObjectKey{Value: "controller-test-ss"}, - Nqn: "nqn.2022-09.io.spdk:opi2"}}}) - if err != nil { - log.Printf("could not create NVMe subsystem: %v", err) - return err - } - log.Printf("Added: %v", rs1) - // Step2: NVMeController - rc1, err := c1.CreateNVMeController(ctx, &pb.CreateNVMeControllerRequest{ - NvMeController: &pb.NVMeController{ - Spec: &pb.NVMeControllerSpec{ - Id: &pbc.ObjectKey{Value: "controller-test"}, - SubsystemId: &pbc.ObjectKey{Value: "controller-test-ss"}, - NvmeControllerId: 13}}}) - if err != nil { - log.Printf("could not create NVMe subsystem: %v", err) - return err - } - log.Printf("Added: %v", rc1) - - // NVMeNamespace - rn1, err := c1.CreateNVMeNamespace(ctx, &pb.CreateNVMeNamespaceRequest{ - NvMeNamespace: &pb.NVMeNamespace{ - Spec: &pb.NVMeNamespaceSpec{ - Id: &pbc.ObjectKey{Value: "namespace-test"}, - SubsystemId: &pbc.ObjectKey{Value: "namespace-test-ss"}, - VolumeId: &pbc.ObjectKey{Value: "Malloc1"}, - HostNsid: 123}}}) - if err != nil { - log.Printf("could not create NVMe subsystem: %v", err) - return err - } - log.Printf("Added: %v", rn1) - return nil -} - // NVMeControllerConnect Connects to remote NVMf controller func NVMeControllerConnect(id string, trAddr string, subnqn string, trSvcID int64, hostnqn string) error { if conn == nil {