Skip to content
This repository has been archived by the owner on Nov 9, 2020. It is now read-only.

Commit

Permalink
[E2E] Validation after admincli vmgroup and config ops (#1568)
Browse files Browse the repository at this point in the history
* Validation after admincli vmgroup and config ops
  • Loading branch information
Shahzeb Patel authored Jul 11, 2017
1 parent 6184b1b commit 0d677c2
Showing 1 changed file with 58 additions and 6 deletions.
64 changes: 58 additions & 6 deletions tests/utils/admincli/vmgroupmgmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,55 @@
package admincli

import (
"fmt"
"log"
"strings"
"fmt"

"github.com/vmware/docker-volume-vsphere/tests/constants/admincli"
"github.com/vmware/docker-volume-vsphere/tests/utils/ssh"
)

// CreateVMgroup method is going to create a vmgroup and adds vm to it.
func CreateVMgroup(ip, name, vmName, dsName string) (string, error) {
log.Printf("Creating a vmgroup [%s] on esx [%s]\n", name, ip)
return ssh.InvokeCommand(ip, admincli.CreateVMgroup+name+" --default-datastore="+dsName+admincli.VMlist+vmName)
out, err := ssh.InvokeCommand(ip, admincli.CreateVMgroup+name+" --default-datastore="+dsName+admincli.VMlist+vmName)

if err != nil {
return out, err
}

// Verify the vmgroup creation
if IsVmgroupPresent(ip, name) {
return out, nil
}

msg := "Could not verify presence of vmgroup " + name + " on esx " + ip
return msg, fmt.Errorf(msg)

}

// DeleteVMgroup method deletes a vmgroup and removes its volumes as well if "delete_vol" is set
func DeleteVMgroup(ip, name string, delete_vol bool) (string, error) {
log.Printf("Deleting a vmgroup [%s] on esx [%s] with delete_vol[%d]\n", name, ip, delete_vol)
var out string
var err error
if delete_vol {
return ssh.InvokeCommand(ip, admincli.RemoveVMgroup+name+admincli.RemoveVolumes)
out, err = ssh.InvokeCommand(ip, admincli.RemoveVMgroup+name+admincli.RemoveVolumes)
} else {
return ssh.InvokeCommand(ip, admincli.RemoveVMgroup+name)
out, err = ssh.InvokeCommand(ip, admincli.RemoveVMgroup+name)
}

if err != nil {
return out, err
}

// Verify the vmgroup removal
if IsVmgroupPresent(ip, name) != true {
return out, nil
}

msg := "Could not verify removal of vmgroup " + name + " on esx " + ip
return msg, fmt.Errorf(msg)
}

// AddVMToVMgroup - Adds vm to vmgroup
Expand Down Expand Up @@ -93,13 +121,37 @@ func ConfigInit(ip string) (string, error) {
}

log.Printf("Initializing the SingleNode Config DB on esx [%s] \n", ip)
return ssh.InvokeCommand(ip, admincli.InitLocalConfigDb)
out, err := ssh.InvokeCommand(ip, admincli.InitLocalConfigDb)

if err != nil {
return out, err
}

// verify the DB init
if GetDBmode(ip) == admincli.DBSingleNode {
return out, nil
}

msg := "Could not init DB to SingleNode on esx " + ip
return msg, fmt.Errorf(msg)
}

// ConfigRemove - Remove the (local) Single Node Config DB
func ConfigRemove(ip string) (string, error) {
log.Printf("Removing the SingleNode Config DB on esx [%s] \n", ip)
return ssh.InvokeCommand(ip, admincli.RemoveLocalConfigDb)
out, err := ssh.InvokeCommand(ip, admincli.RemoveLocalConfigDb)

if err != nil {
return out, err
}

// verify the DB removal
if GetDBmode(ip) == admincli.DBNotConfigured {
return out, nil
}

msg := "Could not remove DB on esx " + ip
return msg, fmt.Errorf(msg)
}

// IsVmgroupPresent - checks for a vmgroup in list of vmgroups
Expand Down

0 comments on commit 0d677c2

Please sign in to comment.