Merge "add timezone to alarms queried from db"
This commit is contained in:
commit
08c95a9d8b
@ -102,7 +102,7 @@ python-novaclient==10.1.0
|
|||||||
python-openstackclient==3.12.0
|
python-openstackclient==3.12.0
|
||||||
python-subunit==1.2.0
|
python-subunit==1.2.0
|
||||||
python-swiftclient==3.5.0
|
python-swiftclient==3.5.0
|
||||||
pytz==2018.3
|
pytz==2013.6
|
||||||
PyYAML==3.12
|
PyYAML==3.12
|
||||||
pyzabbix==0.7.4
|
pyzabbix==0.7.4
|
||||||
reno==2.7.0
|
reno==2.7.0
|
||||||
|
@ -47,3 +47,4 @@ six>=1.11.0 # MIT
|
|||||||
debtcollector>=1.19.0 # Apache-2.0
|
debtcollector>=1.19.0 # Apache-2.0
|
||||||
cotyledon>=1.6.8 # Apache-2.0
|
cotyledon>=1.6.8 # Apache-2.0
|
||||||
futures>=3.0.0;python_version=='2.7' or python_version=='2.6' # BSD
|
futures>=3.0.0;python_version=='2.7' or python_version=='2.6' # BSD
|
||||||
|
pytz>=2013.6 # MIT
|
@ -11,10 +11,9 @@
|
|||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
|
||||||
from dateutil import parser
|
from dateutil import parser
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
from osprofiler import profiler
|
from osprofiler import profiler
|
||||||
|
|
||||||
@ -107,9 +106,14 @@ class AlarmApis(EntityGraphApisBase):
|
|||||||
alarm.payload[VProps.VITRAGE_OPERATIONAL_SEVERITY] = \
|
alarm.payload[VProps.VITRAGE_OPERATIONAL_SEVERITY] = \
|
||||||
OperationalAlarmSeverity.OK
|
OperationalAlarmSeverity.OK
|
||||||
for alarm in alarms:
|
for alarm in alarms:
|
||||||
alarm.payload[HProps.START_TIMESTAMP] = str(alarm.start_timestamp)
|
start_timestamp = \
|
||||||
|
self.db.history_facade.add_utc_timezone(alarm.start_timestamp)
|
||||||
|
alarm.payload[HProps.START_TIMESTAMP] = str(start_timestamp)
|
||||||
if alarm.end_timestamp <= db_time():
|
if alarm.end_timestamp <= db_time():
|
||||||
alarm.payload[HProps.END_TIMESTAMP] = str(alarm.end_timestamp)
|
end_timestamp = \
|
||||||
|
self.db.history_facade.add_utc_timezone(
|
||||||
|
alarm.end_timestamp)
|
||||||
|
alarm.payload[HProps.END_TIMESTAMP] = str(end_timestamp)
|
||||||
|
|
||||||
return alarms
|
return alarms
|
||||||
|
|
||||||
|
@ -51,9 +51,13 @@ class RcaApis(EntityGraphApisBase):
|
|||||||
admin=is_admin_project)
|
admin=is_admin_project)
|
||||||
|
|
||||||
for n in db_nodes:
|
for n in db_nodes:
|
||||||
n.payload[HProps.START_TIMESTAMP] = str(n.start_timestamp)
|
start_timestamp = \
|
||||||
|
self.db.history_facade.add_utc_timezone(n.start_timestamp)
|
||||||
|
n.payload[HProps.START_TIMESTAMP] = str(start_timestamp)
|
||||||
if n.end_timestamp <= db_time():
|
if n.end_timestamp <= db_time():
|
||||||
n.payload[HProps.END_TIMESTAMP] = str(n.end_timestamp)
|
end_timestamp = \
|
||||||
|
self.db.history_facade.add_utc_timezone(n.end_timestamp)
|
||||||
|
n.payload[HProps.END_TIMESTAMP] = str(end_timestamp)
|
||||||
|
|
||||||
vertices = [Vertex(vertex_id=n.vitrage_id, properties=n.payload) for n
|
vertices = [Vertex(vertex_id=n.vitrage_id, properties=n.payload) for n
|
||||||
in db_nodes]
|
in db_nodes]
|
||||||
|
@ -14,12 +14,15 @@
|
|||||||
|
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
|
||||||
from oslo_db.sqlalchemy import utils as sqlalchemyutils
|
import pytz
|
||||||
from oslo_log import log
|
|
||||||
from oslo_utils import timeutils
|
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
from sqlalchemy import and_
|
from sqlalchemy import and_
|
||||||
from sqlalchemy import or_
|
from sqlalchemy import or_
|
||||||
|
|
||||||
|
from oslo_db.sqlalchemy import utils as sqlalchemyutils
|
||||||
|
from oslo_log import log
|
||||||
|
from oslo_utils import timeutils
|
||||||
|
|
||||||
from vitrage.common.constants import EdgeLabel as ELable
|
from vitrage.common.constants import EdgeLabel as ELable
|
||||||
from vitrage.common.constants import HistoryProps as HProps
|
from vitrage.common.constants import HistoryProps as HProps
|
||||||
from vitrage.common.exception import VitrageInputError
|
from vitrage.common.exception import VitrageInputError
|
||||||
@ -51,6 +54,11 @@ class HistoryFacadeConnection(object):
|
|||||||
self._edges.end_all_edges(end_time)
|
self._edges.end_all_edges(end_time)
|
||||||
self._changes.add_end_changes(changes_to_add, end_time)
|
self._changes.add_end_changes(changes_to_add, end_time)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def add_utc_timezone(time):
|
||||||
|
time = pytz.utc.localize(time)
|
||||||
|
return time
|
||||||
|
|
||||||
def count_active_alarms(self, project_id=None, is_admin_project=False):
|
def count_active_alarms(self, project_id=None, is_admin_project=False):
|
||||||
|
|
||||||
session = self._engine_facade.get_session()
|
session = self._engine_facade.get_session()
|
||||||
|
Loading…
Reference in New Issue
Block a user