Add InsecureSkipVerify functionality.
This commit is contained in:
parent
79ae6869a7
commit
62df6ed37f
2 changed files with 11 additions and 4 deletions
|
@ -3,11 +3,13 @@ package nbclient
|
||||||
type NetBox struct {
|
type NetBox struct {
|
||||||
RootURL string
|
RootURL string
|
||||||
Token string
|
Token string
|
||||||
|
InsecureSkipVerify bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *NetBox) New(root, token string) error {
|
func (n *NetBox) New(root, token string, TlsSkipVerify bool) error {
|
||||||
n.RootURL = root
|
n.RootURL = root
|
||||||
n.Token = token
|
n.Token = token
|
||||||
|
n.InsecureSkipVerify = TlsSkipVerify
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package nbclient
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"crypto/tls"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
@ -85,9 +86,13 @@ func (i *Dcim_Interfaces_Create) CreateInterface(n *NetBox) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
transport := &http.Transport{
|
||||||
|
TLSClientConfig: &tls.Config{InsecureSkipVerify: n.InsecureSkipVerify},
|
||||||
|
}
|
||||||
timeout := time.Duration(60 * time.Second)
|
timeout := time.Duration(60 * time.Second)
|
||||||
client := &http.Client{
|
client := &http.Client{
|
||||||
Timeout: timeout,
|
Timeout: timeout,
|
||||||
|
Transport: transport,
|
||||||
}
|
}
|
||||||
request, err := http.NewRequest("POST", n.RootURL+"/dcim/interfaces/", bytes.NewBuffer(interfaceData))
|
request, err := http.NewRequest("POST", n.RootURL+"/dcim/interfaces/", bytes.NewBuffer(interfaceData))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue