summaryrefslogtreecommitdiff
path: root/opendc/api/v2/tiles/tileId/rack
diff options
context:
space:
mode:
Diffstat (limited to 'opendc/api/v2/tiles/tileId/rack')
-rw-r--r--opendc/api/v2/tiles/tileId/rack/endpoint.py86
-rw-r--r--opendc/api/v2/tiles/tileId/rack/machines/endpoint.py46
-rw-r--r--opendc/api/v2/tiles/tileId/rack/machines/position/endpoint.py64
3 files changed, 60 insertions, 136 deletions
diff --git a/opendc/api/v2/tiles/tileId/rack/endpoint.py b/opendc/api/v2/tiles/tileId/rack/endpoint.py
index 64245856..0e1017e8 100644
--- a/opendc/api/v2/tiles/tileId/rack/endpoint.py
+++ b/opendc/api/v2/tiles/tileId/rack/endpoint.py
@@ -10,18 +10,14 @@ def GET(request):
# Make sure required parameters are there
try:
- request.check_required_parameters(
- path={
- 'tileId': 'int'
- },
- )
+ request.check_required_parameters(path={'tileId': 'int'}, )
except exceptions.ParameterError as e:
return Response(400, e.message)
# Instantiate a Tile from the database
- tile = Tile.from_primary_key((request.params_path['tileId'],))
+ tile = Tile.from_primary_key((request.params_path['tileId'], ))
# Make sure this Tile exists
@@ -35,7 +31,7 @@ def GET(request):
# Instantiate a Rack from the database
- rack = Rack.from_primary_key((tile.object_id,))
+ rack = Rack.from_primary_key((tile.object_id, ))
# Make sure this Rack exists
@@ -46,11 +42,7 @@ def GET(request):
rack.read()
- return Response(
- 200,
- 'Successfully retrieved {}.'.format(rack),
- rack.to_JSON()
- )
+ return Response(200, 'Successfully retrieved {}.'.format(rack), rack.to_JSON())
def POST(request):
@@ -59,25 +51,19 @@ def POST(request):
# Make sure required parameters are there
try:
- request.check_required_parameters(
- path={
- 'tileId': 'int'
- },
- body={
- 'rack': {
- 'name': 'string',
- 'capacity': 'int',
- 'powerCapacityW': 'int'
- }
- }
- )
+ request.check_required_parameters(path={'tileId': 'int'},
+ body={'rack': {
+ 'name': 'string',
+ 'capacity': 'int',
+ 'powerCapacityW': 'int'
+ }})
except exceptions.ParameterError as e:
return Response(400, e.message)
# Instantiate a Tile from the database
- tile = Tile.from_primary_key((request.params_path['tileId'],))
+ tile = Tile.from_primary_key((request.params_path['tileId'], ))
# Make sure this Tile exists
@@ -109,11 +95,7 @@ def POST(request):
rack.read()
- return Response(
- 200,
- 'Successfully added {}.'.format(rack),
- rack.to_JSON()
- )
+ return Response(200, 'Successfully added {}.'.format(rack), rack.to_JSON())
def PUT(request):
@@ -122,25 +104,19 @@ def PUT(request):
# Make sure required parameters are there
try:
- request.check_required_parameters(
- path={
- 'tileId': 'int'
- },
- body={
- 'rack': {
- 'name': 'string',
- 'capacity': 'int',
- 'powerCapacityW': 'int'
- }
- }
- )
+ request.check_required_parameters(path={'tileId': 'int'},
+ body={'rack': {
+ 'name': 'string',
+ 'capacity': 'int',
+ 'powerCapacityW': 'int'
+ }})
except exceptions.ParameterError as e:
return Response(400, e.message)
# Instantiate a Tile from the database
- tile = Tile.from_primary_key((request.params_path['tileId'],))
+ tile = Tile.from_primary_key((request.params_path['tileId'], ))
# Make sure this Tile exists
@@ -154,7 +130,7 @@ def PUT(request):
# Instantiate a Rack from the database
- rack = Rack.from_primary_key((tile.object_id,))
+ rack = Rack.from_primary_key((tile.object_id, ))
# Make sure this Rack exists
@@ -172,11 +148,7 @@ def PUT(request):
rack.read()
- return Response(
- 200,
- 'Successfully updated {}.'.format(rack),
- rack.to_JSON()
- )
+ return Response(200, 'Successfully updated {}.'.format(rack), rack.to_JSON())
def DELETE(request):
@@ -185,18 +157,14 @@ def DELETE(request):
# Make sure required parameters are there
try:
- request.check_required_parameters(
- path={
- 'tileId': 'int'
- },
- )
+ request.check_required_parameters(path={'tileId': 'int'}, )
except exceptions.ParameterError as e:
return Response(400, e.message)
# Instantiate a Tile from the database
- tile = Tile.from_primary_key((request.params_path['tileId'],))
+ tile = Tile.from_primary_key((request.params_path['tileId'], ))
# Make sure this Tile exists
@@ -210,7 +178,7 @@ def DELETE(request):
# Instantiate a Rack from the database
- rack = Rack.from_primary_key((tile.object_id,))
+ rack = Rack.from_primary_key((tile.object_id, ))
# Make sure this Rack exists
@@ -230,8 +198,4 @@ def DELETE(request):
# Return this Rack
- return Response(
- 200,
- 'Successfully deleted {}.'.format(rack),
- rack.to_JSON()
- )
+ return Response(200, 'Successfully deleted {}.'.format(rack), rack.to_JSON())
diff --git a/opendc/api/v2/tiles/tileId/rack/machines/endpoint.py b/opendc/api/v2/tiles/tileId/rack/machines/endpoint.py
index 5272c117..1ff25f44 100644
--- a/opendc/api/v2/tiles/tileId/rack/machines/endpoint.py
+++ b/opendc/api/v2/tiles/tileId/rack/machines/endpoint.py
@@ -10,11 +10,7 @@ def GET(request):
# Make sure required parameters are there
try:
- request.check_required_parameters(
- path={
- 'tileId': 'int'
- }
- )
+ request.check_required_parameters(path={'tileId': 'int'})
except exceptions.ParameterError as e:
return Response(400, e.message)
@@ -40,11 +36,7 @@ def GET(request):
for machine in machines:
machine.read()
- return Response(
- 200,
- 'Successfully retrieved Machines for {}.'.format(rack),
- [x.to_JSON() for x in machines]
- )
+ return Response(200, 'Successfully retrieved Machines for {}.'.format(rack), [x.to_JSON() for x in machines])
def POST(request):
@@ -53,22 +45,18 @@ def POST(request):
# Make sure required parameters are there
try:
- request.check_required_parameters(
- path={
- 'tileId': 'int'
- },
- body={
- 'machine': {
- 'rackId': 'int',
- 'position': 'int',
- 'tags': 'list-string',
- 'cpuIds': 'list-int',
- 'gpuIds': 'list-int',
- 'memoryIds': 'list-int',
- 'storageIds': 'list-int'
- }
- }
- )
+ request.check_required_parameters(path={'tileId': 'int'},
+ body={
+ 'machine': {
+ 'rackId': 'int',
+ 'position': 'int',
+ 'tags': 'list-string',
+ 'cpuIds': 'list-int',
+ 'gpuIds': 'list-int',
+ 'memoryIds': 'list-int',
+ 'storageIds': 'list-int'
+ }
+ })
except exceptions.ParameterError as e:
return Response(400, e.message)
@@ -111,8 +99,4 @@ def POST(request):
machine.read()
- return Response(
- 200,
- 'Successfully added {}.'.format(machine),
- machine.to_JSON()
- )
+ return Response(200, 'Successfully added {}.'.format(machine), machine.to_JSON())
diff --git a/opendc/api/v2/tiles/tileId/rack/machines/position/endpoint.py b/opendc/api/v2/tiles/tileId/rack/machines/position/endpoint.py
index 99011fa4..d82014b3 100644
--- a/opendc/api/v2/tiles/tileId/rack/machines/position/endpoint.py
+++ b/opendc/api/v2/tiles/tileId/rack/machines/position/endpoint.py
@@ -10,12 +10,7 @@ def GET(request):
# Make sure required parameters are there
try:
- request.check_required_parameters(
- path={
- 'tileId': 'int',
- 'position': 'int'
- }
- )
+ request.check_required_parameters(path={'tileId': 'int', 'position': 'int'})
except exceptions.ParameterError as e:
return Response(400, e.message)
@@ -38,34 +33,28 @@ def GET(request):
machine.read()
- return Response(
- 200,
- 'Successfully retrieved {}.'.format(machine),
- machine.to_JSON()
- )
+ return Response(200, 'Successfully retrieved {}.'.format(machine), machine.to_JSON())
def PUT(request):
"""Update the Machine at this location in this Rack."""
try:
- request.check_required_parameters(
- path={
- 'tileId': 'int',
- 'position': 'int'
- },
- body={
- 'machine': {
- 'rackId': 'int',
- 'position': 'int',
- 'tags': 'list-string',
- 'cpuIds': 'list-int',
- 'gpuIds': 'list-int',
- 'memoryIds': 'list-int',
- 'storageIds': 'list-int'
- }
- }
- )
+ request.check_required_parameters(path={
+ 'tileId': 'int',
+ 'position': 'int'
+ },
+ body={
+ 'machine': {
+ 'rackId': 'int',
+ 'position': 'int',
+ 'tags': 'list-string',
+ 'cpuIds': 'list-int',
+ 'gpuIds': 'list-int',
+ 'memoryIds': 'list-int',
+ 'storageIds': 'list-int'
+ }
+ })
except exceptions.ParameterError as e:
return Response(400, e.message)
@@ -114,11 +103,7 @@ def PUT(request):
machine.read()
- return Response(
- 200,
- 'Successfully updated {}.'.format(machine),
- machine.to_JSON()
- )
+ return Response(200, 'Successfully updated {}.'.format(machine), machine.to_JSON())
def DELETE(request):
@@ -127,12 +112,7 @@ def DELETE(request):
# Make sure required parameters are there
try:
- request.check_required_parameters(
- path={
- 'tileId': 'int',
- 'position': 'int'
- }
- )
+ request.check_required_parameters(path={'tileId': 'int', 'position': 'int'})
except exceptions.ParameterError as e:
return Response(400, e.message)
@@ -157,8 +137,4 @@ def DELETE(request):
# Return this Machine
- return Response(
- 200,
- 'Successfully deleted {}.'.format(machine),
- machine.to_JSON()
- )
+ return Response(200, 'Successfully deleted {}.'.format(machine), machine.to_JSON())