Enhance CLI NS launch with config parameter
Fix ns config to check for empty
osmclient test using python module included
Change-Id: Ied096ed0affbd6ab58228d16916196635359d027
Signed-off-by: yadavmr <my00514913@techmahindra.com>
diff --git a/robot-systest/lib/cli/ns_lib.robot b/robot-systest/lib/cli/ns_lib.robot
new file mode 100644
index 0000000..e3e3a02
--- /dev/null
+++ b/robot-systest/lib/cli/ns_lib.robot
@@ -0,0 +1,129 @@
+# -*- coding: utf-8 -*-
+
+##
+# Copyright 2019 Tech Mahindra Limited
+#
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+##
+
+## Change log:
+# 1. Feature 7829: Jayant Madavi, Mrityunjay Yadav : MY00514913@techmahindra.com : 06-aug-2019 : Improvement to the code, robot framework initial seed code.
+##
+
+
+*** Variables ***
+${success_return_code} 0
+${ns_launch_max_wait_time} 5min
+${ns_launch_pol_time} 30sec
+${ns_delete_max_wait_time} 1min
+${ns_delete_pol_time} 15sec
+
+
+*** Keywords ***
+Get NS List
+ [Documentation] Get ns instance list
+
+ ${rc} ${stdout}= Run and Return RC and Output osm ns-list
+ log ${stdout}
+ Should Be Equal As Integers ${rc} ${success_return_code}
+
+
+Launch Network Services and Return
+ [Arguments] ${vim_name}
+
+ Should Not Be Empty ${nsd_ids} There are no NS descriptors to launch the NS
+ :FOR ${nsd} IN @{nsd_ids}
+ \ ${ns_name}= GENERATE NAME
+ \ Append To List ${ns_ids} ${ns_name}
+ \ Create Network Service ${nsd} ${vim_name} ${ns_name}
+ \ Delete NS ${ns_name}
+
+
+Create Network Service
+ [Documentation] Create ns at osm
+ [Arguments] ${nsd} ${vim_name} ${ns_name}
+
+ ${ns_config}= Get Environment Variable NS_CONFIG ${EMPTY}
+ Run Keyword If ${ns_config}!='${EMPTY}' Create Network Service With Config ${nsd} ${vim_name} ${ns_name} ${ns_config}
+ ... ELSE Create Network Service Without Config ${nsd} ${vim_name} ${ns_name}
+
+ WAIT UNTIL KEYWORD SUCCEEDS ${ns_launch_max_wait_time} ${ns_launch_pol_time} Check For NS Instance To Configured ${ns_name}
+ Check For NS Instance For Failure ${ns_name}
+
+
+Create Network Service Without Config
+ [Documentation] Create ns at osm
+ [Arguments] ${nsd} ${vim_name} ${ns_name}
+
+ ${rc} ${stdout}= Run and Return RC and Output osm ns-create --ns_name ${ns_name} --nsd_name ${nsd} --vim_account ${vim_name}
+ log ${stdout}
+ Should Be Equal As Integers ${rc} ${success_return_code}
+
+
+Create Network Service With Config
+ [Documentation] Create ns at osm
+ [Arguments] ${nsd} ${vim_name} ${ns_name} ${ns_config}
+
+ ${rc} ${stdout}= Run and Return RC and Output osm ns-create --ns_name ${ns_name} --nsd_name ${nsd} --vim_account ${vim_name} --config ${ns_config}
+ log ${stdout}
+ Should Be Equal As Integers ${rc} ${success_return_code}
+
+
+Delete NS
+ [Documentation] Delete ns
+ [Arguments] ${ns}
+
+ ${rc} ${stdout}= Run and Return RC and Output osm ns-delete ${ns}
+ log ${stdout}
+ Should Be Equal As Integers ${rc} ${success_return_code}
+
+ WAIT UNTIL KEYWORD SUCCEEDS ${ns_delete_max_wait_time} ${ns_delete_pol_time} Check For NS Instance To Be Delete ${ns}
+
+
+Check For NS Instance To Configured
+ [Arguments] ${ns_name}
+
+ ${rc} ${stdout}= Run and Return RC and Output osm ns-list --filter name="${ns_name}"
+ log ${stdout}
+ Should Be Equal As Integers ${rc} ${success_return_code}
+ Should Contain Any ${stdout} configured failed
+
+
+Check For NS Instance For Failure
+ [Arguments] ${ns_name}
+
+ ${rc} ${stdout}= Run and Return RC and Output osm ns-list --filter name="${ns_name}"
+ log ${stdout}
+ Should Be Equal As Integers ${rc} ${success_return_code}
+ Should Not Contain ${stdout} failed
+
+
+Check For NS Instance To Be Delete
+ [Arguments] ${ns}
+
+ ${rc} ${stdout}= Run and Return RC and Output osm ns-list
+ log ${stdout}
+ Should Be Equal As Integers ${rc} ${success_return_code}
+ Should Not Contain ${stdout} ${ns}
+
+
+Force Delete NS
+ [Documentation] Forcely Delete ns
+ [Arguments] ${ns}
+
+ ${rc} ${stdout}= Run and Return RC and Output osm ns-delete ${ns}
+ log ${stdout}
+ Should Be Equal As Integers ${rc} ${success_return_code}
+ WAIT UNTIL KEYWORD SUCCEEDS ${ns_delete_max_wait_time} ${ns_delete_pol_time} Check For NS Instance To Be Delete ${ns}
diff --git a/robot-systest/lib/cli/nsd_lib.robot b/robot-systest/lib/cli/nsd_lib.robot
new file mode 100644
index 0000000..6a4ccbf
--- /dev/null
+++ b/robot-systest/lib/cli/nsd_lib.robot
@@ -0,0 +1,84 @@
+# -*- coding: utf-8 -*-
+
+##
+# Copyright 2019 Tech Mahindra Limited
+#
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+##
+
+## Change log:
+# 1. Feature 7829: Jayant Madavi, Mrityunjay Yadav : MY00514913@techmahindra.com : 06-sep-2019
+##
+
+*** Variables ***
+${success_return_code} 0
+${delete_max_wait_time} 1min
+${delete_pol_time} 15sec
+
+
+*** Keywords ***
+Get NSDs List
+ [Documentation] Get nsds list
+
+ ${rc} ${stdout}= Run and Return RC and Output osm nsd-list
+ log ${stdout}
+ Should Be Equal As Integers ${rc} ${success_return_code}
+
+
+Create NSD
+ [Documentation] Create nsd at osm
+ [Arguments] ${nsd_pkg}
+
+ ${rc} ${stdout}= Run and Return RC and Output osm nsd-create ${nsd_pkg}
+ log ${stdout}
+ Should Be Equal As Integers ${rc} ${success_return_code}
+ [Return] ${stdout}
+
+
+Delete NSD
+ [Documentation] Delete nsd
+ [Arguments] ${nsd_id}
+
+ ${rc} ${stdout}= Run and Return RC and Output osm nsd-delete ${nsd_id}
+ log ${stdout}
+ Should Be Equal As Integers ${rc} ${success_return_code}
+ WAIT UNTIL KEYWORD SUCCEEDS ${delete_max_wait_time} ${delete_pol_time} Check For NSD ${nsd_id}
+
+
+Check For NSD
+ [Arguments] ${nsd_id}
+
+ ${rc} ${stdout}= Run and Return RC and Output osm nsd-list
+ log ${stdout}
+ Should Be Equal As Integers ${rc} ${success_return_code}
+ Should Not Contain ${stdout} ${nsd_id}
+
+
+Force Delete NSD
+ [Documentation] Forcely Delete nsd
+ [Arguments] ${nsd_id}
+
+ ${rc} ${stdout}= Run and Return RC and Output osm nsd-delete ${nsd_id}
+ log ${stdout}
+ Should Be Equal As Integers ${rc} ${success_return_code}
+
+
+Build NS Descriptor
+ [Documentation] Build NS Descriptor from the descriptor-packages
+ [Arguments] ${nsd path}
+
+ ${rc} ${stdout}= Run and Return RC and Output make -C '${CURDIR}${/}../../..${nsd path}'
+ log ${stdout}
+ Should Be Equal As Integers ${rc} ${success_return_code}
diff --git a/robot-systest/lib/cli/vim_account_lib.robot b/robot-systest/lib/cli/vim_account_lib.robot
new file mode 100644
index 0000000..699d199
--- /dev/null
+++ b/robot-systest/lib/cli/vim_account_lib.robot
@@ -0,0 +1,115 @@
+# -*- coding: utf-8 -*-
+
+##
+# Copyright 2019 Tech Mahindra Limited
+#
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+##
+
+## Change log:
+# 1. Feature 7829: Jayant Madavi, Mrityunjay Yadav : MY00514913@techmahindra.com : 06-sep-2019
+##
+
+
+*** Variables ***
+${success_return_code} 0
+${name} "helloworld-os"
+${user} "robottest"
+${password} "fred"
+${authurl} "https://169.254.169.245/"
+${type} "openstack"
+${desc} "a test vim"
+${tenant} "robottest2"
+
+
+*** Keywords ***
+Create Vim Account
+ [Documentation] Create a new vim account
+
+ ${rc} ${stdout}= Run and Return RC and Output osm vim-create --name ${name} --user ${user} --password ${password} --auth_url ${authurl} --tenant ${tenant} --account_type ${type} --description ${desc}
+ log ${stdout}
+ Should Be Equal As Integers ${rc} ${success_return_code}
+
+
+Get Vim List
+ [Documentation] Get a vim account list
+
+ ${rc} ${stdout}= Run and Return RC and Output osm vim-list
+ log ${stdout}
+ Log To Console ${stdout}
+ Should Be Equal As Integers ${rc} ${success_return_code}
+
+
+Delete Vim Account
+ [Documentation] delete vim account details
+
+ ${rc} ${stdout}= Run and Return RC and Output osm vim-delete ${name}
+ log ${stdout}
+ Should Be Equal As Integers ${rc} ${success_return_code}
+
+
+VIM Setup To Launch Network Services
+ [Documentation] Setup a VIM to launch network services
+
+ ${vmware_url}= Get Environment Variable VCD_AUTH_URL ${EMPTY}
+ ${openstack_url}= Get Environment Variable OS_AUTH_URL ${EMPTY}
+ ${vmware_vim}= Run Keyword And Return If '${vmware_url}'!='${EMPTY}' Setup Vmware Vim ${vmware_url} 'vmware' 'pytest system test'
+ ${openstack_vim}= Run Keyword And Return If '${openstack_url}'!='${EMPTY}' Setup Openstack Vim ${openstack_url} 'openstack' 'pytest system test'
+
+ Log Many @{vim}
+
+
+Setup Openstack Vim
+ [Documentation] Openstack Vim Account Setup
+ [Arguments] ${authurl} ${type} ${desc}
+
+ ${user}= Get Environment Variable OS_USERNAME ''
+ ${password}= Get Environment Variable OS_PASSWORD ''
+ ${tenant}= Get Environment Variable OS_PROJECT_NAME ''
+ ${vim-config}= Get Environment Variable OS_VIM_CONFIG ''
+ ${vim_name}= GENERATE NAME
+
+ ${rc} ${stdout}= Run and Return RC and Output osm vim-create --name ${vim_name} --user ${user} --password ${password} --auth_url ${authurl} --tenant ${tenant} --account_type ${type} --description ${desc} --config ${vim-config}
+ log ${stdout}
+ Should Be Equal As Integers ${rc} ${success_return_code}
+ Append To List ${vim} ${stdout}
+ [Return] ${stdout}
+
+
+Setup Vmware Vim
+ [Documentation] Vmware Vim Account Setup
+ [Arguments] ${authurl} ${type} ${desc}
+
+ ${user}= Get Environment Variable VCD_USERNAME ''
+ ${password}= Get Environment Variable VCD_PASSWORD ''
+ ${tenant}= Get Environment Variable VCD_TENANT_NAME ''
+ ${vcd-org}= Get Environment Variable VCD_ORGANIZATION ''
+ ${vim-config}= Get Environment Variable VCD_VIM_CONFIG ''
+ ${vim_name}= GENERATE NAME
+
+ ${rc} ${stdout}= Run and Return RC and Output osm vim-create --name ${vim_name} --user ${user} --password ${password} --auth_url ${authurl} --tenant ${tenant} --account_type ${type} --description ${desc} --config ${vim-config}
+ log ${stdout}
+ Should Be Equal As Integers ${rc} ${success_return_code}
+ Append To List ${vim} ${stdout}
+ [Return] ${stdout}
+
+
+Force Delete Vim Account
+ [Documentation] delete vim account details
+ [Arguments] ${vim_name}
+
+ ${rc} ${stdout}= Run and Return RC and Output osm vim-delete ${vim_name}
+ log ${stdout}
+ Should Be Equal As Integers ${rc} ${success_return_code}
diff --git a/robot-systest/lib/cli/vnfd_lib.robot b/robot-systest/lib/cli/vnfd_lib.robot
new file mode 100644
index 0000000..1b99f43
--- /dev/null
+++ b/robot-systest/lib/cli/vnfd_lib.robot
@@ -0,0 +1,85 @@
+# -*- coding: utf-8 -*-
+
+##
+# Copyright 2019 Tech Mahindra Limited
+#
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+##
+
+## Change log:
+# 1. Feature 7829: Jayant Madavi, Mrityunjay Yadav : MY00514913@techmahindra.com : 06-sep-2019
+##
+
+*** Variables ***
+${success_return_code} 0
+${delete_max_wait_time} 1min
+${delete_pol_time} 15sec
+
+
+*** Keywords ***
+Get VNFDs List
+ [Documentation] Get vnfds list
+
+ ${rc} ${stdout}= Run and Return RC and Output osm vnfd-list
+ log ${stdout}
+ log ${rc}
+ Should Be Equal As Integers ${rc} ${success_return_code}
+
+
+Create VNFD
+ [Documentation] Create vnfd at osm
+ [Arguments] ${vnfd_pkg}
+
+ ${rc} ${stdout}= Run and Return RC and Output osm vnfd-create ${vnfd_pkg}
+ log ${stdout}
+ Should Be Equal As Integers ${rc} ${success_return_code}
+ [Return] ${stdout}
+
+
+Delete VNFD
+ [Documentation] Delete vnfd
+ [Arguments] ${vnfd_id}
+
+ ${rc} ${stdout}= Run and Return RC and Output osm vnfd-delete ${vnfd_id}
+ log ${stdout}
+ Should Be Equal As Integers ${rc} ${success_return_code}
+ WAIT UNTIL KEYWORD SUCCEEDS ${delete_max_wait_time} ${delete_pol_time} Check For VNFD ${vnfd_id}
+
+
+Check For VNFD
+ [Arguments] ${vnfd_id}
+
+ ${rc} ${stdout}= Run and Return RC and Output osm vnfd-list
+ log ${stdout}
+ Should Be Equal As Integers ${rc} ${success_return_code}
+ Should Not Contain ${stdout} ${vnfd_id}
+
+
+Force Delete VNFD
+ [Documentation] Forcely Delete vnfd
+ [Arguments] ${vnfd_id}
+
+ ${rc} ${stdout}= Run and Return RC and Output osm vnfd-delete ${vnfd_id}
+ log ${stdout}
+ Should Be Equal As Integers ${rc} ${success_return_code}
+
+
+Build VNF Descriptor
+ [Documentation] Build VNF Descriptor from the descriptor-packages
+ [Arguments] ${vnfd path}
+
+ ${rc} ${stdout}= Run and Return RC and Output make -C '${CURDIR}${/}../../..${vnfd path}'
+ log ${stdout}
+ Should Be Equal As Integers ${rc} ${success_return_code}