Skip to content

Commit

Permalink
Merge pull request #643 from jojimt/gw-api2
Browse files Browse the repository at this point in the history
Propagate gw config to the aci-gw
  • Loading branch information
Joji Mekkatt authored Nov 30, 2016
2 parents 1a8bb70 + aee507e commit c39b3d8
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,8 @@ host-integ-test: host-cleanup start-aci-gw

start-aci-gw:
@echo dev: starting aci gw...
docker pull contiv/aci-gw:integ_test
docker run --net=host -itd -e "APIC_URL=SANITY" -e "APIC_USERNAME=IGNORE" -e "APIC_PASSWORD=IGNORE" -e "APIC_LEAF_NODE=IGNORE" -e "APIC_PHYS_DOMAIN=IGNORE" --name=contiv-aci-gw contiv/aci-gw:integ_test
docker pull contiv/aci-gw:11-28-2016.1.3_2i
docker run --net=host -itd -e "APIC_URL=SANITY" -e "APIC_USERNAME=IGNORE" -e "APIC_PASSWORD=IGNORE" --name=contiv-aci-gw contiv/aci-gw:11-28-2016.1.3_2i

host-cleanup:
@echo dev: cleaning up services...
Expand Down
18 changes: 13 additions & 5 deletions netmaster/objApi/infraproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,16 @@ const (
cProvide = "PROVIDE"
cInternal = "INTERNAL"
cExternal = "EXTERNAL"
aciGwAPIVersion = "v1.1"
aciGwAPIVersion = "v1.2"
)

