21241598 Juno upgrade may not correctly update neutron information
authorThanukrishnamurthy Madhusudhanan<thanukrishnamurthy.madhusudha@oracle.com>
Wed, 15 Jul 2015 10:23:59 -0700
changeset 4653 4fb953160e20
parent 4652 d0e37876680e
child 4654 94e90d50dc0e
21241598 Juno upgrade may not correctly update neutron information 21444880 When the evs information is empty neutron data model is not created in backend
components/openstack/neutron/files/evs/migrate/evs-neutron-migration.py
components/openstack/neutron/files/neutron-upgrade
--- a/components/openstack/neutron/files/evs/migrate/evs-neutron-migration.py	Wed Jul 15 09:34:52 2015 -0700
+++ b/components/openstack/neutron/files/evs/migrate/evs-neutron-migration.py	Wed Jul 15 10:23:59 2015 -0700
@@ -36,7 +36,7 @@
 
 from neutron import context as ctx
 from neutron.db import common_db_mixin, model_base
-from neutron.plugins.evs.migrate import havana_api 
+from neutron.plugins.evs.migrate import havana_api
 
 
 def create_db_network(nw, engine, ext_ro):
@@ -141,10 +141,6 @@
         evs_contr = rc.get_object(evsc.EVSController())
     except:
         raise SystemExit(_("Could not retrieve EVS info from EVS Controller"))
-    evsinfo = evs_contr.getEVSInfo()
-    if not evsinfo:
-        print "No data to migrate"
-        return
 
     config.readfp(open("/etc/neutron/neutron.conf"))
     if config.has_option("database", 'connection'):
@@ -161,6 +157,7 @@
     neutron_engine = sa.create_engine(SQL_CONNECTION)
     router_port_ids = {}
 
+    evsinfo = evs_contr.getEVSInfo()
     for e in evsinfo:
         ext_ro = False
         for p in e.props:
@@ -368,7 +365,8 @@
     for t in meta.tables.values():
         for fk in t.foreign_keys:
             if fk.column.table.name == "routers":
-                engine.execute(DropConstraint(fk.constraint))
+                if fk.constraint.name:
+                    engine.execute(DropConstraint(fk.constraint))
     for t in meta.tables.values():
         if t.name == "routers":
             t.drop(bind=conn)
@@ -378,7 +376,8 @@
     for t in meta.tables.values():
         for fk in t.foreign_keys:
             if fk.column.table.name == "floatingips":
-                engine.execute(DropConstraint(fk.constraint))
+                if fk.constraint.name:
+                    engine.execute(DropConstraint(fk.constraint))
     for t in meta.tables.values():
         if t.name == "floatingips":
             t.drop(bind=conn)
--- a/components/openstack/neutron/files/neutron-upgrade	Wed Jul 15 09:34:52 2015 -0700
+++ b/components/openstack/neutron/files/neutron-upgrade	Wed Jul 15 10:23:59 2015 -0700
@@ -44,7 +44,6 @@
     ('keystone_authtoken', 'admin_user'),
     ('keystone_authtoken', 'admin_password'),
     ('keystone_authtoken', 'signing_dir'),
-    ('database', 'connection'),
 ]
 
 
@@ -91,7 +90,16 @@
         sys.exit(smf_include.SMF_EXIT_OK)
 
     # look for any .new files
+    db_connection = None
     if glob.glob('/etc/neutron/*.new'):
+        # extract sql_connection from evs_plugin.ini
+        db_connection = 'sqlite:////var/lib/neutron/neutron.sqlite'
+        evs_ini = iniparse.RawConfigParser()
+        evs_ini.read('/etc/neutron/plugins/evs/evs_plugin.ini')
+        if evs_ini.has_section('DATABASE'):
+            if evs_ini.has_option('DATABASE', 'sql_connection'):
+                db_connection = evs_ini.get('DATABASE', 'sql_connection')
+
         # the versions are different, so perform an upgrade
         # modify the configuration files
 
@@ -113,7 +121,21 @@
     # In certain cases the database section does not exist and the
     # default database chosen is sqlite.
     if config.has_section('database'):
-        db_connection = config.get('database', 'connection')
+        if db_connection:
+            config.set('database', 'connection', db_connection)
+            with open('/etc/neutron/neutron.conf', 'wb+') as fh:
+                config.write(fh)
+            if 'sqlite' in db_connection:
+                print "WARNING: Neutron database is on sqlite"
+                print "which is not a supported backend for"
+                print "Solaris Openstack. Please make sure"
+                print "to migrate to MySQL after upgrade to Juno"
+        # Need this else part because this code path is exercised
+        # during fresh install of Juno, when the
+        # [database].connection is set to default mysql
+        else:
+            db_connection = config.get('database', 'connection')
+
         engine = sqlalchemy.create_engine(db_connection)
 
         # migrate EVS to Neutron db