diff options
Diffstat (limited to 'opendc')
| -rw-r--r-- | opendc/api/v1/paths/pathId/branches/endpoint.py | 12 | ||||
| -rw-r--r-- | opendc/models/machine.py | 10 | ||||
| -rw-r--r-- | opendc/models/rack.py | 5 | ||||
| -rw-r--r-- | opendc/models/room.py | 5 | ||||
| -rw-r--r-- | opendc/models/tile.py | 5 |
5 files changed, 24 insertions, 13 deletions
diff --git a/opendc/api/v1/paths/pathId/branches/endpoint.py b/opendc/api/v1/paths/pathId/branches/endpoint.py index 1f330472..13638ffa 100644 --- a/opendc/api/v1/paths/pathId/branches/endpoint.py +++ b/opendc/api/v1/paths/pathId/branches/endpoint.py @@ -111,6 +111,9 @@ def POST(request): old_room.datacenter_id = path_parameters['datacenterId'] + if old_room.topology_id is None: + old_room.topology_id = old_room.id + message = old_room.generate_api_call(path_parameters, request.token) response = Request(message).process() @@ -124,6 +127,9 @@ def POST(request): old_tile.room_id = path_parameters['roomId'] + if old_tile.topology_id is None: + old_tile.topology_id = old_tile.id + message = old_tile.generate_api_call(path_parameters, request.token) response = Request(message).process() @@ -137,6 +143,9 @@ def POST(request): old_rack = Rack.query('id', old_objects[0].id)[0] + if old_rack.topology_id is None: + old_rack.topology_id = old_rack.id + message = old_rack.generate_api_call(path_parameters, request.token) response = Request(message).process() @@ -150,6 +159,9 @@ def POST(request): old_machine.read() old_machine.rack_id = path_parameters['rackId'] + if old_machine.topology_id is None: + old_machine.topology_id = old_machine.id + message = old_machine.generate_api_call(path_parameters, request.token) response = Request(message).process() diff --git a/opendc/models/machine.py b/opendc/models/machine.py index 0d9fbd54..f233d329 100644 --- a/opendc/models/machine.py +++ b/opendc/models/machine.py @@ -15,14 +15,15 @@ class Machine(Model): 'cpuIds': 'cpu_ids', 'gpuIds': 'gpu_ids', 'memoryIds': 'memory_ids', - 'storageIds': 'storage_ids' + 'storageIds': 'storage_ids', + 'topologyId': 'topology_id' } } PATH = '/v1/tiles/{tileId}/rack/machines' TABLE_NAME = 'machines' - COLUMNS = ['id', 'rack_id', 'position'] + COLUMNS = ['id', 'rack_id', 'position', 'topology_id'] COLUMNS_PRIMARY_KEY = ['id'] device_table_to_attribute = { @@ -37,11 +38,6 @@ class Machine(Model): for device_table in self.device_table_to_attribute.keys(): - # First, create the statements to execute - - statements = [] - values = [] - # First, delete current machine-device links statement = 'DELETE FROM machine_{} WHERE machine_id = %s'.format(device_table) diff --git a/opendc/models/rack.py b/opendc/models/rack.py index 74104fcb..43916490 100644 --- a/opendc/models/rack.py +++ b/opendc/models/rack.py @@ -9,14 +9,15 @@ class Rack(Model): 'id': 'id', 'name': 'name', 'capacity': 'capacity', - 'powerCapacityW': 'power_capacity_w' + 'powerCapacityW': 'power_capacity_w', + 'topologyId': 'topology_id' } } PATH = '/v1/tiles/{tileId}/rack' TABLE_NAME = 'racks' - COLUMNS = ['id', 'name', 'capacity', 'power_capacity_w'] + COLUMNS = ['id', 'name', 'capacity', 'power_capacity_w', 'topology_id'] COLUMNS_PRIMARY_KEY = ['id'] @classmethod diff --git a/opendc/models/room.py b/opendc/models/room.py index 66346bb2..209e4e77 100644 --- a/opendc/models/room.py +++ b/opendc/models/room.py @@ -9,14 +9,15 @@ class Room(Model): 'id': 'id', 'datacenterId': 'datacenter_id', 'name': 'name', - 'roomType': 'type' + 'roomType': 'type', + 'topologyId': 'topology_id' } } PATH = '/v1/datacenters/{datacenterId}/rooms' TABLE_NAME = 'rooms' - COLUMNS = ['id', 'name', 'datacenter_id', 'type'] + COLUMNS = ['id', 'name', 'datacenter_id', 'type', 'topology_id'] 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 344b6135..e7f64160 100644 --- a/opendc/models/tile.py +++ b/opendc/models/tile.py @@ -12,14 +12,15 @@ class Tile(Model): 'objectId': 'object_id', 'objectType': 'object_type', 'positionX': 'position_x', - 'positionY': 'position_y' + 'positionY': 'position_y', + 'topologyId': 'topology_id' } } PATH = '/v1/rooms/{roomId}/tiles' TABLE_NAME = 'tiles' - COLUMNS = ['id', 'position_x', 'position_y', 'room_id', 'object_id'] + COLUMNS = ['id', 'position_x', 'position_y', 'room_id', 'object_id', 'topology_id'] COLUMNS_PRIMARY_KEY = ['id'] def google_id_has_at_least(self, google_id, authorization_level): |
