Project Cleanup
This commit is contained in:
parent
55104a5538
commit
f4789375e9
6
main.py
6
main.py
|
@ -26,8 +26,6 @@ for _project in allProjects['projects']:
|
|||
testProject=_project
|
||||
testProjectExists=True
|
||||
|
||||
|
||||
|
||||
if testProjectExists:
|
||||
log.error("Project already exists")
|
||||
log.info(testProject['id'])
|
||||
|
@ -38,7 +36,9 @@ else:
|
|||
testProject=y.ks.createProject(testProjectName,"Description goes here")['project']
|
||||
log.info(testProject['id'])
|
||||
|
||||
|
||||
#Does my test network exist?
|
||||
allNetworks=y.neutron.getAllNetworks(testProject['id'])
|
||||
log.info(allNetworks)
|
||||
|
||||
|
||||
def cleanUp():
|
||||
|
|
|
@ -10,6 +10,7 @@ class OpenStackConnection_x:
|
|||
someProp=0
|
||||
ks=False
|
||||
nova=False
|
||||
neutron=False
|
||||
|
||||
catalogData=""
|
||||
novaURL=""
|
||||
|
@ -27,9 +28,11 @@ class OpenStackConnection_x:
|
|||
log.info("Initalising connection")
|
||||
from myOpenstackApp.keystone import myopenstack_keystone
|
||||
from myOpenstackApp.nova import myopenstack_nova
|
||||
from myOpenstackApp.neutron import myopenstack_neutron
|
||||
|
||||
self.ks=myopenstack_keystone(self)
|
||||
self.nova=myopenstack_nova(self)
|
||||
self.neutron=myopenstack_neutron(self)
|
||||
self.interface=os.getenv("OS_INTERFACE")
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
import imp
|
||||
import json
|
||||
import myOpenstackApp.OpenStackConnection
|
||||
|
||||
class myopenstack_neutron():
|
||||
def __init__(self,conn: myOpenstackApp.OpenStackConnection.OpenStackConnection_x ) -> None:
|
||||
self.conn=conn
|
||||
|
||||
def getAllNetworks(_self, projectID):
|
||||
result_Data=_self.conn.make_request("GET", "networks?project_id="+projectID, "",
|
||||
_self.conn.ks.getEndpointByNameAndInterface("neutron",_self.conn.interface)["url"]).json()
|
||||
return result_Data
|
||||
|
||||
def listAllFloatingIPsByProject(_self,projectID):
|
||||
result_Data=_self.conn.make_request("GET", "floatingips?project_id="+projectID, "",
|
||||
_self.conn.ks.getEndpointByNameAndInterface("neutron",_self.conn.interface)["url"]).json()
|
||||
return result_Data
|
||||
|
||||
def ipInSubnet(_self,network,netmask,ip):
|
||||
#Network, netmask and ip must be supplied in integer form
|
||||
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
|
Loading…
Reference in New Issue