Skip to content

Commit

Permalink
Disk key give the size of the disk
Browse files Browse the repository at this point in the history
Disk key should give the size of the first disk in GB, not the number of hard
drive. During the nova boot, nova will compare this value with the
minimal mandatory size associated with the Glance image.

Without this patch, nova will always fail and returns the "no valid host was found"
message as soon as the size is greater than 1.
  • Loading branch information
goneri committed Dec 30, 2015
1 parent 5d90574 commit f36b90a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ yields (without logging output):
],
"cpu": "12",
"memory": "98304",
"disk": "7",
"disk": "500",
"arch": "x86_64"
},
{
Expand All @@ -41,7 +41,7 @@ yields (without logging output):
],
"cpu": "16",
"memory": "131072",
"disk": "0",
"disk": "500",
"arch": "x86_64"
},
{
Expand All @@ -59,7 +59,7 @@ yields (without logging output):
],
"cpu": "20",
"memory": "98304",
"disk": "1",
"disk": "1200",
"arch": "x86_64"
}
]
Expand Down
23 changes: 17 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,19 @@ func getDisk(client *wsman.Client) string {
log.Printf("Error getting disks: %v\n", err)
return "-1"
}
vds := search.All(search.Tag("DCIM_VirtualDiskView", "*"), res.AllBodyElements())
return strconv.Itoa(len(vds))
vd := search.First(search.Tag("DCIM_VirtualDiskView", "*"), res.AllBodyElements())
if vd == nil {
log.Printf("Error getting first disk information\n")
return "-1"
}
sizeBytes := search.First(search.Tag("SizeInBytes", "*"), vd.Children())
if sizeBytes == nil {
log.Printf("Error getting first disk size\n")
return "-1"
}
count, err := strconv.Atoi(string(sizeBytes.Content))
sizeGBytes := count / (1024 * 1024 * 1024)
return strconv.Itoa(sizeGBytes)
}

func getCPU(client *wsman.Client) string {
Expand Down Expand Up @@ -152,15 +163,15 @@ func getBootNic(client *wsman.Client, nics []*dom.Element) *dom.Element {
os.Exit(1)
}
fqdd := string(n.Content) // Only care about integrated nics
if ! strings.HasPrefix(fqdd, "NIC.Integrated.") {
log.Printf("%s is not integrated, skipping\n",fqdd)
if !strings.HasPrefix(fqdd, "NIC.Integrated.") {
log.Printf("%s is not integrated, skipping\n", fqdd)
continue
}
speed := search.First(search.Tag("LinkSpeed","*"),nic.Children())
speed := search.First(search.Tag("LinkSpeed", "*"), nic.Children())
// If there is not speed setting, then the server is too old to report it.
// Happily enough, that also means it is too old for 10 gig ports to be a thing.
if speed != nil && string(speed.Content) != "3" {
log.Printf("%s is not a gigabit Ethernet port\n",fqdd)
log.Printf("%s is not a gigabit Ethernet port\n", fqdd)
continue
}
fqdds = append(fqdds, fqdd)
Expand Down

0 comments on commit f36b90a

Please sign in to comment.