new-openstackcheck/main.py

32 lines
727 B
Python
Raw Permalink Normal View History

2022-10-10 05:29:15 +00:00
import ng_openstack.keystone
2022-10-10 05:25:49 +00:00
import os
2022-10-10 06:33:10 +00:00
import json
2022-10-10 05:25:49 +00:00
2022-10-10 06:33:10 +00:00
2022-11-02 05:30:36 +00:00
# import ng_openstack
from ng_openstack.logger import log
2022-10-10 06:33:10 +00:00
2022-11-02 05:30:36 +00:00
log.info("Starting")
2022-11-03 00:29:58 +00:00
myOpenstack=ng_openstack.OpenstackConnection()
myOpenstack.keystone.getCatalog()
allProjects=myOpenstack.keystone.getAllProjects()
2022-11-02 06:10:46 +00:00
testProjectName="SmokeTest"
2022-11-03 00:29:58 +00:00
testProjectExists=False
2022-11-02 06:10:46 +00:00
#Does my test project ID already exist?
2022-11-03 00:29:58 +00:00
for _project in allProjects['projects']:
if _project['name']==testProjectName:
testProjectExists=True
if testProjectExists:
2022-11-02 06:10:46 +00:00
log.error("Project already exists")
else:
2022-11-03 00:29:58 +00:00
# Create test project
2022-11-02 06:10:46 +00:00
log.info("{} project does not exist, creating".format(testProjectName))
2022-11-03 00:29:58 +00:00
myOpenstack.keystone.createProject(testProjectName,"Description goes here")