github.com/niedbalski/juju@v0.0.0-20190215020005-8ff100488e47/provider/common/disk.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 jujuos "github.com/juju/os" 8 jujuseries "github.com/juju/os/series" 9 ) 10 11 // MinRootDiskSizeGiB is the minimum size for the root disk of an 12 // instance, in Gigabytes. This value accommodates the anticipated 13 // size of the initial image, any updates, and future application 14 // data. 15 func MinRootDiskSizeGiB(series string) uint64 { 16 // See comment below that explains why we're ignoring the error 17 os, _ := jujuseries.GetOSFromSeries(series) 18 switch os { 19 case jujuos.Ubuntu, jujuos.CentOS, jujuos.OpenSUSE: 20 return 8 21 case jujuos.Windows: 22 return 40 23 // By default we just return a "sane" default, since the error will just 24 // be returned by the api and seen in juju status 25 default: 26 return 8 27 } 28 } 29 30 // MiBToGiB converts the provided megabytes (base-2) into the nearest 31 // gigabytes (base-2), rounding up. This is useful for providers that 32 // deal in gigabytes (while juju deals in megabytes). 33 func MiBToGiB(m uint64) uint64 { 34 return (m + 1023) / 1024 35 }