# export PACKAGES_FOLDER=<PACKAGES_FOLDER=>
# export ROBOT_DEVOPS_FOLDER=<ROBOT_DEVOPS_FOLDER>
# export ROBOT_REPORT_FOLDER=<ROBOT_REPORT_FOLDER>
+# K8s_01 variables - Installation of a K8s cluster from a NS
+# export IP_VM1=<JUJU_MACHINE1_IP>
+# export IP_VM2=<JUJU_MACHINE2_IP>
+# export IP_VM3=<JUJU_MACHINE3_IP>
+# export IP_VM4=<JUJU_MACHINE4_IP>
+# export IP_JUJU=<JUJU_CONTROLLER_IP>
*** Keywords ***
Create Network Service
- [Arguments] ${nsd} ${vim_name} ${ns_name} ${ns_config} ${publickey} ${ns_launch_max_wait_time}=5min
+ [Arguments] ${nsd} ${vim_name} ${ns_name} ${ns_config} ${publickey} ${ns_launch_max_wait_time}=5min ${config_file}=${EMPTY}
${config_attr} Set Variable If '${ns_config}'!='${EMPTY}' --config '${ns_config}' \
${sshkeys_attr} Set Variable If '${publickey}'!='${EMPTY}' --ssh_keys ${publickey} \
+ ${config_file_attr} Set Variable If '${config_file}'!='${EMPTY}' --config_file '${config_file}' \
- ${ns_id}= Instantiate Network Service ${ns_name} ${nsd} ${vim_name} ${config_attr} ${sshkeys_attr}
+ ${ns_id}= Instantiate Network Service ${ns_name} ${nsd} ${vim_name} ${config_attr} ${sshkeys_attr} ${config_file_attr}
log ${ns_id}
WAIT UNTIL KEYWORD SUCCEEDS ${ns_launch_max_wait_time} ${ns_launch_pol_time} Check For NS Instance To Configured ${ns_name}
--- /dev/null
+# Copyright 2020 Canonical Ltd.
+#
+# 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.
+
+from jinja2 import Template
+
+class renderTemplate():
+
+ def render_template(self, template_file, config_file, **kwargs):
+ """Renders a template with the values provided
+
+ Args:
+ template_file: Template we want to render
+ config_file: Output file once the template is rendered
+
+ Returns:
+ content: The output of the config file
+ """
+
+ with open(template_file, "r") as t_file:
+ content = t_file.read()
+ template = Template(content)
+ content = template.render(kwargs)
+ with open(config_file, "w") as c_file:
+ c_file.write(content)
+ return content
--- /dev/null
+# Copyright 2020 Canonical Ltd.
+# 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.
+
+from pathlib import Path
+
+# Get ${HOME} from local machine
+home = str(Path.home())
+# NS and VNF descriptor package files
+vnfd_pkg1 = 'k8s_jujucontroller_vnf.tar.gz'
+vnfd_pkg2 = 'k8s_jujumachine_vnf.tar.gz'
+nsd_pkg = 'k8s_juju_ns.tar.gz'
+# NS and VNF descriptor package files
+vnfd_name1 = 'k8s_jujucontroller_vnf'
+vnfd_name2 = 'k8s_jujumachine_vnf'
+nsd_name = 'k8s_juju'
+# VNF Member indexes
+vnf_member_index_1 = 'k8s_vnf1'
+vnf_member_index_2 = 'k8s_vnf2'
+vnf_member_index_3 = 'k8s_vnf3'
+vnf_member_index_4 = 'k8s_vnf4'
+vnf_member_index_5 = 'k8s_juju'
+# Username
+username = 'ubuntu'
+# Kubeconfig file
+kubeconfig_file = '/home/ubuntu/.kube/config'
+# NS instance name
+ns_name = 'k8s-cluster'
+# SSH keys to be used
+publickey = home + '/.ssh/id_rsa.pub'
+privatekey = home + '/.ssh/id_rsa'
+# Template and config file to use
+template = 'k8s_juju_template.yaml'
+config_file = 'config.yaml'
--- /dev/null
+# Copyright 2020 Canonical Ltd.
+#
+# 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.
+
+---
+additionalParamsForVnf:
+ -
+ member-vnf-index: k8s_juju
+ additionalParams:
+ MACHINE1: "{{ IP_VM1 }}"
+ MACHINE2: "{{ IP_VM2 }}"
+ MACHINE3: "{{ IP_VM3 }}"
+ MACHINE4: "{{ IP_VM4 }}"
+ MACHINE5: ""
+ MACHINE6: ""
+ MACHINE7: ""
+ MACHINE8: ""
+ MACHINE9: ""
+ MACHINE10: ""
+ BUNDLE: ""
+vld:
+ -
+ name: mgmtnet
+ vim-network-name: {{ NETWORK }} #The network in the VIM to connect all nodes of the clusters
+ vnfd-connection-point-ref:
+ -
+ ip-address: "{{ IP_VM1 }}"
+ member-vnf-index-ref: k8s_vnf1
+ vnfd-connection-point-ref: mgmt
+ -
+ ip-address: "{{ IP_VM2 }}"
+ member-vnf-index-ref: k8s_vnf2
+ vnfd-connection-point-ref: mgmt
+ -
+ ip-address: "{{ IP_VM3 }}"
+ member-vnf-index-ref: k8s_vnf3
+ vnfd-connection-point-ref: mgmt
+ -
+ ip-address: "{{ IP_VM4 }}"
+ member-vnf-index-ref: k8s_vnf4
+ vnfd-connection-point-ref: mgmt
+ -
+ ip-address: "{{ IP_JUJU }}"
+ member-vnf-index-ref: k8s_juju
+ vnfd-connection-point-ref: mgmt
--- /dev/null
+# Copyright 2020 Canonical Ltd.
+#
+# 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.
+
+*** Settings ***
+Library OperatingSystem
+Library String
+Library Collections
+Library Process
+Library SSHLibrary
+Library %{ROBOT_DEVOPS_FOLDER}/lib/renderTemplate.py
+
+Resource %{ROBOT_DEVOPS_FOLDER}/lib/vnfd_lib.robot
+Resource %{ROBOT_DEVOPS_FOLDER}/lib/nsd_lib.robot
+Resource %{ROBOT_DEVOPS_FOLDER}/lib/ns_lib.robot
+Resource %{ROBOT_DEVOPS_FOLDER}/lib/ssh_lib.robot
+
+Variables %{ROBOT_DEVOPS_FOLDER}/resources/k8s_01-create_k8s_cluster_data.py
+
+Suite Teardown Run Keyword And Ignore Error Test Cleanup
+
+
+*** Variables ***
+${username} ubuntu
+${password} ${EMPTY}
+
+
+*** Test Cases ***
+Render a template
+ [Tags] newK8sCluster sanity regression
+
+ ${stdout}= Render template %{ROBOT_DEVOPS_FOLDER}/resources/${template} %{ROBOT_DEVOPS_FOLDER}/resources/${config_file} IP_VM1=%{IP_VM1} IP_VM2=%{IP_VM2} IP_VM3=%{IP_VM3} IP_VM4=%{IP_VM4} IP_JUJU=%{IP_JUJU} NETWORK=%{VIM_MGMT_NET}
+ Log To Console \n${stdout}
+
+Create Controller VNF Descriptor
+ [Tags] newK8sCluster sanity regression
+
+ Create VNFD '%{PACKAGES_FOLDER}/${vnfd_pkg1}'
+
+Create Machines VNF Descriptor
+ [Tags] newK8sCluster sanity regression
+
+ Create VNFD '%{PACKAGES_FOLDER}/${vnfd_pkg2}'
+
+Create K8s Cluster NS Descriptor
+ [Tags] newK8sCluster sanity regression
+
+ Create NSD '%{PACKAGES_FOLDER}/${nsd_pkg}'
+
+Instantiate K8s Cluster Network Service
+ [Tags] newK8sCluster sanity regression
+
+ ${id}= Create Network Service ${nsd_name} %{VIM_TARGET} ${ns_name} ns_config=${EMPTY} publickey=${publickey} ns_launch_max_wait_time=70min config_file=%{ROBOT_DEVOPS_FOLDER}/resources/${config_file}
+ Set Suite Variable ${ns_id} ${id}
+
+Get Management Ip Addresses
+ [Tags] newK8sCluster sanity regression
+
+ ${ip_addr_1} Get Vnf Management Ip Address ${ns_id} ${vnf_member_index_1}
+ log ${ip_addr_1}
+ Set Suite Variable ${vnf_1_ip_addr} ${ip_addr_1}
+ ${ip_addr_2} Get Vnf Management Ip Address ${ns_id} ${vnf_member_index_2}
+ log ${ip_addr_2}
+ Set Suite Variable ${vnf_2_ip_addr} ${ip_addr_2}
+ ${ip_addr_3} Get Vnf Management Ip Address ${ns_id} ${vnf_member_index_3}
+ log ${ip_addr_3}
+ Set Suite Variable ${vnf_3_ip_addr} ${ip_addr_3}
+ ${ip_addr_4} Get Vnf Management Ip Address ${ns_id} ${vnf_member_index_4}
+ log ${ip_addr_4}
+ Set Suite Variable ${vnf_4_ip_addr} ${ip_addr_4}
+ ${ip_addr_5} Get Vnf Management Ip Address ${ns_id} ${vnf_member_index_5}
+ log ${ip_addr_5}
+ Set Suite Variable ${vnf_5_ip_addr} ${ip_addr_5}
+
+Test SSH Access
+ [Tags] newK8sCluster sanity regression
+
+ Variable Should Exist ${vnf_1_ip_addr} msg=IP address of the management VNF '${vnf_member_index_1}' is not available
+ Variable Should Exist ${vnf_2_ip_addr} msg=IP address of the management VNF '${vnf_member_index_2}' is not available
+ Variable Should Exist ${vnf_3_ip_addr} msg=IP address of the management VNF '${vnf_member_index_3}' is not available
+ Variable Should Exist ${vnf_4_ip_addr} msg=IP address of the management VNF '${vnf_member_index_4}' is not available
+ Variable Should Exist ${vnf_5_ip_addr} msg=IP address of the management VNF '${vnf_member_index_5}' is not available
+ Sleep 30s Waiting ssh daemon to be up
+ Test SSH Connection ${vnf_1_ip_addr} ${username} ${password} ${privatekey}
+ Test SSH Connection ${vnf_2_ip_addr} ${username} ${password} ${privatekey}
+ Test SSH Connection ${vnf_3_ip_addr} ${username} ${password} ${privatekey}
+ Test SSH Connection ${vnf_4_ip_addr} ${username} ${password} ${privatekey}
+ Test SSH Connection ${vnf_5_ip_addr} ${username} ${password} ${privatekey}
+
+Check kubeconfig file
+ [Tags] newK8sCluster sanity regression
+
+ Check If remote File Exists ${vnf_5_ip_addr} ${username} ${password} ${privatekey} ${kubeconfig_file}
+
+Delete NS Instance
+ [Tags] newK8sCluster sanity regression cleanup
+
+ Delete NS ${ns_name}
+
+
+Delete NS Descriptor
+ [Tags] newK8sCluster sanity regression cleanup
+
+ Delete NSD ${nsd_name}
+
+
+Delete Controller VNF Descriptor
+ [Tags] newK8sCluster sanity regression cleanup
+
+ Delete VNFD ${vnfd_name1}
+
+Delete Machines VNF Descriptor
+ [Tags] newK8sCluster sanity regression cleanup
+
+ Delete VNFD ${vnfd_name2}
+
+
+*** Keywords ***
+Test Cleanup
+ [Documentation] Test Suite Cleanup: Deleting descriptors and NS instance
+
+ Run Keyword If Test Failed Delete NS ${ns_name}
+
+ Run Keyword If Test Failed Delete NSD ${nsd_name}
+
+ Run Keyword If Test Failed Delete VNFD ${vnfd_name}