+ ${rc} ${output}= Run And Return Rc And Output openstack security group create ${SecurityGroupName} ${additional_args}
+ Log ${output}
+ Should Not Be True ${rc}
+ ${sgp_id}= Should Match Regexp ${output} [0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}
+ Log ${sgp_id}
+ [Return] ${output} ${sgp_id}
+
+Neutron Security Group Update
+ [Arguments] ${SecurityGroupName} ${additional_args}=${EMPTY}
+ [Documentation] Updating security groups
+ ${rc} ${output}= Run And Return Rc And Output openstack security group set ${SecurityGroupName} ${additional_args}
+ Log ${output}
+ Should Not Be True ${rc}
+ [Return] ${output}
+
+Delete SecurityGroup
+ [Arguments] ${sg_name}
+ [Documentation] Delete Security group
+ ${rc} ${output}= Run And Return Rc And Output openstack security group delete ${sg_name}
+ Log ${output}
+ Should Not Be True ${rc}
+
+Neutron Security Group Rule Create
+ [Arguments] ${Security_group_name} &{Kwargs}
+ [Documentation] Creates neutron security rule with Openstack CLI with or without optional params, here security group name is mandatory args, rule with optional params can be created by passing the optional args values ex: direction=${INGRESS_EGRESS}, Then these optional params are catenated with mandatory args, example of usage: "Neutron Security Group Rule Create ${SGP_SSH} direction=${RULE_PARAMS[0]} ethertype=${RULE_PARAMS[1]} ..."
+ Run Keyword If ${Kwargs} Log ${Kwargs}
+ ${description} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} description default=${None}
+ ${direction} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} direction default=${None}
+ ${ethertype} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} ethertype default=${None}
+ ${port_range_max} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} port_range_max default=${None}
+ ${port_range_min} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} port_range_min default=${None}
+ ${protocol} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} protocol default=${None}
+ ${remote_group_id} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} remote_group_id default=${None}
+ ${remote_ip_prefix} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} remote_ip_prefix default=${None}
+ ${cmd}= Set Variable openstack security group rule create ${Security_group_name}
+ ${cmd}= Run Keyword If '${description}'!='None' Catenate ${cmd} --description ${description}
+ ... ELSE Catenate ${cmd}
+ ${cmd}= Run Keyword If '${direction}'!='None' Catenate ${cmd} --${direction}
+ ... ELSE Catenate ${cmd}
+ ${cmd}= Run Keyword If '${ethertype}'!='None' Catenate ${cmd} --ethertype ${ethertype}
+ ... ELSE Catenate ${cmd}
+ ${cmd}= Run Keyword If '${port_range_min}'!='None' and '${port_range_max}'!='None' Catenate ${cmd} --dst-port ${port_range_min}:${port_range_max}
+ ... ELSE IF '${port_range_max}'!='None' Catenate ${cmd} --dst-port ${port_range_max}
+ ... ELSE IF '${port_range_min}'!='None' Catenate ${cmd} --dst-port ${port_range_min}
+ ... ELSE Catenate ${cmd}
+ ${cmd}= Run Keyword If '${protocol}'!='None' Catenate ${cmd} --protocol ${protocol}
+ ... ELSE Catenate ${cmd}
+ ${cmd}= Run Keyword If '${remote_group_id}'!='None' Catenate ${cmd} --remote-group ${remote_group_id}
+ ... ELSE Catenate ${cmd}
+ ${cmd}= Run Keyword If '${remote_ip_prefix}'!='None' Catenate ${cmd} --src-ip ${remote_ip_prefix}
+ ... ELSE Catenate ${cmd}
+ ${rc} ${output}= Run And Return Rc And Output ${cmd}
+ ${rule_id}= Should Match Regexp ${output} [0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}
+ Log ${rule_id}
+ Should Not Be True ${rc}
+ [Return] ${output} ${rule_id}
+
+Neutron Security Group Rule Create Legacy Cli
+ [Arguments] ${Security_group_name} &{Kwargs}
+ [Documentation] Creates neutron security rule with neutron request with or without optional params, here security group name is mandatory args, rule with optional params can be created by passing the optional args values ex: direction=${INGRESS_EGRESS}, Then these optional params are catenated with mandatory args, example of usage: "Neutron Security Group Rule Create ${SGP_SSH} direction=${RULE_PARAMS[0]} ethertype=${RULE_PARAMS[1]} ..."
+ Run Keyword If ${Kwargs} Log ${Kwargs}
+ ${description} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} description default=${None}
+ ${direction} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} direction default=${None}
+ ${ethertype} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} ethertype default=${None}
+ ${port_range_max} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} port_range_max default=${None}
+ ${port_range_min} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} port_range_min default=${None}
+ ${protocol} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} protocol default=${None}
+ ${remote_group_id} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} remote_group_id default=${None}
+ ${remote_ip_prefix} Run Keyword If ${Kwargs} Pop From Dictionary ${Kwargs} remote_ip_prefix default=${None}
+ ${cmd}= Set Variable neutron security-group-rule-create ${Security_group_name}
+ ${cmd}= Run Keyword If '${description}'!='None' Catenate ${cmd} --description ${description}
+ ... ELSE Catenate ${cmd}
+ ${cmd}= Run Keyword If '${direction}'!='None' Catenate ${cmd} --direction ${direction}
+ ... ELSE Catenate ${cmd}
+ ${cmd}= Run Keyword If '${ethertype}'!='None' Catenate ${cmd} --ethertype ${ethertype}
+ ... ELSE Catenate ${cmd}
+ ${cmd}= Run Keyword If '${port_range_max}'!='None' Catenate ${cmd} --port_range_max ${port_range_max}
+ ... ELSE Catenate ${cmd}
+ ${cmd}= Run Keyword If '${port_range_min}'!='None' Catenate ${cmd} --port_range_min ${port_range_min}
+ ... ELSE Catenate ${cmd}
+ ${cmd}= Run Keyword If '${protocol}'!='None' Catenate ${cmd} --protocol ${protocol}
+ ... ELSE Catenate ${cmd}
+ ${cmd}= Run Keyword If '${remote_group_id}'!='None' Catenate ${cmd} --remote_group_id ${remote_group_id}
+ ... ELSE Catenate ${cmd}
+ ${cmd}= Run Keyword If '${remote_ip_prefix}'!='None' Catenate ${cmd} --remote_ip_prefix ${remote_ip_prefix}
+ ... ELSE Catenate ${cmd}
+ ${rc} ${output}= Run And Return Rc And Output ${cmd}
+ ${rule_id}= Should Match Regexp ${output} [0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}
+ Log ${rule_id}
+ Should Not Be True ${rc}
+ [Return] ${output} ${rule_id}
+
+Security Group Create Without Default Security Rules
+ [Arguments] ${sg_name} ${additional_args}=${EMPTY}
+ [Documentation] Create Neutron Security Group with no default rules, using specified name and optional arguments.
+ Neutron Security Group Create ${sg_name} ${additional_args}
+ Delete All Security Group Rules ${sg_name}
+
+Delete All Security Group Rules
+ [Arguments] ${sg_name}
+ [Documentation] Delete all security rules from a specified security group
+ ${rc} ${sg_rules_output}= Run And Return Rc And Output openstack security group rule list ${sg_name} -cID -fvalue
+ Log ${sg_rules_output}
+ Should Not Be True ${rc}
+ @{sg_rules}= Split String ${sg_rules_output} \n
+ : FOR ${rule} IN @{sg_rules}
+ \ ${rc} ${output}= Run And Return Rc And Output openstack security group rule delete ${rule}
+ \ Log ${output}
+ \ Should Not Be True ${rc}
+
+Create Allow All SecurityGroup
+ [Arguments] ${sg_name} ${ether_type}=IPv4
+ [Documentation] Allow all TCP/UDP/ICMP packets for this suite
+ Neutron Security Group Create ${sg_name}
+ Neutron Security Group Rule Create ${sg_name} direction=ingress ethertype=${ether_type} port_range_max=65535 port_range_min=1 protocol=tcp
+ Neutron Security Group Rule Create ${sg_name} direction=egress ethertype=${ether_type} port_range_max=65535 port_range_min=1 protocol=tcp
+ Neutron Security Group Rule Create ${sg_name} direction=ingress ethertype=${ether_type} protocol=icmp
+ Neutron Security Group Rule Create ${sg_name} direction=egress ethertype=${ether_type} protocol=icmp
+ Neutron Security Group Rule Create ${sg_name} direction=ingress ethertype=${ether_type} port_range_max=65535 port_range_min=1 protocol=udp
+ Neutron Security Group Rule Create ${sg_name} direction=egress ethertype=${ether_type} port_range_max=65535 port_range_min=1 protocol=udp
+
+Create Neutron Port With Additional Params
+ [Arguments] ${network_name} ${port_name} ${additional_args}=${EMPTY}
+ [Documentation] Create Port With given additional parameters
+ ${rc} ${output}= Run And Return Rc And Output neutron -v port-create ${network_name} --name ${port_name} ${additional_args}
+ Log ${output}
+ Should Not Be True ${rc}
+ ${port_id}= Should Match Regexp ${OUTPUT} [0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}
+ Log ${port_id}
+ [Return] ${OUTPUT} ${port_id}
+
+Get Ports MacAddr
+ [Arguments] ${portName_list}
+ [Documentation] Retrieve the port MacAddr for the given list of port name and return the MAC address list.
+ ${MacAddr-list} Create List
+ : FOR ${portName} IN @{portName_list}
+ \ ${macAddr}= OpenStackOperations.Get Port Mac ${portName} ${devstack_conn_id}
+ \ Append To List ${MacAddr-list} ${macAddr}
+ [Return] ${MacAddr-list}
+
+Get Port Ip
+ [Arguments] ${port_name}
+ [Documentation] Keyword would return the IP of the ${port_name} received.
+ ${rc} ${output}= Run And Return Rc And Output openstack port list | grep "${port_name}" | awk -F\\' '{print $2}'
+ ${splitted_output}= Split String ${output} ${EMPTY}
+ ${port_ip}= Get from List ${splitted_output} 0
+ Should Not Be True ${rc}
+ [Return] ${port_ip}
+
+Get Port Mac
+ [Arguments] ${port_name} ${conn_id}=${devstack_conn_id}
+ [Documentation] Keyword would return the MAC ID of the ${port_name} received.
+ ${rc} ${output}= Run And Return Rc And Output openstack port show ${port_name} | grep mac_address | awk '{print $4}'
+ ${splitted_output}= Split String ${output} ${EMPTY}
+ ${port_mac}= Get from List ${splitted_output} 0
+ Should Not Be True ${rc}
+ [Return] ${port_mac}
+
+Create L2Gateway
+ [Arguments] ${bridge_name} ${intf_name} ${gw_name}
+ [Documentation] Keyword to create an L2 Gateway ${gw_name} for bridge ${bridge_name} connected to interface ${intf_name} (Using Neutron CLI).
+ ${rc} ${l2gw_output}= Run And Return Rc And Output ${L2GW_CREATE} name=${bridge_name},interface_names=${intf_name} ${gw_name}
+ Log ${l2gw_output}
+ [Return] ${l2gw_output}
+
+Create L2Gateway Connection
+ [Arguments] ${gw_name} ${net_name}
+ [Documentation] Keyword would create a new L2 Gateway Connection for ${gw_name} to ${net_name} (Using Neutron CLI).
+ ${rc} ${l2gw_output}= Run And Return Rc And Output ${L2GW_CONN_CREATE} ${gw_name} ${net_name}
+ Log ${l2gw_output}
+ Should Not Be True ${rc}
+ [Return] ${l2gw_output}
+
+Get All L2Gateway
+ [Documentation] Keyword to return all the L2 Gateways available (Using Neutron CLI).
+ ${rc} ${output}= Run And Return Rc And Output ${L2GW_GET_YAML}
+ Should Not Be True ${rc}
+ [Return] ${output}
+
+Get All L2Gateway Connection
+ [Documentation] Keyword to return all the L2 Gateway connections available (Using Neutron CLI).
+ ${rc} ${output}= Run And Return Rc And Output ${L2GW_GET_CONN_YAML}
+ Should Not Be True ${rc}
+ [Return] ${output}
+
+Get L2Gateway
+ [Arguments] ${gw_id}
+ [Documentation] Keyword to check if the ${gw_id} is available in the L2 Gateway list (Using Neutron CLI).
+ ${rc} ${output}= Run And Return Rc And Output ${L2GW_SHOW} ${gw_id}
+ Log ${output}
+ Should Not Be True ${rc}
+ [Return] ${output}
+
+Get L2gw Id
+ [Arguments] ${l2gw_name}
+ [Documentation] Keyword to retrieve the L2 Gateway ID for the ${l2gw_name} (Using Neutron CLI).
+ ${rc} ${output}= Run And Return Rc And Output ${L2GW_GET} | grep "${l2gw_name}" | awk '{print $2}'
+ Log ${output}
+ Should Not Be True ${rc}
+ ${splitted_output}= Split String ${output} ${EMPTY}
+ ${l2gw_id}= Get from List ${splitted_output} 0
+ [Return] ${l2gw_id}
+
+Get L2gw Connection Id
+ [Arguments] ${l2gw_name}
+ [Documentation] Keyword to retrieve the L2 Gateway Connection ID for the ${l2gw_name} (Using Neutron CLI).
+ ${l2gw_id}= OpenStackOperations.Get L2gw Id ${l2gw_name}
+ ${rc} ${output}= Run And Return Rc And Output ${L2GW_GET_CONN} | grep "${l2gw_id}" | awk '{print $2}'
+ Should Not Be True ${rc}
+ ${splitted_output}= Split String ${output} ${EMPTY}
+ ${splitted_output}= Split String ${output} ${EMPTY}
+ ${l2gw_conn_id}= Get from List ${splitted_output} 0
+ [Return] ${l2gw_conn_id}