GithubHelp home page GithubHelp logo

infoblox-go-client's Introduction

Infoblox Go Client

An Infoblox NIOS WAPI client library in Golang. The library enables us to do a CRUD oprations on NIOS Objects.

This library is compatible with Go 1.2+

Build Status

Build Status

Prerequisites

  • Infoblox GRID with 2.9 or above WAPI support
  • Go 1.21 or above

Installation

To get the latest released version v2.7.0 of Go Client use below command.

go get github.com/infobloxopen/infoblox-go-client/v2

To get the previous major version v1.1.1 use below command.

go get github.com/infobloxopen/infoblox-go-client

Note: Go client version v2.0.0 and above have breaking changes and are not backward compatible.

Usage

The following is a very simple example for the client usage:

   package main

   import (
     "fmt"
     ibclient "github.com/infobloxopen/infoblox-go-client/v2"
   )

   func main() {
     hostConfig := ibclient.HostConfig{
        Scheme:  "https",
     	Host:    "<NIOS grid IP>",
        Version: "<WAPI version>",
        Port:    "PORT",
     }
     authConfig := ibclient.AuthConfig{
        Username: "username",
        Password: "password",
     }
     transportConfig := ibclient.NewTransportConfig("false", 20, 10)
     requestBuilder := &ibclient.WapiRequestBuilder{}
     requestor := &ibclient.WapiHttpRequestor{}
     conn, err := ibclient.NewConnector(hostConfig, authConfig, transportConfig, requestBuilder, requestor)
     if err != nil {
     	fmt.Println(err)
     }
     defer conn.Logout()
     objMgr := ibclient.NewObjectManager(conn, "myclient", "")
     //Fetches grid information
     fmt.Println(objMgr.GetGridLicense())
   } 

Supported NIOS operations

  • AllocateIP
  • AllocateNetwork
  • AllocateNetworkContainer
  • CreateARecord
  • CreateAAAARecord
  • CreateZoneAuth
  • CreateCNAMERecord
  • CreateDefaultNetviews
  • CreateZoneForward
  • CreateEADefinition
  • CreateHostRecord
  • CreateNetwork
  • CreateNetworkContainer
  • CreateNetworkView
  • CreatePTRRecord
  • CreateTXTRecord
  • CreateZoneDelegated
  • DeleteARecord
  • DeleteAAAARecord
  • DeleteZoneAuth
  • DeleteZoneForward
  • DeleteCNAMERecord
  • DeleteFixedAddress
  • DeleteHostRecord
  • DeleteNetwork
  • DeleteNetworkView
  • DeletePTRRecord
  • DeleteTXTRecord
  • DeleteZoneDelegated
  • GetAllMembers
  • GetARecordByRef
  • GetARecord
  • GetAAAARecordByRef
  • GetAAAARecord
  • GetCapacityReport
  • GetCNAMERecordByRef
  • GetCNAMERecord
  • GetDhcpMember
  • GetDnsMember
  • GetEADefinition
  • GetFixedAddress
  • GetFixedAddressByRef
  • GetHostRecord
  • GetHostRecordByRef
  • SearchHostRecordByAltId
  • SearchObjectByAltId
  • GetIpAddressFromHostRecord
  • GetNetwork
  • GetNetworkByRef
  • GetNetworkContainer
  • GetNetworkContainerByRef
  • GetNetworkView
  • GetNetworkViewByRef
  • GetPTRRecordByRef
  • GetPTRRecord
  • GetTXTRecord
  • GetTXTRecordByRef
  • GetZoneAuthByRef
  • GetZoneDelegated
  • GetUpgradeStatus (2.7 or above)
  • GetAllMembers
  • GetZoneForwardByRef
  • GetZoneForwardFilters
  • GetGridInfo
  • GetGridLicense
  • ReleaseIP
  • UpdateAAAARecord
  • UpdateCNAMERecord
  • UpdateDhcpStatus
  • UpdateDnsStatus
  • UpdateFixedAddress
  • UpdateHostRecord
  • UpdateNetwork
  • UpdateNetworkContainer
  • UpdateNetworkView
  • UpdatePTRRecord
  • UpdateTXTRecord
  • UpdateARecord
  • UpdateZoneDelegated
  • UpdateZoneForward

infoblox-go-client's People

Contributors

achernevskii avatar adsri avatar ajeyhiremath avatar akshay8 avatar anagha-infoblox avatar avrajath avatar chinmayb avatar dhawal55 avatar eest avatar gfenn-newbury avatar hemanthka677 avatar jkraj avatar johnbelamaric avatar khrisrichardson avatar martinweindel avatar mhermida avatar ngarratt avatar r0fls avatar ranjishmp avatar rhossili avatar saiprasannasastry avatar sdas-infoblox avatar shadtimm avatar skudriavtsev avatar smalisetti-infoblox avatar somashekhar avatar survivorbat avatar szuecs avatar ytsarev avatar yuewko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

infoblox-go-client's Issues

Example usage: Set DHCP options

Would it be possible for you to provide an example of the following

Using the API to create a network , set the specific DHCP options of that network (router, DNS servers, domain etc) set the member servers for that DHCP scope and define a range within the scope . How do I gracefully handle a network that already exists , the Python low level API has an update_if_exists flag which is useful

network = objects.Network.create(conn, network_view='default', cidr=cidr,update_if_exists=True,options=options,members=dhcp_members)
package main

import (
	"fmt"

	ibclient "github.com/infobloxopen/infoblox-go-client"
)

