Merge "use 'true' and 'false' instead of magic num"

This commit is contained in:
Jenkins 2017-02-15 12:55:29 +00:00 committed by Gerrit Code Review
commit e59816494d
16 changed files with 41 additions and 41 deletions

View File

@ -30,12 +30,12 @@ LOG = log.getLogger(__name__)
class AlarmsController(RootRestController):
@pecan.expose('json')
def index(self, vitrage_id, all_tenants='0'):
def index(self, vitrage_id, all_tenants=False):
return self.post(vitrage_id, all_tenants)
@pecan.expose('json')
def post(self, vitrage_id, all_tenants='0'):
if all_tenants == '1':
def post(self, vitrage_id, all_tenants=False):
if all_tenants:
enforce("list alarms:all_tenants", pecan.request.headers,
pecan.request.enforcer, {})
else:
@ -52,7 +52,7 @@ class AlarmsController(RootRestController):
abort(404, str(e))
@staticmethod
def _get_alarms(vitrage_id=None, all_tenants=0):
def _get_alarms(vitrage_id=None, all_tenants=False):
alarms_json = pecan.request.client.call(pecan.request.context,
'get_alarms',
vitrage_id=vitrage_id,

View File

@ -30,12 +30,12 @@ LOG = log.getLogger(__name__)
class RCAController(RootRestController):
@pecan.expose('json')
def index(self, alarm_id, all_tenants='0'):
def index(self, alarm_id, all_tenants=False):
return self.get(alarm_id, all_tenants)
@pecan.expose('json')
def get(self, alarm_id, all_tenants='0'):
if all_tenants == '1':
def get(self, alarm_id, all_tenants=False):
if all_tenants:
enforce('get rca:all_tenants', pecan.request.headers,
pecan.request.enforcer, {})
else:

View File

@ -34,7 +34,7 @@ LOG = log.getLogger(__name__)
class TopologyController(RootRestController):
@pecan.expose('json')
def post(self, depth, graph_type, query, root, all_tenants=0):
def post(self, depth, graph_type, query, root, all_tenants=False):
if all_tenants:
enforce('get topology:all_tenants', pecan.request.headers,
pecan.request.enforcer, {})

View File

@ -39,7 +39,7 @@ class AlarmApis(EntityGraphApisBase):
is_admin_project = ctx.get(self.IS_ADMIN_PROJECT_PROPERTY, False)
if not vitrage_id or vitrage_id == 'all':
if all_tenants == "1":
if all_tenants:
alarms = self.entity_graph.get_vertices(
query_dict=ALARMS_ALL_QUERY)
else:

View File

@ -47,7 +47,7 @@ class RcaApis(EntityGraphApisBase):
direction=Direction.IN,
edge_query_dict=EDGE_QUERY)
if all_tenants == '1':
if all_tenants:
unified_graph = found_graph_in
unified_graph.union(found_graph_out)
else:

View File

@ -37,7 +37,7 @@ class TestApis(TestEntityGraphUnitBase):
ctx = {'tenant': 'project_1', 'is_admin': True}
# Action
alarms = apis.get_alarms(ctx, vitrage_id='all', all_tenants='0')
alarms = apis.get_alarms(ctx, vitrage_id='all', all_tenants=False)
alarms = json.loads(alarms)['alarms']
# Test assertions
@ -51,7 +51,7 @@ class TestApis(TestEntityGraphUnitBase):
ctx = {'tenant': 'project_2', 'is_admin': False}
# Action
alarms = apis.get_alarms(ctx, vitrage_id='all', all_tenants='0')
alarms = apis.get_alarms(ctx, vitrage_id='all', all_tenants=False)
alarms = json.loads(alarms)['alarms']
# Test assertions
@ -65,7 +65,7 @@ class TestApis(TestEntityGraphUnitBase):
ctx = {'tenant': 'project_1', 'is_admin': False}
# Action
alarms = apis.get_alarms(ctx, vitrage_id='all', all_tenants='1')
alarms = apis.get_alarms(ctx, vitrage_id='all', all_tenants=True)
alarms = json.loads(alarms)['alarms']
# Test assertions
@ -79,7 +79,7 @@ class TestApis(TestEntityGraphUnitBase):
ctx = {'tenant': 'project_1', 'is_admin': True}
# Action
graph_rca = apis.get_rca(ctx, root='alarm_on_host', all_tenants='0')
graph_rca = apis.get_rca(ctx, root='alarm_on_host', all_tenants=False)
graph_rca = json.loads(graph_rca)
# Test assertions
@ -95,7 +95,7 @@ class TestApis(TestEntityGraphUnitBase):
# Action
graph_rca = apis.get_rca(ctx,
root='alarm_on_instance_3',
all_tenants='0')
all_tenants=False)
graph_rca = json.loads(graph_rca)
# Test assertions
@ -109,7 +109,7 @@ class TestApis(TestEntityGraphUnitBase):
ctx = {'tenant': 'project_2', 'is_admin': False}
# Action
graph_rca = apis.get_rca(ctx, root='alarm_on_host', all_tenants='0')
graph_rca = apis.get_rca(ctx, root='alarm_on_host', all_tenants=False)
graph_rca = json.loads(graph_rca)
# Test assertions
@ -123,7 +123,7 @@ class TestApis(TestEntityGraphUnitBase):
ctx = {'tenant': 'project_1', 'is_admin': False}
# Action
graph_rca = apis.get_rca(ctx, root='alarm_on_host', all_tenants='1')
graph_rca = apis.get_rca(ctx, root='alarm_on_host', all_tenants=True)
graph_rca = json.loads(graph_rca)
# Test assertions
@ -143,7 +143,7 @@ class TestApis(TestEntityGraphUnitBase):
depth=10,
query=None,
root='RESOURCE:openstack.cluster:OpenStack Cluster',
all_tenants=0)
all_tenants=False)
graph_topology = json.loads(graph_topology)
# Test assertions
@ -165,7 +165,7 @@ class TestApis(TestEntityGraphUnitBase):
depth=10,
query=None,
root='RESOURCE:openstack.cluster:OpenStack Cluster',
all_tenants=0)
all_tenants=False)
graph_topology = json.loads(graph_topology)
# Test assertions
@ -187,7 +187,7 @@ class TestApis(TestEntityGraphUnitBase):
depth=10,
query=None,
root='RESOURCE:openstack.cluster:OpenStack Cluster',
all_tenants=1)
all_tenants=True)
graph_topology = json.loads(graph_topology)
# Test assertions

