Skip to content

Commit

Permalink
fix review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
shaleman committed Sep 2, 2015
1 parent d9d6db4 commit d9b2397
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 22 deletions.
41 changes: 24 additions & 17 deletions drivers/ovsSwitch.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,28 @@ func setLinkUp(name string) error {
return netlink.LinkSetUp(iface)
}

// getOvsPostName returns OVS port name depending on if we use Veth pairs
func getOvsPostName(intfName string) string {
var ovsPortName string

if useVethPair {
ovsPortName = strings.Replace(intfName, "port", "vport", 1)
} else {
ovsPortName = intfName
}

return ovsPortName
}

// CreatePort creates a port in ovs switch
func (sw *OvsSwitch) CreatePort(intfName string, cfgEp *OvsCfgEndpointState, pktTag int) error {
var ovsPortName string
var ovsIntfType string

// Get OVS port name
ovsPortName := getOvsPostName(intfName)

// Create Veth pairs if required
if useVethPair {
// Generate interface
ovsPortName = strings.Replace(intfName, "port", "vport", 1)
ovsIntfType = ""

// Create a Veth pair
Expand All @@ -238,7 +253,6 @@ func (sw *OvsSwitch) CreatePort(intfName string, cfgEp *OvsCfgEndpointState, pkt
return err
}
} else {
ovsPortName = intfName
ovsIntfType = "internal"

}
Expand Down Expand Up @@ -296,13 +310,8 @@ func (sw *OvsSwitch) CreatePort(intfName string, cfgEp *OvsCfgEndpointState, pkt

// UpdatePort updates an OVS port without creating it
func (sw *OvsSwitch) UpdatePort(intfName string, cfgEp *OvsCfgEndpointState, pktTag int) error {
var ovsPortName string
if useVethPair {
// Generate interface
ovsPortName = strings.Replace(intfName, "port", "vport", 1)
} else {
ovsPortName = intfName
}
// Get OVS port name
ovsPortName := getOvsPostName(intfName)

// Add the endpoint to ofnet
if sw.netType == "vxlan" {
Expand Down Expand Up @@ -341,20 +350,18 @@ func (sw *OvsSwitch) DeletePort(epOper *OvsOperEndpointState) error {
return nil
}

var ovsPortName string
if useVethPair {
// Generate interface
ovsPortName = strings.Replace(epOper.PortName, "port", "vport", 1)
// Get the OVS port name
ovsPortName := getOvsPostName(epOper.PortName)

// Delete the Veth pairs if required
if useVethPair {
// Delete a Veth pair
err := deleteVethPair(ovsPortName, epOper.PortName)
if err != nil {
log.Errorf("Error creating veth pairs. Err: %v", err)
return err
}

} else {
ovsPortName = epOper.PortName
}

// Remove info from ofnet
Expand Down
10 changes: 5 additions & 5 deletions mgmtfn/dockplugin/dockplugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func logEvent(typ string) {
log.Infof("Handling %q event", typ)
}

// activate the plugin and register it as a network driver.
// deactivate the plugin
func deactivate(hostname string) func(http.ResponseWriter, *http.Request) {
return func(w http.ResponseWriter, r *http.Request) {
logEvent("deactivate")
Expand Down Expand Up @@ -506,9 +506,9 @@ func netdcliGetNetwork(name string) ([]drivers.OvsCfgNetworkState, error) {

// GetNetworkName gets network name from network UUID
func GetNetworkName(nwID string) (string, error) {
api := libnetClient.NewRemoteAPI("")
libnetAPI := libnetClient.NewRemoteAPI("")

nw, err := api.NetworkByID(nwID)
nw, err := libnetAPI.NetworkByID(nwID)
if err != nil {
log.Infof("Error: %v", err)
return "", err
Expand All @@ -521,9 +521,9 @@ func GetNetworkName(nwID string) (string, error) {

// GetEndPointName Returns endpoint name from networkId, endpointId
func GetEndPointName(nwID, epID string) (string, error) {
api := libnetClient.NewRemoteAPI("")
libnetAPI := libnetClient.NewRemoteAPI("")

nw, err := api.NetworkByID(nwID)
nw, err := libnetAPI.NetworkByID(nwID)
if err != nil {
log.Infof("Error: %v", err)
return "", err
Expand Down

0 comments on commit d9b2397

Please sign in to comment.