Browse Source

Use vars() more readable then __dict__

Change-Id: I20ace9a4bf9aac5048a1e1b991648e17e07f9c74
changes/52/738352/1
Eyal 1 week ago
parent
commit
e364c1ed2c
11 changed files with 12 additions and 12 deletions
  1. +1
    -1
      vitrage/api/policy.py
  2. +1
    -1
      vitrage/datasources/aodh/driver.py
  3. +1
    -1
      vitrage/datasources/ceilometer/driver.py
  4. +1
    -1
      vitrage/datasources/cinder/volume/driver.py
  5. +1
    -1
      vitrage/datasources/nova/instance/driver.py
  6. +1
    -1
      vitrage/datasources/nova/zone/driver.py
  7. +1
    -1
      vitrage/datasources/transformer_base.py
  8. +2
    -2
      vitrage/graph/driver/elements.py
  9. +1
    -1
      vitrage/opts.py
  10. +1
    -1
      vitrage/tests/unit/datasources/aodh/aodh_transformer_base_test.py
  11. +1
    -1
      vitrage/tests/unit/datasources/ceilometer/ceilometer_transformer_base_test.py

+ 1
- 1
vitrage/api/policy.py View File

@@ -31,7 +31,7 @@ def enforce(rule, headers, enforcer, target):
}

if not isinstance(target, dict):
target = target.__dict__
target = vars(target)

target = dict(recursive_keypairs(target))



+ 1
- 1
vitrage/datasources/aodh/driver.py View File

@@ -309,7 +309,7 @@ class AodhDriver(AlarmDriverBase):
entity.update(self._parse_changed_rule(
changed_rule[changed_type]))
# handle other changed alarm properties
elif changed_type in AodhProps.__dict__.values():
elif changed_type in vars(AodhProps).values():
entity[changed_type] = changed_info

return self._filter_and_cache_alarm(entity, old_alarm,


+ 1
- 1
vitrage/datasources/ceilometer/driver.py View File

@@ -344,7 +344,7 @@ class CeilometerDriver(AlarmDriverBase):
entity.update(self._parse_changed_rule(
changed_rule[changed_type]))
# handle other changed alarm properties
elif changed_type in CeilProps.__dict__.values():
elif changed_type in vars(CeilProps).values():
entity[changed_type] = changed_info

return self._filter_and_cache_alarm(entity, old_alarm,


+ 1
- 1
vitrage/datasources/cinder/volume/driver.py View File

@@ -33,7 +33,7 @@ class CinderVolumeDriver(DriverBase):

@staticmethod
def extract_events(volumes):
return [volume.__dict__ for volume in volumes]
return [vars(volume) for volume in volumes]

def get_all(self, datasource_action):
return self.make_pickleable(


+ 1
- 1
vitrage/datasources/nova/instance/driver.py View File

@@ -102,7 +102,7 @@ class InstanceDriver(NovaDriverBase):

@staticmethod
def extract_events(instances):
events = [instance.__dict__ for instance in instances]
events = [vars(instance) for instance in instances]
for e in events:
if e['status'].lower() == 'deleted':
e[DSProps.EVENT_TYPE] = GraphAction.DELETE_ENTITY


+ 1
- 1
vitrage/datasources/nova/zone/driver.py View File

@@ -22,7 +22,7 @@ class ZoneDriver(NovaDriverBase):
def filter_internal_zone(zones):
zones_res = []
for zone in zones:
zone_dict = zone.__dict__
zone_dict = vars(zone)
if zone_dict['zoneName'] and zone_dict['zoneName'] != 'internal':
zones_res.append(zone_dict)
return zones_res


+ 1
- 1
vitrage/datasources/transformer_base.py View File

@@ -320,7 +320,7 @@ class TransformerBase(object):
:rtype: str
"""
if DSProps.EVENT_TYPE in entity_event and \
entity_event[DSProps.EVENT_TYPE] in GraphAction.__dict__.values():
entity_event[DSProps.EVENT_TYPE] in vars(GraphAction).values():
return entity_event[DSProps.EVENT_TYPE]

datasource_action = entity_event[DSProps.DATASOURCE_ACTION]


+ 2
- 2
vitrage/graph/driver/elements.py View File

@@ -83,7 +83,7 @@ class Vertex(PropertiesElement):
:type other: Vertex
:rtype: bool
"""
return self.__dict__ == other.__dict__ and \
return vars(self) == vars(other) and \
self.properties == other.properties

def copy(self):
@@ -152,7 +152,7 @@ class Edge(PropertiesElement):
:type other: Edge
:rtype: bool
"""
return self.__dict__ == other.__dict__ and \
return vars(self) == vars(other) and \
self.properties == other.properties

def other_vertex(self, v_id):


+ 1
- 1
vitrage/opts.py View File

@@ -86,7 +86,7 @@ def datasources_opts():
return [(datasource, module.OPTS) for datasource in datasources
for module in
[importutils.import_module(DATASOURCES_PATH + datasource)]
if 'OPTS' in module.__dict__]
if 'OPTS' in vars(module)]


def _get_datasources_folders(top=os.getcwd()):


+ 1
- 1
vitrage/tests/unit/datasources/aodh/aodh_transformer_base_test.py View File

@@ -65,7 +65,7 @@ class AodhTransformerBaseTest(base.BaseTest):

def _validate_action(self, alarm, wrapper):
if DSProps.EVENT_TYPE in alarm \
and alarm[DSProps.EVENT_TYPE] in GraphAction.__dict__.values():
and alarm[DSProps.EVENT_TYPE] in vars(GraphAction).values():
self.assertEqual(alarm[DSProps.EVENT_TYPE], wrapper.action)
return



+ 1
- 1
vitrage/tests/unit/datasources/ceilometer/ceilometer_transformer_base_test.py View File

@@ -69,7 +69,7 @@ class CeilometerTransformerBaseTest(base.BaseTest):

def _validate_action(self, alarm, wrapper):
if DSProps.EVENT_TYPE in alarm \
and alarm[DSProps.EVENT_TYPE] in GraphAction.__dict__.values():
and alarm[DSProps.EVENT_TYPE] in vars(GraphAction).values():
self.assertEqual(alarm[DSProps.EVENT_TYPE], wrapper.action)
return



Loading…
Cancel
Save