Created
          December 5, 2015 22:16 
        
      - 
      
- 
        Save dave-tucker/b7928cfbe1c8a4549858 to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | package main | |
| import ( | |
| "fmt" | |
| log "github.com/Sirupsen/logrus" | |
| "github.com/docker/machine/commands/mcndirs" | |
| "github.com/docker/machine/libmachine" | |
| ) | |
| func GetMachines() error { | |
| api := libmachine.GetDefaultStore() | |
| api.Path = mcndirs.GetBaseDir() | |
| log.Info("Listing machines") | |
| machines, err := api.List() | |
| if err != nil { | |
| return err | |
| } | |
| if len(machines) == 0 { | |
| return fmt.Errorf("no machines!") | |
| } | |
| log.Info("Getting host IPs...") | |
| for m := range machines { | |
| ip, err := machines[m].Driver.GetIP() | |
| if err != nil { | |
| return err | |
| } | |
| log.Infof("IP: %s", ip) | |
| } | |
| return nil | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment