summaryrefslogtreecommitdiff
path: root/opendc/models
diff options
context:
space:
mode:
Diffstat (limited to 'opendc/models')
-rw-r--r--opendc/models/allowed_object.py2
-rw-r--r--opendc/models/authorization.py2
-rw-r--r--opendc/models/cpu.py2
-rw-r--r--opendc/models/datacenter.py2
-rw-r--r--opendc/models/experiment.py2
-rw-r--r--opendc/models/failure_model.py2
-rw-r--r--opendc/models/gpu.py2
-rw-r--r--opendc/models/job.py2
-rw-r--r--opendc/models/machine.py2
-rw-r--r--opendc/models/machine_state.py2
-rw-r--r--opendc/models/memory.py2
-rw-r--r--opendc/models/model.py22
-rw-r--r--opendc/models/object.py2
-rw-r--r--opendc/models/path.py2
-rw-r--r--opendc/models/queued_experiment.py2
-rw-r--r--opendc/models/rack.py2
-rw-r--r--opendc/models/room.py2
-rw-r--r--opendc/models/room_type.py2
-rw-r--r--opendc/models/scheduler.py2
-rw-r--r--opendc/models/section.py2
-rw-r--r--opendc/models/simulation.py2
-rw-r--r--opendc/models/storage.py2
-rw-r--r--opendc/models/task.py2
-rw-r--r--opendc/models/task_state.py2
-rw-r--r--opendc/models/tile.py2
-rw-r--r--opendc/models/trace.py2
-rw-r--r--opendc/models/user.py2
27 files changed, 37 insertions, 37 deletions
diff --git a/opendc/models/allowed_object.py b/opendc/models/allowed_object.py
index 7ff742fe..62fcb1ae 100644
--- a/opendc/models/allowed_object.py
+++ b/opendc/models/allowed_object.py
@@ -9,7 +9,7 @@ class AllowedObject(Model):
}
}
- TABLE_NAME = 'allowed_objects'
+ COLLECTION_NAME = 'allowed_objects'
COLUMNS = ['room_type', 'object_type']
COLUMNS_PRIMARY_KEY = ['room_type', 'object_type']
diff --git a/opendc/models/authorization.py b/opendc/models/authorization.py
index 82d37b76..4c714e6d 100644
--- a/opendc/models/authorization.py
+++ b/opendc/models/authorization.py
@@ -11,7 +11,7 @@ class Authorization(Model):
}
}
- TABLE_NAME = 'authorizations'
+ COLLECTION_NAME = 'authorizations'
COLUMNS = ['user_id', 'simulation_id', 'authorization_level']
COLUMNS_PRIMARY_KEY = ['user_id', 'simulation_id']
diff --git a/opendc/models/cpu.py b/opendc/models/cpu.py
index 5b9b44fb..7ab8cecc 100644
--- a/opendc/models/cpu.py
+++ b/opendc/models/cpu.py
@@ -16,7 +16,7 @@ class CPU(Model):
}
}
- TABLE_NAME = 'cpus'
+ COLLECTION_NAME = 'cpus'
COLUMNS = [
'id',
diff --git a/opendc/models/datacenter.py b/opendc/models/datacenter.py
index 29f8367c..21e37b52 100644
--- a/opendc/models/datacenter.py
+++ b/opendc/models/datacenter.py
@@ -13,7 +13,7 @@ class Datacenter(Model):
PATH = '/v1/simulations/{simulationId}/datacenters'
- TABLE_NAME = 'datacenters'
+ COLLECTION_NAME = 'datacenters'
COLUMNS = ['id', 'simulation_id', 'starred']
COLUMNS_PRIMARY_KEY = ['id']
diff --git a/opendc/models/experiment.py b/opendc/models/experiment.py
index e875f8d1..23d80047 100644
--- a/opendc/models/experiment.py
+++ b/opendc/models/experiment.py
@@ -17,7 +17,7 @@ class Experiment(Model):
}
}
- TABLE_NAME = 'experiments'
+ COLLECTION_NAME = 'experiments'
COLUMNS = ['id', 'simulation_id', 'path_id', 'trace_id', 'scheduler_name', 'name', 'state', 'last_simulated_tick']
COLUMNS_PRIMARY_KEY = ['id']
diff --git a/opendc/models/failure_model.py b/opendc/models/failure_model.py
index ff6459e9..cffa2c47 100644
--- a/opendc/models/failure_model.py
+++ b/opendc/models/failure_model.py
@@ -10,7 +10,7 @@ class FailureModel(Model):
}
}
- TABLE_NAME = 'failure_models'
+ COLLECTION_NAME = 'failure_models'
COLUMNS = ['id', 'name', 'rate']
COLUMNS_PRIMARY_KEY = ['id']
diff --git a/opendc/models/gpu.py b/opendc/models/gpu.py
index 37de235c..d56ceba6 100644
--- a/opendc/models/gpu.py
+++ b/opendc/models/gpu.py
@@ -16,7 +16,7 @@ class GPU(Model):
}
}
- TABLE_NAME = 'gpus'
+ COLLECTION_NAME = 'gpus'
COLUMNS = [
'id',
diff --git a/opendc/models/job.py b/opendc/models/job.py
index e013b991..aaf2a20c 100644
--- a/opendc/models/job.py
+++ b/opendc/models/job.py
@@ -9,7 +9,7 @@ class Job(Model):
}
}
- TABLE_NAME = 'jobs'
+ COLLECTION_NAME = 'jobs'
COLUMNS = ['id', 'name']
COLUMNS_PRIMARY_KEY = ['id']
diff --git a/opendc/models/machine.py b/opendc/models/machine.py
index e6e49c4b..b79cae94 100644
--- a/opendc/models/machine.py
+++ b/opendc/models/machine.py
@@ -22,7 +22,7 @@ class Machine(Model):
PATH = '/v1/tiles/{tileId}/rack/machines'
- TABLE_NAME = 'machines'
+ COLLECTION_NAME = 'machines'
COLUMNS = ['id', 'rack_id', 'position', 'topology_id']
COLUMNS_PRIMARY_KEY = ['id']
diff --git a/opendc/models/machine_state.py b/opendc/models/machine_state.py
index 3e3fdab9..ba6d261f 100644
--- a/opendc/models/machine_state.py
+++ b/opendc/models/machine_state.py
@@ -13,7 +13,7 @@ class MachineState(Model):
}
}
- TABLE_NAME = 'machine_states'
+ COLLECTION_NAME = 'machine_states'
COLUMNS = ['id', 'machine_id', 'experiment_id', 'tick', 'temperature_c', 'in_use_memory_mb',
'load_fraction']
diff --git a/opendc/models/memory.py b/opendc/models/memory.py
index 961c0479..496c887f 100644
--- a/opendc/models/memory.py
+++ b/opendc/models/memory.py
@@ -16,7 +16,7 @@ class Memory(Model):
}
}
- TABLE_NAME = 'memories'
+ COLLECTION_NAME = 'memories'
COLUMNS = [
'id',
diff --git a/opendc/models/model.py b/opendc/models/model.py
index 00ab50d1..e9ce4f5e 100644
--- a/opendc/models/model.py
+++ b/opendc/models/model.py
@@ -13,7 +13,7 @@ class Model(object):
PATH = ''
PATH_PARAMETERS = {}
- TABLE_NAME = ''
+ COLLECTION_NAME = ''
COLUMNS = []
COLUMNS_PRIMARY_KEY = []
@@ -34,7 +34,7 @@ class Model(object):
identifiers.append('{} = {}'.format(attribute, getattr(self, attribute)))
return '{} ({})'.format(
- self.TABLE_NAME[:-1].title().replace('_', ''),
+ self.COLLECTION_NAME[:-1].title().replace('_', ''),
'; '.join(identifiers)
)
@@ -183,7 +183,7 @@ class Model(object):
"""
query = 'SELECT * FROM {} WHERE {}'.format(
- cls.TABLE_NAME,
+ cls.COLLECTION_NAME,
cls._generate_primary_key_string()
)
@@ -206,11 +206,11 @@ class Model(object):
"""Return all instances of the Model in the database where column_name = value."""
if column_name is not None and value is not None:
- statement = 'SELECT * FROM {} WHERE {} = %s'.format(cls.TABLE_NAME, column_name)
+ statement = 'SELECT * FROM {} WHERE {} = %s'.format(cls.COLLECTION_NAME, column_name)
database_models = database.fetch_all(statement, (value,))
else:
- statement = 'SELECT * FROM {}'.format(cls.TABLE_NAME)
+ statement = 'SELECT * FROM {}'.format(cls.COLLECTION_NAME)
database_models = database.fetch_all(statement)
models = []
@@ -231,7 +231,7 @@ class Model(object):
self.read()
statement = 'DELETE FROM {} WHERE {}'.format(
- self.TABLE_NAME,
+ self.COLLECTION_NAME,
self._generate_primary_key_string()
)
@@ -255,14 +255,14 @@ class Model(object):
if column is None:
query = query.format(
- self.TABLE_NAME,
+ self.COLLECTION_NAME,
self._generate_primary_key_string()
)
values = self._generate_primary_key_tuple()
else:
query = query.format(
- self.TABLE_NAME,
+ self.COLLECTION_NAME,
'{} = %s'.format(column)
)
values = (getattr(self, column),)
@@ -281,7 +281,7 @@ class Model(object):
"""Insert this Model into the database without removing its id."""
statement = 'INSERT INTO {} ({}) VALUES ({})'.format(
- self.TABLE_NAME,
+ self.COLLECTION_NAME,
self._generate_insert_columns_string(),
self._generate_insert_placeholders_string()
)
@@ -303,7 +303,7 @@ class Model(object):
"""Read this Model's non-primary key attributes from the database."""
if not self.exists():
- raise exceptions.RowNotFoundError(self.TABLE_NAME)
+ raise exceptions.RowNotFoundError(self.COLLECTION_NAME)
database_model = self.from_primary_key(self._generate_primary_key_tuple())
@@ -316,7 +316,7 @@ class Model(object):
"""Update this Model's non-primary key attributes in the database."""
statement = 'UPDATE {} SET {} WHERE {}'.format(
- self.TABLE_NAME,
+ self.COLLECTION_NAME,
self._generate_update_columns_string(),
self._generate_primary_key_string()
)
diff --git a/opendc/models/object.py b/opendc/models/object.py
index f9990d81..dab2f24e 100644
--- a/opendc/models/object.py
+++ b/opendc/models/object.py
@@ -9,7 +9,7 @@ class Object(Model):
}
}
- TABLE_NAME = 'objects'
+ COLLECTION_NAME = 'objects'
COLUMNS = ['id', 'type']
COLUMNS_PRIMARY_KEY = ['id']
diff --git a/opendc/models/path.py b/opendc/models/path.py
index 09651a66..093c9346 100644
--- a/opendc/models/path.py
+++ b/opendc/models/path.py
@@ -14,7 +14,7 @@ class Path(Model):
}
}
- TABLE_NAME = 'paths'
+ COLLECTION_NAME = 'paths'
COLUMNS = ['id', 'simulation_id', 'name', 'datetime_created']
COLUMNS_PRIMARY_KEY = ['id']
diff --git a/opendc/models/queued_experiment.py b/opendc/models/queued_experiment.py
index 1cb52c49..cd00a495 100644
--- a/opendc/models/queued_experiment.py
+++ b/opendc/models/queued_experiment.py
@@ -8,6 +8,6 @@ class QueuedExperiment(Model):
}
}
- TABLE_NAME = 'queued_experiments'
+ COLLECTION_NAME = 'queued_experiments'
COLUMNS = ['experiment_id']
COLUMNS_PRIMARY_KEY = ['experiment_id']
diff --git a/opendc/models/rack.py b/opendc/models/rack.py
index 43916490..7b085a57 100644
--- a/opendc/models/rack.py
+++ b/opendc/models/rack.py
@@ -16,7 +16,7 @@ class Rack(Model):
PATH = '/v1/tiles/{tileId}/rack'
- TABLE_NAME = 'racks'
+ COLLECTION_NAME = 'racks'
COLUMNS = ['id', 'name', 'capacity', 'power_capacity_w', 'topology_id']
COLUMNS_PRIMARY_KEY = ['id']
diff --git a/opendc/models/room.py b/opendc/models/room.py
index 209e4e77..a4266627 100644
--- a/opendc/models/room.py
+++ b/opendc/models/room.py
@@ -16,7 +16,7 @@ class Room(Model):
PATH = '/v1/datacenters/{datacenterId}/rooms'
- TABLE_NAME = 'rooms'
+ COLLECTION_NAME = 'rooms'
COLUMNS = ['id', 'name', 'datacenter_id', 'type', 'topology_id']
COLUMNS_PRIMARY_KEY = ['id']
diff --git a/opendc/models/room_type.py b/opendc/models/room_type.py
index 1d107e95..c252e4fe 100644
--- a/opendc/models/room_type.py
+++ b/opendc/models/room_type.py
@@ -8,7 +8,7 @@ class RoomType(Model):
}
}
- TABLE_NAME = 'room_types'
+ COLLECTION_NAME = 'room_types'
COLUMNS = ['name']
COLUMNS_PRIMARY_KEY = ['name']
diff --git a/opendc/models/scheduler.py b/opendc/models/scheduler.py
index b70830ab..c9523ce2 100644
--- a/opendc/models/scheduler.py
+++ b/opendc/models/scheduler.py
@@ -8,7 +8,7 @@ class Scheduler(Model):
}
}
- TABLE_NAME = 'schedulers'
+ COLLECTION_NAME = 'schedulers'
COLUMNS = ['name']
COLUMNS_PRIMARY_KEY = ['name']
diff --git a/opendc/models/section.py b/opendc/models/section.py
index 4e953eae..53b5e6c9 100644
--- a/opendc/models/section.py
+++ b/opendc/models/section.py
@@ -13,7 +13,7 @@ class Section(Model):
}
}
- TABLE_NAME = 'sections'
+ COLLECTION_NAME = 'sections'
COLUMNS = ['id', 'path_id', 'datacenter_id', 'start_tick']
COLUMNS_PRIMARY_KEY = ['id']
diff --git a/opendc/models/simulation.py b/opendc/models/simulation.py
index 8c3726c8..af47b4c5 100644
--- a/opendc/models/simulation.py
+++ b/opendc/models/simulation.py
@@ -14,7 +14,7 @@ class Simulation(Model):
}
}
- TABLE_NAME = 'simulations'
+ COLLECTION_NAME = 'simulations'
COLUMNS = ['id', 'datetime_created', 'datetime_last_edited', 'name']
COLUMNS_PRIMARY_KEY = ['id']
diff --git a/opendc/models/storage.py b/opendc/models/storage.py
index 02c568fb..3f84ba5e 100644
--- a/opendc/models/storage.py
+++ b/opendc/models/storage.py
@@ -16,7 +16,7 @@ class Storage(Model):
}
}
- TABLE_NAME = 'storages'
+ COLLECTION_NAME = 'storages'
COLUMNS = [
'id',
diff --git a/opendc/models/task.py b/opendc/models/task.py
index ff1dd16a..411405c2 100644
--- a/opendc/models/task.py
+++ b/opendc/models/task.py
@@ -12,7 +12,7 @@ class Task(Model):
}
}
- TABLE_NAME = 'tasks'
+ COLLECTION_NAME = 'tasks'
COLUMNS = ['id', 'start_tick', 'total_flop_count', 'job_id', 'core_count']
COLUMNS_PRIMARY_KEY = ['id']
diff --git a/opendc/models/task_state.py b/opendc/models/task_state.py
index 83cc6a62..ad78cc67 100644
--- a/opendc/models/task_state.py
+++ b/opendc/models/task_state.py
@@ -14,7 +14,7 @@ class TaskState(Model):
}
}
- TABLE_NAME = 'task_states'
+ COLLECTION_NAME = 'task_states'
COLUMNS = ['id', 'task_id', 'experiment_id', 'tick', 'flops_left', 'cores_used']
COLUMNS_PRIMARY_KEY = ['id']
diff --git a/opendc/models/tile.py b/opendc/models/tile.py
index e7f64160..ac22ccac 100644
--- a/opendc/models/tile.py
+++ b/opendc/models/tile.py
@@ -19,7 +19,7 @@ class Tile(Model):
PATH = '/v1/rooms/{roomId}/tiles'
- TABLE_NAME = 'tiles'
+ COLLECTION_NAME = 'tiles'
COLUMNS = ['id', 'position_x', 'position_y', 'room_id', 'object_id', 'topology_id']
COLUMNS_PRIMARY_KEY = ['id']
diff --git a/opendc/models/trace.py b/opendc/models/trace.py
index 99245ac3..2f5e33cd 100644
--- a/opendc/models/trace.py
+++ b/opendc/models/trace.py
@@ -9,7 +9,7 @@ class Trace(Model):
}
}
- TABLE_NAME = 'traces'
+ COLLECTION_NAME = 'traces'
COLUMNS = ['id', 'name']
COLUMNS_PRIMARY_KEY = ['id']
diff --git a/opendc/models/user.py b/opendc/models/user.py
index fde45b0c..0406c31c 100644
--- a/opendc/models/user.py
+++ b/opendc/models/user.py
@@ -12,7 +12,7 @@ class User(Model):
}
}
- TABLE_NAME = 'users'
+ COLLECTION_NAME = 'users'
COLUMNS = ['id', 'google_id', 'email', 'given_name', 'family_name']
COLUMNS_PRIMARY_KEY = ['id']