summaryrefslogtreecommitdiff
path: root/opendc/models/cpu.py
blob: a2a0e79f505e6a3d8c2ab7af46293d3f2dfb6709 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from opendc.models.model import Model

class CPU(Model):

    JSON_TO_PYTHON_DICT = {
        'CPU': {
            'id': 'id',
            'manufacturer': 'manufacturer',
            'family': 'family',
            'generation': 'generation',
            'model': 'model',
            'clockRateMhz': 'clock_rate_mhz',
            'numberOfCores': 'number_of_cores',
            'energyConsumptionW': 'energy_consumption_w',
            'failureModelId': 'failure_model_id'
        }
    }

    TABLE_NAME = 'cpus'

    COLUMNS = [
        'id',
        'manufacturer',
        'family',
        'generation',
        'model',
        'clock_rate_mhz',
        'number_of_cores',
        'energy_consumption_w',
        'failure_model_id'
    ]

    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 CPU."""

        if authorization_level in ['EDIT', 'OWN']:
            return False

        return True