diff options
author | jose.lausuch <jose.lausuch@ericsson.com> | 2017-02-06 22:10:00 +0100 |
---|---|---|
committer | jose.lausuch <jose.lausuch@ericsson.com> | 2017-02-09 14:09:03 +0100 |
commit | 2b191ef958106da17594ee8a4143a392984822b0 (patch) | |
tree | 80c3fe103be7c702b807cfd779d6e60074e759d1 /opnfv/deployment/factory.py | |
parent | 10eef5153d7d45889f36b330bda20478b7bad8a2 (diff) |
[deployment handler] Refactor the old installer_handler
This is a util library to interact with the
deployment regardless of the installer.
Objects:
- Deployment
- Node
- DeploymentHandler
- ApexAdapter
- FuelAdapter
- Factory
The installer adapters implement some of the
abstract functions of DeploymentHandler class
that can't be generalized.
Printout of example.py:
http://pastebin.com/raw/SF3A1fee
More info: JIRA: RELENG-149
Change-Id: I5c9e94459d5be0bfad6ffac29908a8cfc7ba919c
Signed-off-by: jose.lausuch <jose.lausuch@ericsson.com>
Diffstat (limited to 'opnfv/deployment/factory.py')
-rw-r--r-- | opnfv/deployment/factory.py | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/opnfv/deployment/factory.py b/opnfv/deployment/factory.py new file mode 100644 index 0000000..e48a751 --- /dev/null +++ b/opnfv/deployment/factory.py @@ -0,0 +1,44 @@ +############################################################################## +# Copyright (c) 2017 Ericsson AB and others. +# Author: Jose Lausuch (jose.lausuch@ericsson.com) +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + +from opnfv.deployment.apex import adapter as apex_adapter +from opnfv.deployment.fuel import adapter as fuel_adapter +from opnfv.utils import opnfv_logger as logger + +logger = logger.Logger(__name__).getLogger() + + +class Factory(object): + + INSTALLERS = ["fuel", "apex", "compass", "joid", "daisy"] + + def __init__(self): + pass + + @staticmethod + def get_handler(installer, + installer_ip, + installer_user, + installer_pwd=None, + pkey_file=None): + + if installer not in Factory.INSTALLERS: + raise Exception("This is not an OPNFV installer.") + + if installer.lower() == "apex": + return apex_adapter.ApexAdapter(installer_ip=installer_ip, + installer_user=installer_user, + pkey_file=pkey_file) + elif installer.lower() == "fuel": + return fuel_adapter.FuelAdapter(installer_ip=installer_ip, + installer_user=installer_user, + installer_pwd=installer_pwd) + else: + raise Exception("Installer adapter is not implemented.") |