forked from microsoft/hcsshim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetcomputesystemproperties.go
43 lines (35 loc) · 1.05 KB
/
getcomputesystemproperties.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
36
37
38
39
40
41
42
43
package hcsshim
import (
"encoding/json"
"github.com/Sirupsen/logrus"
)
// ComputeSystemProperties is a struct describing the returned properties.
type ComputeSystemProperties struct {
ID string
Name string
Stopped bool
AreUpdatesPending bool
}
// GetComputeSystemProperties gets the properties for the compute system with the given ID.
func GetComputeSystemProperties(id string, flags uint32) (ComputeSystemProperties, error) {
title := "hcsshim::GetComputeSystemProperties "
csProps := ComputeSystemProperties{
Stopped: false,
AreUpdatesPending: false,
}
logrus.Debugf("Calling proc")
var buffer *uint16
err := getComputeSystemProperties(id, flags, &buffer)
if err != nil {
err = makeError(err, title, "")
logrus.Error(err)
return csProps, err
}
propData := convertAndFreeCoTaskMemString(buffer)
logrus.Debugf(title+" - succeeded output=%s", propData)
if err = json.Unmarshal([]byte(propData), &csProps); err != nil {
logrus.Error(err)
return csProps, err
}
return csProps, nil
}