Stuck on Neutron catalog URL
This commit is contained in:
parent
48b9345fc0
commit
c422a7285c
28
main.py
28
main.py
|
@ -7,25 +7,25 @@ import json
|
||||||
from ng_openstack.logger import log
|
from ng_openstack.logger import log
|
||||||
|
|
||||||
log.info("Starting")
|
log.info("Starting")
|
||||||
x=ng_openstack.OpenstackConnection("Fido",10)
|
myOpenstack=ng_openstack.OpenstackConnection()
|
||||||
# x.keystone.getAllProjects()
|
myOpenstack.keystone.getCatalog()
|
||||||
x.keystone.getCatalog()
|
|
||||||
|
|
||||||
# print (x.keystone.catalogData)
|
|
||||||
|
|
||||||
# neutronService=x.keystone.getServicebyName("Neutron")
|
allProjects=myOpenstack.keystone.getAllProjects()
|
||||||
# print(neutronService)
|
|
||||||
# neutronURL=x.keystone.getEndpointByNameIDAndInterface("NeuTrOn","internal")['url']
|
|
||||||
# print(neutronURL)
|
|
||||||
projects=x.keystone.getAllProjects()
|
|
||||||
print(projects)
|
|
||||||
testProjectName="SmokeTest"
|
testProjectName="SmokeTest"
|
||||||
|
testProjectExists=False
|
||||||
|
|
||||||
#Does my test project ID already exist?
|
#Does my test project ID already exist?
|
||||||
if testProjectName in projects['projects']:
|
for _project in allProjects['projects']:
|
||||||
|
if _project['name']==testProjectName:
|
||||||
|
testProjectExists=True
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if testProjectExists:
|
||||||
log.error("Project already exists")
|
log.error("Project already exists")
|
||||||
log.error(projects['projects'][testProjectName])
|
|
||||||
else:
|
else:
|
||||||
|
# Create test project
|
||||||
log.info("{} project does not exist, creating".format(testProjectName))
|
log.info("{} project does not exist, creating".format(testProjectName))
|
||||||
x.keystone.createProject(testProjectName,"Description goes here")
|
myOpenstack.keystone.createProject(testProjectName,"Description goes here")
|
||||||
#create test project
|
|
||||||
|
|
|
@ -10,11 +10,10 @@ class OpenstackConnection():
|
||||||
keystone=Openstack_Keystone(requestor)
|
keystone=Openstack_Keystone(requestor)
|
||||||
|
|
||||||
|
|
||||||
def __init__(self, name, age):
|
def __init__(self, someVar="", someotherVar=""):
|
||||||
self.name = name
|
self.someotherVar = someotherVar
|
||||||
self.age = age
|
self.someVar = someVar
|
||||||
self.speed = 0
|
|
||||||
self.moving = False
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def human_age(self):
|
def human_age(self):
|
||||||
|
@ -33,28 +32,4 @@ class OpenstackConnection():
|
||||||
return self.name == other.name and self.age == other.age
|
return self.name == other.name and self.age == other.age
|
||||||
|
|
||||||
def make_sound(self):
|
def make_sound(self):
|
||||||
print(self.SOUND)
|
print(self.SOUND)
|
||||||
|
|
||||||
def bark(self):
|
|
||||||
self.make_sound()
|
|
||||||
|
|
||||||
def walk(self, speed, distance):
|
|
||||||
self._set_speed(speed)
|
|
||||||
self._move(distance)
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def can_woof(cls, animal):
|
|
||||||
return animal.SOUND == cls.SOUND
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def is_dog(animal):
|
|
||||||
return animal.can_woof()
|
|
||||||
|
|
||||||
def _set_speed(self, speed):
|
|
||||||
self.speed = speed
|
|
||||||
|
|
||||||
def _move(self, distance):
|
|
||||||
self.moving = True
|
|
||||||
for _ in range(distance):
|
|
||||||
print('.', end='')
|
|
||||||
print('')
|
|
|
@ -9,3 +9,15 @@ def listAllFloatingIPsByProject(projectID):
|
||||||
def ipInSubnet(network,netmask,ip):
|
def ipInSubnet(network,netmask,ip):
|
||||||
#Network, netmask and ip must be supplied in integer form
|
#Network, netmask and ip must be supplied in integer form
|
||||||
return (ip & netmask) == network
|
return (ip & netmask) == network
|
||||||
|
|
||||||
|
def createNetwork(_self,name,project_id,description=""):
|
||||||
|
data={
|
||||||
|
"network": {
|
||||||
|
"name": name,
|
||||||
|
"admin_state_up": true,
|
||||||
|
"tenant_id": project_id,
|
||||||
|
"description": description
|
||||||
|
}
|
||||||
|
}
|
||||||
|
newNetwork=_self.requestor.make_request("POST", "projects", data, )
|
||||||
|
return newNetwork
|
|
@ -49,28 +49,28 @@ class Openstack_Request:
|
||||||
url = os.getenv("OS_AUTH_URL") + '/auth/tokens'
|
url = os.getenv("OS_AUTH_URL") + '/auth/tokens'
|
||||||
xdata = {
|
xdata = {
|
||||||
"auth": {
|
"auth": {
|
||||||
"scope": {
|
"scope": {
|
||||||
"project": {
|
"project": {
|
||||||
"domain": {
|
|
||||||
"name": scopeDomain
|
|
||||||
},
|
|
||||||
"id": scopeProject
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"identity": {
|
|
||||||
"password": {
|
|
||||||
"user": {
|
|
||||||
"domain": {
|
"domain": {
|
||||||
"name": authDomain
|
"name": scopeDomain
|
||||||
},
|
},
|
||||||
"password": password,
|
"id": scopeProject
|
||||||
"name": username
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"methods": [
|
"identity": {
|
||||||
"password"
|
"password": {
|
||||||
]
|
"user": {
|
||||||
}
|
"domain": {
|
||||||
|
"name": authDomain
|
||||||
|
},
|
||||||
|
"password": password,
|
||||||
|
"name": username
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"methods": [
|
||||||
|
"password"
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue