github.com/altoros/juju-vmware@v0.0.0-20150312064031-f19ae857ccca/provider/common/util.go (about)

     1  // Copyright 2014 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package common
     5  
     6  import (
     7  	"fmt"
     8  
     9  	"github.com/juju/names"
    10  
    11  	"github.com/juju/juju/environs"
    12  )
    13  
    14  // EnvFullName returns a string based on the provided environment
    15  // that is suitable for identifying the env on a provider.
    16  func EnvFullName(env environs.Environ) string {
    17  	envUUID, _ := env.Config().UUID() // Env should have validated this.
    18  	return fmt.Sprintf("juju-%s", envUUID)
    19  }
    20  
    21  // MachineFullName returns a string based on the provided environment
    22  // and machine ID that is suitable for identifying instances on a
    23  // provider.
    24  func MachineFullName(env environs.Environ, machineId string) string {
    25  	envstr := EnvFullName(env)
    26  	machineTag := names.NewMachineTag(machineId)
    27  	return fmt.Sprintf("%s-%s", envstr, machineTag)
    28  }