Allow modules to be registered dynamically
Add a stevedore entrypoint (dragonflow.db.models). Modules containing models (e.g. the files in dragonflow/db/models) can now be registered dynamically (i.e. not hard-coded). The changes to setup.cfg show how this is done. Change-Id: I42c0b35e54693b9690771398a99c2d9a4d1c9ab0
This commit is contained in:
parent
3076ceb35c
commit
da6a6d1938
@ -9,14 +9,17 @@
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
from dragonflow.db.models import active_port # noqa
|
||||
from dragonflow.db.models import bgp # noqa
|
||||
from dragonflow.db.models import core # noqa
|
||||
from dragonflow.db.models import l2 # noqa
|
||||
from dragonflow.db.models import l3 # noqa
|
||||
from dragonflow.db.models import migration # noqa
|
||||
from dragonflow.db.models import qos # noqa
|
||||
from dragonflow.db.models import secgroups # noqa
|
||||
from dragonflow.db.models import service # noqa
|
||||
from dragonflow.db.models import sfc # noqa
|
||||
from dragonflow.db.models import trunk # noqa
|
||||
|
||||
import stevedore
|
||||
|
||||
|
||||
def load_all_extensions():
|
||||
"""Load all available modules with DF models"""
|
||||
manager = stevedore.ExtensionManager( # noqa F841
|
||||
'dragonflow.db.models',
|
||||
)
|
||||
# NOTE(oanson) In case Stevedore changes and we need to manually load
|
||||
# the extensions:
|
||||
# modules = [extension.plugin for extension in manager]
|
||||
|
||||
load_all_extensions()
|
||||
|
12
setup.cfg
12
setup.cfg
@ -110,3 +110,15 @@ dragonflow.controller.apps =
|
||||
sg = dragonflow.controller.apps.sg:SGApp
|
||||
trunk = dragonflow.controller.apps.trunk:TrunkApp
|
||||
tunneling = dragonflow.controller.apps.tunneling:TunnelingApp
|
||||
dragonflow.db.models =
|
||||
active_port = dragonflow.db.models.active_port
|
||||
bgp = dragonflow.db.models.bgp
|
||||
core = dragonflow.db.models.core
|
||||
l2 = dragonflow.db.models.l2
|
||||
l3 = dragonflow.db.models.l3
|
||||
migration = dragonflow.db.models.migration
|
||||
qos = dragonflow.db.models.qos
|
||||
secgroups = dragonflow.db.models.secgroups
|
||||
service = dragonflow.db.models.service
|
||||
sfc = dragonflow.db.models.sfc
|
||||
trunk = dragonflow.db.models.trunk
|
||||
|
Loading…
Reference in New Issue
Block a user