Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion pkg/hns/netconf.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,18 @@ func (n *NetConf) MarshalPolicies() []json.RawMessage {

var result []json.RawMessage
for _, policyArg := range n.AdditionalArgs {
if data, err := json.Marshal(policyArg); err == nil {
if !strings.EqualFold(policyArg.Type, "EndpointPolicy") {
continue
}
if data, err := json.Marshal(policyArg.Value); err == nil {
result = append(result, data)
}
}

return result
}


// ApplyOutboundNatPolicy applies NAT Policy in VFP using HNS
// Simultaneously an exception is added for the network that has to be Nat'd
func (n *NetConf) ApplyOutboundNatPolicy(nwToNat string) {
Expand Down
10 changes: 5 additions & 5 deletions pkg/hns/netconf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ var _ = Describe("HNS NetConf", func() {
n := NetConf{
AdditionalArgs: []policyArgument{
{
Type: "someType",
Type: "EndpointPolicy",
Value: map[string]interface{}{
"someKey": "someValue",
},
Expand All @@ -141,13 +141,13 @@ var _ = Describe("HNS NetConf", func() {
}

result := n.MarshalPolicies()
Expect(len(result)).To(Equal(2))
Expect(len(result)).To(Equal(1))

var policy policyArgument
var policy map[string]interface{}
err := json.Unmarshal(result[0], &policy)
Expect(err).ToNot(HaveOccurred())
Expect(policy.Type).To(Equal("someType"))
Expect(policy.Value).To(HaveKeyWithValue("someKey", "someValue"))
Expect(policy).Should(HaveKey("someKey"))
Expect(policy["someKey"]).To(Equal("someValue"))
})
})

Expand Down
12 changes: 7 additions & 5 deletions plugins/main/windows/overlay/overlay_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,14 @@ func cmdAdd(args *skel.CmdArgs) error {
if len(n.endpointMacPrefix) != 5 || n.endpointMacPrefix[2] != '-' {
return fmt.Errorf("endpointMacPrefix [%v] is invalid, value must be of the format xx-xx", n.endpointMacPrefix)
}
} else{
n.endpointMacPrefix="0E-2A"
}

networkName := n.Name
hnsNetwork, err := hcsshim.GetHNSNetworkByName(networkName)
if err != nil {
return err
return fmt.Errorf("Error while GETHNSNewtorkByName(%v): %v",networkName,err)
}

if hnsNetwork == nil {
Expand All @@ -86,13 +88,13 @@ func cmdAdd(args *skel.CmdArgs) error {
// run the IPAM plugin and get back the config to apply
r, err := ipam.ExecAdd(n.IPAM.Type, args.StdinData)
if err != nil {
return nil, err
return nil, fmt.Errorf("Error while ipam.ExecAdd: %v",err)
}

// Convert whatever the IPAM result was into the current Result type
result, err := current.NewResultFromResult(r)
if err != nil {
return nil, err
return nil, fmt.Errorf("Error while NewResultFromResult: %v",err)
}

if len(result.IPs) == 0 {
Expand Down Expand Up @@ -124,12 +126,12 @@ func cmdAdd(args *skel.CmdArgs) error {
})

if err != nil {
return err
return fmt.Errorf("Error while ProvisionEndpoint(%v,%v,%v) :%v",epName, hnsNetwork.Id,args.ContainerID, err)
}

result, err := hns.ConstructResult(hnsNetwork, hnsEndpoint)
if err != nil {
return err
return fmt.Errorf("Error while constructResult: %v",err)
}

return types.PrintResult(result, cniVersion)
Expand Down