diff --git a/cmd/scp/scp.go b/cmd/scp/scp.go index 0b55622..c24cbd4 100644 --- a/cmd/scp/scp.go +++ b/cmd/scp/scp.go @@ -2,10 +2,11 @@ package scp import ( "errors" + "strings" + "github.com/mhewedy/vermin/cmd" "github.com/mhewedy/vermin/db" "github.com/mhewedy/vermin/ip" - "strings" ) const ( @@ -45,7 +46,7 @@ func toVmPath(srcDest string) (vmPath, bool) { } func copyFromVM(vmPath vmPath, localFile string) error { - ipAddr, err := ip.Find(vmPath.name, false) + ipAddr, err := ip.GetIpAddress(vmPath.name) if err != nil { return err } @@ -55,7 +56,7 @@ func copyFromVM(vmPath vmPath, localFile string) error { } func copyToVM(localFile string, vmPath vmPath) error { - ipAddr, err := ip.Find(vmPath.name, false) + ipAddr, err := ip.GetIpAddress(vmPath.name) if err != nil { return err } @@ -66,12 +67,12 @@ func copyToVM(localFile string, vmPath vmPath) error { func copyBetweenVMs(srcVmPath vmPath, destVmPath vmPath) error { - srcIPAddr, err := ip.Find(srcVmPath.name, false) + srcIPAddr, err := ip.GetIpAddress(srcVmPath.name) if err != nil { return err } - destIPAddr, err := ip.Find(destVmPath.name, false) + destIPAddr, err := ip.GetIpAddress(destVmPath.name) if err != nil { return err } diff --git a/provisioners/ansible.go b/provisioners/ansible.go index 5ad5fdb..bfcad17 100644 --- a/provisioners/ansible.go +++ b/provisioners/ansible.go @@ -13,7 +13,7 @@ func (Ansible) Accept(ptype string) bool { func (Ansible) Exec(vmName string, script string) error { - ipAddr, err := ip.Find(vmName, false) + ipAddr, err := ip.GetIpAddress(vmName) if err != nil { return err } diff --git a/vms/mount.go b/vms/mount.go index 6424449..f67d5a4 100644 --- a/vms/mount.go +++ b/vms/mount.go @@ -2,6 +2,7 @@ package vms import ( "fmt" + "github.com/mhewedy/vermin/hypervisor" "github.com/mhewedy/vermin/ip" ) @@ -12,7 +13,7 @@ var ( ) func Unmount(vmName string) error { - ipAddr, err := ip.Find(vmName, false) + ipAddr, err := ip.GetIpAddress(vmName) if err != nil { return err } @@ -25,7 +26,7 @@ func Unmount(vmName string) error { } func Mount(vmName, hostPath, guestPath string) error { - ipAddr, err := ip.Find(vmName, false) + ipAddr, err := ip.GetIpAddress(vmName) if err != nil { return err } @@ -38,7 +39,7 @@ func Mount(vmName, hostPath, guestPath string) error { } func ListMounts(vmName string) (string, error) { - ipAddr, err := ip.Find(vmName, false) + ipAddr, err := ip.GetIpAddress(vmName) if err != nil { return "", err } diff --git a/vms/vms.go b/vms/vms.go index 95fe262..890dedd 100644 --- a/vms/vms.go +++ b/vms/vms.go @@ -3,6 +3,9 @@ package vms import ( "errors" "fmt" + "os" + "strings" + "github.com/mhewedy/vermin/cmd/scp" "github.com/mhewedy/vermin/cmd/ssh" "github.com/mhewedy/vermin/db" @@ -10,8 +13,6 @@ import ( "github.com/mhewedy/vermin/images" "github.com/mhewedy/vermin/ip" "github.com/mhewedy/vermin/progress" - "os" - "strings" ) func Tag(vmName string, tag string, remove bool) error { @@ -31,7 +32,7 @@ func Start(vmName string) error { } if isRunningVM(vmName) { - return fmt.Errorf(`VM already running, use "vermin ssh %s" to ssh into the VM.`, vmName) + return fmt.Errorf(`vm already running, use "vermin ssh %s" to ssh into the VM`, vmName) } if err := start(vmName); err != nil { @@ -46,7 +47,7 @@ func Stop(vmName string) error { } if !isRunningVM(vmName) { - return fmt.Errorf(`VM already stopped, use "vermin start %s" to start the VM.`, vmName) + return fmt.Errorf(`vm already stopped, use "vermin start %s" to start the VM`, vmName) } progress.Immediate("Stopping", vmName) @@ -89,7 +90,7 @@ func Exec(vmName string, cmd string) error { func Remove(vmName string, force bool) error { if !force && isRunningVM(vmName) { - return errors.New("Cannot stop running VM, use -f flag to force remove") + return errors.New("cannot stop running VM, use -f flag to force remove") } if err := checkVM(vmName); err != nil { @@ -153,12 +154,12 @@ func IP(vmName string, purge bool, global bool) (string, error) { return "", err } } - return ip.Find(vmName, purge) + return ip.GetIpAddress(vmName) } func Modify(vmName string, cpus int, mem int) error { if isRunningVM(vmName) { - return fmt.Errorf(`Cannot Modify running VM, use "vermin stop %s" to stop the VM first.`, vmName) + return fmt.Errorf(`cannot modify running VM, use "vermin stop %s" to stop the VM first`, vmName) } return hypervisor.Modify(vmName, cpus, mem) @@ -183,7 +184,7 @@ func Commit(vmName, imageName string, override bool) error { } if isRunningVM(vmName) { - return fmt.Errorf(`VM is running, use "vermin stop %s" to stop the VM before commiting image from it.`, vmName) + return fmt.Errorf(`vm is running, use "vermin stop %s" to stop the VM before commiting image from it`, vmName) } return images.Commit(vmName, imageName, override)