Skip to content

Commit

Permalink
Make epg<-->network relationship an association instead of a child->p…
Browse files Browse the repository at this point in the history
…arent (#23)
  • Loading branch information
jojimt authored and shaleman committed May 24, 2016
1 parent 945d1d9 commit e2527ca
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 56 deletions.
11 changes: 1 addition & 10 deletions appProfile.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,14 @@
{
"name": "appProfile",
"type": "object",
"key": [ "tenantName", "networkName", "appProfileName" ],
"key": [ "tenantName", "appProfileName" ],
"properties": {
"tenantName": {
"type": "string",
"title": "Tenant Name",
"length": 64,
"format": "^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\\\-]*[a-zA-Z0-9])\\\\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\\\\-]*[A-Za-z0-9])$"
},
"networkName": {
"type": "string",
"title": "Network of App Prof",
"length": 64,
"format": "^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\\\-]*[a-zA-Z0-9])\\\\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\\\\-]*[A-Za-z0-9])$"
},
"appProfileName": {
"type": "string",
"title": "Application Profile Name",
Expand All @@ -38,9 +32,6 @@
"links": {
"tenant": {
"ref": "tenant"
},
"network": {
"ref": "network"
}
}
}
Expand Down
6 changes: 2 additions & 4 deletions client/contivModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var AppProfileSummaryView = React.createClass({
<ModalTrigger modal={<AppProfileModalView appProfile={ appProfile }/>}>
<tr key={ appProfile.key } className="info">


</tr>
</ModalTrigger>
);
Expand All @@ -24,7 +24,7 @@ var AppProfileSummaryView = React.createClass({
<thead>
<tr>


</tr>
</thead>
<tbody>
Expand All @@ -48,8 +48,6 @@ var AppProfileModalView = React.createClass({

<Input type='text' label='Member groups of the appProf' ref='endpointGroups' defaultValue={obj.endpointGroups} placeholder='Member groups of the appProf' />

<Input type='text' label='Network of App Prof' ref='networkName' defaultValue={obj.networkName} placeholder='Network of App Prof' />

<Input type='text' label='Tenant Name' ref='tenantName' defaultValue={obj.tenantName} placeholder='Tenant Name' />

</div>
Expand Down
27 changes: 12 additions & 15 deletions client/contivModelClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,7 @@ type AppProfile struct {

AppProfileName string `json:"appProfileName,omitempty"` // Application Profile Name
EndpointGroups []string `json:"endpointGroups,omitempty"`
NetworkName string `json:"networkName,omitempty"` // Network of App Prof
TenantName string `json:"tenantName,omitempty"` // Tenant Name
TenantName string `json:"tenantName,omitempty"` // Tenant Name

// add link-sets and links
LinkSets AppProfileLinkSets `json:"link-sets,omitempty"`
Expand All @@ -165,8 +164,7 @@ type AppProfileLinkSets struct {
}

type AppProfileLinks struct {
Network Link `json:"Network,omitempty"`
Tenant Link `json:"Tenant,omitempty"`
Tenant Link `json:"Tenant,omitempty"`
}

type Bgp struct {
Expand Down Expand Up @@ -237,7 +235,6 @@ type Network struct {
}

type NetworkLinkSets struct {
AppProfiles map[string]Link `json:"AppProfiles,omitempty"`
EndpointGroups map[string]Link `json:"EndpointGroups,omitempty"`
Servicelbs map[string]Link `json:"Servicelbs,omitempty"`
Services map[string]Link `json:"Services,omitempty"`
Expand Down Expand Up @@ -386,7 +383,7 @@ type VolumeProfileLinks struct {
// AppProfilePost posts the appProfile object
func (c *ContivClient) AppProfilePost(obj *AppProfile) error {
// build key and URL
keyStr := obj.TenantName + ":" + obj.NetworkName + ":" + obj.AppProfileName
keyStr := obj.TenantName + ":" + obj.AppProfileName
url := c.baseURL + "/api/appProfiles/" + keyStr + "/"

// http post the object
Expand Down Expand Up @@ -416,9 +413,9 @@ func (c *ContivClient) AppProfileList() (*[]*AppProfile, error) {
}

// AppProfileGet gets the appProfile object
func (c *ContivClient) AppProfileGet(tenantName string, networkName string, appProfileName string) (*AppProfile, error) {
func (c *ContivClient) AppProfileGet(tenantName string, appProfileName string) (*AppProfile, error) {
// build key and URL
keyStr := tenantName + ":" + networkName + ":" + appProfileName
keyStr := tenantName + ":" + appProfileName
url := c.baseURL + "/api/appProfiles/" + keyStr + "/"

// http get the object
Expand All @@ -433,9 +430,9 @@ func (c *ContivClient) AppProfileGet(tenantName string, networkName string, appP
}

// AppProfileDelete deletes the appProfile object
func (c *ContivClient) AppProfileDelete(tenantName string, networkName string, appProfileName string) error {
func (c *ContivClient) AppProfileDelete(tenantName string, appProfileName string) error {
// build key and URL
keyStr := tenantName + ":" + networkName + ":" + appProfileName
keyStr := tenantName + ":" + appProfileName
url := c.baseURL + "/api/appProfiles/" + keyStr + "/"

// http get the object
Expand Down Expand Up @@ -516,7 +513,7 @@ func (c *ContivClient) BgpDelete(hostname string) error {
// EndpointGroupPost posts the endpointGroup object
func (c *ContivClient) EndpointGroupPost(obj *EndpointGroup) error {
// build key and URL
keyStr := obj.TenantName + ":" + obj.NetworkName + ":" + obj.GroupName
keyStr := obj.TenantName + ":" + obj.GroupName
url := c.baseURL + "/api/endpointGroups/" + keyStr + "/"

// http post the object
Expand Down Expand Up @@ -546,9 +543,9 @@ func (c *ContivClient) EndpointGroupList() (*[]*EndpointGroup, error) {
}

// EndpointGroupGet gets the endpointGroup object
func (c *ContivClient) EndpointGroupGet(tenantName string, networkName string, groupName string) (*EndpointGroup, error) {
func (c *ContivClient) EndpointGroupGet(tenantName string, groupName string) (*EndpointGroup, error) {
// build key and URL
keyStr := tenantName + ":" + networkName + ":" + groupName
keyStr := tenantName + ":" + groupName
url := c.baseURL + "/api/endpointGroups/" + keyStr + "/"

// http get the object
Expand All @@ -563,9 +560,9 @@ func (c *ContivClient) EndpointGroupGet(tenantName string, networkName string, g
}

// EndpointGroupDelete deletes the endpointGroup object
func (c *ContivClient) EndpointGroupDelete(tenantName string, networkName string, groupName string) error {
func (c *ContivClient) EndpointGroupDelete(tenantName string, groupName string) error {
// build key and URL
keyStr := tenantName + ":" + networkName + ":" + groupName
keyStr := tenantName + ":" + groupName
url := c.baseURL + "/api/endpointGroups/" + keyStr + "/"

// http get the object
Expand Down
13 changes: 6 additions & 7 deletions client/contivModelClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,11 @@ def __init__(self, baseUrl):
self.baseUrl = baseUrl
# Create appProfile
def createAppProfile(self, obj):
postUrl = self.baseUrl + '/api/appProfiles/' + obj.tenantName + ":" + obj.networkName + ":" + obj.appProfileName + '/'
postUrl = self.baseUrl + '/api/appProfiles/' + obj.tenantName + ":" + obj.appProfileName + '/'

jdata = json.dumps({
"appProfileName": obj.appProfileName,
"endpointGroups": obj.endpointGroups,
"networkName": obj.networkName,
"tenantName": obj.tenantName,
})

Expand All @@ -90,9 +89,9 @@ def createAppProfile(self, obj):
errorExit("AppProfile create failure")

# Delete appProfile
def deleteAppProfile(self, tenantName, networkName, appProfileName):
def deleteAppProfile(self, tenantName, appProfileName):
# Delete AppProfile
deleteUrl = self.baseUrl + '/api/appProfiles/' + tenantName + ":" + networkName + ":" + appProfileName + '/'
deleteUrl = self.baseUrl + '/api/appProfiles/' + tenantName + ":" + appProfileName + '/'
response = httpDelete(deleteUrl)

if response == "Error":
Expand Down Expand Up @@ -143,7 +142,7 @@ def listBgp(self):
return json.loads(retData)
# Create endpointGroup
def createEndpointGroup(self, obj):
postUrl = self.baseUrl + '/api/endpointGroups/' + obj.tenantName + ":" + obj.networkName + ":" + obj.groupName + '/'
postUrl = self.baseUrl + '/api/endpointGroups/' + obj.tenantName + ":" + obj.groupName + '/'

jdata = json.dumps({
"groupName": obj.groupName,
Expand All @@ -159,9 +158,9 @@ def createEndpointGroup(self, obj):
errorExit("EndpointGroup create failure")

# Delete endpointGroup
def deleteEndpointGroup(self, tenantName, networkName, groupName):
def deleteEndpointGroup(self, tenantName, groupName):
# Delete EndpointGroup
deleteUrl = self.baseUrl + '/api/endpointGroups/' + tenantName + ":" + networkName + ":" + groupName + '/'
deleteUrl = self.baseUrl + '/api/endpointGroups/' + tenantName + ":" + groupName + '/'
response = httpDelete(deleteUrl)

if response == "Error":
Expand Down
20 changes: 4 additions & 16 deletions contivModel.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ type AppProfile struct {

AppProfileName string `json:"appProfileName,omitempty"` // Application Profile Name
EndpointGroups []string `json:"endpointGroups,omitempty"`
NetworkName string `json:"networkName,omitempty"` // Network of App Prof
TenantName string `json:"tenantName,omitempty"` // Tenant Name
TenantName string `json:"tenantName,omitempty"` // Tenant Name

// add link-sets and links
LinkSets AppProfileLinkSets `json:"link-sets,omitempty"`
Expand All @@ -34,8 +33,7 @@ type AppProfileLinkSets struct {
}

type AppProfileLinks struct {
Network modeldb.Link `json:"Network,omitempty"`
Tenant modeldb.Link `json:"Tenant,omitempty"`
Tenant modeldb.Link `json:"Tenant,omitempty"`
}

type Bgp struct {
Expand Down Expand Up @@ -106,7 +104,6 @@ type Network struct {
}

type NetworkLinkSets struct {
AppProfiles map[string]modeldb.Link `json:"AppProfiles,omitempty"`
EndpointGroups map[string]modeldb.Link `json:"EndpointGroups,omitempty"`
Servicelbs map[string]modeldb.Link `json:"Servicelbs,omitempty"`
Services map[string]modeldb.Link `json:"Services,omitempty"`
Expand Down Expand Up @@ -800,7 +797,7 @@ func restoreAppProfile() error {
// Validate a appProfile object
func ValidateAppProfile(obj *AppProfile) error {
// Validate key is correct
keyStr := obj.TenantName + ":" + obj.NetworkName + ":" + obj.AppProfileName
keyStr := obj.TenantName + ":" + obj.AppProfileName
if obj.Key != keyStr {
log.Errorf("Expecting AppProfile Key: %s. Got: %s", keyStr, obj.Key)
return errors.New("Invalid Key")
Expand All @@ -817,15 +814,6 @@ func ValidateAppProfile(obj *AppProfile) error {
return errors.New("appProfileName string invalid format")
}

if len(obj.NetworkName) > 64 {
return errors.New("networkName string too long")
}

networkNameMatch := regexp.MustCompile("^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]*[a-zA-Z0-9])\\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\\-]*[A-Za-z0-9])$")
if networkNameMatch.MatchString(obj.NetworkName) == false {
return errors.New("networkName string invalid format")
}

if len(obj.TenantName) > 64 {
return errors.New("tenantName string too long")
}
Expand Down Expand Up @@ -1340,7 +1328,7 @@ func restoreEndpointGroup() error {
// Validate a endpointGroup object
func ValidateEndpointGroup(obj *EndpointGroup) error {
// Validate key is correct
keyStr := obj.TenantName + ":" + obj.NetworkName + ":" + obj.GroupName
keyStr := obj.TenantName + ":" + obj.GroupName
if obj.Key != keyStr {
log.Errorf("Expecting EndpointGroup Key: %s. Got: %s", keyStr, obj.Key)
return errors.New("Invalid Key")
Expand Down
2 changes: 1 addition & 1 deletion endpointGroup.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"name": "endpointGroup",
"type": "object",
"key": [ "tenantName", "networkName", "groupName" ],
"key": [ "tenantName", "groupName" ],
"properties": {
"groupName": {
"type": "string",
Expand Down
3 changes: 0 additions & 3 deletions network.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@
"services": {
"ref": "service"
},
"appProfiles": {
"ref": "appProfile"
},
"endpointGroups": {
"ref": "endpointGroup"
},
Expand Down

0 comments on commit e2527ca

Please sign in to comment.