Skip to content

Commit

Permalink
Merge pull request #55 from akhiljns/ipfindFix
Browse files Browse the repository at this point in the history
Ipfind fix
  • Loading branch information
mhewedy authored Apr 8, 2024
2 parents c5829fd + c2f8821 commit 9918b92
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 17 deletions.
11 changes: 6 additions & 5 deletions cmd/scp/scp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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
}
Expand All @@ -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
}
Expand All @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion provisioners/ansible.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
7 changes: 4 additions & 3 deletions vms/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package vms

import (
"fmt"

"github.com/mhewedy/vermin/hypervisor"
"github.com/mhewedy/vermin/ip"
)
Expand All @@ -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
}
Expand All @@ -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
}
Expand All @@ -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
}
Expand Down
17 changes: 9 additions & 8 deletions vms/vms.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ package vms
import (
"errors"
"fmt"
"os"
"strings"

"github.com/mhewedy/vermin/cmd/scp"
"github.com/mhewedy/vermin/cmd/ssh"
"github.com/mhewedy/vermin/db"
"github.com/mhewedy/vermin/hypervisor"
"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 {
Expand All @@ -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 {
Expand All @@ -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)
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 9918b92

Please sign in to comment.