Beispiel #1
0
func TestHeketiVolumeSnapshotBehavior(t *testing.T) {

	// Setup the VM storage topology
	teardownCluster(t)
	setupCluster(t)
	defer teardownCluster(t)

	// Create a volume
	volReq := &api.VolumeCreateRequest{}
	volReq.Size = 1024
	volReq.Durability.Type = api.DurabilityReplicate
	volReq.Durability.Replicate.Replica = 3
	volReq.Snapshot.Enable = true
	volReq.Snapshot.Factor = 1.5

	volInfo, err := heketi.VolumeCreate(volReq)
	tests.Assert(t, err == nil)

	// SSH into system and execute gluster command to create a snapshot
	exec := ssh.NewSshExecWithKeyFile(logger, "vagrant", "../config/insecure_private_key")
	cmd := []string{
		fmt.Sprintf("sudo gluster --mode=script snapshot create mysnap %v no-timestamp", volInfo.Name),
		"sudo gluster --mode=script snapshot activate mysnap",
	}
	_, err = exec.ConnectAndExec("192.168.10.100:22", cmd, 10, true)
	tests.Assert(t, err == nil, err)

	// Try to delete the volume
	err = heketi.VolumeDelete(volInfo.Id)
	tests.Assert(t, err != nil, err)

	// Now clean up the snapshot
	cmd = []string{
		"sudo gluster --mode=script snapshot deactivate mysnap",
		"sudo gluster --mode=script snapshot delete mysnap",
	}
	_, err = exec.ConnectAndExec("192.168.10.100:22", cmd, 10, true)
	tests.Assert(t, err == nil, err)

	// Try to delete the volume
	err = heketi.VolumeDelete(volInfo.Id)
	tests.Assert(t, err == nil, err)
}
Beispiel #2
0
type SshConfig struct {
	PrivateKeyFile string `json:"keyfile"`
	User           string `json:"user"`
	Port           string `json:"port"`
	Fstab          string `json:"fstab"`

	// Experimental Settings
	RebalanceOnExpansion bool `json:"rebalance_on_expansion"`
}

var (
	logger           = utils.NewLogger("[sshexec]", utils.LEVEL_DEBUG)
	ErrSshPrivateKey = errors.New("Unable to read private key file")
	sshNew           = func(logger *utils.Logger, user string, file string) (Ssher, error) {
		s := ssh.NewSshExecWithKeyFile(logger, user, file)
		if s == nil {
			return nil, ErrSshPrivateKey
		}
		return s, nil
	}
)

func NewSshExecutor(config *SshConfig) (*SshExecutor, error) {
	godbc.Require(config != nil)

	s := &SshExecutor{}
	s.RemoteExecutor = s
	s.Throttlemap = make(map[string]chan bool)

	// Set configuration