// appNwSpec Applications network spec per the composition
type appNwSpec struct {
ACIGwAPIVersion string `json:"aci-gw-api-version,omitempty"`
TenantName string `json:"tenant,omitempty"`
AppName string `json:"app-prof,omitempty"`
ContractDefs []contrSpec `json:"contract-defs,omitempty"` // defined by this app
ACIGwAPIVersion string `json:"aci-gw-api-version,omitempty"`
GWConfig *contivModel.AciGw `json:"gw-config,omitempty"`
TenantName string `json:"tenant,omitempty"`
AppName string `json:"app-prof,omitempty"`
ContractDefs []contrSpec `json:"contract-defs,omitempty"` // defined by this app

Epgs []epgSpec `json:"epgs,omitempty"`
}
Expand Down Expand Up @@ -362,6 +363,13 @@ func CreateAppNw(app *contivModel.AppProfile) error {
ans := &appNwSpec{}

ans.ACIGwAPIVersion = aciGwAPIVersion
gwConfig := contivModel.FindAciGw("aciGw")
if gwConfig == nil {
log.Infof("aciGw object not found -- gw will use env settings")
} else {
ans.GWConfig = gwConfig
log.Infof("gwConfig: %+v", gwConfig)
}
ans.TenantName = app.TenantName
ans.AppName = app.AppProfileName

Expand Down
67 changes: 67 additions & 0 deletions test/integration/app_prof_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ import (

// TestSingleAppProfile verifies a simple app-profile creation
func (its *integTestSuite) TestSingleAppProfile(c *C) {

if its.fabricMode != "aci" {
return // run only in aci mode
}

// Create a tenant
c.Assert(its.client.TenantPost(&client.Tenant{
TenantName: "BBTenant",
Expand Down Expand Up @@ -108,6 +113,45 @@ func (its *integTestSuite) TestSingleAppProfile(c *C) {
c.Assert(its.client.RulePost(rule), IsNil)
}

// if aciGw present, delete it
its.client.AciGwDelete("aciGw")

// Create an app-profile
err = its.client.AppProfilePost(&client.AppProfile{
TenantName: "BBTenant",
AppProfileName: "TestProfile",
EndpointGroups: []string{"epgA", "epgB"},
})
assertErr(err, c, "creating application-profile without aci-gw config")

// set aci-gw config
err = its.client.AciGwPost(&client.AciGw{
Name: "aciGw",
PhysicalDomain: "testDomain",
EnforcePolicies: "yes",
IncludeCommonTenant: "no",
})
assertNoErr(err, c, "creating aciGw config")

// Create an app-profile
err = its.client.AppProfilePost(&client.AppProfile{
TenantName: "BBTenant",
AppProfileName: "TestProfile",
EndpointGroups: []string{"epgA", "epgB"},
})
assertErr(err, c, "creating application-profile without bindings")


// set aci-gw config
err = its.client.AciGwPost(&client.AciGw{
Name: "aciGw",
PathBindings: "topology/pod-1/paths-101/pathep-[eth1/14]",
PhysicalDomain: "testDomain",
EnforcePolicies: "yes",
IncludeCommonTenant: "no",
})
assertNoErr(err, c, "creating aciGw config")

// Create an app-profile
err = its.client.AppProfilePost(&client.AppProfile{
TenantName: "BBTenant",
Expand All @@ -116,6 +160,10 @@ func (its *integTestSuite) TestSingleAppProfile(c *C) {
})
assertNoErr(err, c, "creating application-profile")

gwInsp, err := its.client.AciGwInspect("aciGw")
assertNoErr(err, c, "inspecting aciGw")
c.Assert(gwInsp.Oper.NumAppProfiles, Equals, 1)

// verify tenant state is correct
insp, err := its.client.TenantInspect("BBTenant")
assertNoErr(err, c, "inspecting tenant")
Expand All @@ -127,16 +175,25 @@ func (its *integTestSuite) TestSingleAppProfile(c *C) {
c.Assert(insp.Oper.TotalAppProfiles, Equals, 1)

assertNoErr(its.client.AppProfileDelete("BBTenant", "TestProfile"), c, "deleting app profile")
gwInsp, err = its.client.AciGwInspect("aciGw")
assertNoErr(err, c, "inspecting aciGw")
c.Assert(gwInsp.Oper.NumAppProfiles, Equals, 0)

assertNoErr(its.client.EndpointGroupDelete("BBTenant", "epgA"), c, "deleting endpointGroup")
assertNoErr(its.client.EndpointGroupDelete("BBTenant", "epgB"), c, "deleting endpointGroup")
assertNoErr(its.client.PolicyDelete("BBTenant", "Policy1"), c, "deleting policy")
assertNoErr(its.client.NetworkDelete("BBTenant", "NetNet"), c, "deleting network")
assertNoErr(its.client.ExtContractsGroupDelete("BBTenant", "extWeb"), c, "deleting ext contract")
assertNoErr(its.client.ExtContractsGroupDelete("BBTenant", "extETCD"), c, "deleting ext contract")
assertNoErr(its.client.TenantDelete("BBTenant"), c, "deleting Tenant")
assertNoErr(its.client.AciGwDelete("aciGw"), c, "deleting aci gw config")
}

func (its *integTestSuite) TestMultiAppProfile(c *C) {
if its.fabricMode != "aci" {
return // run only in aci mode
}

// Create a tenant
c.Assert(its.client.TenantPost(&client.Tenant{
TenantName: "AATenant",
Expand Down Expand Up @@ -237,6 +294,16 @@ func (its *integTestSuite) TestMultiAppProfile(c *C) {
c.Assert(its.client.RulePost(rule), IsNil)
}

// set aci-gw config
err = its.client.AciGwPost(&client.AciGw{
Name: "aciGw",
PathBindings: "topology/pod-1/paths-101/pathep-[eth1/14]",
PhysicalDomain: "testDomain",
EnforcePolicies: "yes",
IncludeCommonTenant: "no",
})
assertNoErr(err, c, "creating aciGw config")

// Create an app-profile
err = its.client.AppProfilePost(&client.AppProfile{
TenantName: "AATenant",
Expand Down
4 changes: 2 additions & 2 deletions test/integration/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ func assertNoErr(err error, c *C, msg string) {
// assertErr utility function to assert no error
func assertErr(err error, c *C, msg string) {
if err == nil {
log.Errorf("Expected Error %s.", err)
log.Errorf("Expected Error %s.", msg)
debug.PrintStack()
c.Fatalf("Expected Error %s.", err)
c.Fatalf("Expected Error %s.", msg)
}
}

Expand Down
9 changes: 9 additions & 0 deletions test/systemtests/netprofile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,9 @@ func (s *systemtestSuite) TestNetprofileUpdateNetmasterSwitchover(c *C) {
c.Assert(s.startIperfServers(containers), IsNil)
c.Assert(s.checkIngressRate(containers, netProfile.Bandwidth), IsNil)
c.Assert(s.startIperfClients(containers, netProfile.Bandwidth, false), IsNil)
for _, node := range s.nodes {
c.Assert(node.checkSchedulerNetworkOnNodeCreated([]string{"private"}), IsNil)
}

var leader, oldLeader *node

Expand Down Expand Up @@ -648,6 +651,9 @@ func (s *systemtestSuite) TestNetprofileUpdateNetmasterSwitchover(c *C) {
time.Sleep(5 * time.Second)
c.Assert(s.checkIngressRate(containers, netProfile.Bandwidth), IsNil)
c.Assert(s.startIperfClients(containers, netProfile.Bandwidth, false), IsNil)
for _, node := range s.nodes {
c.Assert(node.checkSchedulerNetworkOnNodeCreated([]string{"private"}), IsNil)
}

netProfile = &client.Netprofile{
ProfileName: "Netprofile",
Expand All @@ -659,6 +665,9 @@ func (s *systemtestSuite) TestNetprofileUpdateNetmasterSwitchover(c *C) {
c.Assert(s.cli.NetprofilePost(netProfile), IsNil)
c.Assert(s.checkIngressRate(containers, netProfile.Bandwidth), IsNil)
c.Assert(s.startIperfClients(containers, netProfile.Bandwidth, false), IsNil)
for _, node := range s.nodes {
c.Assert(node.checkSchedulerNetworkOnNodeCreated([]string{"private"}), IsNil)
}

c.Assert(s.removeContainers(containers), IsNil)

Expand Down
3 changes: 3 additions & 0 deletions test/systemtests/trigger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ func (s *systemtestSuite) TestTriggerNodeReload(c *C) {
network.Ipv6Gateway = "2016:0617::254"
}
c.Assert(s.cli.NetworkPost(network), IsNil)
for _, node := range s.nodes {
c.Assert(node.checkSchedulerNetworkOnNodeCreated([]string{"private"}), IsNil)
}

numContainers := s.basicInfo.Containers
if numContainers < (len(s.nodes) * 2) {
Expand Down

0 comments on commit c39b3d8

Please sign in to comment.