Searching projectS

This commit is contained in:
HawkveltGiteaAdmin committed 2022-11-02 16:40:46 +10:30
1 parent 3b4e13697d
commit 48b9345fc0
3 files changed
+35

No files matched your search

+11
View File
@@ -18,3 +18,14 @@ x.keystone.getCatalog()
# neutronURL=x.keystone.getEndpointByNameIDAndInterface("NeuTrOn","internal")['url']
# print(neutronURL)
projects=x.keystone.getAllProjects()
print(projects)
testProjectName="SmokeTest"
#Does my test project ID already exist?
if testProjectName in projects['projects']:
log.error("Project already exists")
log.error(projects['projects'][testProjectName])
else:
log.info("{} project does not exist, creating".format(testProjectName))
x.keystone.createProject(testProjectName,"Description goes here")
#create test project
+15
View File
@@ -3,6 +3,7 @@ import json
import ng_openstack.openstackRequest
import ng_openstack.settings
import os
from ng_openstack.logger import log
class Openstack_Keystone():
def __init__(self, requestor):
@@ -60,3 +61,17 @@ class Openstack_Keystone():
if str(_endpoint['interface']).lower()==str(interface).lower():
# print(_endpoint)
return(_endpoint)
def createProject(_self,name,description):
log.info("Creating a project")
data={
"project": {
"description": description,
"enabled": True,
"is_domain": False,
"name": name
}
}
_self.newProjectData=_self.requestor.make_request("POST", "projects", data,
os.getenv("OS_AUTH_URL")).json()
return _self.newProjectData
+9
View File
@@ -0,0 +1,9 @@
sample={'projects': [{'id': '0f19c4e649e6478599f7564ee8e2b3a4', 'name': 'Miners', 'domain_id': 'default', 'description': '', 'enabled': True, 'parent_id': 'default', 'is_domain': False, 'tags': [], 'options': {}, 'links': {'self': 'http://api.nexgencloud.com:5000/v3/projects/0f19c4e649e6478599f7564ee8e2b3a4'}}, {'id': '1a6b60869a35494688c49843b046a220', 'name': 'Daniel Turner - 429885', 'domain_id': 'default', 'description': 'Fleio created for Daniel Turner', 'enabled': True, 'parent_id': 'default', 'is_domain': False, 'tags': [], 'options': {}, 'links': {'self': 'http://api.nexgencloud.com:5000/v3/projects/1a6b60869a35494688c49843b046a220'}}, {'id': '1d9d5d28a7504e9380d9c7119e039c19', 'name': 'Vastai inc - 264398', 'domain_id': 'default', 'description': 'Fleio created for Vastai inc', 'enabled': True, 'parent_id': 'default', 'is_domain': False, 'tags': [], 'options': {}, 'links': {'self': 'http://api.nexgencloud.com:5000/v3/projects/1d9d5d28a7504e9380d9c7119e039c19'}}, {'id': '5150e484b9364c8d9fedd8c6ce904341', 'name': 'Dinis Teixeira - 60647', 'domain_id': 'default', 'description': 'Fleio created for Dinis Teixeira', 'enabled': True, 'parent_id': 'default', 'is_domain': False, 'tags': [], 'options': {}, 'links': {'self': 'http://api.nexgencloud.com:5000/v3/projects/5150e484b9364c8d9fedd8c6ce904341'}}, {'id': '516ac4c3cec741889f3cff32221a768e', 'name': 'Miguel Gomes - 572772', 'domain_id': 'default', 'description': 'Fleio created for Miguel Gomes', 'enabled': True, 'parent_id': 'default', 'is_domain': False, 'tags': [], 'options': {}, 'links': {'self': 'http://api.nexgencloud.com:5000/v3/projects/516ac4c3cec741889f3cff32221a768e'}}, {'id': '63290c5a628d459ca80ceb0cc3eef198', 'name': 'Emelia Beeson - 376752', 'domain_id': 'default', 'description': 'Fleio created for Emelia Beeson', 'enabled': True, 'parent_id': 'default', 'is_domain': False, 'tags': [], 'options': {}, 'links': {'self': 'http://api.nexgencloud.com:5000/v3/projects/63290c5a628d459ca80ceb0cc3eef198'}}, {'id': '64b3a1c668c049eca15b00838f88de09', 'name': 'Fleio', 'domain_id': 'default', 'description': '', 'enabled': True, 'parent_id': 'default', 'is_domain': False, 'tags': [], 'options': {}, 'links': {'self': 'http://api.nexgencloud.com:5000/v3/projects/64b3a1c668c049eca15b00838f88de09'}}, {'id': '65a3c4d4deca4053a7ef1eb480d3a141', 'name': 'Luis Sarabando - 891512', 'domain_id': 'default', 'description': 'Fleio created for Luis Sarabando', 'enabled': True, 'parent_id': 'default', 'is_domain': False, 'tags': [], 'options': {}, 'links': {'self': 'http://api.nexgencloud.com:5000/v3/projects/65a3c4d4deca4053a7ef1eb480d3a141'}}, {'id': '74b0d73ec8c84abe81ea1977519e0488', 'name': 'SmokeTest', 'domain_id': 'default', 'description': 'Description goes here', 'enabled': True, 'parent_id': 'default', 'is_domain': False, 'tags': [], 'options': {}, 'links': {'self': 'http://api.nexgencloud.com:5000/v3/projects/74b0d73ec8c84abe81ea1977519e0488'}}, {'id': '8f526efe5899415f8cede048c5594aa4', 'name': 'admin', 'domain_id': 'default', 'description': 'Bootstrap project for initializing the cloud.', 'enabled': True, 'parent_id': 'default', 'is_domain': False, 'tags': [], 'options': {}, 'links': {'self': 'http://api.nexgencloud.com:5000/v3/projects/8f526efe5899415f8cede048c5594aa4'}}, {'id': '9f0ffbe458fe41c6b1577fdeadeb9d91', 'name': 'Adrian Enduser - 660204', 'domain_id': 'default', 'description': 'Fleio created for Adrian Enduser', 'enabled': True, 'parent_id': 'default', 'is_domain': False, 'tags': [], 'options': {}, 'links': {'self': 'http://api.nexgencloud.com:5000/v3/projects/9f0ffbe458fe41c6b1577fdeadeb9d91'}}, {'id': 'c437866c719543f8b6e9406464ba89dc', 'name': 'Bogdan Ciuta - 342642', 'domain_id': 'default', 'description': 'Fleio created for Bogdan Ciuta', 'enabled': True, 'parent_id': 'default', 'is_domain': False, 'tags': [], 'options': {}, 'links': {'self': 'http://api.nexgencloud.com:5000/v3/projects/c437866c719543f8b6e9406464ba89dc'}}, {'id': 'c9dbe0f742fa41919c913fbae31b12b8', 'name': 'service', 'domain_id': 'default', 'description': 'Service Project', 'enabled': True, 'parent_id': 'default', 'is_domain': False, 'tags': [], 'options': {}, 'links': {'self': 'http://api.nexgencloud.com:5000/v3/projects/c9dbe0f742fa41919c913fbae31b12b8'}}, {'id': 'ceadc2eefdc54d3582d6be7663e5522e', 'name': 'John Doe - 555526', 'domain_id': 'default', 'description': 'Fleio created for John Doe', 'enabled': True, 'parent_id': 'default', 'is_domain': False, 'tags': [], 'options': {}, 'links': {'self': 'http://api.nexgencloud.com:5000/v3/projects/ceadc2eefdc54d3582d6be7663e5522e'}}, {'id': 'cf168ada62bf4bf9b717460c08766c23', 'name': 'smokecheck', 'domain_id': '1eeb8f4d0ae343f2b8a23d97b2abbccc', 'description': 'Temporary project for smoke test', 'enabled': True, 'parent_id': '1eeb8f4d0ae343f2b8a23d97b2abbccc', 'is_domain': False, 'tags': [], 'options': {}, 'links': {'self': 'http://api.nexgencloud.com:5000/v3/projects/cf168ada62bf4bf9b717460c08766c23'}}, {'id': 'cf8a2c43ad654Line truncated
toFind='SmokeTest'
# if toFind in sample['projects']:
# print("found")
for x in sample['projects']:
if x['name']==toFind: print(x)