diff --git a/cindercompatibleapi/converter/volume.go b/cindercompatibleapi/converter/volume.go old mode 100644 new mode 100755 index fee10b94c..345fe9a30 --- a/cindercompatibleapi/converter/volume.go +++ b/cindercompatibleapi/converter/volume.go @@ -447,18 +447,19 @@ func InitializeConnectionReq(initializeConnectionReq *InitializeConnectionReqSpe continue } - portName, err := volDriver.GetInitiatorInfo() + portNameList, err := volDriver.GetInitiatorInfo() if err != nil { glog.Errorf("cannot get initiator for driver volume type %s, err: %v", volDriverType, err) continue } - initiator := &model.Initiator{ - PortName: portName, - Protocol: volDriverType, + for _, portName := range portNameList { + initiator := &model.Initiator{ + PortName: portName, + Protocol: volDriverType, + } + initiators = append(initiators, initiator) } - - initiators = append(initiators, initiator) } if len(initiators) == 0 { diff --git a/csi/cmd/block/Dockerfile b/csi/cmd/block/Dockerfile index 6fe6e96d1..f6b6c4386 100755 --- a/csi/cmd/block/Dockerfile +++ b/csi/cmd/block/Dockerfile @@ -12,6 +12,7 @@ COPY nvme-cli-1.8.1 /nvme-cli-1.8.1 RUN apt-get update && \ apt-get -y install open-iscsi \ sysfsutils \ + sg3-utils \ kmod \ ceph-common \ nfs-common \ diff --git a/csi/common/node.go b/csi/common/node.go old mode 100644 new mode 100755 index 77bc12b1a..2c5880700 --- a/csi/common/node.go +++ b/csi/common/node.go @@ -137,18 +137,22 @@ func NodeGetInfo( continue } - portName, err := volDriver.GetInitiatorInfo() + portNameList, err := volDriver.GetInitiatorInfo() if err != nil { glog.Errorf("cannot get initiator for driver volume type %s, err: %v", volDriverType, err) continue } - initiator := &model.Initiator{ - PortName: portName, - Protocol: volDriverType, - } + for _, portName := range portNameList { + if portName != " " { + initiator := &model.Initiator{ + PortName: portName, + Protocol: volDriverType, + } - initiators = append(initiators, initiator) + initiators = append(initiators, initiator) + } + } } if len(initiators) == 0 { diff --git a/csi/deploy/kubernetes/block/csi-attacher-opensdsplugin.yaml b/csi/deploy/kubernetes/block/csi-attacher-opensdsplugin.yaml index 7fb2f4aeb..4d4d5260b 100755 --- a/csi/deploy/kubernetes/block/csi-attacher-opensdsplugin.yaml +++ b/csi/deploy/kubernetes/block/csi-attacher-opensdsplugin.yaml @@ -33,7 +33,7 @@ spec: serviceAccount: csi-attacher-block containers: - name: csi-attacher - image: quay.io/k8scsi/csi-attacher:v1.1.1 + image: quay.io/k8scsi/csi-attacher:v1.2.1 args: - "--v=5" - "--csi-address=$(ADDRESS)" @@ -144,7 +144,7 @@ spec: - name: iscsi-dir hostPath: path: /etc/iscsi/ - type: Directory + type: DirectoryOrCreate - name: ceph-dir hostPath: path: /etc/ceph/ diff --git a/csi/deploy/kubernetes/block/csi-nodeplugin-opensdsplugin.yaml b/csi/deploy/kubernetes/block/csi-nodeplugin-opensdsplugin.yaml index 3eb6e102f..3b03f1f27 100755 --- a/csi/deploy/kubernetes/block/csi-nodeplugin-opensdsplugin.yaml +++ b/csi/deploy/kubernetes/block/csi-nodeplugin-opensdsplugin.yaml @@ -21,7 +21,7 @@ spec: hostNetwork: true containers: - name: node-driver-registrar - image: quay.io/k8scsi/csi-node-driver-registrar:v1.1.0 + image: quay.io/k8scsi/csi-node-driver-registrar:v1.2.0 args: - "--v=5" - "--csi-address=/csi/csi.sock" @@ -155,7 +155,7 @@ spec: - name: iscsi-dir hostPath: path: /etc/iscsi/ - type: Directory + type: DirectoryOrCreate - name: ceph-dir hostPath: path: /etc/ceph/ @@ -171,4 +171,4 @@ spec: - name: hosts hostPath: path: /etc - type: Directory \ No newline at end of file + type: Directory diff --git a/csi/deploy/kubernetes/block/csi-provisioner-opensdsplugin.yaml b/csi/deploy/kubernetes/block/csi-provisioner-opensdsplugin.yaml index 3c43716bb..51a45c6a7 100755 --- a/csi/deploy/kubernetes/block/csi-provisioner-opensdsplugin.yaml +++ b/csi/deploy/kubernetes/block/csi-provisioner-opensdsplugin.yaml @@ -33,7 +33,7 @@ spec: serviceAccount: csi-provisioner-block containers: - name: csi-provisioner - image: quay.io/k8scsi/csi-provisioner:v1.1.0 + image: quay.io/k8scsi/csi-provisioner:v1.4.0 args: - "--provisioner=csi-opensdsplugin-block" - "--csi-address=$(ADDRESS)" @@ -123,4 +123,4 @@ spec: - name: certificate-path hostPath: path: /opt/opensds-security - type: DirectoryOrCreate \ No newline at end of file + type: DirectoryOrCreate diff --git a/csi/deploy/kubernetes/block/csi-snapshotter-opensdsplugin.yaml b/csi/deploy/kubernetes/block/csi-snapshotter-opensdsplugin.yaml index 8b53f40b0..6c6c8b3bf 100755 --- a/csi/deploy/kubernetes/block/csi-snapshotter-opensdsplugin.yaml +++ b/csi/deploy/kubernetes/block/csi-snapshotter-opensdsplugin.yaml @@ -33,7 +33,7 @@ spec: serviceAccount: csi-snapshotter-block containers: - name: csi-snapshotter - image: quay.io/k8scsi/csi-snapshotter:v1.1.0 + image: quay.io/k8scsi/csi-snapshotter:v1.2.2 args: - "--snapshotter=csi-opensdsplugin-block" - "--csi-address=$(ADDRESS)" diff --git a/csi/deploy/kubernetes/file/csi-attacher-opensdsplugin.yaml b/csi/deploy/kubernetes/file/csi-attacher-opensdsplugin.yaml index 99aa56888..1fe7367e2 100755 --- a/csi/deploy/kubernetes/file/csi-attacher-opensdsplugin.yaml +++ b/csi/deploy/kubernetes/file/csi-attacher-opensdsplugin.yaml @@ -33,7 +33,7 @@ spec: serviceAccount: csi-attacher-file containers: - name: csi-attacher - image: quay.io/k8scsi/csi-attacher:v1.1.1 + image: quay.io/k8scsi/csi-attacher:v1.2.1 args: - "--v=5" - "--csi-address=$(ADDRESS)" @@ -144,7 +144,7 @@ spec: - name: iscsi-dir hostPath: path: /etc/iscsi/ - type: Directory + type: DirectoryOrCreate - name: ceph-dir hostPath: path: /etc/ceph/ diff --git a/csi/deploy/kubernetes/file/csi-nodeplugin-opensdsplugin.yaml b/csi/deploy/kubernetes/file/csi-nodeplugin-opensdsplugin.yaml index 84d42ccd4..52bfd8d5c 100755 --- a/csi/deploy/kubernetes/file/csi-nodeplugin-opensdsplugin.yaml +++ b/csi/deploy/kubernetes/file/csi-nodeplugin-opensdsplugin.yaml @@ -21,7 +21,7 @@ spec: hostNetwork: true containers: - name: node-driver-registrar - image: quay.io/k8scsi/csi-node-driver-registrar:v1.1.0 + image: quay.io/k8scsi/csi-node-driver-registrar:v1.2.0 args: - "--v=5" - "--csi-address=/csi/csi.sock" @@ -155,7 +155,7 @@ spec: - name: iscsi-dir hostPath: path: /etc/iscsi/ - type: Directory + type: DirectoryOrCreate - name: ceph-dir hostPath: path: /etc/ceph/ @@ -171,4 +171,4 @@ spec: - name: hosts hostPath: path: /etc - type: Directory \ No newline at end of file + type: Directory diff --git a/csi/deploy/kubernetes/file/csi-provisioner-opensdsplugin.yaml b/csi/deploy/kubernetes/file/csi-provisioner-opensdsplugin.yaml index 296f479ca..45e84e326 100755 --- a/csi/deploy/kubernetes/file/csi-provisioner-opensdsplugin.yaml +++ b/csi/deploy/kubernetes/file/csi-provisioner-opensdsplugin.yaml @@ -33,7 +33,7 @@ spec: serviceAccount: csi-provisioner-file containers: - name: csi-provisioner - image: quay.io/k8scsi/csi-provisioner:v1.1.0 + image: quay.io/k8scsi/csi-provisioner:v1.4.0 args: - "--provisioner=csi-opensdsplugin-file" - "--csi-address=$(ADDRESS)" @@ -123,4 +123,4 @@ spec: - name: certificate-path hostPath: path: /opt/opensds-security - type: DirectoryOrCreate \ No newline at end of file + type: DirectoryOrCreate diff --git a/csi/deploy/kubernetes/file/csi-snapshotter-opensdsplugin.yaml b/csi/deploy/kubernetes/file/csi-snapshotter-opensdsplugin.yaml index e26e7074a..fd29e0e1e 100755 --- a/csi/deploy/kubernetes/file/csi-snapshotter-opensdsplugin.yaml +++ b/csi/deploy/kubernetes/file/csi-snapshotter-opensdsplugin.yaml @@ -33,7 +33,7 @@ spec: serviceAccount: csi-snapshotter-file containers: - name: csi-snapshotter - image: quay.io/k8scsi/csi-snapshotter:v1.1.0 + image: quay.io/k8scsi/csi-snapshotter:v1.2.2 args: - "--snapshotter=csi-opensdsplugin-file" - "--csi-address=$(ADDRESS)" diff --git a/csi/plugins/block/volume.go b/csi/plugins/block/volume.go index f64952756..ba86af037 100644 --- a/csi/plugins/block/volume.go +++ b/csi/plugins/block/volume.go @@ -24,8 +24,8 @@ import ( "github.com/golang/glog" "github.com/opensds/nbp/csi/common" "github.com/opensds/nbp/csi/util" + nbputil "github.com/opensds/nbp/util" "github.com/opensds/opensds/client" - nbputil "github.com/opensds/nbp/util" "github.com/opensds/opensds/contrib/connector" "github.com/opensds/opensds/pkg/model" "google.golang.org/grpc/codes" @@ -263,9 +263,9 @@ func (v *Volume) ControllerPublishVolume(req *csi.ControllerPublishVolumeRequest var protocol = strings.ToLower(pool.Extras.IOConnectivity.AccessProtocol) attachReq := &model.VolumeAttachmentSpec{ - VolumeId: req.VolumeId, - HostId: req.NodeId, - AttachMode: attachMode, + VolumeId: req.VolumeId, + HostId: req.NodeId, + AttachMode: attachMode, ConnectionInfo: model.ConnectionInfo{ DriverVolumeType: protocol, }, @@ -591,8 +591,7 @@ func (v *Volume) NodeStageVolume(req *csi.NodeStageVolumeRequest) (*csi.NodeStag // NodeUnstageVolume implementation func (v *Volume) NodeUnstageVolume(req *csi.NodeUnstageVolumeRequest) (*csi.NodeUnstageVolumeResponse, error) { - - vol, _, err := v.getVolumeAndAttachmentByVolumeId(req.VolumeId) + vol, attachment, err := v.getVolumeAndAttachmentByVolumeId(req.VolumeId) if err != nil { return nil, status.Error(codes.NotFound, err.Error()) } @@ -619,6 +618,20 @@ func (v *Volume) NodeUnstageVolume(req *csi.NodeUnstageVolumeRequest) (*csi.Node glog.Error(msg) return nil, status.Error(codes.FailedPrecondition, msg) } + + volConnector := connector.NewConnector(attachment.DriverVolumeType) + if volConnector == nil { + msg := fmt.Sprintf("unsupported driver volume type: %s", attachment.DriverVolumeType) + glog.Error(msg) + return nil, status.Error(codes.FailedPrecondition, msg) + } + + err = volConnector.Detach(attachment.ConnectionData) + if err != nil { + msg := fmt.Sprintf("failed to detach device: %v", err) + glog.Error(msg) + return nil, status.Error(codes.FailedPrecondition, msg) + } } if CSIBlock == vol.Metadata[CSIVolumeMode] { diff --git a/flexvolume/cmd/flex-plugin/main.go b/flexvolume/cmd/flex-plugin/main.go index f4cdf4fd6..659a820f7 100755 --- a/flexvolume/cmd/flex-plugin/main.go +++ b/flexvolume/cmd/flex-plugin/main.go @@ -141,7 +141,7 @@ func (plugin *OpenSDSPlugin) Attach(opts interface{}) Result { } //create attachment to indicate the volume is been processed. - localIqn, _ := connector.NewConnector("iscsi").GetInitiatorInfo() + localIqnList, _ := connector.NewConnector("iscsi").GetInitiatorInfo() attachReq := &model.VolumeAttachmentSpec{ VolumeId: volID, @@ -150,7 +150,7 @@ func (plugin *OpenSDSPlugin) Attach(opts interface{}) Result { OsType: runtime.GOOS, Ip: connector.GetHostIP(), Host: hostname, - Initiator: localIqn, + Initiator: localIqnList[0], }, Status: VOLUME_STATUS_ATTACHING, Metadata: vol.Metadata, diff --git a/vendor/github.com/opensds/opensds/contrib/connector/common.go b/vendor/github.com/opensds/opensds/contrib/connector/common.go index 3363ce15a..26e7402bb 100644 --- a/vendor/github.com/opensds/opensds/contrib/connector/common.go +++ b/vendor/github.com/opensds/opensds/contrib/connector/common.go @@ -111,13 +111,6 @@ func Mount(device, mountpoint, fsType string, mountFlags []string) error { return err } - // Make sure the mount is not lost after the host reboots - cmd := fmt.Sprintf("echo \"%s %s %s defaults 0 0\" >> /etc/fstab", device, mountpoint, fsType) - _, err = ExecCmd("/bin/bash", "-c", cmd) - if err != nil { - return err - } - return nil } @@ -131,11 +124,6 @@ func Umount(mountpoint string) error { return err } - cmd := fmt.Sprintf("cat -n /etc/fstab | grep -w '%s' | awk -F ' ' '{ print $1 }'| xargs -i sed -i '{}d' /etc/fstab", mountpoint) - _, err = ExecCmd("/bin/bash", "-c", cmd) - if err != nil { - return err - } return nil } diff --git a/vendor/github.com/opensds/opensds/contrib/connector/connector.go b/vendor/github.com/opensds/opensds/contrib/connector/connector.go old mode 100644 new mode 100755 index c8c38a6db..0ae5b7267 --- a/vendor/github.com/opensds/opensds/contrib/connector/connector.go +++ b/vendor/github.com/opensds/opensds/contrib/connector/connector.go @@ -42,7 +42,7 @@ const ( type Connector interface { Attach(map[string]interface{}) (string, error) Detach(map[string]interface{}) error - GetInitiatorInfo() (string, error) + GetInitiatorInfo() ([]string, error) } var cnts = map[string]Connector{} diff --git a/vendor/github.com/opensds/opensds/contrib/connector/fc/fc.go b/vendor/github.com/opensds/opensds/contrib/connector/fc/fc.go old mode 100644 new mode 100755 index 163c10a21..6ac1495c6 --- a/vendor/github.com/opensds/opensds/contrib/connector/fc/fc.go +++ b/vendor/github.com/opensds/opensds/contrib/connector/fc/fc.go @@ -41,6 +41,6 @@ func (f *FC) Detach(conn map[string]interface{}) error { } // GetInitiatorInfo ... -func (f *FC) GetInitiatorInfo() (string, error) { +func (f *FC) GetInitiatorInfo() ([]string, error) { return getInitiatorInfo() } diff --git a/vendor/github.com/opensds/opensds/contrib/connector/fc/fibreChannel.go b/vendor/github.com/opensds/opensds/contrib/connector/fc/fibreChannel.go old mode 100644 new mode 100755 index 5657b5b78..1f45da85d --- a/vendor/github.com/opensds/opensds/contrib/connector/fc/fibreChannel.go +++ b/vendor/github.com/opensds/opensds/contrib/connector/fc/fibreChannel.go @@ -227,22 +227,23 @@ func getFChbasInfo() ([]map[string]string, error) { return hbasInfos, nil } -func getInitiatorInfo() (string, error) { +func getInitiatorInfo() ([]string, error) { hbas, err := getFChbasInfo() if err != nil { - return "", err + return nil, err } var initiatorInfo []string - for _, hba := range hbas { if v, ok := hba[connector.PortName]; ok { - initiatorInfo = append(initiatorInfo, "port_name:"+v) - } - if v, ok := hba[connector.NodeName]; ok { - initiatorInfo = append(initiatorInfo, "node_name:"+v) + initiatorInfo = append(initiatorInfo, v) } } - return strings.Join(initiatorInfo, ","), nil + //Check for atleast one initiator + if (0 == len(initiatorInfo)){ + return nil, errors.New("No initiator info found.") + } + + return initiatorInfo, nil } diff --git a/vendor/github.com/opensds/opensds/contrib/connector/iscsi/helper.go b/vendor/github.com/opensds/opensds/contrib/connector/iscsi/helper.go old mode 100644 new mode 100755 index 4b7087174..6eb409af9 --- a/vendor/github.com/opensds/opensds/contrib/connector/iscsi/helper.go +++ b/vendor/github.com/opensds/opensds/contrib/connector/iscsi/helper.go @@ -372,19 +372,19 @@ func getTgtPortalAndTgtIQN() (string, string, error) { } -func getInitiatorInfo() (string, error) { +func getInitiatorInfo() ([]string, error) { initiators, err := getInitiator() if err != nil { - return "", err + return nil, err } if len(initiators) == 0 { - return "", errors.New("No iqn found") + return nil, errors.New("No iqn found") } if len(initiators) > 1 { - return "", errors.New("the number of iqn is wrong") + return nil, errors.New("the number of iqn is wrong") } - return initiators[0], nil + return initiators, nil } diff --git a/vendor/github.com/opensds/opensds/contrib/connector/iscsi/iscsi.go b/vendor/github.com/opensds/opensds/contrib/connector/iscsi/iscsi.go old mode 100644 new mode 100755 index b96c40b3e..e60910bbc --- a/vendor/github.com/opensds/opensds/contrib/connector/iscsi/iscsi.go +++ b/vendor/github.com/opensds/opensds/contrib/connector/iscsi/iscsi.go @@ -33,6 +33,6 @@ func (isc *Iscsi) Detach(conn map[string]interface{}) error { } // GetInitiatorInfo implementation -func (isc *Iscsi) GetInitiatorInfo() (string, error) { +func (isc *Iscsi) GetInitiatorInfo() ([]string, error) { return getInitiatorInfo() } diff --git a/vendor/github.com/opensds/opensds/contrib/connector/nfs/helper.go b/vendor/github.com/opensds/opensds/contrib/connector/nfs/helper.go old mode 100644 new mode 100755 index a2742f3a3..718759b6d --- a/vendor/github.com/opensds/opensds/contrib/connector/nfs/helper.go +++ b/vendor/github.com/opensds/opensds/contrib/connector/nfs/helper.go @@ -103,6 +103,6 @@ func disconnect(conn map[string]interface{}) error { return errors.New("disconnect method of nfs is not implemented") } -func getInitiatorInfo() (string, error) { - return "", errors.New("get initiator information method of nfs is not implemented") +func getInitiatorInfo() ([]string, error) { + return nil, errors.New("get initiator information method of nfs is not implemented") } diff --git a/vendor/github.com/opensds/opensds/contrib/connector/nfs/nfs.go b/vendor/github.com/opensds/opensds/contrib/connector/nfs/nfs.go old mode 100644 new mode 100755 index a5f55a7ad..89f516c9a --- a/vendor/github.com/opensds/opensds/contrib/connector/nfs/nfs.go +++ b/vendor/github.com/opensds/opensds/contrib/connector/nfs/nfs.go @@ -33,6 +33,6 @@ func (n *NFS) Detach(conn map[string]interface{}) error { } // GetInitiatorInfo implementation -func (n *NFS) GetInitiatorInfo() (string, error) { +func (n *NFS) GetInitiatorInfo() ([]string, error) { return getInitiatorInfo() } diff --git a/vendor/github.com/opensds/opensds/contrib/connector/nvmeof/nvmeof.go b/vendor/github.com/opensds/opensds/contrib/connector/nvmeof/nvmeof.go old mode 100644 new mode 100755 index 4004c4f02..22b95741b --- a/vendor/github.com/opensds/opensds/contrib/connector/nvmeof/nvmeof.go +++ b/vendor/github.com/opensds/opensds/contrib/connector/nvmeof/nvmeof.go @@ -35,6 +35,6 @@ func (nof *Nvmeof) Detach(conn map[string]interface{}) error { } // GetInitiatorInfo implementation -func (nof *Nvmeof) GetInitiatorInfo() (string, error) { +func (nof *Nvmeof) GetInitiatorInfo() ([]string, error) { return getInitiatorInfo() } diff --git a/vendor/github.com/opensds/opensds/contrib/connector/nvmeof/nvmeof_helper.go b/vendor/github.com/opensds/opensds/contrib/connector/nvmeof/nvmeof_helper.go old mode 100644 new mode 100755 index 5b14e6c92..037bde1f2 --- a/vendor/github.com/opensds/opensds/contrib/connector/nvmeof/nvmeof_helper.go +++ b/vendor/github.com/opensds/opensds/contrib/connector/nvmeof/nvmeof_helper.go @@ -63,28 +63,32 @@ func GetInitiator() ([]string, error) { return nqns, errors.New("can not find any nqn initiator") } -func getInitiatorInfo() (string, error) { +func getInitiatorInfo() ([]string, error) { initiators, err := GetInitiator() if err != nil { - return "", err + return nil, err } if len(initiators) == 0 { - return "", errors.New("no nqn found") + return nil, errors.New("no nqn found") } if len(initiators) > 1 { - return "", errors.New("the number of nqn is wrong") + return nil, errors.New("the number of nqn is wrong") } hostName, err := connector.GetHostName() if err != nil { - return "", errors.New("can not get hostname") + return nil, errors.New("can not get hostname") } - info := initiators[0] + "." + hostName - return info, nil + hostName = initiators[0] + "." + hostName + + initiator := make([]string, 1) + initiator = append(initiator, hostName) + + return initiator, nil } // GetNvmeDevice get all the nvme devices diff --git a/vendor/github.com/opensds/opensds/contrib/connector/rbd/rbd.go b/vendor/github.com/opensds/opensds/contrib/connector/rbd/rbd.go old mode 100644 new mode 100755 index 1c601771e..f90922a83 --- a/vendor/github.com/opensds/opensds/contrib/connector/rbd/rbd.go +++ b/vendor/github.com/opensds/opensds/contrib/connector/rbd/rbd.go @@ -105,14 +105,18 @@ func (*RBD) Detach(conn map[string]interface{}) error { } // GetInitiatorInfo implementation -func (*RBD) GetInitiatorInfo() (string, error) { +func (*RBD) GetInitiatorInfo() ([]string, error) { + hostName, err := connector.GetHostName() if err != nil { - return "", err + return nil, err } - return hostName, nil + initiator := make([]string, 1) + initiator = append(initiator, hostName) + + return initiator, nil } func parseName(name string) (poolName, imageName, snapName string, err error) { diff --git a/vendor/github.com/opensds/opensds/pkg/db/drivers/etcd/etcd.go b/vendor/github.com/opensds/opensds/pkg/db/drivers/etcd/etcd.go index bb4ab52cc..f0b8385ec 100644 --- a/vendor/github.com/opensds/opensds/pkg/db/drivers/etcd/etcd.go +++ b/vendor/github.com/opensds/opensds/pkg/db/drivers/etcd/etcd.go @@ -297,7 +297,7 @@ func (c *Client) CreateFileShareAcl(ctx *c.Context, fshare *model.FileShareAclSp for _, acl := range acls { if acl.AccessTo == fshare.AccessTo { - errstr := "for fileshareID: "+acl.FileShareId+", acl is already set with ip: "+acl.AccessTo+". If you want to set new acl, first delete the existing one" + errstr := "for fileshareID: " + acl.FileShareId + ", acl is already set with ip: " + acl.AccessTo + ". If you want to set new acl, first delete the existing one" log.Error(errstr) return nil, fmt.Errorf(errstr) } @@ -1426,6 +1426,8 @@ func (c *Client) CreateVolume(ctx *c.Context, vol *model.VolumeSpec) (*model.Vol } vol.TenantId = ctx.TenantId + // Set attached as false when creating volume + vol.Attached = new(bool) volBody, err := json.Marshal(vol) if err != nil { return nil, err @@ -1622,15 +1624,15 @@ func (c *Client) ListVolumesWithFilter(ctx *c.Context, m map[string][]string) ([ // If DurableName is there in filter we need to parse the sub structure 'identifier' to filter out matching volume spec var vols = []*model.VolumeSpec{} if val, ok := m["DurableName"]; ok { - for _,vol := range volumes { - v :=c.FindVolumeValue("DurableName",vol) + for _, vol := range volumes { + v := c.FindVolumeValue("DurableName", vol) if v == val[0] { - vols =append(vols,vol) - return vols,nil + vols = append(vols, vol) + return vols, nil } } - return vols,nil + return vols, nil } tmpVolumes := c.FilterAndSort(volumes, m, sortableKeysMap[typeVolumes]) @@ -1684,6 +1686,10 @@ func (c *Client) UpdateVolume(ctx *c.Context, vol *model.VolumeSpec) (*model.Vol result.GroupId = vol.GroupId } + if vol.Attached != nil { + result.Attached = vol.Attached + } + // Set update time result.UpdatedAt = time.Now().Format(constants.TimeFormat) diff --git a/vendor/github.com/opensds/opensds/pkg/dock/client/client.go b/vendor/github.com/opensds/opensds/pkg/dock/client/client.go index c100b0468..d93229c02 100755 --- a/vendor/github.com/opensds/opensds/pkg/dock/client/client.go +++ b/vendor/github.com/opensds/opensds/pkg/dock/client/client.go @@ -15,9 +15,13 @@ package client import ( + "time" + log "github.com/golang/glog" pb "github.com/opensds/opensds/pkg/model/proto" "google.golang.org/grpc" + "google.golang.org/grpc/connectivity" + "google.golang.org/grpc/keepalive" ) // Client interface provides an abstract description about how to interact @@ -30,8 +34,6 @@ type Client interface { pb.FileShareDockClient Connect(edp string) error - - Close() } // DockClient structure is one implementation of Client interface and will be @@ -48,7 +50,15 @@ func NewClient() Client { return &DockClient{} } func (c *DockClient) Connect(edp string) error { // Set up a connection to the Dock server. - conn, err := grpc.Dial(edp, grpc.WithInsecure()) + if c.ClientConn != nil && c.ClientConn.GetState() == connectivity.Ready { + return nil + } + var kacp = keepalive.ClientParameters{ + Time: 10 * time.Second, // send pings every 10 seconds if there is no activity + Timeout: time.Second, // wait 1 second for ping ack before considering the connection dead + PermitWithoutStream: true, // send pings even without active streams + } + conn, err := grpc.Dial(edp, grpc.WithInsecure(), grpc.WithKeepaliveParams(kacp)) if err != nil { log.Errorf("did not connect: %+v\n", err) return err @@ -61,7 +71,3 @@ func (c *DockClient) Connect(edp string) error { return nil } - -func (c *DockClient) Close() { - c.ClientConn.Close() -} diff --git a/vendor/github.com/opensds/opensds/pkg/model/status.go b/vendor/github.com/opensds/opensds/pkg/model/status.go index b71a72718..6f6390949 100644 --- a/vendor/github.com/opensds/opensds/pkg/model/status.go +++ b/vendor/github.com/opensds/opensds/pkg/model/status.go @@ -14,6 +14,12 @@ package model +// Storage pool status +const ( + PoolAvailable = "available" + PoolUnAvailable = "unavailable" +) + // fileshare status const ( FileShareCreating = "creating" @@ -46,7 +52,6 @@ const ( const ( VolumeCreating = "creating" VolumeAvailable = "available" - VolumeInUse = "inUse" VolumeDeleting = "deleting" VolumeError = "error" VolumeErrorDeleting = "errorDeleting" @@ -54,16 +59,6 @@ const ( VolumeExtending = "extending" ) -// volume attach status -const ( - VolumeAttaching = "attaching" - VolumeAttached = "attached" - VolumeDetached = "detached" - VolumeReserved = "reserved" - VolumeErrorAttaching = "errorAttaching" - VolumeErrorDetaching = "errorDetaching" -) - // volume snapshot status const ( VolumeSnapCreating = "creating" diff --git a/vendor/github.com/opensds/opensds/pkg/model/volume.go b/vendor/github.com/opensds/opensds/pkg/model/volume.go index e2488ecd4..7b22f156b 100755 --- a/vendor/github.com/opensds/opensds/pkg/model/volume.go +++ b/vendor/github.com/opensds/opensds/pkg/model/volume.go @@ -76,7 +76,7 @@ type VolumeSpec struct { // The uuid of the replication which the volume belongs to. ReplicationDriverData map[string]string `json:"replicationDriverData,omitempty"` // Attach status of the volume. - AttachStatus string + Attached *bool `json:"attached,omitempty"` // Whether the volume can be attached more than once, default value is false. MultiAttach bool `json:"multiAttach,omitempty"` diff --git a/vendor/github.com/opensds/opensds/testutils/collection/data.go b/vendor/github.com/opensds/opensds/testutils/collection/data.go index 147377827..bd51369db 100644 --- a/vendor/github.com/opensds/opensds/testutils/collection/data.go +++ b/vendor/github.com/opensds/opensds/testutils/collection/data.go @@ -163,6 +163,7 @@ var ( }, Name: "sample-pool-01", Description: "This is the first sample storage pool for testing", + Status: "available", StorageType: "block", TotalCapacity: int64(100), FreeCapacity: int64(90), @@ -195,6 +196,7 @@ var ( }, Name: "sample-pool-02", Description: "This is the second sample storage pool for testing", + Status: "available", StorageType: "block", TotalCapacity: int64(200), FreeCapacity: int64(170), @@ -1172,6 +1174,7 @@ var ( "name": "sample-pool-01", "description": "This is the first sample storage pool for testing", "storageType": "block", + "status": "available", "totalCapacity": 100, "freeCapacity": 90, "dockId": "b7602e18-771e-11e7-8f38-dbd6d291f4e0", diff --git a/vmware/ngc/NGC-AdapterManager/src/main/java/org/opensds/vmware/ngc/adapters/opensds/OpenSDS.java b/vmware/ngc/NGC-AdapterManager/src/main/java/org/opensds/vmware/ngc/adapters/opensds/OpenSDS.java index 1deb280aa..c8d6e46d6 100644 --- a/vmware/ngc/NGC-AdapterManager/src/main/java/org/opensds/vmware/ngc/adapters/opensds/OpenSDS.java +++ b/vmware/ngc/NGC-AdapterManager/src/main/java/org/opensds/vmware/ngc/adapters/opensds/OpenSDS.java @@ -224,7 +224,8 @@ public List listSnapshot(String volumeId) throws Exception { if (jsonArray != null) { for (int i = 0; i < jsonArray.length(); i++) { JSONObject snapshot = jsonArray.getJSONObject(i); - snapshots.add(SnapshotMOBuilder.build(snapshot)); + if(snapshot.getString("status").equals("available")) + snapshots.add(SnapshotMOBuilder.build(snapshot)); } } diff --git a/vmware/ngc/NGC-AdapterManager/src/main/java/org/opensds/vmware/ngc/adapters/opensds/RestClient.java b/vmware/ngc/NGC-AdapterManager/src/main/java/org/opensds/vmware/ngc/adapters/opensds/RestClient.java index cd63a55d9..ae3f20c7c 100644 --- a/vmware/ngc/NGC-AdapterManager/src/main/java/org/opensds/vmware/ngc/adapters/opensds/RestClient.java +++ b/vmware/ngc/NGC-AdapterManager/src/main/java/org/opensds/vmware/ngc/adapters/opensds/RestClient.java @@ -167,8 +167,8 @@ void findDeviceInfo(String ip, int port) throws Exception { throw new Exception(msg); } - storage = new StorageMO(OPENSDS_STORAGENAME.getValue(), response.getString("name"), - "", response.getString("status"), OPENSDS_VENDOR.getValue()); + storage = new StorageMO(OPENSDS_STORAGENAME.getValue()+ip, response.getString("name"), + "", "Available", OPENSDS_VENDOR.getValue()); logger.info(String.format("OpenSDS Storage Device: %s", storage)); } diff --git a/vmware/ngc/NGC-AdapterManager/src/main/java/org/opensds/vmware/ngc/common/Request.java b/vmware/ngc/NGC-AdapterManager/src/main/java/org/opensds/vmware/ngc/common/Request.java index 604b99b63..15ef08036 100644 --- a/vmware/ngc/NGC-AdapterManager/src/main/java/org/opensds/vmware/ngc/common/Request.java +++ b/vmware/ngc/NGC-AdapterManager/src/main/java/org/opensds/vmware/ngc/common/Request.java @@ -36,7 +36,7 @@ import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.util.EntityUtils; - +import org.json.JSONObject; import org.opensds.vmware.ngc.exceptions.HttpException; public class Request { @@ -109,6 +109,10 @@ Object call(HttpUriRequest req) throws Exception { } String result = EntityUtils.toString(response.getEntity(), "utf-8"); + if(result.equals("")) + { + return new JSONObject(); + } return this.handler.parseResponseBody(result); } diff --git a/vmware/ngc/NGC-AdapterManager/src/main/resources/constants.properties b/vmware/ngc/NGC-AdapterManager/src/main/resources/constants.properties index 91d02d7ec..92ab50125 100644 --- a/vmware/ngc/NGC-AdapterManager/src/main/resources/constants.properties +++ b/vmware/ngc/NGC-AdapterManager/src/main/resources/constants.properties @@ -1,6 +1,6 @@ OPENSDS_TENANT=admin OPENSDS_DOMAIN=default OPENSDS_AVAILABILITYZONE=default -OPENSDS_STORAGENAME=OpenSDS-LVM +OPENSDS_STORAGENAME=OpenSDS- OPENSDS_VENDOR=OpenSDS OPENSDS_HOST_ACCESSMODE=agentless \ No newline at end of file diff --git a/vmware/ngc/NGC-AdapterManager/src/test/README.txt b/vmware/ngc/NGC-AdapterManager/src/test/README.txt new file mode 100644 index 000000000..0262fd105 --- /dev/null +++ b/vmware/ngc/NGC-AdapterManager/src/test/README.txt @@ -0,0 +1,6 @@ +Unit tests Requirement for NGC +================================ +1. Before running unit tests, make sure you have a working OpenSDS Hotpot environment. +2. Set required fields in //test//resources//config.properties +3. Set eclipse project to run unit tests and coverage. +4. Install Junit5 (Java build path -> Librararies -> Add library -> Junit5 \ No newline at end of file diff --git a/vmware/ngc/NGC-AdapterManager/src/test/java/org/opensds/vmware/ngc/adapters/opensds/OpenSDSTest.java b/vmware/ngc/NGC-AdapterManager/src/test/java/org/opensds/vmware/ngc/adapters/opensds/OpenSDSTest.java new file mode 100644 index 000000000..d9a54f3a0 --- /dev/null +++ b/vmware/ngc/NGC-AdapterManager/src/test/java/org/opensds/vmware/ngc/adapters/opensds/OpenSDSTest.java @@ -0,0 +1,111 @@ +package org.opensds.vmware.ngc.adapters.opensds; + +import static org.junit.jupiter.api.Assertions.*; + +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.util.List; +import java.util.Properties; + +import org.junit.jupiter.api.Test; +import org.opensds.vmware.ngc.models.ALLOC_TYPE; +import org.opensds.vmware.ngc.models.ATTACH_MODE; +import org.opensds.vmware.ngc.models.ATTACH_PROTOCOL; +import org.opensds.vmware.ngc.models.ConnectMO; +import org.opensds.vmware.ngc.models.HOST_OS_TYPE; +import org.opensds.vmware.ngc.models.POOL_TYPE; +import org.opensds.vmware.ngc.models.SnapshotMO; +import org.opensds.vmware.ngc.models.StoragePoolMO; +import org.opensds.vmware.ngc.models.VolumeMO; + +class OpenSDSTest { + private String openSdsIP; + private String userName; + private String password; + private int port; + private String esxIP; + private String esxIQN; + private static int VOLUME_SIZE=1; + private static int VOLUME_EXPAND_SIZE=2; + private static int SLEEP_DURATION=2000; + + @Test + void ITtestOpenSDS() throws Exception { + OpenSDS osds = new OpenSDS("OpenSDS"); + readDefaultConfig(); + osds.login(openSdsIP, port, userName, password); + osds.getDeviceInfo(); + List pools = osds.listStoragePools(); + StoragePoolMO pool = SelectBlockPool(pools); + if (pool == null) { + fail("List Pool Failure"); + } + VolumeMO volume = osds.createVolume("test_volume", "test volume creation", ALLOC_TYPE.THIN, VOLUME_SIZE*UNIT_TYPE.GB.getUnit(), + pool.id); + Thread.sleep(SLEEP_DURATION); + if (volume == null) { + fail("Volume Creation Failure"); + } + osds.expandVolume(volume.id, (long) VOLUME_EXPAND_SIZE * UNIT_TYPE.GB.getUnit()); + Thread.sleep(SLEEP_DURATION); + osds.createVolumeSnapshot(volume.id, "test_volume_snap"); + Thread.sleep(SLEEP_DURATION); + List volumes = osds.listVolumes(); + if (volumes == null) { + fail("List Volumes Failure"); + } + List pool_volumes = osds.listVolumes(pool.id); + if (pool_volumes == null) { + fail("List Volumes with PoolID Failure"); + } + List snapshots = osds.listSnapshot(volume.id); + if (snapshots == null) { + fail("List Sanpshot Failure"); + } + StoragePoolMO pool1 = osds.getStoragePool(pool.id); + if (pool1 == null) { + fail("Get Pool Failure"); + } + List filterVolume = osds.listVolumes("DurableName", volume.wwn); + if (filterVolume == null) { + fail("List Volumes by DurableName Failed"); + } + VolumeMO filterVolume1 = osds.queryVolumeByID(volume.wwn); + if (filterVolume1 == null) { + fail("List Volumes by ID Failed"); + } + ConnectMO connectMO = new ConnectMO("esx_host", HOST_OS_TYPE.ESXI, esxIQN, esxIP, null, ATTACH_MODE.RW, + ATTACH_PROTOCOL.ISCSI); + osds.attachVolume(volume.id, connectMO); + Thread.sleep(SLEEP_DURATION); + osds.detachVolume(volume.id, connectMO); + Thread.sleep(SLEEP_DURATION); + osds.deleteVolumeSnapshot(snapshots.get(0).id); + Thread.sleep(SLEEP_DURATION); + osds.deleteVolume(volume.id); + osds.logout(); + } + + private StoragePoolMO SelectBlockPool(List pools) { + + for (StoragePoolMO temp : pools) { + if (temp.type == POOL_TYPE.BLOCK) { + return temp; + } + } + return null; + } + + public void readDefaultConfig() throws IOException { + Properties p = new Properties(); + p.load(new FileReader(new File(".\\src\\test\\resources\\config.properties"))); + esxIP = p.getProperty("ESX_IP"); + esxIQN = p.getProperty("ESX_IQN"); + openSdsIP = p.getProperty("HostIP"); + userName = p.getProperty("UserName"); + password = p.getProperty("Password"); + port = Integer.parseInt(p.getProperty("Port")); + } + +} diff --git a/vmware/ngc/NGC-AdapterManager/src/test/resources/config.properties b/vmware/ngc/NGC-AdapterManager/src/test/resources/config.properties new file mode 100644 index 000000000..789252315 --- /dev/null +++ b/vmware/ngc/NGC-AdapterManager/src/test/resources/config.properties @@ -0,0 +1,7 @@ +HostIP= +Port=50040 +Password= +UserName= +AuthEnabled=true +ESX_IP= +ESX_IQN= diff --git a/vmware/ngc/NGC-Plugin/pom.xml b/vmware/ngc/NGC-Plugin/pom.xml index 2aac7cd20..3e25ff510 100644 --- a/vmware/ngc/NGC-Plugin/pom.xml +++ b/vmware/ngc/NGC-Plugin/pom.xml @@ -125,6 +125,19 @@ ${basedir}/lib/ngc-adapter-manager.jar system + + junit + junit + 4.13 + test + + + + org.mockito + mockito-all + 1.10.19 + test + \ No newline at end of file diff --git a/vmware/ngc/NGC-Plugin/src/test/java/org/opensds/vmware/ngc/service/impl/DatastoreTest.java b/vmware/ngc/NGC-Plugin/src/test/java/org/opensds/vmware/ngc/service/impl/DatastoreTest.java new file mode 100644 index 000000000..fd4cb86dc --- /dev/null +++ b/vmware/ngc/NGC-Plugin/src/test/java/org/opensds/vmware/ngc/service/impl/DatastoreTest.java @@ -0,0 +1,81 @@ +/** + * + */ + +package org.opensds.vmware.ngc.service.impl; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.runners.MockitoJUnitRunner; +import org.opensds.vmware.ngc.dao.DeviceRepository; +import org.opensds.vmware.ngc.entity.ResultInfo; +import org.opensds.vmware.ngc.model.DeviceInfo; +import org.opensds.vmware.ngc.model.datastore.NFSDatastore; +import org.opensds.vmware.ngc.model.datastore.VMFSDatastore; +import org.opensds.vmware.ngc.service.impl.DatastoreServiceImpl; +import org.springframework.beans.factory.annotation.Autowired; +import static org.mockito.Mockito.*; + +import static org.junit.Assert.assertEquals; + +import org.junit.Before; + +@RunWith(MockitoJUnitRunner.class) +public class DatastoreTest { + + @InjectMocks + public DatastoreServiceImpl datastoreService; + + @Mock + VMFSDatastore vmfsDataStore; + + @Mock + NFSDatastore nfsDataStore; + + @Mock + public DeviceRepository deviceRepository; + + + @Test + public void create_datastore_test_when_all_param_null(){ + ResultInfo resultInfo = datastoreService.create(null, null, null); + assertEquals(resultInfo.getStatus(), "error"); + } + + @Test + public void create_datastore_test_default_vmfsdatastore(){ + + ResultInfo resultInfo = datastoreService.create(null, null, vmfsDataStore); + assertEquals(resultInfo.getStatus(), "error"); + } + + @Test + public void create_datastore_test_default_nfsdatastore(){ + + ResultInfo resultInfo = datastoreService.create(null, null, nfsDataStore); + assertEquals(resultInfo.getStatus(), "error"); + } + + + @Test + public void create_datastore_test_nfsdatastore_with_empty_storageid(){ + NFSDatastore nfsDataStoreStoId = new NFSDatastore(); + nfsDataStoreStoId.setStorageId(""); + ResultInfo resultInfo = datastoreService.create(null, null, nfsDataStoreStoId); + assertEquals(resultInfo.getStatus(), "error"); + } + + @Test + public void create_datastore_test_nfsdatastore_with_storageid(){ + DeviceInfo deviceInfo=null; + NFSDatastore nfsDataStoreStoId = new NFSDatastore(); + nfsDataStoreStoId.setStorageId("storage_1"); + when(deviceRepository.get(nfsDataStoreStoId.getStorageId())).thenReturn(deviceInfo); + ResultInfo resultInfo = datastoreService.create(null, null, nfsDataStoreStoId); + assertEquals(resultInfo.getStatus(), "error"); + } + + +} \ No newline at end of file diff --git a/vmware/vro/plugin/src/test/README.txt b/vmware/vro/plugin/src/test/README.txt new file mode 100644 index 000000000..cfb1cdef9 --- /dev/null +++ b/vmware/vro/plugin/src/test/README.txt @@ -0,0 +1,7 @@ +Unit tests Requirement for VRO +================================ +1. Before running unit tests, make sure you have a working OpenSDS Hotpot environment. +2. Set required fields in //test//resources//config.properties +3. To set volume Id, create a volume in OpenSDS manually and give the volume ID in config.properties +4. Set eclipse project to run unit tests and coverage. +5. Install Junit5 (Java build path -> Librararies -> Add library -> Junit5 \ No newline at end of file diff --git a/vmware/vro/plugin/src/test/java/org/opensds/storage/vro/plugin/adapter/opensds/services/ConfigurationTest.java b/vmware/vro/plugin/src/test/java/org/opensds/storage/vro/plugin/adapter/opensds/services/ConfigurationTest.java new file mode 100644 index 000000000..d4611105b --- /dev/null +++ b/vmware/vro/plugin/src/test/java/org/opensds/storage/vro/plugin/adapter/opensds/services/ConfigurationTest.java @@ -0,0 +1,13 @@ +package org.opensds.storage.vro.plugin.adapter.opensds.services; + +import org.junit.jupiter.api.Test; + +class ConfigurationTest { + + @Test + void testRegister() throws Exception { + Configuration conf = new Configuration("testID", "opensds"); + conf.register("OpenSDS_Test", "127.0.0.1", "50040", "admin", "opensds@123", true, "V1"); + } + +} diff --git a/vmware/vro/plugin/src/test/java/org/opensds/storage/vro/plugin/adapter/opensds/services/OpenSDSInfoTest.java b/vmware/vro/plugin/src/test/java/org/opensds/storage/vro/plugin/adapter/opensds/services/OpenSDSInfoTest.java new file mode 100644 index 000000000..d6f5cce1c --- /dev/null +++ b/vmware/vro/plugin/src/test/java/org/opensds/storage/vro/plugin/adapter/opensds/services/OpenSDSInfoTest.java @@ -0,0 +1,46 @@ +package org.opensds.storage.vro.plugin.adapter.opensds.services; + +import org.junit.jupiter.api.Test; + +class OpenSDSInfoTest { + + @Test + void testOpenSDSInfo() { + OpenSDSInfo OpenSDSInfo = new OpenSDSInfo("testId", "testHostName", "testPort"); + OpenSDSInfo.hashCode(); + OpenSDSInfo.getHostName(); + OpenSDSInfo.getURL(); + OpenSDSInfo.getProductSN(); + OpenSDSInfo.toString(); + } + + @Test + void testEqualsObject() { + OpenSDSInfo OpenSDSInfo = new OpenSDSInfo("testId", "testHostName", "testPort"); + OpenSDSInfo obj = new OpenSDSInfo("testId", "testHostName", "testPort"); + OpenSDSInfo.equals(obj); + } + + @Test + void testNotEqualsObject() { + OpenSDSInfo OpenSDSInfo = new OpenSDSInfo(); + OpenSDSInfo obj = new OpenSDSInfo("testId", "testHostName", "testPort"); + OpenSDSInfo.equals(obj); + } + + @Test + void testBaseArrayInfo() { + BaseArrayInfo baseArray = new BaseArrayInfo("testID", "testHost", "testPort"); + baseArray.getId(); + baseArray.getHostName(); + baseArray.getPassword(); + baseArray.getURL(); + baseArray.getArrayName(); + baseArray.toString(); + baseArray.getProductModel(); + baseArray.getProductName(); + baseArray.getProductVersion(); + + } + +} diff --git a/vmware/vro/plugin/src/test/java/org/opensds/storage/vro/plugin/adapter/opensds/services/VolumeServiceTest.java b/vmware/vro/plugin/src/test/java/org/opensds/storage/vro/plugin/adapter/opensds/services/VolumeServiceTest.java new file mode 100644 index 000000000..f168f0e6c --- /dev/null +++ b/vmware/vro/plugin/src/test/java/org/opensds/storage/vro/plugin/adapter/opensds/services/VolumeServiceTest.java @@ -0,0 +1,66 @@ +package org.opensds.storage.vro.plugin.adapter.opensds.services; + +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.util.Properties; + +import org.junit.jupiter.api.Test; + +class VolumeServiceTest { + private OpenSDSInfo arrayInfo = new OpenSDSInfo("OpenSDS", "test", "50040"); + private String profileId; + private String esxIP; + private String esxIQN; + private String volId; + + public void readDefaultConfig() throws IOException { + System.out.println("Working Directory = " + System.getProperty("user.dir")); + Properties p = new Properties(); + p.load(new FileReader(new File(".\\src\\test\\resources\\config.properties"))); + setOpenSDSInfo(p); + profileId = p.getProperty("ProfileID"); + esxIP = p.getProperty("ESX_IP"); + esxIQN = p.getProperty("ESX_IQN"); + volId = p.getProperty("VOLUME_ID"); + } + + void setOpenSDSInfo(Properties p) { + arrayInfo.setArrayName("OpenSDS"); + arrayInfo.setHostName(p.getProperty("HostIP")); + arrayInfo.setPort(p.getProperty("Port")); + arrayInfo.setPassword(p.getProperty("Password")); + arrayInfo.setUsername(p.getProperty("UserName")); + arrayInfo.setauthEnabled(p.getProperty("AuthEnabled").equals("true") ? true : false); + arrayInfo.setProductModel("V1"); + } + + @Test + void testCreateVolume() throws Exception { + readDefaultConfig(); + VolumeService volumeService = new VolumeService(); + volumeService.createVolume(arrayInfo, "test_script_vol", "test_script_vol", 1, profileId); + } + + @Test + void testcreateAndAttachVolume() throws Exception { + VolumeService volumeService = new VolumeService(); + readDefaultConfig(); + volumeService.createAndAttachVolume(arrayInfo, "attach_vol", "attach volume test", 1, profileId, esxIP, esxIQN); + } + + @Test + void testDeleteVolume() throws Exception { + VolumeService volumeService = new VolumeService(); + readDefaultConfig(); + volumeService.deleteVolume(arrayInfo, volId); + } + + @Test + void testexpandVolume() throws Exception { + VolumeService volumeService = new VolumeService(); + readDefaultConfig(); + volumeService.expandVolume(arrayInfo, volId, 2); + } + +} diff --git a/vmware/vro/plugin/src/test/resources/config.properties b/vmware/vro/plugin/src/test/resources/config.properties new file mode 100644 index 000000000..fc5afdf57 --- /dev/null +++ b/vmware/vro/plugin/src/test/resources/config.properties @@ -0,0 +1,9 @@ +HostIP= +Port=50040 +Password= +UserName= +AuthEnabled=true +ProfileID= +ESX_IP= +ESX_IQN= +VOLUME_ID= \ No newline at end of file