From f7ab4d3ff7d9bbc998b1399eecade179e72ab9ea Mon Sep 17 00:00:00 2001 From: jack ma <625198232@qq.com> Date: Thu, 14 Mar 2019 10:09:20 +0800 Subject: [PATCH] Implement ExtendVolume, CreateSnapshot, PullSnapshot, DeleteSnapshot functions --- .../drivers/huawei/fusionstorage/dsware.go | 87 +++++++++++++++++++ .../drivers/huawei/fusionstorage/fsclient.go | 32 ++++++- 2 files changed, 118 insertions(+), 1 deletion(-) diff --git a/contrib/drivers/huawei/fusionstorage/dsware.go b/contrib/drivers/huawei/fusionstorage/dsware.go index 005787bc3..0578edf56 100644 --- a/contrib/drivers/huawei/fusionstorage/dsware.go +++ b/contrib/drivers/huawei/fusionstorage/dsware.go @@ -337,3 +337,90 @@ func (d *Driver) TerminateConnection(opt *pb.DeleteAttachmentOpts) error { return nil } + +func (d *Driver) PullVolume(volIdentifier string) (*VolumeSpec, error) { + // Not used , do nothing + return nil, nil +} + +func (d *Driver) ExtendVolume(opt *pb.ExtendVolumeOpts) (*VolumeSpec, error) { + err := d.cli.extendVolume(EncodeName(opt.GetId()), opt.GetSize()< 0 { @@ -476,3 +476,33 @@ func (c *Cli) RunCmd(args ...string) ([]string, error) { return nil, NewCliError(result) } + +func (c *Cli) extendVolume(name string, newSize int64) error { + url := "/volume/expand" + params := map[string]interface{}{"volName": name, "newVolSize": newSize} + _, err := c.request(url, "POST", false, params) + if err != nil { + return err + } + return nil +} + +func (c *Cli) createSnapshot(snapName, volName string) error { + url := "/snapshot/create" + params := map[string]interface{}{"volName": volName, "snapshotName": snapName} + _, err := c.request(url, "POST", false, params) + if err != nil { + return err + } + return nil +} + +func (c *Cli) deleteSnapshot(snapName string) error { + url := "/snapshot/delete" + params := map[string]interface{}{"snapshotName": snapName} + _, err := c.request(url, "POST", false, params) + if err != nil { + return err + } + return nil +}