Skip to content

Commit

Permalink
Add return_fields, use cidr to get fixed address
Browse files Browse the repository at this point in the history
1) Added return_fields so that all fields supported by go objects are
returned by Infoblox.

2) Allow specifying Cidr when searching for fixed address in Infoblox.
  • Loading branch information
yuewko committed Jul 13, 2016
1 parent 9d1c008 commit 6ca1547
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
19 changes: 7 additions & 12 deletions object_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,19 +240,14 @@ func (objMgr *ObjectManager) AllocateNetwork(netview string, cidr string, prefix
return
}

func (objMgr *ObjectManager) GetFixedAddress(netview string, ipAddr string, macAddr string) (*FixedAddress, error) {
func (objMgr *ObjectManager) GetFixedAddress(netview string, cidr string, ipAddr string, macAddr string) (*FixedAddress, error) {
var res []FixedAddress

fixedAddr := NewFixedAddress(FixedAddress{
NetviewName: netview})

if ipAddr != "" {
fixedAddr.IPAddress = ipAddr
}

if macAddr != "" {
fixedAddr.Mac = macAddr
}
NetviewName: netview,
Cidr: cidr,
IPAddress: ipAddr,
Mac: macAddr})

err := objMgr.connector.GetObject(fixedAddr, "", &res)

Expand All @@ -263,9 +258,9 @@ func (objMgr *ObjectManager) GetFixedAddress(netview string, ipAddr string, macA
return &res[0], nil
}

func (objMgr *ObjectManager) ReleaseIP(netview string, ipAddr string, macAddr string) (string, error) {
func (objMgr *ObjectManager) ReleaseIP(netview string, cidr string, ipAddr string, macAddr string) (string, error) {
fmt.Printf("ReleaseIP called: '%s', '%s', '%s'\n", netview, ipAddr, macAddr)
fixAddress, _ := objMgr.GetFixedAddress(netview, ipAddr, macAddr)
fixAddress, _ := objMgr.GetFixedAddress(netview, cidr, ipAddr, macAddr)
fmt.Printf("GetFixedAddress() returns: '%s'\n", fixAddress)

if fixAddress == nil {
Expand Down
6 changes: 5 additions & 1 deletion objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ type NetworkView struct {
func NewNetworkView(nv NetworkView) *NetworkView {
res := nv
res.objectType = "networkview"
res.returnFields = []string{"extattrs", "name"}

return &res
}
Expand All @@ -61,7 +62,7 @@ type Network struct {
func NewNetwork(nw Network) *Network {
res := nw
res.objectType = "network"
res.returnFields = []string{"extattrs", "network_view", "network"}
res.returnFields = []string{"extattrs", "network", "network_view"}

return &res
}
Expand All @@ -77,6 +78,7 @@ type NetworkContainer struct {
func NewNetworkContainer(nc NetworkContainer) *NetworkContainer {
res := nc
res.objectType = "networkcontainer"
res.returnFields = []string{"extattrs", "network", "network_view"}

return &res
}
Expand All @@ -94,6 +96,7 @@ type FixedAddress struct {
func NewFixedAddress(fixedAddr FixedAddress) *FixedAddress {
res := fixedAddr
res.objectType = "fixedaddress"
res.returnFields = []string{"extattrs", "ipv4addr", "mac", "network", "network_view"}

return &res
}
Expand All @@ -112,6 +115,7 @@ type EADefinition struct {
func NewEADefinition(eadef EADefinition) *EADefinition {
res := eadef
res.objectType = "extensibleattributedef"
res.returnFields = []string{"allowed_object_types", "comment", "flags", "list_values", "name", "type"}

return &res
}
Expand Down

0 comments on commit 6ca1547

Please sign in to comment.