func main() {
	hostConfig := ibclient.HostConfig{
		Host:     "XXXXXXXX",
		Version:  "2.2",
		Port:     "443",
		Username: "XXXXXX",
		Password: "XXXXXXX",
	}
	transportConfig := ibclient.NewTransportConfig("false", 20, 10)
	requestBuilder := &ibclient.WapiRequestBuilder{}
	requestor := &ibclient.WapiHttpRequestor{}
	conn, err := ibclient.NewConnector(hostConfig, transportConfig, requestBuilder, requestor)
	if err != nil {
		fmt.Println(err)
	}
	defer conn.Logout()

	// No idea what the cmp type or what my tenant id id , so need to work on that
	objMgr := ibclient.NewObjectManager(conn, "", "")

	//Fetches grid information
	fmt.Println(objMgr.GetFixedAddressByRef("fixedaddress/ZG5zLmZpeGVkX2FkZHJlc3MkMTAuMy4yNi4xMDEuMC4u:10.3.26.101/default"))

	net, err := objMgr.CreateNetwork("default", "10.200.0.0/16", false, "Azure prefix (testing)", nil)
	
	if err != nil {
		fmt.Println(err)
	}
	fmt.Print(net)
	fmt.Print(net.ReturnFields())

Not possible to set query parameters like _max_results

Since its not possible to set _max_results as query parameter, it is not possible to get records from a zone with more than 1000 records. It fails with the following error:

... 2018-11-23T12:00:00.000000Z info WAPI request error: 400('400 Bad Request') Contents: { "Error": "AdmConProtoError: Result set too large (> 1000)", "code": "Client.Ibap.Proto", "text": "Result set too large (> 1000)" } ...

Further it takes a long time until GetObject returns, since it tries to get the records four times (2x makeRequest in GetObject and 2x SendRequest in makeRequest).

So it would be nice if the following things get fixed:

  1. Allow to set Query Parameters like _max_results and so on
  2. Abort after the first failed request

`develop` branch can be removed

A request has been made by community users and developers to remove develop branch and maintain only master branch. Since it created more confusion and also considerable efforts to maintain 2 branches.

Support Pagination

I'm leveraging this library for a usecase that wants to perform large bulk queries against the database which may return more than 1000 results; GetObject has no pagination support as written, making large response sets a firm error case in the client.

Would love a paginated GetObject.

Kind request for a release

Could you pretty please cut a new release so that we don't have to depend on a git sha? We need the GetTXTRecord method, but it's missing in 2.1.0

information about ip address

I want to be able to search the IPAM database for information about an IP address or hostname. For example:

GET  /wapi/2.9/ipv4address?ip_address=10.0.14.9

I can't find a way to do that with the object manager. Is there a way to do this?

If not, would you be open to a PR to add it?

CHANGELOG.md

Can we get an changelog for the project to track the features/bug fixes going into each release.

GetObject forces proxy on HTTP 200 status and no payload

Seeing an issue where we are trying to query the comment field for FixedAddress using GetObject. The comment is non-existent. The response is good (200) but there's no data (which is correct) but the client sets queryParams.forceProxy = true and loops on. Shouldn't
GetObject() allow len(resp) to be 0 instead of forcing proxy?

---------------- REQ ------------------
GET /wapi/v2.3.1/fixedaddress?_return_fields=extattrs%2Cipv4addr%2Cmac%2Cname%2Cnetwork%2Cnetwork_view%2Ccomment HTTP/1.1
Host: 10.16.129.188:443
Authorization: Basic YWRtaW46ZW9zcGx1cw==
Content-Type: application/json

{"network_view":"view1","network":"10.153.200.0/31","comment":"bogus"}
-----------------------
----------------RESP ------------------
HTTP/1.1 200 OK
Connection: close
Transfer-Encoding: chunked
Cache-Control: no-cache, no-store
Content-Type: application/json
Date: Wed, 10 Apr 2019 20:51:46 GMT
Pragma: no-cache

2
[]
0


-----------------------
---------------- REQ ------------------
GET /wapi/v2.3.1/fixedaddress?_proxy_search=GM&_return_fields=extattrs%2Cipv4addr%2Cmac%2Cname%2Cnetwork%2Cnetwork_view%2Ccomment HTTP/1.1
Host: 10.16.129.188:443
Authorization: Basic YWRtaW46ZW9zcGx1cw==
Content-Type: application/json

{"network_view":"view1","network":"10.153.200.0/31","comment":"bogus"}
-----------------------
----------------RESP ------------------
HTTP/1.1 500 Internal Server Error
Connection: close
Content-Type: application/json
Date: Wed, 10 Apr 2019 20:51:47 GMT
Content-Length: 0


-----------------------
---------------- REQ ------------------
GET /wapi/v2.3.1/fixedaddress?_proxy_search=GM&_return_fields=extattrs%2Cipv4addr%2Cmac%2Cname%2Cnetwork%2Cnetwork_view%2Ccomment HTTP/1.1
Host: 10.16.129.188:443
Authorization: Basic YWRtaW46ZW9zcGx1cw==
Content-Type: application/json

{"network_view":"view1","network":"10.153.200.0/31","comment":"bogus"}
-----------------------
----------------RESP ------------------
HTTP/1.1 500 Internal Server Error
Connection: close
Content-Type: application/json
Date: Wed, 10 Apr 2019 20:51:47 GMT
Content-Length: 0


-----------------------

WAPI request error: 500('500 Internal Server Error')
        Contents:

Possibility to UPDATE a CNAME entry

related to hashicorp/terraform-provider-infoblox#36

Possibility to update a CNAME in the GO Library

It seems possible with the API

curl -k -u admin:infoblox -H 'content-type: application/json' -X PUT "https://gridmaster/wapi/v2.11/record:cname/ZG5zLmJpbmRfY25hbWUkLl9kZWZhdWx0LmNvbS5pbmZvLmRlbW8uY2 5hbWV0ZXN0:cnametest.demo.info.com/default?_return_fields%2B=name&_return_as_object=1" -d '{"name":"cname.demo.info.com"}'

json: cannot unmarshal object into Go value of type

When trying to creating/fetching Infoblox objects (eg. record host etc) like so:

		//"record:host/ZG5zLmhvc3QkLl9kZWZhdWx0LmNvbS56b25lLmhvc3Q:host.zone.com/default")`
	

         hostRec, err := objMgr.GetHostRecord("record:host/ZG5zLmhvc3QkLl9kZWZhdWx0LmNvbS56b25lLmhvc3Q:host.zone.com/default")
	// var unmarshalledHostRec *ibclient.HostRecord
	// json.Unmarshal()
	if err != nil {
		fmt.Printf("objMgr.GetHostRecord(): %s", err)
	}

	fmt.Printf("Record Name: %s", hostRec.Name)

I am getting the below:

    "_ref": "record:host/ZG5zLmhvc3QkLl9kZWZhdWx0LmNvbS56b25lLmhvc3Q:host.zone.com/default",
    "extattrs": {},
    "ipv4addrs": [
        {
            "_ref": "record:host_ipv4addr/ZG5zLmhvc3RfYWRkcmVzcyQuX2RlZmF1bHQuY29tLnpvbmUuaG9zdC4xMC4yMjIuMC4xMi4:10.222.0.12/host.zone.com/default",
            "configure_for_dhcp": false,
            "host": "host.zone.com",
            "ipv4addr": "10.222.0.12"
        }
    ],
    "name": "host.zone.com",
    "view": "default",
    "zone": "zone.com"
}',`
`, err: 'json: cannot unmarshal object into Go value of type []map[string]interface {}'

and yet, it prints out the output correctly:

Record Name: host.zone.com%

Any advice?

Add useful fields for Authoritative Zone resource

Context

When creating an Authoritative Zone in DNS using the current client, only the desired FQDN is accepted as an argument. This does not allow a user to set a Nameserver Group, or the TTLs for SOA records, for instance.

CreateZoneAuth(fqdn string, ea EA) (*ZoneAuth, error)

Proposed Changes

Add the following fields for Authoritative Zone resources. These are already present in the Infoblox NIOS API, they just aren't exposed here in the Go Client.

  • ns_group
  • restart_if_needed
  • comment
  • soa_default_ttl
  • soa_expire
  • soa_negative_ttl
  • soa_refresh
  • soa_retry

Related Work

With these fields exposed in the Infoblox Go Client, we can then add an Authoritative Zone resource to the Infoblox Terraform Provider.

Update TXT Record - New object ref is not returned

_, err = objMgr.connector.UpdateObject(&res[0], res[0].Ref)
if err != nil || res == nil || len(res) == 0 {
return nil, err
}
return &res[0], nil

When updating an Infoblox TXT record, the new ref is not returned, as the value is discarded when calling connector.UpdateObject (see above), and the old value (&res[0]) is the one returned. This causes a 404 at the next time the TXT record needs a getbyid run on it, as the actual ref/ID is now different.

See the below for an example where the update works (in this case, updating the host record), and returns the ref of the new object:

ref, err := objMgr.connector.UpdateObject(updateHostRecord, hostRref)
return ref, err

v2 introduced long timeout when fetching A record

This project is being used by by the infoblox plugin to the external-dns project. An issue has been raised there that appears to trace back to a change in v2 of this library causing issues.

Related issue: kubernetes-sigs/external-dns#2945

In that issue, a commenter states the following:

I did a bit of a test by dragging some code out of External DNS into a new Go project, and it appears to be the change to the github.com/infobloxopen/infoblox-go-client/v2 version of the infoblox-go-client package that has caused the issue. Listing A records in the original version in my test gave me a response in about ~300ms, whereas with the v2 version, it gives me a warning about there being over 1,000 records (which is a lie) and then eventually returns after about 15-20 seconds.

DeleteNetworkContainer

The go client has a CreateNetworkContainer and GetNetworkContainer but not DeleteNetworkContainer. There is a request in the terraform-provider-infoblox to include Network containers as a resource. We will want Delete to do testing and not have a dangling resource and people expect it.

infobloxopen/terraform-provider-infoblox/issues/27

Unknown extensible attribute: Cloud API Owned

I would like to use the AllocateIP function on a on-prem infoblox environment with WAPI Version 2.3.1 but i get the error: Unknown extensible attribute: Cloud API Owned.
It would be nice if the object_manager functions could be used on on-prem instances as well.

Add support for pagination

At support for pagination so large record sets can be worked with. We have many zones with well over a 1000 records let a lone more than 1000 zones.

Fake client for unit testing or more exported fields

Hey folks,
It would great if the library offers fake client which can be used for unit testing or at least make all fields of the arguments used in the IBConnector interface easy accessible. Currently it is really difficult to mock e.g. GetObject if the searchFields of QueryParams are unexported.

What are you thinking about this?

Next Available Network

We are looking to get some functionality where we can get the next available network from this client. Ideally that would then bleed into Terraform functionality that we would like to leverage.

IPv6 Support

Enhancement request to support IPv6 in all applicable functions and objects and add AAAA support.

Make SearchHostRecordByAltId method more generic

In the IBObjectManager interface there's a SearchHostRecordByAltId method.

This method does combined searching, meaning:

  1. First it tries to find HostRecord by ref.
  2. If first step is failed, it tries to find HostRecord by EAs.

This method has the name specific to terraform provider, I think that we should make this method more generic by renaming it, and documenting it's params.

Related terraform provider discussion: infobloxopen/terraform-provider-infoblox#225 (comment)

GetHostRecord method has unneeded paramaters

GetHostRecord method takes parameters that are not used:

func (objMgr *ObjectManager) GetHostRecord(recordName string, netview string, cidr string, ipAddr string) (*HostRecord, error) {
var res []HostRecord
recordHost := NewHostRecord(HostRecord{})
if recordName != "" {
recordHost.Name = recordName
}
err := objMgr.connector.GetObject(recordHost, "", &res)
if err != nil || res == nil || len(res) == 0 {
return nil, err
}
return &res[0], err
}

The unwanted params should be removed to avoid confusion

A module like this should never log an error, never log anything to stdout, and should always return an error if one exists

A module should never log an error. It should always be returned to the user to decide what to do with the error (ignore or move on). When it is logged to stdout randomly by underlying packages the caller of the api can't really control or even know what is going on. This is so established, I couldn't even find an article that talks about doing it, they all just assume you are already doing it because it is so basic to the language.

https://golang.org/doc/effective_go.html#errors
https://medium.com/@hussachai/error-handling-in-go-a-quick-opinionated-guide-9199dd7c7f76
https://blog.golang.org/error-handling-and-go
https://medium.com/rungo/error-handling-in-go-f0125de052f0
https://blog.logrocket.com/error-handling-in-golang/

All of these are talking about different techniques around error handling, but all assume any non-main function is returning error for the higher level functions to manage.

I see in this codebase has a large number of areas where the log package is used to print errors, sometimes without the underlying package even returning the error.

In NewTransportConfig
if err != nil { log.Printf("Cannot load certificate file '%s'", sslVerify) return } if !caPool.AppendCertsFromPEM(cert) { err = fmt.Errorf("Cannot append certificate from file '%s'", sslVerify) return }

Error is just printed in the first block and the second block creates an error but does not return it?

In getHTTPResponseError
msg := fmt.Sprintf("WAPI request error: %d('%s')\nContents:\n%s\n", resp.StatusCode, resp.Status, content) log.Printf(msg) return errors.New(msg)

This at least returns the error but it still should not print to stdout.

if err != nil { log.Fatal(err) }
Here we kill the program because of the error. What if I wanted there to be an error here? what if I was checking for something to not work?

if err != nil { log.Printf("Http Reponse ioutil.ReadAll() Error: '%s'", err) return }

Here we at least return the error but still it should not be printed out.

There are many more examples but I think this is enough for the post.

remove old dependency for logrus

We get build failures, because of your dependency

You should update github.com/Sirupsen/logrus to github.com/sirupsen/logrus

% make test
go test -v -race github.com/szuecs/external-dns github.com/szuecs/external-dns/controller github.com/szuecs/external-dns/endpoint github.com/szuecs/external-dns/internal/testutils  github.com/szuecs/external-dns/pkg/apis/externaldns github.com/szuecs/external-dns/pkg /apis/externaldns/validation github.com/szuecs/external-dns/plan github.com/szuecs/external- dns/provider github.com/szuecs/external-dns/registry github.com/szuecs/external-dns/source
../../kubernetes-incubator/external-dns/vendor/github.com/infobloxopen/infoblox-go-client/lock.go:5:2: case-insensitive import collision: "github.com/kubernetes-incubator/external-dns/vendor/github.com/Sirupsen/logrus" and "github.com/kubernetes-incubator/external-dns/vendor/github.com/sirupsen/logrus"
vendor/github.com/infobloxopen/infoblox-go-client/lock.go:5:2: case-insensitive import collision: "github.com/szuecs/external-dns/vendor/github.com/Sirupsen/logrus" and "github.com/szuecs/external-dns/vendor/github.com/sirupsen/logrus"
make: *** [test] Error 1

ObjectManager does not implement IBObjectManager

Hey guys, I'm trying to create a REST API around InfoBlox and I'm attempting to use dependency injection using interfaces and structs so I can mock the IBObjectManager in my tests.

Now when I try to create an ObjectManager using:

func GetInfoBloxObjectManager() *ibclient.IBObjectManager {
  // [...]
  return &ibclient.NewObjectManager(conn, "client", "")
}

My IDE shows me the error:

Type does not implement 'ibclient.IBObjectManager' need method: GetCNAMERecordByRef(ref string) (*RecordA, error) have method: GetCNAMERecordByRef(ref string) (*RecordCNAME, error)

Is IBObjectManager not supposed to be the interface of the ObjectManager? Or am I doing something wrong here?

"Field is not searchable" when getting record with EA

I'm attempting to get a record (either A or CNAME, using GetObject), by specifying an object like this:

	obj := ibclient.NewRecordA(
		ibclient.RecordA{
			Name:     "foo.com",
			Ipv4Addr: "1.2.3.4",
			View:     "default",
			Ea:      ibclient.EA{eaKey: eaVal},
		},
	)

The body of the HTTP request that gets constructed looks like this;

'{"ipv4addr":"1.2.3.4","name":"foo.com","view":"default","extattrs":{"My-EA":{"value":"testing"}}}'

However, I'm getting this error:

{ "Error": "AdmConProtoError: Field is not searchable: extattrs",
  "code": "Client.Ibap.Proto",
  "text": "Field is not searchable: extattrs"
}

The extattrs are not searchable. I need them to be, as all of the objects I create will have "My-EA", and at a certain point I'll have a general GetObject call to get all objects that I've created (by using the EA as my search pattern), and nothing more. Is this possible?

Make enough components public to allow extensions from connector for custom queries

It should be easy to leverage the Connector components to make custom queries; as a for-instance, there's not currently a mechanism in the package for making paginated queries.

Unfortunately, in order to create a GetObjectPaginated function, one would need makeRequest and QueryParams to be fully public, or in the latter case have a method to generate a QueryParams struct from a public method.

https://github.com/infobloxopen/infoblox-go-client/blob/master/connector.go#L252 being private means I'd have to generate my own version that calls all the public methods it does, which is not ideal.

forceProxy bool
QueryParams.forceProxy being private stymies me creating my own makeRequest; I can create a QueryParams object but it's unable to be set to anything but false. By extension this makes BuildRequest less accessible.

Feature Request: Ability to add comments

As the title says, I would like to add a comment to these records I'm creating. This may not work well with some of the "New" functions since it would break people's code, but it looks like it could be added to all the objects with the appropriate json tags.

Make golint happy

I noticed that running golint (https://github.com/golang/lint) will output a bunch of suggestions against master. Most of them are related to missing documentation comments for exported functions, but also some letter case fixes and code construct suggestions. I am opening an issue instead of a PR because it is unclear to me how these things should be handled and I am not in a good position to document the package.

Output:

connector.go:20:6: exported type HostConfig should have comment or be unexported
connector.go:28:6: exported type TransportConfig should have comment or be unexported
connector.go:31:2: struct field HttpRequestTimeout should be HTTPRequestTimeout
connector.go:32:2: struct field HttpPoolConnections should be HTTPPoolConnections
connector.go:35:1: exported function NewTransportConfig should have comment or be unexported
connector.go:49:10: should replace errors.New(fmt.Sprintf(...)) with fmt.Errorf(...)
connector.go:61:6: exported type HttpRequestBuilder should have comment or be unexported
connector.go:61:6: type HttpRequestBuilder should be HTTPRequestBuilder
connector.go:68:6: exported type HttpRequestor should have comment or be unexported
connector.go:68:6: type HttpRequestor should be HTTPRequestor
connector.go:73:6: exported type WapiRequestBuilder should have comment or be unexported
connector.go:77:6: exported type WapiHttpRequestor should have comment or be unexported
connector.go:77:6: type WapiHttpRequestor should be WapiHTTPRequestor
connector.go:81:6: exported type IBConnector should have comment or be unexported
connector.go:88:6: exported type Connector should have comment or be unexported
connector.go:95:6: exported type RequestType should have comment or be unexported
connector.go:98:2: exported const CREATE should have comment (or a comment on this block) or be unexported
connector.go:119:6: func getHttpResponseError should be getHTTPResponseError
connector.go:127:1: exported method WapiHttpRequestor.Init should have comment or be unexported
connector.go:144:1: exported method WapiHttpRequestor.SendRequest should have comment or be unexported
connector.go:165:1: exported method WapiRequestBuilder.Init should have comment or be unexported
connector.go:169:1: exported method WapiRequestBuilder.BuildUrl should have comment or be unexported
connector.go:169:32: method BuildUrl should be BuildURL
connector.go:196:1: exported method WapiRequestBuilder.BuildBody should have comment or be unexported
connector.go:197:6: var objJson should be objJSON
connector.go:208:3: var eaSearchJson should be eaSearchJSON
connector.go:219:1: exported method WapiRequestBuilder.BuildRequest should have comment or be unexported
connector.go:254:1: exported method Connector.CreateObject should have comment or be unexported
connector.go:272:1: exported method Connector.GetObject should have comment or be unexported
connector.go:292:1: exported method Connector.DeleteObject should have comment or be unexported
connector.go:310:1: exported method Connector.UpdateObject should have comment or be unexported
connector.go:327:1: exported method Connector.Logout should have comment or be unexported
connector.go:336:5: exported var ValidateConnector should have comment or be unexported
connector.go:349:1: exported function NewConnector should have comment or be unexported
connector_test.go:30:31: method BuildUrl should be BuildURL
connector_test.go:50:6: type FakeHttpRequestor should be FakeHTTPRequestor
connector_test.go:94:5: var expectedUrlStr should be expectedURLStr
connector_test.go:106:5: var expectedUrlStr should be expectedURLStr
connector_test.go:117:5: var expectedUrlStr should be expectedURLStr
lock.go:15:6: exported type Lock should have comment or be unexported
lock.go:20:6: exported type NetworkViewLock should have comment or be unexported
lock.go:185:1: exported method NetworkViewLock.Lock should have comment or be unexported
lock.go:210:10: if block ends with a return statement, so drop this else and outdent its block
lock.go:225:1: exported method NetworkViewLock.UnLock should have comment or be unexported
object_manager.go:10:6: exported type IBObjectManager should have comment or be unexported
object_manager.go:29:6: exported type ObjectManager should have comment or be unexported
object_manager.go:35:1: exported function NewObjectManager should have comment or be unexported
object_manager.go:45:41: method parameter cloudApiOwned should be cloudAPIOwned
object_manager.go:53:1: exported method ObjectManager.CreateNetworkView should have comment or be unexported
object_manager.go:80:1: exported method ObjectManager.CreateDefaultNetviews should have comment or be unexported
object_manager.go:92:1: exported method ObjectManager.CreateNetwork should have comment or be unexported
object_manager.go:110:1: exported method ObjectManager.CreateNetworkContainer should have comment or be unexported
object_manager.go:122:1: exported method ObjectManager.GetNetworkView should have comment or be unexported
object_manager.go:136:1: exported method ObjectManager.UpdateNetworkViewEA should have comment or be unexported
object_manager.go:151:9: should omit 2nd value from range; this loop is equivalent to `for k := range ...`
object_manager.go:162:1: exported function BuildNetworkViewFromRef should have comment or be unexported
object_manager.go:177:1: exported function BuildNetworkFromRef should have comment or be unexported
object_manager.go:193:1: exported method ObjectManager.GetNetwork should have comment or be unexported
object_manager.go:216:1: exported method ObjectManager.GetNetworkContainer should have comment or be unexported
object_manager.go:232:1: exported function GetIPAddressFromRef should have comment or be unexported
object_manager.go:243:1: exported method ObjectManager.AllocateIP should have comment or be unexported
object_manager.go:273:1: exported method ObjectManager.AllocateNetwork should have comment or be unexported
object_manager.go:292:1: exported method ObjectManager.GetFixedAddress should have comment or be unexported
object_manager.go:313:1: exported method ObjectManager.UpdateFixedAddress should have comment or be unexported
object_manager.go:332:1: exported method ObjectManager.ReleaseIP should have comment or be unexported
object_manager.go:340:1: exported method ObjectManager.DeleteNetwork should have comment or be unexported
object_manager.go:349:1: exported method ObjectManager.GetEADefinition should have comment or be unexported
object_manager.go:363:1: exported method ObjectManager.CreateEADefinition should have comment or be unexported
object_manager.go:437:1: comment on exported method ObjectManager.GetGridLicense should be of the form "GetGridLicense ..."
objects.go:9:7: don't use ALL_CAPS in Go names; use CamelCase
objects.go:9:7: exported const MACADDR_ZERO should have comment or be unexported
objects.go:11:6: exported type Bool should have comment or be unexported
objects.go:13:6: exported type EA should have comment or be unexported
objects.go:15:6: exported type EASearch should have comment or be unexported
objects.go:17:6: exported type EADefListValue should have comment or be unexported
objects.go:19:6: exported type IBBase should have comment or be unexported
objects.go:25:6: exported type IBObject should have comment or be unexported
objects.go:32:1: exported method IBBase.ObjectType should have comment or be unexported
objects.go:36:1: exported method IBBase.ReturnFields should have comment or be unexported
objects.go:40:1: exported method IBBase.EaSearch should have comment or be unexported
objects.go:44:6: exported type NetworkView should have comment or be unexported
objects.go:51:1: exported function NewNetworkView should have comment or be unexported
objects.go:68:1: exported function NewUpgradeStatus should have comment or be unexported
objects.go:90:6: exported type Network should have comment or be unexported
objects.go:98:1: exported function NewNetwork should have comment or be unexported
objects.go:106:6: exported type ServiceStatus should have comment or be unexported
objects.go:112:6: exported type LanHaPortSetting should have comment or be unexported
objects.go:120:6: exported type PhysicalPortSetting should have comment or be unexported
objects.go:126:6: exported type NetworkSetting should have comment or be unexported
objects.go:133:2: struct field VlanId should be VlanID
objects.go:135:6: exported type Ipv6Setting should have comment or be unexported
objects.go:142:2: struct field VirtualIp should be VirtualIP
objects.go:143:2: struct field VlanId should be VlanID
objects.go:147:6: exported type NodeInfo should have comment or be unexported
objects.go:149:2: struct field HwId should be HwID
objects.go:175:1: exported function NewMember should have comment or be unexported
objects.go:197:1: exported function NewGridLicense should have comment or be unexported
objects.go:210:1: exported function NewLicense should have comment or be unexported
objects.go:239:1: exported function NewCapcityReport should have comment or be unexported
objects.go:247:6: exported type NTPserver should have comment or be unexported
objects.go:256:6: exported type NTPSetting should have comment or be unexported
objects.go:264:6: exported type Grid should have comment or be unexported
objects.go:271:1: exported function NewGrid should have comment or be unexported
objects.go:279:6: exported type NetworkContainer should have comment or be unexported
objects.go:287:1: exported function NewNetworkContainer should have comment or be unexported
objects.go:295:6: exported type FixedAddress should have comment or be unexported
objects.go:305:1: exported function NewFixedAddress should have comment or be unexported
objects.go:313:6: exported type EADefinition should have comment or be unexported
objects.go:324:1: exported function NewEADefinition should have comment or be unexported
objects.go:332:6: exported type UserProfile should have comment or be unexported
objects.go:338:1: exported function NewUserProfile should have comment or be unexported
objects.go:346:6: exported type RecordA should have comment or be unexported
objects.go:356:1: exported function NewRecordA should have comment or be unexported
objects.go:364:6: exported type RecordCNAME should have comment or be unexported
objects.go:374:1: exported function NewRecordCNAME should have comment or be unexported
objects.go:382:6: exported type RecordHostIpv4Addr should have comment or be unexported
objects.go:386:6: exported type RecordHost should have comment or be unexported
objects.go:397:1: exported function NewRecordHost should have comment or be unexported
objects.go:405:6: exported type RecordTXT should have comment or be unexported
objects.go:415:1: exported function NewRecordTXT should have comment or be unexported
objects.go:423:6: exported type ZoneAuth should have comment or be unexported
objects.go:431:1: exported function NewZoneAuth should have comment or be unexported
objects.go:439:1: exported method EA.MarshalJSON should have comment or be unexported
objects.go:450:1: exported method EASearch.MarshalJSON should have comment or be unexported
objects.go:459:1: exported method EADefListValue.MarshalJSON should have comment or be unexported
objects.go:466:1: exported method Bool.MarshalJSON should have comment or be unexported
objects.go:474:1: exported method EA.UnmarshalJSON should have comment or be unexported
objects.go:503:1: exported method EADefListValue.UnmarshalJSON should have comment or be unexported
objects.go:503:1: receiver name v should be consistent with previous receiver name val for EADefListValue
objects.go:514:6: exported type RequestBody should have comment or be unexported
objects.go:524:6: exported type SingleRequest should have comment or be unexported
objects.go:529:6: exported type MultiRequest should have comment or be unexported
objects.go:534:1: exported method MultiRequest.MarshalJSON should have comment or be unexported
objects.go:538:1: exported function NewMultiRequest should have comment or be unexported
objects.go:544:1: exported function NewRequest should have comment or be unexported

Segfault due to missing error check with bad HostConfig settings

In connector.go, line 264, a call to BuildRequest is made, but err is never checked before req is passed to SendRequest on line 265. In the event BuildRequest fails, which is possible if the Connector's HostConfig object has an invalid Host attribute (for example, if it's accidentally specified as a URL rather than an IP/hostname) then req is nil.

When this is passed to SendRequest, it is blindly passed to the Do method of net/http.Client which then segfaults.

There should probably be some error checking here to fail more gracefully and/or some validation of the contents of HostConfig in Init on line 174

Ability to restart services

After updating a host record, we need to be able to restart services. Is this capability being worked on?

FixedAddress: "Name" field is not filled in when searching

Hello,

Starting with version 0.5.0 the FixedAddress struct contains a "Name" field which I had use for. I noticed however that the Name field will always be empty when searching. This is because at least in my WAPI version the wapidoc states that only "ipv4addr" and "network_view" is included in the basic object and NewFixedAddress() does not include "name" when filling in the returnFields slice:

func NewFixedAddress(fixedAddr FixedAddress) *FixedAddress {
        res := fixedAddr
        res.objectType = "fixedaddress"
        res.returnFields = []string{"extattrs", "ipv4addr", "mac", "network", "network_view"}

        return &res
}

Since returnFields is unexported I can not add "name" from my own code. I noticed there seemed to exist some basic idea of having a function to modify this slice because of a commented out SetReturnFields() function:

type IBObject interface {
        ObjectType() string
        ReturnFields() []string
        EaSearch() EASearch
        //SetReturnFields([]string)
}

... but I see no further traces of such code.

How to get a Ref?

Hi,

How do I get object refs? For example, I want to delete a CNAME and DeleteCNAMERecord takes one parameter ref string...

Thanks

Use option structs instead of arguments

With the recent addition of additional arguments with v2 the functions became very hard to use (or rather, even worse than before).

Without advanced IDE support that shows the parameter names inline (only GoLand for now) it's very hard to identify the arguments, especially when omitting a lot of them. A common pattern in Go is using a struct as a single argument, that then contains the different options. It has several advantages over the current approach:

  • shorter method signature
  • optional arguments can simply be omitted
  • used arguments are easy to identify as you have to put the attribute name in front of them
  • easy to expand with further attributes without breaking changes

for example:

hostRecord, err = objMgr.CreateHostRecord(true, false, deviceFQDN, networkView, "default."+networkView, subnet.String(), "", "", "", "", "", false, 0, "", make(ibclient.EA), nil)

could become

hostRecord, err = objMgr.CreateHostRecord(CreateHostRecordOptions{
	NetworkView: networkView,
	DNSView: "default."+networkView,
	EnableDNS: true,
	IPv4CIDR: subnet.String(),
})

The latter is a lot easier to read and understand quickly. While it would be another breaking change in a short time, it's a worthy improvement in my opinion.

Also, if you would've used this approach before, a lot of the breaking API changes with v2 wouldn't have been breaking changes.

Vlan support

Be nice to updated the terraform provider with vlan support...could it be added to the client library first?

Create new release

Please create a new release so the latest code can be referenced by External DNS Infoblox plugin build.

Recent update removed "Ipv4Addr" field from RecordHost (now HostRecord)

Hello,

I tried updating to 0.6.0 and it broke my code. The initial problem was that Host record related structs had been renamed from "RecordHost[...]" to "HostRecord[...]". While I guess that "HostRecord" reads a bit more naturally it's a bit strange since all other record types are still called "RecordA", "RecordCNAME" etc.

I can live with that change, but I also noticed the now renamed HostRecord struct no longer contains the field "Ipv4Addr". I have been using that to search for hosts by IP address like so:

var hostResult []ibclient.RecordHost

recordHostObj := ibclient.NewRecordHost(ibclient.RecordHost{
    Ipv4Addr: ip,
})

err := conn.GetObject(recordHostObj, "", &hostResult)

This of course no longer works. Was this removed on purpose and I am supposed to fill in an Ipv4Addrs slice instead or should it be added back?

Pinging @saiprasannasastry and @jkraj since you were involved in changing the code.

Searching network based on EA's not working when body is passed in GET request

The call https://github.com/infobloxopen/docker-infoblox/blob/v1.1.0-pre/driver/infoblox_ipam.go#L117

networkByName, err := ibDrv.objMgr.GetNetwork(netview, "", ibclient.EA{"Network Name": networkName})

eventually constructs the URL as

$ curl -k -u admin:infoblox -H "Content-Type:application/json" -X GET 'https://10.120.21.150:443/wapi/v2.6/network?%2ANetwork+Name=new-net1&_return_fields=extattrs%2Cnetwork%2Cnetwork_view' -d '{"network_view":"global"}

'[
   {
       "_ref": "network/ZG5zLm5ldHdvcmskNDAuMC4wLjAvMjQvMA:40.0.0.0/24/default",
       "extattrs": {
           "CMP Type": {
               "value": "Docker"
           },
           "Cloud API Owned": {
               "value": "True"
           },
           "Network Name": {
               "value": "new-net1"
           },
           "Tenant ID": {
               "value": "DVZR:HNJZ:42OG:XTRO:YOHD:VDYA:EBKK:UDO7:ILEA:JF7R:KYGG:QCIO"
           }
       },
       "network": "40.0.0.0/24",
       "network_view": "default"
   }

It queried for a network with EA “network-name = new-net1” in “global” network view but got the network with this name in “default” view. The GET request ignores the body if there are parameters in the query string. This request should have failed but currently passes in our code.

So either all parameters needs to be passed in the body or as query parameters.

  1. Passing all prams as body
$ curl -k -u admin:infoblox -H "Content-Type:application/json" -X GET 'https://10.120.21.150:443/wapi/v2.6/network?_return_fields=extattrs%2Cnetwork%2Cnetwork_view' -d '{ "*Network Name":"new-net1"}'

[
   {
       "_ref": "network/ZG5zLm5ldHdvcmskNDAuMC4wLjAvMjQvMA:40.0.0.0/24/default",
       "extattrs": {
           "CMP Type": {
               "value": "Docker"
           },
           "Cloud API Owned": {
               "value": "True"
           },
           "Network Name": {
               "value": "new-net1"
           },
           "Tenant ID": {
               "value": "DVZR:HNJZ:42OG:XTRO:YOHD:VDYA:EBKK:UDO7:ILEA:JF7R:KYGG:QCIO"
           }
       },
       "network": "40.0.0.0/24",
       "network_view": "default"
   }



$ curl -k -u admin:infoblox -H "Content-Type:application/json" -X GET 'https://10.120.21.150:443/wapi/v2.6/network?_return_fields=extattrs%2Cnetwork%2Cnetwork_view' -d '{"network_view":"global", "*Network Name":"new-net1"}'

{ "Error": "AdmConDataNotFoundError: Network View global not found",
 "code": "Client.Ibap.Data.NotFound",
 "text": "Network View global not found"
}
  1. Passing all prams in query
$ curl -k -u admin:infoblox -H "Content-Type:application/json" -X GET 'https://10.120.21.150:443/wapi/v2.6/network?%2ANetwork+Name=new-net1&network_view=default&_return_fields=extattrs%2Cnetwork%2Cnetwork_view'

[
   {
       "_ref": "network/ZG5zLm5ldHdvcmskNDAuMC4wLjAvMjQvMA:40.0.0.0/24/default",
       "extattrs": {
           "CMP Type": {
               "value": "Docker"
           },
           "Cloud API Owned": {
               "value": "True"
           },
           "Network Name": {
               "value": "new-net1"
           },
           "Tenant ID": {
               "value": "DVZR:HNJZ:42OG:XTRO:YOHD:VDYA:EBKK:UDO7:ILEA:JF7R:KYGG:QCIO"
           }
       },
       "network": "40.0.0.0/24",
       "network_view": "default"
   }



$ curl -k -u admin:infoblox -H "Content-Type:application/json" -X GET 'https://10.120.21.150:443/wapi/v2.6/network?%2ANetwork+Name=new-net1&network_view=global&_return_fields=extattrs%2Cnetwork%2Cnetwork_view'
{ "Error": "AdmConDataNotFoundError: Network View global not found",
 "code": "Client.Ibap.Data.NotFound",
 "text": "Network View global not found"
}

Search All capabilities?

hello,

I have used the python library infoblox maintains to great success, and I wanted to try to rewrite some of my tools into golang that use it, but it appears this library is missing some features that the python library has (if I am wrong, please set me straight!).

Specifically the python library has a a search_all function on the Objects, as the python library has to then be able to get all the Zones defined, and then search_all for Records of a given type in that Zone, to then parse out desired data.

In python this is done something like this:

# get all the zones
zones = objects.DNSZone.search_all(conn)

# or if I have a given zone, get all the A records:
for z in zones:
     v4_host_records = objects.HostRecordV4.search_all(
                conn, max_results=settings.infoblox_max_results, zone=z.fqdn
            )

Does this capability exist with the go library, and i'm just not seeing it?

Thanks,

Will

Add GitHub Action as a CI/CD tool for pull requests

Problem:
When a PR is raised on a master branch we need an CI script to build and test the test cases for the PR raised code block before it can be reviewed.

Solution:
Propose a GitHub action which can automate this process.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.