Skip to content

Commit

Permalink
Change app to appProfile
Browse files Browse the repository at this point in the history
  • Loading branch information
jojimt committed Mar 4, 2016
1 parent 9c4fa80 commit 2ee80bd
Show file tree
Hide file tree
Showing 9 changed files with 226 additions and 192 deletions.
30 changes: 0 additions & 30 deletions app.json

This file was deleted.

42 changes: 42 additions & 0 deletions appProfile.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"name": "contivModel",
"objects": [
{
"name": "appProfile",
"type": "object",
"key": [ "tenantName", "networkName", "appProfileName" ],
"properties": {
"appProfileName": {
"type": "string",
"title": "Application Profile Name"
},
"endpointGroups": {
"type": "array",
"items": "string",
"title": "Member groups of the appProf"
},
"networkName": {
"type": "string",
"title": "Network of App Prof"
},
"tenantName": {
"type": "string",
"title": "Tenant Name"
}
},
"link-sets": {
"endpointGroups": {
"ref": "endpointGroup"
}
},
"links": {
"tenant": {
"ref": "tenant"
},
"network": {
"ref": "network"
}
}
}
]
}
30 changes: 17 additions & 13 deletions client/contivModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
// This file is auto generated by modelgen tool
// Do not edit this file manually

var AppSummaryView = React.createClass({
var AppProfileSummaryView = React.createClass({
render: function() {
var self = this

// Walk thru all objects
var appListView = self.props.apps.map(function(app){
var appProfileListView = self.props.appProfiles.map(function(appProfile){
return (
<ModalTrigger modal={<AppModalView app={ app }/>}>
<tr key={ app.key } className="info">
<ModalTrigger modal={<AppProfileModalView appProfile={ appProfile }/>}>
<tr key={ appProfile.key } className="info">


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


</tr>
</thead>
<tbody>
{ appListView }
{ appProfileListView }
</tbody>
</Table>
</div>
);
}
});

var AppModalView = React.createClass({
var AppProfileModalView = React.createClass({
render() {
var obj = this.props.app
var obj = this.props.appProfile
return (
<Modal {...this.props} bsStyle='primary' bsSize='large' title='App' animation={false}>
<Modal {...this.props} bsStyle='primary' bsSize='large' title='AppProfile' animation={false}>
<div className='modal-body' style={ {margin: '5%',} }>


<Input type='text' label='Application Name' ref='appName' defaultValue={obj.appName} placeholder='Application Name' />
<Input type='text' label='Application Profile Name' ref='appProfileName' defaultValue={obj.appProfileName} placeholder='Application Profile Name' />

<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' />

Expand All @@ -57,8 +61,8 @@ var AppModalView = React.createClass({
}
});

module.exports.AppSummaryView = AppSummaryView
module.exports.AppModalView = AppModalView
module.exports.AppProfileSummaryView = AppProfileSummaryView
module.exports.AppProfileModalView = AppProfileModalView
var EndpointGroupSummaryView = React.createClass({
render: function() {
var self = this
Expand Down
71 changes: 38 additions & 33 deletions client/contivModelClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,24 +142,27 @@ func NewContivClient(baseURL string) (*ContivClient, error) {
return &client, nil
}

type App struct {
type AppProfile struct {
// every object has a key
Key string `json:"key,omitempty"`

AppName string `json:"appName,omitempty"` // Application Name
TenantName string `json:"tenantName,omitempty"` // Tenant Name
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

// add link-sets and links
LinkSets AppLinkSets `json:"link-sets,omitempty"`
Links AppLinks `json:"links,omitempty"`
LinkSets AppProfileLinkSets `json:"link-sets,omitempty"`
Links AppProfileLinks `json:"links,omitempty"`
}

type AppLinkSets struct {
Services map[string]modeldb.Link `json:"Services,omitempty"`
type AppProfileLinkSets struct {
EndpointGroups map[string]modeldb.Link `json:"EndpointGroups,omitempty"`
}

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

type EndpointGroup struct {
Expand All @@ -183,8 +186,9 @@ type EndpointGroupLinkSets struct {
}

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

type Global struct {
Expand Down Expand Up @@ -227,6 +231,7 @@ type Network struct {
}

type NetworkLinkSets struct {
AppProfiles map[string]modeldb.Link `json:"AppProfiles,omitempty"`
EndpointGroups map[string]modeldb.Link `json:"EndpointGroups,omitempty"`
Services map[string]modeldb.Link `json:"Services,omitempty"`
}
Expand Down Expand Up @@ -351,7 +356,7 @@ type Tenant struct {
}

type TenantLinkSets struct {
Apps map[string]modeldb.Link `json:"Apps,omitempty"`
AppProfiles map[string]modeldb.Link `json:"AppProfiles,omitempty"`
EndpointGroups map[string]modeldb.Link `json:"EndpointGroups,omitempty"`
Networks map[string]modeldb.Link `json:"Networks,omitempty"`
Policies map[string]modeldb.Link `json:"Policies,omitempty"`
Expand Down Expand Up @@ -407,65 +412,65 @@ type VolumeProfileLinks struct {
Tenant modeldb.Link `json:"Tenant,omitempty"`
}

// AppPost posts the app object
func (c *ContivClient) AppPost(obj *App) error {
// AppProfilePost posts the appProfile object
func (c *ContivClient) AppProfilePost(obj *AppProfile) error {
// build key and URL
keyStr := obj.TenantName + ":" + obj.AppName
url := c.baseURL + "/api/apps/" + keyStr + "/"
keyStr := obj.TenantName + ":" + obj.NetworkName + ":" + obj.AppProfileName
url := c.baseURL + "/api/appProfiles/" + keyStr + "/"

// http post the object
err := httpPost(url, obj)
if err != nil {
log.Debugf("Error creating app %+v. Err: %v", obj, err)
log.Debugf("Error creating appProfile %+v. Err: %v", obj, err)
return err
}

return nil
}

// AppList lists all app objects
func (c *ContivClient) AppList() (*[]*App, error) {
// AppProfileList lists all appProfile objects
func (c *ContivClient) AppProfileList() (*[]*AppProfile, error) {
// build key and URL
url := c.baseURL + "/api/apps/"
url := c.baseURL + "/api/appProfiles/"

// http get the object
var objList []*App
var objList []*AppProfile
err := httpGet(url, &objList)
if err != nil {
log.Debugf("Error getting apps. Err: %v", err)
log.Debugf("Error getting appProfiles. Err: %v", err)
return nil, err
}

return &objList, nil
}

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

// http get the object
var obj App
var obj AppProfile
err := httpGet(url, &obj)
if err != nil {
log.Debugf("Error getting app %+v. Err: %v", keyStr, err)
log.Debugf("Error getting appProfile %+v. Err: %v", keyStr, err)
return nil, err
}

return &obj, nil
}

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

// http get the object
err := httpDelete(url)
if err != nil {
log.Debugf("Error deleting app %s. Err: %v", keyStr, err)
log.Debugf("Error deleting appProfile %s. Err: %v", keyStr, err)
return err
}

Expand Down
32 changes: 17 additions & 15 deletions client/contivModelClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,36 +72,38 @@ def httpGet(url):
class objmodelClient:
def __init__(self, baseUrl):
self.baseUrl = baseUrl
# Create app
def createApp(self, obj):
postUrl = self.baseUrl + '/api/Apps/' + obj.tenantName + ":" + obj.appName + '/'
# Create appProfile
def createAppProfile(self, obj):
postUrl = self.baseUrl + '/api/AppProfiles/' + obj.tenantName + ":" + obj.networkName + ":" + obj.appProfileName + '/'

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

# Post the data
response = httpPost(postUrl, jdata)

if response == "Error":
errorExit("App create failure")
errorExit("AppProfile create failure")

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

if response == "Error":
errorExit("App create failure")
errorExit("AppProfile create failure")

# List all app objects
def listApp(self):
# Get a list of app objects
retDate = urllib2.urlopen(self.baseUrl + '/api/apps/')
# List all appProfile objects
def listAppProfile(self):
# Get a list of appProfile objects
retDate = urllib2.urlopen(self.baseUrl + '/api/appProfiles/')
if retData == "Error":
errorExit("list App failed")
errorExit("list AppProfile failed")

return json.loads(retData)
# Create endpointGroup
Expand Down
Loading

0 comments on commit 2ee80bd

Please sign in to comment.