forked from juju/juju
-
Notifications
You must be signed in to change notification settings - Fork 0
/
disk.go
35 lines (31 loc) · 1.07 KB
/
disk.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright 2014 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package common
import (
jujuos "github.com/juju/juju/core/os"
jujuseries "github.com/juju/juju/core/series"
)
// MinRootDiskSizeGiB is the minimum size for the root disk of an
// instance, in Gigabytes. This value accommodates the anticipated
// size of the initial image, any updates, and future application
// data.
func MinRootDiskSizeGiB(series string) uint64 {
// See comment below that explains why we're ignoring the error
os, _ := jujuseries.GetOSFromSeries(series)
switch os {
case jujuos.Ubuntu, jujuos.CentOS, jujuos.OpenSUSE:
return 8
case jujuos.Windows:
return 40
// By default we just return a "sane" default, since the error will just
// be returned by the api and seen in juju status
default:
return 8
}
}
// MiBToGiB converts the provided megabytes (base-2) into the nearest
// gigabytes (base-2), rounding up. This is useful for providers that
// deal in gigabytes (while juju deals in megabytes).
func MiBToGiB(m uint64) uint64 {
return (m + 1023) / 1024
}