projects
/
osm
/
POL.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Point dependencies to branch
[osm/POL.git]
/
osm_policy_module
/
core
/
database.py
diff --git
a/osm_policy_module/core/database.py
b/osm_policy_module/core/database.py
index
e326ca2
..
7bf11d8
100644
(file)
--- a/
osm_policy_module/core/database.py
+++ b/
osm_policy_module/core/database.py
@@
-26,8
+26,17
@@
import logging
import os
from typing import Iterable, List
import os
from typing import Iterable, List
-from peewee import CharField, IntegerField, ForeignKeyField, Model, TextField, AutoField, DateTimeField, Proxy, \
- BooleanField
+from peewee import (
+ CharField,
+ IntegerField,
+ ForeignKeyField,
+ Model,
+ TextField,
+ AutoField,
+ DateTimeField,
+ Proxy,
+ BooleanField,
+)
from peewee_migrate import Router
from playhouse.db_url import connect
from peewee_migrate import Router
from playhouse.db_url import connect
@@
-48,7
+57,7
@@
class BaseModel(Model):
class ScalingGroup(BaseModel):
nsr_id = CharField()
class ScalingGroup(BaseModel):
nsr_id = CharField()
- vnf_member_index =
Intege
rField()
+ vnf_member_index =
Cha
rField()
name = CharField()
content = TextField()
name = CharField()
content = TextField()
@@
-56,44
+65,50
@@
class ScalingGroup(BaseModel):
class ScalingPolicy(BaseModel):
name = CharField()
cooldown_time = IntegerField()
class ScalingPolicy(BaseModel):
name = CharField()
cooldown_time = IntegerField()
- scale_in_operation = CharField(default=
'AND'
)
- scale_out_operation = CharField(default=
'OR'
)
+ scale_in_operation = CharField(default=
"AND"
)
+ scale_out_operation = CharField(default=
"OR"
)
enabled = BooleanField(default=True)
last_scale = DateTimeField(default=datetime.datetime.now)
enabled = BooleanField(default=True)
last_scale = DateTimeField(default=datetime.datetime.now)
- scaling_group = ForeignKeyField(ScalingGroup, related_name='scaling_policies', on_delete='CASCADE')
+ scaling_group = ForeignKeyField(
+ ScalingGroup, related_name="scaling_policies", on_delete="CASCADE"
+ )
class ScalingCriteria(BaseModel):
name = CharField()
class ScalingCriteria(BaseModel):
name = CharField()
- scaling_policy = ForeignKeyField(ScalingPolicy, related_name='scaling_criterias', on_delete='CASCADE')
+ scaling_policy = ForeignKeyField(
+ ScalingPolicy, related_name="scaling_criterias", on_delete="CASCADE"
+ )
class ScalingAlarm(BaseModel):
alarm_uuid = CharField(unique=True)
action = CharField()
class ScalingAlarm(BaseModel):
alarm_uuid = CharField(unique=True)
action = CharField()
- vnf_member_index =
Intege
rField()
+ vnf_member_index =
Cha
rField()
vdu_name = CharField()
vdu_name = CharField()
- scaling_criteria = ForeignKeyField(ScalingCriteria, related_name='scaling_alarms', on_delete='CASCADE')
- last_status = CharField(default='insufficient-data')
+ scaling_criteria = ForeignKeyField(
+ ScalingCriteria, related_name="scaling_alarms", on_delete="CASCADE"
+ )
+ last_status = CharField(default="insufficient-data")
class VnfAlarm(BaseModel):
alarm_id = CharField()
alarm_uuid = CharField(unique=True)
nsr_id = CharField()
class VnfAlarm(BaseModel):
alarm_id = CharField()
alarm_uuid = CharField(unique=True)
nsr_id = CharField()
- vnf_member_index =
Intege
rField()
+ vnf_member_index =
Cha
rField()
vdu_name = CharField()
class AlarmAction(BaseModel):
type = CharField()
url = TextField()
vdu_name = CharField()
class AlarmAction(BaseModel):
type = CharField()
url = TextField()
- alarm = ForeignKeyField(VnfAlarm, related_name=
'actions', on_delete='CASCADE'
)
+ alarm = ForeignKeyField(VnfAlarm, related_name=
"actions", on_delete="CASCADE"
)
class DatabaseManager:
def __init__(self, config: Config):
class DatabaseManager:
def __init__(self, config: Config):
- db.initialize(connect(config.get(
'sql', 'database_uri'
)))
+ db.initialize(connect(config.get(
"sql", "database_uri"
)))
def create_tables(self) -> None:
db.connect()
def create_tables(self) -> None:
db.connect()
@@
-104,7
+119,6
@@
class DatabaseManager:
class ScalingAlarmRepository:
class ScalingAlarmRepository:
-
@staticmethod
def list(*expressions) -> Iterable[ScalingAlarm]:
return ScalingAlarm.select().where(*expressions)
@staticmethod
def list(*expressions) -> Iterable[ScalingAlarm]:
return ScalingAlarm.select().where(*expressions)
@@
-123,7
+137,6
@@
class ScalingAlarmRepository:
class ScalingGroupRepository:
class ScalingGroupRepository:
-
@staticmethod
def list(*expressions) -> Iterable[ScalingGroup]:
return ScalingGroup.select().where(*expressions)
@staticmethod
def list(*expressions) -> Iterable[ScalingGroup]:
return ScalingGroup.select().where(*expressions)
@@
-138,7
+151,6
@@
class ScalingGroupRepository:
class ScalingPolicyRepository:
class ScalingPolicyRepository:
-
@staticmethod
def list(*expressions, join_classes: List = None) -> Iterable[ScalingPolicy]:
query = ScalingPolicy.select()
@staticmethod
def list(*expressions, join_classes: List = None) -> Iterable[ScalingPolicy]:
query = ScalingPolicy.select()
@@
-161,7
+173,6
@@
class ScalingPolicyRepository:
class ScalingCriteriaRepository:
class ScalingCriteriaRepository:
-
@staticmethod
def list(*expressions, join_classes: List = None) -> Iterable[ScalingCriteria]:
query = ScalingCriteria.select()
@staticmethod
def list(*expressions, join_classes: List = None) -> Iterable[ScalingCriteria]:
query = ScalingCriteria.select()
@@
-184,7
+195,6
@@
class ScalingCriteriaRepository:
class VnfAlarmRepository:
class VnfAlarmRepository:
-
@staticmethod
def list(*expressions) -> Iterable[VnfAlarm]:
return VnfAlarm.select().where(*expressions)
@staticmethod
def list(*expressions) -> Iterable[VnfAlarm]:
return VnfAlarm.select().where(*expressions)
@@
-199,7
+209,6
@@
class VnfAlarmRepository:
class AlarmActionRepository:
class AlarmActionRepository:
-
@staticmethod
def list(*expressions) -> Iterable[AlarmAction]:
return AlarmAction.select().where(*expressions)
@staticmethod
def list(*expressions) -> Iterable[AlarmAction]:
return AlarmAction.select().where(*expressions)