-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* VMWare FCD skeleton code. * Wrap errors and use single context
- Loading branch information
1 parent
e6ca11f
commit 54c6c56
Showing
4 changed files
with
118 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
package vmware | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/pkg/errors" | ||
"github.com/vmware/govmomi/cns" | ||
"github.com/vmware/govmomi/vim25" | ||
"github.com/vmware/govmomi/vim25/methods" | ||
"github.com/vmware/govmomi/vim25/soap" | ||
"github.com/vmware/govmomi/vim25/types" | ||
"github.com/vmware/govmomi/vslm" | ||
|
||
"github.com/kanisterio/kanister/pkg/blockstorage" | ||
) | ||
|
||
var _ blockstorage.Provider = (*fcdProvider)(nil) | ||
|
||
type fcdProvider struct { | ||
gom *vslm.GlobalObjectManager | ||
cns *cns.Client | ||
} | ||
|
||
// NewProvider creates new VMWare FCD provider with the config. | ||
// URL taken from config helps to establish connection. | ||
func NewProvider(config map[string]string) (blockstorage.Provider, error) { | ||
u, err := soap.ParseURL(config["url"]) | ||
if err != nil { | ||
return nil, errors.Wrap(err, "Failed to get config") | ||
} | ||
soapCli := soap.NewClient(u, true) | ||
ctx := context.Background() | ||
cli, err := vim25.NewClient(ctx, soapCli) | ||
req := types.Login{ | ||
This: *cli.ServiceContent.SessionManager, | ||
} | ||
req.UserName = u.User.Username() | ||
req.Password, _ = u.User.Password() | ||
_, err = methods.Login(ctx, cli, &req) | ||
if err != nil { | ||
return nil, errors.Wrap(err, "Failed to login") | ||
} | ||
cnsCli, err := cns.NewClient(ctx, cli) | ||
if err != nil { | ||
return nil, errors.Wrap(err, "Failed to create CNS client") | ||
} | ||
vslmCli, err := vslm.NewClient(ctx, cli) | ||
if err != nil { | ||
return nil, errors.Wrap(err, "Failed to create VSLM client") | ||
} | ||
gom := vslm.NewGlobalObjectManager(vslmCli) | ||
return &fcdProvider{ | ||
cns: cnsCli, | ||
gom: gom, | ||
}, nil | ||
} | ||
|
||
func (p *fcdProvider) Type() blockstorage.Type { | ||
return blockstorage.TypeFCD | ||
} | ||
|
||
func (p *fcdProvider) VolumeCreate(ctx context.Context, volume blockstorage.Volume) (*blockstorage.Volume, error) { | ||
return nil, errors.New("Not implemented") | ||
} | ||
|
||
func (p *fcdProvider) VolumeCreateFromSnapshot(ctx context.Context, snapshot blockstorage.Snapshot, tags map[string]string) (*blockstorage.Volume, error) { | ||
return nil, errors.New("Not implemented") | ||
} | ||
|
||
func (p *fcdProvider) VolumeDelete(ctx context.Context, volume *blockstorage.Volume) error { | ||
return errors.New("Not implemented") | ||
} | ||
|
||
func (p *fcdProvider) VolumeGet(ctx context.Context, id string, zone string) (*blockstorage.Volume, error) { | ||
return nil, errors.New("Not implemented") | ||
} | ||
|
||
func (p *fcdProvider) SnapshotCopy(ctx context.Context, from blockstorage.Snapshot, to blockstorage.Snapshot) (*blockstorage.Snapshot, error) { | ||
return nil, errors.New("Not implemented") | ||
} | ||
|
||
func (p *fcdProvider) SnapshotCreate(ctx context.Context, volume blockstorage.Volume, tags map[string]string) (*blockstorage.Snapshot, error) { | ||
return nil, errors.New("Not implemented") | ||
} | ||
|
||
func (p *fcdProvider) SnapshotCreateWaitForCompletion(ctx context.Context, snapshot *blockstorage.Snapshot) error { | ||
return errors.New("Not implemented") | ||
} | ||
|
||
func (p *fcdProvider) SnapshotDelete(ctx context.Context, snapshot *blockstorage.Snapshot) error { | ||
return errors.New("Not implemented") | ||
} | ||
|
||
func (p *fcdProvider) SnapshotGet(ctx context.Context, id string) (*blockstorage.Snapshot, error) { | ||
return nil, errors.New("Not implemented") | ||
} | ||
|
||
func (p *fcdProvider) SetTags(ctx context.Context, resource interface{}, tags map[string]string) error { | ||
return errors.New("Not implemented") | ||
} | ||
|
||
func (p *fcdProvider) VolumesList(ctx context.Context, tags map[string]string, zone string) ([]*blockstorage.Volume, error) { | ||
return nil, errors.New("Not implemented") | ||
} | ||
|
||
func (p *fcdProvider) SnapshotsList(ctx context.Context, tags map[string]string) ([]*blockstorage.Snapshot, error) { | ||
return nil, errors.New("Not implemented") | ||
} |