Update from master part 2
[osm/tests.git] / robot-systest / lib / openstack_lib.robot
index 1f1020d..bdf49aa 100644 (file)
@@ -64,7 +64,7 @@ Get Project Quota
     [Arguments]   ${field}
 
     Should Not Be Empty   ${field}
-    ${rc}   ${stdout}=   Run and Return RC and Output   openstack quota show -c ${field} -f value
+    ${rc}   ${stdout}=   Run and Return RC and Output   openstack quota show -f yaml | yq '.[] | select(.Resource=="${field}") | .Limit'
     Log   ${stdout}
     Should Be Equal As Integers   ${rc}   ${success_return_code}
     [Return]   ${stdout}
@@ -147,6 +147,17 @@ Delete Volume
     [Return]   ${stdout}
 
 
+Get Subnet
+    [Documentation]   Get subnet information in JSON format
+    [Arguments]   ${subnet_id}
+
+    Should Not Be Empty   ${subnet_id}
+    ${rc}   ${stdout}=   Run and Return RC and Output   openstack subnet show ${subnet_id} -f json
+    Log   ${stdout}
+    Should Be Equal As Integers   ${rc}   ${success_return_code}
+    [Return]   ${stdout}
+
+
 Stop Server
     [Documentation]   Stop a server
     [Arguments]   ${server_id}
@@ -180,3 +191,23 @@ Delete Server
     [Return]   ${stdout}
 
 
+Create Flavor
+    [Documentation]   Create a Flavor
+    [Arguments]   ${flavor_name}   ${cpu}=1   ${ram}=1024   ${disk}=10
+
+    Should Not Be Empty   ${flavor_name}
+    ${rc}   ${flavor_id}=   Run and Return RC and Output   openstack flavor create ${flavor_name} --ram ${ram} --disk ${disk} --vcpus ${cpu} -f yaml | yq '.id' | tr -d \\"
+    Log   ${flavor_id}
+    Should Be Equal As Integers   ${rc}   ${success_return_code}
+    [Return]   ${flavor_id}
+
+
+Delete Flavor
+    [Documentation]   Delete a Flavor
+    [Arguments]   ${flavor_id}
+
+    Should Not Be Empty   ${flavor_id}
+    ${rc}   ${stdout}=   Run and Return RC and Output   openstack flavor delete ${flavor_id}
+    Log   ${stdout}
+    Should Be Equal As Integers   ${rc}   ${success_return_code}
+    [Return]   ${stdout}