summaryrefslogtreecommitdiff
path: root/opendc/models
diff options
context:
space:
mode:
Diffstat (limited to 'opendc/models')
-rw-r--r--opendc/models/job.py19
-rw-r--r--opendc/models/machine.py2
-rw-r--r--opendc/models/rack.py2
-rw-r--r--opendc/models/room.py2
-rw-r--r--opendc/models/task.py4
-rw-r--r--opendc/models/tile.py2
6 files changed, 25 insertions, 6 deletions
diff --git a/opendc/models/job.py b/opendc/models/job.py
new file mode 100644
index 00000000..fb133a72
--- /dev/null
+++ b/opendc/models/job.py
@@ -0,0 +1,19 @@
+from opendc.models.model import Model
+
+class Job(Model):
+
+ JSON_TO_PYTHON_DICT = {
+ 'Job': {
+ 'id': 'id',
+ 'name': 'name'
+ }
+ }
+
+ TABLE_NAME = 'jobs'
+ COLUMNS = ['id', 'name']
+ COLUMNS_PRIMARY_KEY = ['id']
+
+ def google_id_has_at_least(self, google_id, authorization_level):
+ """Return True if the user has at least the given auth level over this Job."""
+
+ return authorization_level not in ['EDIT', 'OWN']
diff --git a/opendc/models/machine.py b/opendc/models/machine.py
index a2b7f57d..90945ef1 100644
--- a/opendc/models/machine.py
+++ b/opendc/models/machine.py
@@ -19,7 +19,7 @@ class Machine(Model):
}
}
- PATH = '/v1/simulations/{simulationId}/datacenters/{datacenterId}/rooms/{roomId}/tiles/{tileId}/rack/machines'
+ PATH = '/v1/tiles/{tileId}/rack/machines'
TABLE_NAME = 'machines'
COLUMNS = ['id', 'rack_id', 'position']
diff --git a/opendc/models/rack.py b/opendc/models/rack.py
index a9aeeff9..b547afa1 100644
--- a/opendc/models/rack.py
+++ b/opendc/models/rack.py
@@ -14,7 +14,7 @@ class Rack(Model):
}
}
- PATH = '/v1/simulations/{simulationId}/datacenters/{datacenterId}/rooms/{roomId}/tiles/{tileId}/rack'
+ PATH = '/v1/tiles/{tileId}/rack'
TABLE_NAME = 'racks'
COLUMNS = ['id', 'name', 'capacity', 'power_capacity_w']
diff --git a/opendc/models/room.py b/opendc/models/room.py
index b8be88f9..76f9f7b3 100644
--- a/opendc/models/room.py
+++ b/opendc/models/room.py
@@ -13,7 +13,7 @@ class Room(Model):
}
}
- PATH = '/v1/simulations/{simulationId}/datacenters/{datacenterId}/rooms'
+ PATH = '/v1/datacenters/{datacenterId}/rooms'
TABLE_NAME = 'rooms'
COLUMNS = ['id', 'name', 'datacenter_id', 'type']
diff --git a/opendc/models/task.py b/opendc/models/task.py
index aa9838a5..da0f5785 100644
--- a/opendc/models/task.py
+++ b/opendc/models/task.py
@@ -7,14 +7,14 @@ class Task(Model):
'id': 'id',
'startTick': 'start_tick',
'totalFlopCount': 'total_flop_count',
- 'traceId': 'trace_id',
+ 'jobId': 'job_id',
'taskDependencyId': 'task_dependency_id',
'parallelizability': 'parallelizability'
}
}
TABLE_NAME = 'tasks'
- COLUMNS = ['id', 'start_tick', 'total_flop_count', 'trace_id', 'task_dependency_id', 'parallelizability']
+ COLUMNS = ['id', 'start_tick', 'total_flop_count', 'job_id', 'task_dependency_id', 'parallelizability']
COLUMNS_PRIMARY_KEY = ['id']
def google_id_has_at_least(self, google_id, authorization_level):
diff --git a/opendc/models/tile.py b/opendc/models/tile.py
index 95445419..748c76c5 100644
--- a/opendc/models/tile.py
+++ b/opendc/models/tile.py
@@ -16,7 +16,7 @@ class Tile(Model):
}
}
- PATH = '/v1/simulations/{simulationId}/datacenters/{datacenterId}/rooms/{roomId}/tiles'
+ PATH = '/v1/rooms/{roomId}/tiles'
TABLE_NAME = 'tiles'
COLUMNS = ['id', 'position_x', 'position_y', 'room_id', 'object_id']