-
Notifications
You must be signed in to change notification settings - Fork 88
/
object_manager_apps.go
55 lines (50 loc) · 1.33 KB
/
object_manager_apps.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
44
45
46
47
48
49
50
51
52
53
54
55
package ibclient
import "fmt"
func (objMgr *ObjectManager) GetDnsMember(ref string) ([]Dns, error) {
var res []Dns
queryParams := NewQueryParams(false, nil)
dns := NewDns(Dns{})
err := objMgr.connector.GetObject(dns, ref, queryParams, &res)
if err != nil {
return nil, err
} else if res == nil || len(res) == 0 {
return nil, NewNotFoundError(
fmt.Sprintf(
"could not find any node"))
}
return res, nil
}
func (objMgr *ObjectManager) GetDhcpMember(ref string) ([]Dhcp, error) {
var res []Dhcp
queryParams := NewQueryParams(false, nil)
dhcp := NewDhcp(Dhcp{})
err := objMgr.connector.GetObject(dhcp, ref, queryParams, &res)
if err != nil {
return nil, err
} else if res == nil || len(res) == 0 {
return nil, NewNotFoundError(
fmt.Sprintf(
"could not find ny node"))
}
return res, nil
}
func (objMgr *ObjectManager) UpdateDnsStatus(ref string, status bool) (Dns, error) {
dns := NewDns(Dns{})
dns.EnableDns = status
resp, err := objMgr.connector.UpdateObject(dns, ref)
if err != nil {
return *dns, err
}
dns.Ref = resp
return *dns, nil
}
func (objMgr *ObjectManager) UpdateDhcpStatus(ref string, status bool) (Dhcp, error) {
dhcp := NewDhcp(Dhcp{})
dhcp.EnableDhcp = status
resp, err := objMgr.connector.UpdateObject(dhcp, ref)
if err != nil {
return *dhcp, err
}
dhcp.Ref = resp
return *dhcp, nil
}