aboutsummaryrefslogtreecommitdiffstats
path: root/app/discover/fetchers/db
diff options
context:
space:
mode:
Diffstat (limited to 'app/discover/fetchers/db')
-rw-r--r--app/discover/fetchers/db/db_access.py27
1 files changed, 18 insertions, 9 deletions
diff --git a/app/discover/fetchers/db/db_access.py b/app/discover/fetchers/db/db_access.py
index 0174c4b..47f4f9e 100644
--- a/app/discover/fetchers/db/db_access.py
+++ b/app/discover/fetchers/db/db_access.py
@@ -11,6 +11,7 @@ import mysql.connector
from discover.configuration import Configuration
from discover.fetcher import Fetcher
+from discover.scan_error import ScanError
from utils.string_utils import jsonify
@@ -27,15 +28,7 @@ class DbAccess(Fetcher):
self.config = Configuration()
self.conf = self.config.get("mysql")
self.connect_to_db()
- cursor = DbAccess.conn.cursor(dictionary=True)
- try:
- # check if DB schema 'neutron' exists
- cursor.execute("SELECT COUNT(*) FROM neutron.agents")
- for row in cursor:
- pass
- self.neutron_db = "neutron"
- except (AttributeError, mysql.connector.errors.ProgrammingError):
- self.neutron_db = "ml2_neutron"
+ self.neutron_db = self.get_neutron_db_name()
def db_connect(self, _host, _port, _user, _pwd, _database):
if DbAccess.conn:
@@ -54,6 +47,22 @@ class DbAccess(Fetcher):
return
DbAccess.query_count_per_con = 0
+ @staticmethod
+ def get_neutron_db_name():
+ # check if DB schema 'neutron' exists
+ cursor = DbAccess.conn.cursor(dictionary=True)
+ cursor.execute('SHOW DATABASES')
+ matches = []
+ for row in cursor:
+ if 'neutron' in row.get('Database', ''):
+ matches.append(row)
+ if not matches:
+ raise ScanError('Unable to find Neutron schema in OpenStack DB')
+ if len(matches) > 1:
+ raise ScanError('Found multiple possible names for Neutron schema '
+ 'in OpenStack DB')
+ return matches[0]
+
def connect_to_db(self, force=False):
if DbAccess.conn:
if not force:
rd.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
# This template configures each role to use a pair of bonded nics (nic2 and
# nic3) and configures an IP address on each relevant isolated network
# for each role, with IPv6 on the External network. This template assumes
# use of network-isolation-v6.yaml.
#
# FIXME: if/when we add functionality to heatclient to include heat
# environment files we should think about using it here to automatically
# include network-isolation-v6.yaml.
resource_registry:
  OS::TripleO::BlockStorage::Net::SoftwareConfig: ../network/config/bond-with-vlans/cinder-storage.yaml
  OS::TripleO::Compute::Net::SoftwareConfig: ../network/config/bond-with-vlans/compute.yaml
  OS::TripleO::Controller::Net::SoftwareConfig: ../network/config/bond-with-vlans/controller-v6.yaml
  OS::TripleO::ObjectStorage::Net::SoftwareConfig: ../network/config/bond-with-vlans/swift-storage.yaml
  OS::TripleO::CephStorage::Net::SoftwareConfig: ../network/config/bond-with-vlans/ceph-storage.yaml