summaryrefslogtreecommitdiff
path: root/vendor/github.com/Microsoft/hcsshim/hnsnetwork.go
diff options
context:
space:
mode:
authorValentin Rothberg <rothberg@redhat.com>2019-01-08 14:52:57 +0100
committerValentin Rothberg <rothberg@redhat.com>2019-01-11 13:38:11 +0100
commitbd40dcfc2bc7c9014ea1f33482fb63aacbcdfe87 (patch)
tree5f06e4e289f16d9164d692590a3fe6541b5384cf /vendor/github.com/Microsoft/hcsshim/hnsnetwork.go
parent545f24421247c9f6251a634764db3f8f8070a812 (diff)
downloadpodman-bd40dcfc2bc7c9014ea1f33482fb63aacbcdfe87.tar.gz
podman-bd40dcfc2bc7c9014ea1f33482fb63aacbcdfe87.tar.bz2
podman-bd40dcfc2bc7c9014ea1f33482fb63aacbcdfe87.zip
vendor: update everything
* If possible, update each dependency to the latest available version. * Use releases over commit IDs and avoid vendoring branches. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'vendor/github.com/Microsoft/hcsshim/hnsnetwork.go')
-rw-r--r--vendor/github.com/Microsoft/hcsshim/hnsnetwork.go178
1 files changed, 36 insertions, 142 deletions
diff --git a/vendor/github.com/Microsoft/hcsshim/hnsnetwork.go b/vendor/github.com/Microsoft/hcsshim/hnsnetwork.go
index 3345bfa3f..f775fa1d0 100644
--- a/vendor/github.com/Microsoft/hcsshim/hnsnetwork.go
+++ b/vendor/github.com/Microsoft/hcsshim/hnsnetwork.go
@@ -1,142 +1,36 @@
-package hcsshim
-
-import (
- "encoding/json"
- "fmt"
- "net"
-
- "github.com/sirupsen/logrus"
-)
-
-// Subnet is assoicated with a network and represents a list
-// of subnets available to the network
-type Subnet struct {
- AddressPrefix string `json:",omitempty"`
- GatewayAddress string `json:",omitempty"`
- Policies []json.RawMessage `json:",omitempty"`
-}
-
-// MacPool is assoicated with a network and represents a list
-// of macaddresses available to the network
-type MacPool struct {
- StartMacAddress string `json:",omitempty"`
- EndMacAddress string `json:",omitempty"`
-}
-
-// HNSNetwork represents a network in HNS
-type HNSNetwork struct {
- Id string `json:"ID,omitempty"`
- Name string `json:",omitempty"`
- Type string `json:",omitempty"`
- NetworkAdapterName string `json:",omitempty"`
- SourceMac string `json:",omitempty"`
- Policies []json.RawMessage `json:",omitempty"`
- MacPools []MacPool `json:",omitempty"`
- Subnets []Subnet `json:",omitempty"`
- DNSSuffix string `json:",omitempty"`
- DNSServerList string `json:",omitempty"`
- DNSServerCompartment uint32 `json:",omitempty"`
- ManagementIP string `json:",omitempty"`
- AutomaticDNS bool `json:",omitempty"`
-}
-
-type hnsNetworkResponse struct {
- Success bool
- Error string
- Output HNSNetwork
-}
-
-type hnsResponse struct {
- Success bool
- Error string
- Output json.RawMessage
-}
-
-// HNSNetworkRequest makes a call into HNS to update/query a single network
-func HNSNetworkRequest(method, path, request string) (*HNSNetwork, error) {
- var network HNSNetwork
- err := hnsCall(method, "/networks/"+path, request, &network)
- if err != nil {
- return nil, err
- }
-
- return &network, nil
-}
-
-// HNSListNetworkRequest makes a HNS call to query the list of available networks
-func HNSListNetworkRequest(method, path, request string) ([]HNSNetwork, error) {
- var network []HNSNetwork
- err := hnsCall(method, "/networks/"+path, request, &network)
- if err != nil {
- return nil, err
- }
-
- return network, nil
-}
-
-// GetHNSNetworkByID
-func GetHNSNetworkByID(networkID string) (*HNSNetwork, error) {
- return HNSNetworkRequest("GET", networkID, "")
-}
-
-// GetHNSNetworkName filtered by Name
-func GetHNSNetworkByName(networkName string) (*HNSNetwork, error) {
- hsnnetworks, err := HNSListNetworkRequest("GET", "", "")
- if err != nil {
- return nil, err
- }
- for _, hnsnetwork := range hsnnetworks {
- if hnsnetwork.Name == networkName {
- return &hnsnetwork, nil
- }
- }
- return nil, fmt.Errorf("Network %v not found", networkName)
-}
-
-// Create Network by sending NetworkRequest to HNS.
-func (network *HNSNetwork) Create() (*HNSNetwork, error) {
- operation := "Create"
- title := "HCSShim::HNSNetwork::" + operation
- logrus.Debugf(title+" id=%s", network.Id)
-
- jsonString, err := json.Marshal(network)
- if err != nil {
- return nil, err
- }
- return HNSNetworkRequest("POST", "", string(jsonString))
-}
-
-// Delete Network by sending NetworkRequest to HNS
-func (network *HNSNetwork) Delete() (*HNSNetwork, error) {
- operation := "Delete"
- title := "HCSShim::HNSNetwork::" + operation
- logrus.Debugf(title+" id=%s", network.Id)
-
- return HNSNetworkRequest("DELETE", network.Id, "")
-}
-
-// Creates an endpoint on the Network.
-func (network *HNSNetwork) NewEndpoint(ipAddress net.IP, macAddress net.HardwareAddr) *HNSEndpoint {
- return &HNSEndpoint{
- VirtualNetwork: network.Id,
- IPAddress: ipAddress,
- MacAddress: string(macAddress),
- }
-}
-
-func (network *HNSNetwork) CreateEndpoint(endpoint *HNSEndpoint) (*HNSEndpoint, error) {
- operation := "CreateEndpoint"
- title := "HCSShim::HNSNetwork::" + operation
- logrus.Debugf(title+" id=%s, endpointId=%s", network.Id, endpoint.Id)
-
- endpoint.VirtualNetwork = network.Id
- return endpoint.Create()
-}
-
-func (network *HNSNetwork) CreateRemoteEndpoint(endpoint *HNSEndpoint) (*HNSEndpoint, error) {
- operation := "CreateRemoteEndpoint"
- title := "HCSShim::HNSNetwork::" + operation
- logrus.Debugf(title+" id=%s", network.Id)
- endpoint.IsRemoteEndpoint = true
- return network.CreateEndpoint(endpoint)
-}
+package hcsshim
+
+import (
+ "github.com/Microsoft/hcsshim/internal/hns"
+)
+
+// Subnet is assoicated with a network and represents a list
+// of subnets available to the network
+type Subnet = hns.Subnet
+
+// MacPool is assoicated with a network and represents a list
+// of macaddresses available to the network
+type MacPool = hns.MacPool
+
+// HNSNetwork represents a network in HNS
+type HNSNetwork = hns.HNSNetwork
+
+// HNSNetworkRequest makes a call into HNS to update/query a single network
+func HNSNetworkRequest(method, path, request string) (*HNSNetwork, error) {
+ return hns.HNSNetworkRequest(method, path, request)
+}
+
+// HNSListNetworkRequest makes a HNS call to query the list of available networks
+func HNSListNetworkRequest(method, path, request string) ([]HNSNetwork, error) {
+ return hns.HNSListNetworkRequest(method, path, request)
+}
+
+// GetHNSNetworkByID
+func GetHNSNetworkByID(networkID string) (*HNSNetwork, error) {
+ return hns.GetHNSNetworkByID(networkID)
+}
+
+// GetHNSNetworkName filtered by Name
+func GetHNSNetworkByName(networkName string) (*HNSNetwork, error) {
+ return hns.GetHNSNetworkByName(networkName)
+}