Skip to content

Commit

Permalink
Add infra-nw support (#15)
Browse files Browse the repository at this point in the history
* Add infra-nw support

* update review comments
  • Loading branch information
pkeerthana authored and shaleman committed Apr 23, 2016
1 parent d83fae6 commit bb05161
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions client/contivModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,8 @@ var NetworkSummaryView = React.createClass({

<td>{ network.networkName }</td>

<td>{ network.nwType }</td>

<td>{ network.pktTag }</td>

<td>{ network.subnet }</td>
Expand All @@ -301,6 +303,7 @@ var NetworkSummaryView = React.createClass({
<th> Encapsulation </th>
<th> Gateway </th>
<th> Network name </th>
<th> Network Type </th>
<th> Vlan/Vxlan Tag </th>
<th> Subnet </th>
</tr>
Expand Down Expand Up @@ -328,6 +331,8 @@ var NetworkModalView = React.createClass({

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

<Input type='text' label='Network Type' ref='nwType' defaultValue={obj.nwType} placeholder='Network Type' />

<Input type='text' label='Vlan/Vxlan Tag' ref='pktTag' defaultValue={obj.pktTag} placeholder='Vlan/Vxlan Tag' />

<Input type='text' label='Subnet' ref='subnet' defaultValue={obj.subnet} placeholder='Subnet' />
Expand Down
1 change: 1 addition & 0 deletions client/contivModelClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ type Network struct {
Encap string `json:"encap,omitempty"` // Encapsulation
Gateway string `json:"gateway,omitempty"` // Gateway
NetworkName string `json:"networkName,omitempty"` // Network name
NwType string `json:"nwType,omitempty"` // Network Type
PktTag int `json:"pktTag,omitempty"` // Vlan/Vxlan Tag
Subnet string `json:"subnet,omitempty"` // Subnet
TenantName string `json:"tenantName,omitempty"` // Tenant Name
Expand Down
6 changes: 6 additions & 0 deletions contivModel.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ type Network struct {
Encap string `json:"encap,omitempty"` // Encapsulation
Gateway string `json:"gateway,omitempty"` // Gateway
NetworkName string `json:"networkName,omitempty"` // Network name
NwType string `json:"nwType,omitempty"` // Network Type
PktTag int `json:"pktTag,omitempty"` // Vlan/Vxlan Tag
Subnet string `json:"subnet,omitempty"` // Subnet
TenantName string `json:"tenantName,omitempty"` // Tenant Name
Expand Down Expand Up @@ -1873,6 +1874,11 @@ func ValidateNetwork(obj *Network) error {
return errors.New("networkName string too long")
}

nwTypeMatch := regexp.MustCompile("^(infra|data)$")
if nwTypeMatch.MatchString(obj.NwType) == false {
return errors.New("nwType string invalid format")
}

subnetMatch := regexp.MustCompile("^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(\\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3})(\\-(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9]))?/(3[0-1]|2[0-9]|1[0-9]|[1-9])$")
if subnetMatch.MatchString(obj.Subnet) == false {
return errors.New("subnet string invalid format")
Expand Down
6 changes: 6 additions & 0 deletions network.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
"title": "Tenant Name",
"length": 64
},
"nwType": {
"type": "string",
"format": "^(infra|data)$",
"title": "Network Type",
"showSummary": true
},
"encap": {
"type": "string",
"format": "^(vlan|vxlan)$",
Expand Down

0 comments on commit bb05161

Please sign in to comment.