github.com/cloud-green/juju@v0.0.0-20151002100041-a00291338d3d/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/juju/environs" 10 ) 11 12 // EnvFullName returns a string based on the provided environment 13 // that is suitable for identifying the env on a provider. The resulting 14 // string clearly associates the value with juju, whereas the 15 // environment's UUID alone isn't very distinctive for humans. This 16 // benefits users by helping them quickly identify in their hosting 17 // management tools which instances are juju related. 18 func EnvFullName(env environs.Environ) string { 19 envUUID, _ := env.Config().UUID() // Env should have validated this. 20 return fmt.Sprintf("juju-%s", envUUID) 21 } 22 23 // MachineFullName returns a string based on the provided environment 24 // and machine ID that is suitable for identifying instances on a 25 // provider. See EnvFullName for an explanation on how this function 26 // helps juju users. 27 func MachineFullName(env environs.Environ, machineID string) string { 28 envstr := EnvFullName(env) 29 return fmt.Sprintf("%s-machine-%s", envstr, machineID) 30 }