From 3bb6cf4b938d3e725860606d3ddaa8eecd872151 Mon Sep 17 00:00:00 2001 From: DR695H Date: Thu, 20 Jun 2019 15:04:04 -0400 Subject: replace aai, closeloop, sdc with jinja Issue-ID: TEST-158 Change-Id: I95a783f26e28512cb4fc98e50931d62001c489c6 Signed-off-by: DR695H --- robot/resources/openstack/cinder_interface.robot | 7 ++++--- robot/resources/openstack/heat_interface.robot | 15 +++++++-------- robot/resources/openstack/keystone_interface.robot | 16 +++++++++------- robot/resources/openstack/neutron_interface.robot | 12 +++++++----- robot/resources/openstack/nova_interface.robot | 15 +++++++++------ 5 files changed, 36 insertions(+), 29 deletions(-) (limited to 'robot/resources/openstack') diff --git a/robot/resources/openstack/cinder_interface.robot b/robot/resources/openstack/cinder_interface.robot index 41667999..ca6e62b7 100644 --- a/robot/resources/openstack/cinder_interface.robot +++ b/robot/resources/openstack/cinder_interface.robot @@ -3,8 +3,8 @@ Documentation The main interface for interacting with Openstack. It handles Library ONAPLibrary.Openstack Library RequestsLibrary Library ONAPLibrary.Utilities +Library ONAPLibrary.Templating Resource ../global_properties.robot -Resource ../json_templater.robot Resource openstack_common.robot @@ -12,7 +12,7 @@ Resource openstack_common.robot ${OPENSTACK_CINDER_API_VERSION} /v1 ${OPENSTACK_CINDER_TYPES_PATH} /types ${OPENSTACK_CINDER_VOLUMES_PATH} /volumes -${OPENSTACK_CINDER_VOLUMES_ADD_BODY_FILE} robot/assets/templates/cinder_add_volume.template +${OPENSTACK_CINDER_VOLUMES_ADD_BODY_FILE} openstack/cinder_add_volume.jinja ${OPENSTACK_CINDER_VOLUMES_TYPE} SSD ${OPENSTACK_CINDER_AVAILABILITY_ZONE} nova @@ -34,7 +34,8 @@ Add Openstack Volume [Arguments] ${alias} ${name} ${size} ${uuid}= Generate UUID4 ${arguments}= Create Dictionary name=${name} description=${GLOBAL_APPLICATION_ID}${uuid} size=${size} type=${OPENSTACK_CINDER_VOLUMES_TYPE} availability_zone=${OPENSTACK_CINDER_AVAILABILITY_ZONE} - ${data}= Fill JSON Template File ${OPENSTACK_CINDER_VOLUMES_ADD_BODY_FILE} ${arguments} + Create Environment cinder ${GLOBAL_TEMPLATE_FOLDER} + ${data}= Apply Template cinder ${OPENSTACK_CINDER_VOLUMES_ADD_BODY_FILE} ${arguments} ${resp}= Internal Post Openstack ${alias} ${GLOBAL_OPENSTACK_CINDER_SERVICE_TYPE} ${OPENSTACK_CINDER_VOLUMES_PATH} data_path= data=${data} Should Be Equal As Strings 200 ${resp.status_code} [Return] ${resp.json()['volume']['id']} diff --git a/robot/resources/openstack/heat_interface.robot b/robot/resources/openstack/heat_interface.robot index 471c2a9f..0362d3eb 100644 --- a/robot/resources/openstack/heat_interface.robot +++ b/robot/resources/openstack/heat_interface.robot @@ -2,17 +2,16 @@ Documentation The interface for interacting with Openstack Heat API. Library ONAPLibrary.Openstack Library RequestsLibrary -Library OperatingSystem -Library StringTemplater -Library Collections +Library OperatingSystem +Library Collections +Library ONAPLibrary.Templating Resource ../global_properties.robot -Resource ../json_templater.robot Resource openstack_common.robot *** Variables *** ${OPENSTACK_HEAT_API_VERSION} /v1 ${OPENSTACK_HEAT_STACK_PATH} /stacks -${OPENSTACK_HEAT_ADD_STACK_TEMPLATE} robot/assets/templates/heat_add_stack.template +${OPENSTACK_HEAT_ADD_STACK_TEMPLATE} openstack/heat_add_stack.jinja *** Keywords *** @@ -40,9 +39,9 @@ Make Add Stack Request ${templatedata}= Template Yaml To Json ${template} ${envdata}= Env Yaml To Json ${env} ${dict}= Create Dictionary template=${templatedata} parameters=${envdata} stack_name=${name} - ${resp}= OperatingSystem.Get File ${OPENSTACK_HEAT_ADD_STACK_TEMPLATE} - ${request}= Template String ${resp} ${dict} - Log $request + Create Environment heat ${GLOBAL_TEMPLATE_FOLDER} + ${request}= Apply Template heat ${OPENSTACK_HEAT_ADD_STACK_TEMPLATE} ${dict} + Log ${request} [Return] ${request} Delete Openstack Stack diff --git a/robot/resources/openstack/keystone_interface.robot b/robot/resources/openstack/keystone_interface.robot index ceb43e8d..1df6ac91 100644 --- a/robot/resources/openstack/keystone_interface.robot +++ b/robot/resources/openstack/keystone_interface.robot @@ -4,10 +4,10 @@ Library ONAPLibrary.Openstack Library RequestsLibrary Library ONAPLibrary.Utilities Library Collections -Library OperatingSystem -Library String +Library OperatingSystem +Library String +Library ONAPLibrary.Templating Resource ../global_properties.robot -Resource ../json_templater.robot Resource openstack_common.robot *** Variables *** @@ -15,8 +15,8 @@ ${OPENSTACK_KEYSTONE_API_v3_VERSION} /v3 ${OPENSTACK_KEYSTONE_API_v2_VERSION} /v2.0 ${OPENSTACK_KEYSTONE_AUTH_v3_PATH} /auth/tokens ${OPENSTACK_KEYSTONE_AUTH_v2_PATH} /tokens -${OPENSTACK_KEYSTONE_AUTH_v2_BODY_FILE} robot/assets/templates/keystone_get_v2_auth.template -${OPENSTACK_KEYSTONE_AUTH_v3_BODY_FILE} robot/assets/templates/keystone_get_v3_auth.template +${OPENSTACK_KEYSTONE_AUTH_v2_BODY_FILE} openstack/keystone_get_v2_auth.jinja +${OPENSTACK_KEYSTONE_AUTH_v3_BODY_FILE} openstack/keystone_get_v3_auth.jinja ${OPENSTACK_KEYSTONE_TENANT_PATH} /tenants *** Keywords *** @@ -67,7 +67,8 @@ Get KeyStoneAuthv2 Data [Documentation] Returns all the data for keystone auth v2 api [Arguments] ${username} ${password} ${path} ${arguments}= Create Dictionary username=${username} password=${password} tenantId=${GLOBAL_INJECTED_OPENSTACK_TENANT_ID} - ${data}= Fill JSON Template File ${OPENSTACK_KEYSTONE_AUTH_v2_BODY_FILE} ${arguments} + Create Environment keystone ${GLOBAL_TEMPLATE_FOLDER} + ${data}= Apply Template keystone ${OPENSTACK_KEYSTONE_AUTH_v2_BODY_FILE} ${arguments} ${data_path}= Catenate ${path}${OPENSTACK_KEYSTONE_AUTH_v2_PATH} [Return] ${data_path} ${data} @@ -75,7 +76,8 @@ Get KeyStoneAuthv3 Data [Documentation] Returns all the data for keystone auth v3 api [Arguments] ${username} ${password} ${path} ${arguments}= Create Dictionary username=${username} password=${password} domain_id=${GLOBAL_INJECTED_OPENSTACK_DOMAIN_ID} project_name=${GLOBAL_INJECTED_OPENSTACK_PROJECT_NAME} - ${data}= Fill JSON Template File ${OPENSTACK_KEYSTONE_AUTH_v3_BODY_FILE} ${arguments} + Create Environment keystone ${GLOBAL_TEMPLATE_FOLDER} + ${data}= Apply Template keystone ${OPENSTACK_KEYSTONE_AUTH_v3_BODY_FILE} ${arguments} ${data_path}= Catenate ${path}${OPENSTACK_KEYSTONE_AUTH_v3_PATH} [Return] ${data_path} ${data} diff --git a/robot/resources/openstack/neutron_interface.robot b/robot/resources/openstack/neutron_interface.robot index 640a237a..058809de 100644 --- a/robot/resources/openstack/neutron_interface.robot +++ b/robot/resources/openstack/neutron_interface.robot @@ -3,16 +3,16 @@ Documentation The main interface for interacting with Openstack. It handles Library ONAPLibrary.Openstack Library RequestsLibrary Library Collections +Library ONAPLibrary.Templating Resource ../global_properties.robot -Resource ../json_templater.robot Resource openstack_common.robot *** Variables *** ${OPENSTACK_NEUTRON_API_VERSION} /v2.0 ${OPENSTACK_NEUTRON_NETWORK_PATH} /networks -${OPENSTACK_NEUTRON_NETWORK_ADD_BODY_FILE} robot/assets/templates/neutron_add_network.template +${OPENSTACK_NEUTRON_NETWORK_ADD_BODY_FILE} openstack/neutron_add_network.jinja ${OPENSTACK_NEUTRON_SUBNET_PATH} /subnets -${OPENSTACK_NEUTRON_SUBNET_ADD_BODY_FILE} robot/assets/templates/neutron_add_subnet.template +${OPENSTACK_NEUTRON_SUBNET_ADD_BODY_FILE} openstack/neutron_add_subnet.jinja ${OPENSTACK_NEUTRON_PORT_PATH} /ports *** Keywords *** @@ -44,7 +44,8 @@ Add Openstack Network [Documentation] Runs an Openstack Request to add a network and returns that network id of the created network [Arguments] ${alias} ${name} ${arguments}= Create Dictionary name=${name} - ${data}= Fill JSON Template File ${OPENSTACK_NEUTRON_NETWORK_ADD_BODY_FILE} ${arguments} + Create Environment openstack ${GLOBAL_TEMPLATE_FOLDER} + ${data}= Apply Template openstack ${OPENSTACK_NEUTRON_NETWORK_ADD_BODY_FILE} ${arguments} ${resp}= Internal Post Openstack ${alias} ${GLOBAL_OPENSTACK_NEUTRON_SERVICE_TYPE} ${OPENSTACK_NEUTRON_NETWORK_PATH} data_path= data=${data} Should Be Equal As Strings 201 ${resp.status_code} [Return] ${resp.json()['network']['id']} @@ -73,7 +74,8 @@ Add Openstack Network With Subnet [Arguments] ${alias} ${name} ${cidr} ${network_id}= Add Openstack Network ${alias} ${name} ${arguments}= Create Dictionary network_id=${network_id} cidr=${cidr} subnet_name=${name} - ${data}= Fill JSON Template File ${OPENSTACK_NEUTRON_SUBNET_ADD_BODY_FILE} ${arguments} + Create Environment openstack ${GLOBAL_TEMPLATE_FOLDER} + ${data}= Apply Template openstack ${OPENSTACK_NEUTRON_SUBNET_ADD_BODY_FILE} ${arguments} ${resp}= Internal Post Openstack ${alias} ${GLOBAL_OPENSTACK_NEUTRON_SERVICE_TYPE} ${OPENSTACK_NEUTRON_SUBNET_PATH} data_path= data=${data} Should Be Equal As Strings 201 ${resp.status_code} [Return] ${network_id} diff --git a/robot/resources/openstack/nova_interface.robot b/robot/resources/openstack/nova_interface.robot index 94a07479..b1f07f86 100644 --- a/robot/resources/openstack/nova_interface.robot +++ b/robot/resources/openstack/nova_interface.robot @@ -3,22 +3,22 @@ Documentation The main interface for interacting with Openstack. It handles Library ONAPLibrary.Openstack Library RequestsLibrary Library ONAPLibrary.JSON +Library ONAPLibrary.Templating Library OperatingSystem Library Collections Resource ../global_properties.robot -Resource ../json_templater.robot Resource openstack_common.robot *** Variables *** ${OPENSTACK_NOVA_API_VERSION} /v2 ${OPENSTACK_NOVA_KEYPAIR_PATH} /os-keypairs -${OPENSTACK_NOVA_KEYPAIR_ADD_BODY_FILE} robot/assets/templates/nova_add_keypair.template +${OPENSTACK_NOVA_KEYPAIR_ADD_BODY_FILE} openstack/nova_add_keypair.jinja ${OPENSTACK_NOVA_KEYPAIR_SSH_KEY} robot/assets/keys/robot_ssh_public_key.txt ${OPENSTACK_NOVA_FLAVORS_PATH} /flavors ${OPENSTACK_NOVA_SERVERS_PATH} /servers ${OPENSTACK_NOVA_IMAGES_PATH} /images ${OPENSTACK_NOVA_SERVERS_REBOOT_BODY} {"reboot" : { "type" : "SOFT" }} -${OPENSTACK_NOVA_SERVER_ADD_BODY_FILE} robot/assets/templates/nova_add_server.template +${OPENSTACK_NOVA_SERVER_ADD_BODY_FILE} openstack/nova_add_server.jinja *** Keywords *** @@ -33,7 +33,8 @@ Add Openstack Keypair [Arguments] ${alias} ${name} ${ssh_key}= OperatingSystem.Get File ${OPENSTACK_NOVA_KEYPAIR_SSH_KEY} ${arguments}= Create Dictionary name=${name} publickey=${ssh_key} - ${data}= Fill JSON Template File ${OPENSTACK_NOVA_KEYPAIR_ADD_BODY_FILE} ${arguments} + Create Environment openstack ${GLOBAL_TEMPLATE_FOLDER} + ${data}= Apply Template openstack ${OPENSTACK_NOVA_KEYPAIR_ADD_BODY_FILE} ${arguments} ${resp}= Internal Post Openstack ${alias} ${GLOBAL_OPENSTACK_NOVA_SERVICE_TYPE} ${OPENSTACK_NOVA_KEYPAIR_PATH} data_path= data=${data} Should Be Equal As Strings 200 ${resp.status_code} [Return] ${resp.json()['keypair']['name']} @@ -84,7 +85,8 @@ Add Server [Documentation] Adds a server for the passed if [Arguments] ${alias} ${name} ${imageRef} ${flavorRef} ${dict}= Create Dictionary name=${name} imageRef=${imageRef} flavorRef=${flavorRef} - ${data}= Fill JSON Template File ${OPENSTACK_NOVA_SERVER_ADD_BODY_FILE} ${dict} + Create Environment openstack ${GLOBAL_TEMPLATE_FOLDER} + ${data}= Apply Template openstack ${OPENSTACK_NOVA_SERVER_ADD_BODY_FILE} ${dict} ${resp}= Internal Post Openstack ${alias} ${GLOBAL_OPENSTACK_NOVA_SERVICE_TYPE} ${OPENSTACK_NOVA_SERVERS_PATH} data_path= data=${data} [Return] ${resp} @@ -98,7 +100,8 @@ Add Server For Image Name ${imageRef}= Get Id For Name ${images} ${imageName} ${flavorRef}= Get Id For Name ${flavors} ${flavorName} ${dict}= Create Dictionary name=${name} imageRef=${imageRef} flavorRef=${flavorRef} public_net_id=${public_net_id} - ${data}= Fill JSON Template File ${OPENSTACK_NOVA_SERVER_ADD_BODY_FILE} ${dict} + Create Environment openstack ${GLOBAL_TEMPLATE_FOLDER} + ${data}= Apply Template openstack ${OPENSTACK_NOVA_SERVER_ADD_BODY_FILE} ${dict} ${resp}= Internal Post Openstack ${alias} ${GLOBAL_OPENSTACK_NOVA_SERVICE_TYPE} ${OPENSTACK_NOVA_SERVERS_PATH} data_path= data=${data} ${status_string}= Convert To String ${resp.status_code} Should Match Regexp ${status_string} ^(202)$ -- cgit 1.2.3-korg