aboutsummaryrefslogtreecommitdiffstats
path: root/src/k8splugin/plugins/ovn4nfvk8s-network/plugin.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/k8splugin/plugins/ovn4nfvk8s-network/plugin.go')
-rw-r--r--src/k8splugin/plugins/ovn4nfvk8s-network/plugin.go34
1 files changed, 15 insertions, 19 deletions
diff --git a/src/k8splugin/plugins/ovn4nfvk8s-network/plugin.go b/src/k8splugin/plugins/ovn4nfvk8s-network/plugin.go
index 959586bc..3f5d80ba 100644
--- a/src/k8splugin/plugins/ovn4nfvk8s-network/plugin.go
+++ b/src/k8splugin/plugins/ovn4nfvk8s-network/plugin.go
@@ -46,6 +46,9 @@ type OVNNbctl struct {
// Run a command via ovn-nbctl
func (ctl *OVNNbctl) Run(args ...string) (string, string, error) {
+ if ctl.exec == nil {
+ ctl.exec = kexec.New()
+ }
if ctl.path == "" {
nbctlPath, err := ctl.exec.LookPath(ovnNbctlCommand)
if err != nil {
@@ -53,9 +56,6 @@ func (ctl *OVNNbctl) Run(args ...string) (string, string, error) {
}
ctl.path = nbctlPath
}
- if ctl.exec == nil {
- ctl.exec = kexec.New()
- }
stdout := &bytes.Buffer{}
stderr := &bytes.Buffer{}
@@ -76,25 +76,21 @@ func init() {
// CreateNetwork in OVN controller
func CreateNetwork(network *v1.OnapNetwork) (string, error) {
- config, err := network.DecodeConfig()
- if err != nil {
- return "", err
- }
- name := config["name"].(string)
- if name == "" {
- return "", pkgerrors.New("Empty Name value")
- }
+ name := network.Spec.Name
+ if name == "" {
+ return "", pkgerrors.New("Invalid Network Name")
+ }
- subnet := config["subnet"].(string)
- if subnet == "" {
- return "", pkgerrors.New("Empty Subnet value")
- }
+ subnet := network.Spec.Subnet
+ if subnet == "" {
+ return "", pkgerrors.New("Invalid Subnet Address")
+ }
- gatewayIPMask := config["gateway"].(string)
- if gatewayIPMask == "" {
- return "", pkgerrors.New("Empty Gateway IP Mask")
- }
+ gatewayIPMask := network.Spec.Gateway
+ if gatewayIPMask == "" {
+ return "", pkgerrors.New("Invalid Gateway Address")
+ }
routerMac, stderr, err := ovnCmd.Run(getAuthStr(), "--if-exist", "-v", "get", "logical_router_port", "rtos-"+name, "mac")
if err != nil {