View File

@ -118,7 +118,7 @@ class BaseApiTest(base.BaseTestCase):
return volume
def _get_host(self):
topology = self.vitrage_client.topology.get(all_tenants=1)
topology = self.vitrage_client.topology.get(all_tenants=True)
host = filter(lambda item: item[VProps.TYPE] == NOVA_HOST_DATASOURCE,
topology['nodes'])
return host[0]

View File

@ -38,7 +38,7 @@ class TestAodhAlarm(BaseAlarmsTest):
self._create_ceilometer_alarm(self._find_instance_resource_id())
# Calculate expected results
api_graph = self.vitrage_client.topology.get(all_tenants=1)
api_graph = self.vitrage_client.topology.get(all_tenants=True)
graph = self._create_graph_from_graph_dictionary(api_graph)
entities = self._entities_validation_data(
host_entities=1,
@ -73,7 +73,7 @@ class TestAodhAlarm(BaseAlarmsTest):
self._create_ceilometer_alarm()
# Calculate expected results
api_graph = self.vitrage_client.topology.get(all_tenants=1)
api_graph = self.vitrage_client.topology.get(all_tenants=True)
graph = self._create_graph_from_graph_dictionary(api_graph)
entities = self._entities_validation_data(
host_entities=1,

View File

@ -37,7 +37,7 @@ class TestCinderVolume(BaseTopologyTest):
num_volumes=self.NUM_VOLUME)
# Calculate expected results
api_graph = self.vitrage_client.topology.get(all_tenants=1)
api_graph = self.vitrage_client.topology.get(all_tenants=True)
graph = self._create_graph_from_graph_dictionary(api_graph)
entities = self._entities_validation_data(
host_entities=1,

View File

@ -42,7 +42,7 @@ class TestHeatStack(BaseTopologyTest):
self._create_stacks(num_stacks=self.NUM_STACKS)
# Calculate expected results
api_graph = self.vitrage_client.topology.get(all_tenants=1)
api_graph = self.vitrage_client.topology.get(all_tenants=True)
graph = self._create_graph_from_graph_dictionary(api_graph)
entities = self._entities_validation_data(
host_entities=1,

View File

@ -43,7 +43,7 @@ class TestNeutron(BaseTopologyTest):
set_public_network=True)
# Calculate expected results
api_graph = self.vitrage_client.topology.get(all_tenants=1)
api_graph = self.vitrage_client.topology.get(all_tenants=True)
graph = self._create_graph_from_graph_dictionary(api_graph)
entities = self._entities_validation_data(
host_entities=1,

View File

@ -35,7 +35,7 @@ class TestNova(BaseTopologyTest):
self._create_entities(num_instances=self.NUM_INSTANCE)
# Calculate expected results
api_graph = self.vitrage_client.topology.get(all_tenants=1)
api_graph = self.vitrage_client.topology.get(all_tenants=True)
graph = self._create_graph_from_graph_dictionary(api_graph)
entities = self._entities_validation_data(
host_entities=1,

View File

@ -39,7 +39,7 @@ class TestStaticPhysical(BaseApiTest):
self._create_switches()
# Calculate expected results
api_graph = self.vitrage_client.topology.get(all_tenants=1)
api_graph = self.vitrage_client.topology.get(all_tenants=True)
graph = self._create_graph_from_graph_dictionary(api_graph)
entities = self._entities_validation_data(
host_entities=1,

View File

@ -128,7 +128,7 @@ class TestRca(BaseRcaTest):
self._create_alarm(
resource_id=self._get_hostname(),
alarm_name=RCA_ALARM_NAME)
topology = self.vitrage_client.topology.get(all_tenants=1)
topology = self.vitrage_client.topology.get(all_tenants=True)
self._validate_set_state(topology=topology['nodes'],
instances=instances)

View File

@ -36,7 +36,7 @@ class BaseTopologyTest(BaseApiTest):
api_graph = self.vitrage_client.topology.get(
limit=4,
root='RESOURCE:openstack.cluster:OpenStack Cluster',
all_tenants=1)
all_tenants=True)
graph = self._create_graph_from_graph_dictionary(api_graph)
entities = self._entities_validation_data()
num_default_entities = self.num_default_entities + \

View File

@ -67,7 +67,7 @@ class TestTopology(BaseTopologyTest):
num_volumes=self.NUM_VOLUME)
# Calculate expected results
api_graph = self.vitrage_client.topology.get(all_tenants=1)
api_graph = self.vitrage_client.topology.get(all_tenants=True)
graph = self._create_graph_from_graph_dictionary(api_graph)
entities = self._entities_validation_data(
host_entities=1,
@ -109,7 +109,7 @@ class TestTopology(BaseTopologyTest):
# Calculate expected results
api_graph = self.vitrage_client.topology.get(
query=self._graph_query(),
all_tenants=1)
all_tenants=True)
graph = self._create_graph_from_graph_dictionary(api_graph)
entities = self._entities_validation_data(
host_entities=1,
@ -144,7 +144,7 @@ class TestTopology(BaseTopologyTest):
# Calculate expected results
api_graph = self.vitrage_client.topology.get(
graph_type='tree', query=NOVA_QUERY, all_tenants=1)
graph_type='tree', query=NOVA_QUERY, all_tenants=True)
graph = self._create_graph_from_tree_dictionary(api_graph)
entities = self._entities_validation_data(
host_entities=1,
@ -179,7 +179,7 @@ class TestTopology(BaseTopologyTest):
# Calculate expected results
api_graph = self.vitrage_client.topology.get(
graph_type='tree', query=self._tree_query(), all_tenants=1)
graph_type='tree', query=self._tree_query(), all_tenants=True)
graph = self._create_graph_from_tree_dictionary(api_graph)
entities = self._entities_validation_data(
host_entities=1, host_edges=1)
@ -209,7 +209,7 @@ class TestTopology(BaseTopologyTest):
# Calculate expected results
api_graph = self.vitrage_client.topology.get(
limit=2, graph_type='tree', query=NOVA_QUERY, all_tenants=1)
limit=2, graph_type='tree', query=NOVA_QUERY, all_tenants=True)
graph = self._create_graph_from_tree_dictionary(api_graph)
entities = self._entities_validation_data(
host_entities=1, host_edges=1)
@ -239,7 +239,7 @@ class TestTopology(BaseTopologyTest):
# Calculate expected results
api_graph = self.vitrage_client.topology.get(
limit=3, graph_type='tree', query=NOVA_QUERY, all_tenants=1)
limit=3, graph_type='tree', query=NOVA_QUERY, all_tenants=True)
graph = self._create_graph_from_tree_dictionary(api_graph)
entities = self._entities_validation_data(
host_entities=1,
@ -277,7 +277,7 @@ class TestTopology(BaseTopologyTest):
api_graph = self.vitrage_client.topology.get(
limit=2,
root='RESOURCE:openstack.cluster:OpenStack Cluster',
all_tenants=1)
all_tenants=True)
graph = self._create_graph_from_graph_dictionary(api_graph)
entities = self._entities_validation_data(
host_entities=1, host_edges=1)
@ -310,7 +310,7 @@ class TestTopology(BaseTopologyTest):
api_graph = self.vitrage_client.topology.get(
limit=3,
root='RESOURCE:openstack.cluster:OpenStack Cluster',
all_tenants=1)
all_tenants=True)
graph = self._create_graph_from_graph_dictionary(api_graph)
entities = self._entities_validation_data(
host_entities=1,
@ -348,7 +348,7 @@ class TestTopology(BaseTopologyTest):
self.vitrage_client.topology.get(
limit=2,
root='RESOURCE:openstack.cluster:OpenStack Cluster',
all_tenants=1)
all_tenants=True)
except ClientException as e:
self.assertEqual(403, e.code)
self.assertEqual(
@ -372,7 +372,7 @@ class TestTopology(BaseTopologyTest):
# Calculate expected results
api_graph = self.vitrage_client.topology.get(
query=self._graph_no_match_query(), all_tenants=1)
query=self._graph_no_match_query(), all_tenants=True)
# Test Assertions
self.assertEqual(
@ -403,7 +403,7 @@ class TestTopology(BaseTopologyTest):
api_graph = self.vitrage_client.topology.get(
graph_type='tree',
query=self._tree_no_match_query(),
all_tenants=1)
all_tenants=True)
# Test Assertions
self.assertEqual({}, api_graph)