|
4 | 4 |
|
5 | 5 | from spaceone.core.model.mongo_model import MongoModel
|
6 | 6 | from spaceone.plugin.model.supervisor_model import Supervisor
|
7 |
| -from spaceone.plugin.manager.plugin_manager.plugin_state import PROVISIONING, ACTIVE, ERROR, RE_PROVISIONING |
| 7 | +from spaceone.plugin.manager.plugin_manager.plugin_state import ( |
| 8 | + PROVISIONING, |
| 9 | + ACTIVE, |
| 10 | + ERROR, |
| 11 | + RE_PROVISIONING, |
| 12 | +) |
8 | 13 |
|
9 |
| -__all__ = ['InstalledPlugin'] |
| 14 | +__all__ = ["InstalledPlugin"] |
10 | 15 |
|
11 | 16 |
|
12 | 17 | class InstalledPlugin(MongoModel):
|
13 | 18 | # TODO: check plugin_id max length
|
14 |
| - plugin_id = StringField(max_length=255, required=True, null=False, unique_with=['version', 'supervisor_id']) |
| 19 | + plugin_id = StringField( |
| 20 | + max_length=255, |
| 21 | + required=True, |
| 22 | + null=False, |
| 23 | + unique_with=["version", "supervisor_id"], |
| 24 | + ) |
15 | 25 | supervisor_id = StringField(max_length=255, required=True, null=False)
|
16 |
| - supervisor = ReferenceField('Supervisor', reverse_delete_rule=CASCADE, required=True, null=False) |
| 26 | + supervisor = ReferenceField( |
| 27 | + "Supervisor", reverse_delete_rule=CASCADE, required=True, null=False |
| 28 | + ) |
17 | 29 | name = StringField(max_length=255)
|
18 | 30 | image = StringField(max_length=255)
|
19 | 31 | version = StringField(max_length=255)
|
20 |
| - state = StringField(max_length=40, |
21 |
| - default=PROVISIONING, |
22 |
| - choices=(PROVISIONING, ACTIVE, ERROR, RE_PROVISIONING)) |
| 32 | + state = StringField( |
| 33 | + max_length=40, |
| 34 | + default=PROVISIONING, |
| 35 | + choices=(PROVISIONING, ACTIVE, ERROR, RE_PROVISIONING), |
| 36 | + ) |
23 | 37 | endpoint = StringField(max_length=255)
|
24 | 38 | endpoints = ListField(StringField(max_length=255))
|
| 39 | + current_index = IntField(default=0) |
25 | 40 | domain_id = StringField(max_length=40, required=True, null=False)
|
26 | 41 | created_at = DateTimeField(auto_now_add=True)
|
27 | 42 | updated_at = DateTimeField(auto_now_add=True)
|
28 | 43 | endpoint_called_at = DateTimeField(default=None, null=True)
|
29 | 44 |
|
30 | 45 | meta = {
|
31 |
| - 'updatable_fields': [ |
32 |
| - 'name', |
33 |
| - 'updated_at', |
34 |
| - 'state', |
35 |
| - 'endpoint', |
36 |
| - 'endpoints', |
37 |
| - 'endpoint_called_at' |
| 46 | + "updatable_fields": [ |
| 47 | + "name", |
| 48 | + "updated_at", |
| 49 | + "state", |
| 50 | + "endpoint", |
| 51 | + "endpoints", |
| 52 | + "current_index", |
| 53 | + "endpoint_called_at", |
38 | 54 | ],
|
39 |
| - 'minimal_fields': [ |
40 |
| - 'plugin_id', |
41 |
| - 'version', |
42 |
| - 'state', |
43 |
| - 'endpoint', |
44 |
| - 'endpoints' |
| 55 | + "minimal_fields": ["plugin_id", "version", "state", "endpoint", "endpoints"], |
| 56 | + "change_query_keys": {"hostname": "supervisor.hostname"}, |
| 57 | + "reference_query_keys": {"supervisor": Supervisor}, |
| 58 | + "ordering": ["name"], |
| 59 | + "indexes": [ |
| 60 | + "plugin_id", |
| 61 | + "supervisor_id", |
| 62 | + "supervisor", |
| 63 | + "domain_id", |
| 64 | + "name", |
| 65 | + "image", |
| 66 | + "version", |
| 67 | + "state", |
| 68 | + "endpoint_called_at", |
45 | 69 | ],
|
46 |
| - 'change_query_keys': { |
47 |
| - 'hostname': 'supervisor.hostname' |
48 |
| - }, |
49 |
| - 'reference_query_keys': { |
50 |
| - 'supervisor': Supervisor |
51 |
| - }, |
52 |
| - 'ordering': ['name'], |
53 |
| - 'indexes': [ |
54 |
| - 'plugin_id', |
55 |
| - 'supervisor_id', |
56 |
| - 'supervisor', |
57 |
| - 'domain_id', |
58 |
| - 'name', |
59 |
| - 'image', |
60 |
| - 'version', |
61 |
| - 'state', |
62 |
| - 'endpoint_called_at' |
63 |
| - ] |
64 | 70 | }
|
65 | 71 |
|
66 | 72 | def update(self, data):
|
67 |
| - data['updated_at'] = datetime.datetime.now() |
| 73 | + data["updated_at"] = datetime.datetime.now() |
68 | 74 | return super().update(data)
|
69 | 75 |
|
70 | 76 | def update_endpoint_called_at(self):
|
71 |
| - data = {'endpoint_called_at': datetime.datetime.now()} |
| 77 | + data = {"endpoint_called_at": datetime.datetime.now()} |
72 | 78 | return super().update(data)
|
0 commit comments