...
1
2
3 package hcs
4
5 import (
6 "context"
7 "encoding/json"
8
9 hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2"
10 "github.com/Microsoft/hcsshim/internal/vmcompute"
11 )
12
13
14 func GetServiceProperties(ctx context.Context, q hcsschema.PropertyQuery) (*hcsschema.ServiceProperties, error) {
15 operation := "hcs::GetServiceProperties"
16
17 queryb, err := json.Marshal(q)
18 if err != nil {
19 return nil, err
20 }
21 propertiesJSON, resultJSON, err := vmcompute.HcsGetServiceProperties(ctx, string(queryb))
22 events := processHcsResult(ctx, resultJSON)
23 if err != nil {
24 return nil, &HcsError{Op: operation, Err: err, Events: events}
25 }
26
27 if propertiesJSON == "" {
28 return nil, ErrUnexpectedValue
29 }
30 properties := &hcsschema.ServiceProperties{}
31 if err := json.Unmarshal([]byte(propertiesJSON), properties); err != nil {
32 return nil, err
33 }
34 return properties, nil
35 }
36
37
38 func ModifyServiceSettings(ctx context.Context, settings hcsschema.ModificationRequest) error {
39 operation := "hcs::ModifyServiceSettings"
40
41 settingsJSON, err := json.Marshal(settings)
42 if err != nil {
43 return err
44 }
45 resultJSON, err := vmcompute.HcsModifyServiceSettings(ctx, string(settingsJSON))
46 events := processHcsResult(ctx, resultJSON)
47 if err != nil {
48 return &HcsError{Op: operation, Err: err, Events: events}
49 }
50 return nil
51 }
52
View as plain text