Revert "External OpenStack action mapping file support"

Mistral API in WSGI is currently broken, see:
https://bugs.launchpad.net/mistral/+bug/1663368

This reverts commit a5fd5d452a.

Change-Id: I890a4be46b350d1adc53cb9ae15e2a7fdcad3e3f
Related-Bug: #1663368
This commit is contained in:
Emilien Macchi 2017-02-09 20:14:58 +00:00
parent a5fd5d452a
commit cc87dd7e2b
4 changed files with 4 additions and 72 deletions

View File

@ -23,19 +23,12 @@ from mistral.actions import action_generator
from mistral.utils import inspect_utils as i_u
from mistral import version
os_actions_mapping_path = cfg.StrOpt(
'openstack_actions_mapping_path',
short='m',
metavar='MAPPING_PATH',
default='actions/openstack/mapping.json',
help='Path to openstack action mapping json file.'
'It could be relative to mistral package '
'directory or absolute.'
)
os_actions_mapping_path = cfg.StrOpt('openstack_actions_mapping_path',
default='actions/openstack/mapping.json')
CONF = cfg.CONF
CONF.register_cli_opt(os_actions_mapping_path)
CONF.register_opt(os_actions_mapping_path)
LOG = logging.getLogger(__name__)
@ -91,7 +84,7 @@ class OpenStackActionGenerator(action_generator.ActionGenerator):
@classmethod
def create_actions(cls):
mapping = get_mapping()
method_dict = mapping.get(cls.action_namespace, {})
method_dict = mapping[cls.action_namespace]
action_classes = []

View File

@ -1,6 +0,0 @@
{
"_comment": "Mapping OpenStack action namespaces to all its actions. Each action name is mapped to python-client method name in this namespace.",
"nova": {
"servers_get": "servers.get"
}
}

View File

@ -10,21 +10,11 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import contextlib
import os
from oslo_config import cfg
from mistral.actions import generator_factory
from mistral.actions.openstack import actions
from mistral.tests.unit import base
ABSOLUTE_TEST_MAPPING_PATH = os.path.realpath(
os.path.join(os.path.dirname(__file__),
"../../../resources/openstack/test_mapping.json")
)
RELATIVE_TEST_MAPPING_PATH = "tests/resources/openstack/test_mapping.json"
MODULE_MAPPING = {
'nova': ['nova.servers_get', actions.NovaAction],
@ -54,9 +44,6 @@ MODULE_MAPPING = {
EXTRA_MODULES = ['neutron', 'swift', 'zaqar', 'tacker']
CONF = cfg.CONF
class GeneratorTest(base.BaseTest):
def test_generator(self):
for generator_cls in generator_factory.all_generators():
@ -78,38 +65,3 @@ class GeneratorTest(base.BaseTest):
self.assertTrue(issubclass(action['class'], action_cls))
self.assertEqual(method_name, action['class'].client_method_name)
def test_missing_module_from_mapping(self):
with _patch_openstack_action_mapping_path(RELATIVE_TEST_MAPPING_PATH):
for generator_cls in generator_factory.all_generators():
action_classes = generator_cls.create_actions()
action_names = [action['name'] for action in action_classes]
cls = MODULE_MAPPING.get(generator_cls.action_namespace)[1]
if cls == actions.NovaAction:
self.assertEqual(['nova.servers_get'], action_names)
else:
self.assertEqual([], action_names)
def test_absolute_mapping_path(self):
with _patch_openstack_action_mapping_path(ABSOLUTE_TEST_MAPPING_PATH):
self.assertTrue(os.path.isabs(ABSOLUTE_TEST_MAPPING_PATH),
"Mapping path is relative: %s" %
ABSOLUTE_TEST_MAPPING_PATH)
for generator_cls in generator_factory.all_generators():
action_classes = generator_cls.create_actions()
action_names = [action['name'] for action in action_classes]
cls = MODULE_MAPPING.get(generator_cls.action_namespace)[1]
if cls == actions.NovaAction:
self.assertEqual(['nova.servers_get'], action_names)
else:
self.assertEqual([], action_names)
@contextlib.contextmanager
def _patch_openstack_action_mapping_path(path):
original_path = CONF.openstack_actions_mapping_path
CONF.set_default("openstack_actions_mapping_path", path)
yield
CONF.set_default("openstack_actions_mapping_path", original_path)

View File

@ -1,7 +0,0 @@
---
features:
- Openstack action mapping file could be specified at sync_db.sh script.
For more details see 'sync_db.sh --help'.
Additionally it is not required from now to list all of the modules
in mapping file.