summaryrefslogtreecommitdiffstats
path: root/src/k8splugin/plugins/ovn4nfvk8s-network
diff options
context:
space:
mode:
authorBin Yang <bin.yang@windriver.com>2019-05-16 01:23:52 +0000
committerGerrit Code Review <gerrit@onap.org>2019-05-16 01:23:52 +0000
commitfe05f71354a64e761bcd4d8b2307d7ede8164302 (patch)
tree88e0226379fa533d7b7b8dba336c12163c5a1329 /src/k8splugin/plugins/ovn4nfvk8s-network
parent82cbd4cf2d85f4e1025e3477c92f706d61cf875a (diff)
parent9b2e8b3e41dd89bd1cb9a661a10d5d76125af5b1 (diff)
Merge "Change format of the network file"
Diffstat (limited to 'src/k8splugin/plugins/ovn4nfvk8s-network')
-rw-r--r--src/k8splugin/plugins/ovn4nfvk8s-network/plugin.go28
-rw-r--r--src/k8splugin/plugins/ovn4nfvk8s-network/plugin_test.go6
2 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..32bca8fb 100644
--- a/src/k8splugin/plugins/ovn4nfvk8s-network/plugin.go
+++ b/src/k8splugin/plugins/ovn4nfvk8s-network/plugin.go
@@ -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 {
diff --git a/src/k8splugin/plugins/ovn4nfvk8s-network/plugin_test.go b/src/k8splugin/plugins/ovn4nfvk8s-network/plugin_test.go
index ce848a71..6a1054ee 100644
--- a/src/k8splugin/plugins/ovn4nfvk8s-network/plugin_test.go
+++ b/src/k8splugin/plugins/ovn4nfvk8s-network/plugin_test.go
@@ -43,7 +43,7 @@ func TestCreateOVN4NFVK8SNetwork(t *testing.T) {
{
label: "Fail to decode a network",
input: &v1.OnapNetwork{},
- expectedError: "Invalid configuration value",
+ expectedError: "Invalid Network Name",
},
{
label: "Fail to create a network",
@@ -52,7 +52,7 @@ func TestCreateOVN4NFVK8SNetwork(t *testing.T) {
Name: "test",
},
Spec: v1.OnapNetworkSpec{
- Config: "{\"cnitype\": \"ovn4nfvk8s\",\"name\": \"mynet\",\"subnet\": \"172.16.33.0/24\",\"gateway\": \"172.16.33.1\",\"routes\": [{\"dst\": \"172.16.29.1/24\",\"gw\": \"100.64.1.1\"}]}",
+ CniType: "ovn4nfvk8s", Name: "mynet", Subnet: "172.16.33.0/24", Gateway: "172.16.33.1/24",
},
},
expectedError: "Failed to get logical router",
@@ -67,7 +67,7 @@ func TestCreateOVN4NFVK8SNetwork(t *testing.T) {
Name: "test",
},
Spec: v1.OnapNetworkSpec{
- Config: "{\"cnitype\": \"ovn4nfvk8s\",\"name\": \"mynet\",\"subnet\": \"172.16.33.0/24\",\"gateway\": \"172.16.33.1\",\"routes\": [{\"dst\": \"172.16.29.1/24\",\"gw\": \"100.64.1.1\"}]}",
+ CniType: "ovn4nfvk8s", Name: "mynet", Subnet: "172.16.33.0/24", Gateway: "172.16.33.1/24",
},
},
expectedResult: "mynet",