From a78db48e89ea73c3be849c5d5176cebeaf9fbcbf Mon Sep 17 00:00:00 2001 From: Tung Doan Date: Wed, 9 May 2018 07:39:35 -0700 Subject: [PATCH] Add .gitreview file, zuul jobs, and refactoring code Change-Id: I005b7f84f63af0bde23b224e792b1f39f6ddb065 --- .coveragerc | 7 + .gitignore | 34 + .gitreview | 4 + .testr.conf | 4 + apmec/alarm_receiver.py | 7 +- apmec/catalogs/tosca/utils.py | 20 +- apmec/cmd/eventlet/apmec_server.py | 3 +- apmec/common/clients.py | 2 +- apmec/db/meo/meo_db_plugin.py | 18 +- .../versions/12a57080b278_alter_devices.py | 2 +- .../e8918cda6433_add_attributes_to_vnffg.py | 2 +- .../mem/infra_drivers/openstack/openstack.py | 4 +- .../openstack/translate_template.py | 10 +- .../monitor_drivers/ceilometer/ceilometer.py | 5 +- apmec/mem/plugin.py | 17 +- .../policy_actions/autoscaling/autoscaling.py | 8 +- apmec/mem/policy_actions/log/log.py | 8 +- apmec/mem/policy_actions/respawn/respawn.py | 8 +- apmec/mem/vim_client.py | 2 +- apmec/meo/drivers/vim/openstack_driver.py | 23 +- apmec/meo/meo_plugin.py | 57 +- .../vim_monitor/vim_monitor_utils.py | 9 +- .../vim_monitor/workflow_generator.py | 5 +- apmec/nfv/__init__.py | 0 apmec/nfv/tacker_client.py | 104 -- apmec/tests/constants.py | 4 +- apmec/tests/etc/samples/install_vnfc.sh | 2 - .../samples/sample-tosca-alarm-respawn.yaml | 57 - .../etc/samples/sample-tosca-alarm-scale.yaml | 82 - .../etc/samples/sample-tosca-mea-values.yaml | 10 - .../sample-tosca-mead-block-storage.yaml | 59 - .../etc/samples/sample-tosca-mead-flavor.yaml | 68 - .../etc/samples/sample-tosca-mead-image.yaml | 71 - .../sample-tosca-mead-large-template.yaml | 137 -- .../samples/sample-tosca-mead-monitor.yaml | 52 - ...ample-tosca-mead-multi-vdu-monitoring.yaml | 175 -- .../samples/sample-tosca-mead-multi-vdu.yaml | 152 -- .../etc/samples/sample-tosca-mead-param.yaml | 101 -- .../samples/sample-tosca-mead-static-ip.yaml | 72 - .../tests/etc/samples/sample-tosca-mead.yaml | 82 - .../etc/samples/sample-tosca-scale-all.yaml | 50 - ...sample_tosca_assign_floatingip_to_vdu.yaml | 44 - .../tests/etc/samples/sample_tosca_meac.yaml | 42 - apmec/tests/etc/samples/test-ns-nsd.yaml | 37 - apmec/tests/etc/samples/test-ns-vnfd1.yaml | 98 -- apmec/tests/etc/samples/test-ns-vnfd2.yaml | 68 - apmec/tests/etc/samples/test-nsd-vnfd1.yaml | 98 -- apmec/tests/etc/samples/test-nsd-vnfd2.yaml | 68 - apmec/tests/etc/samples/test-nsd.yaml | 37 - apmec/tests/functional/clients.py | 2 +- apmec/tests/functional/mem/__init__.py | 0 apmec/tests/functional/mem/test_mea.py | 106 -- .../functional/mem/test_mea_monitoring.py | 67 - apmec/tests/functional/mem/test_mem_param.py | 129 -- apmec/tests/functional/mem/test_tosca_mea.py | 282 ---- .../functional/mem/test_tosca_mea_alarm.py | 151 -- .../mem/test_tosca_mea_block_storage.py | 134 -- .../mem/test_tosca_mea_floatingip.py | 98 -- .../mem/test_tosca_mea_multiple_vdu.py | 90 - .../functional/mem/test_tosca_mea_scale.py | 107 -- apmec/tests/functional/mem/test_tosca_meac.py | 115 -- apmec/tests/functional/mem/test_tosca_mead.py | 65 - apmec/tests/functional/meo/__init__.py | 0 apmec/tests/functional/meo/test_meo.py | 178 -- apmec/tests/functional/meo/test_vim.py | 191 --- apmec/tests/unit/_test_rootwrap_exec.py | 82 - apmec/tests/unit/base.py | 33 - apmec/tests/unit/database_stubs.py | 184 --- apmec/tests/unit/db/__init__.py | 0 apmec/tests/unit/db/base.py | 51 - apmec/tests/unit/db/utils.py | 202 --- apmec/tests/unit/extension_stubs.py | 77 - apmec/tests/unit/extensions/__init__.py | 0 .../unit/extensions/extendedattribute.py | 54 - .../unit/extensions/extensionattribute.py | 102 -- apmec/tests/unit/extensions/foxinsocks.py | 109 -- apmec/tests/unit/extensions/v2attributes.py | 48 - apmec/tests/unit/mem/__init__.py | 0 .../tests/unit/mem/infra_drivers/__init__.py | 0 .../mem/infra_drivers/openstack/__init__.py | 0 .../openstack/data/config_data.yaml | 12 - .../data/hot_alarm_scale_custom.yaml | 26 - .../openstack/data/hot_flavor.yaml | 32 - .../data/hot_flavor_and_capabilities.yaml | 26 - .../openstack/data/hot_flavor_defaults.yaml | 32 - .../openstack/data/hot_flavor_no_units.yaml | 33 - .../data/hot_image_after_processed_image.yaml | 16 - .../hot_image_before_processed_image.yaml | 9 - .../openstack/data/hot_openwrt.yaml | 26 - .../openstack/data/hot_openwrt_ipparams.yaml | 41 - .../openstack/data/hot_openwrt_params.yaml | 35 - .../openstack/data/hot_scale_custom.yaml | 25 - .../openstack/data/hot_scale_main.yaml | 30 - .../data/hot_tosca_alarm_metadata.yaml | 41 - .../data/hot_tosca_alarm_respawn.yaml | 42 - .../openstack/data/hot_tosca_alarm_scale.yaml | 53 - .../data/hot_tosca_allowed_address_pairs.yaml | 88 - .../data/hot_tosca_flavor_all_numa_count.yaml | 22 - .../data/hot_tosca_flavor_all_numa_nodes.yaml | 22 - .../hot_tosca_flavor_cpu_allocations.yaml | 22 - .../data/hot_tosca_flavor_huge_pages.yaml | 22 - .../data/hot_tosca_flavor_numa_nodes.yaml | 22 - .../hot_tosca_flavor_numa_nodes_count.yaml | 22 - .../data/hot_tosca_generic_vnfd_params.yaml | 45 - .../openstack/data/hot_tosca_image.yaml | 34 - .../openstack/data/hot_tosca_mac_ip.yaml | 37 - .../openstack/data/hot_tosca_mgmt_sriov.yaml | 28 - .../data/hot_tosca_monitoring_multi_vdu.yaml | 43 - .../openstack/data/hot_tosca_openwrt.yaml | 25 - .../data/hot_tosca_openwrt_kilo.yaml | 25 - .../data/hot_tosca_openwrt_userdata.yaml | 29 - .../data/hot_tosca_security_groups.yaml | 38 - .../openstack/data/hot_tosca_sriov.yaml | 28 - .../openstack/data/hot_tosca_vnfc.yaml | 36 - .../openstack/data/hot_tosca_vnic_normal.yaml | 28 - .../test_tosca_allowed_address_pairs.yaml | 105 -- .../openstack/data/test_tosca_flavor.yaml | 44 - .../test_tosca_flavor_and_capabilities.yaml | 44 - .../data/test_tosca_flavor_defaults.yaml | 41 - .../data/test_tosca_flavor_no_units.yaml | 43 - .../openstack/data/test_tosca_image.yaml | 42 - .../openstack/data/test_tosca_mac_ip.yaml | 45 - .../openstack/data/test_tosca_meac.yaml | 39 - .../test_tosca_mead_alarm_multi_actions.yaml | 57 - .../data/test_tosca_mead_alarm_respawn.yaml | 57 - .../data/test_tosca_mead_alarm_scale.yaml | 67 - .../openstack/data/test_tosca_openwrt.yaml | 44 - .../data/test_tosca_openwrt_userdata.yaml | 49 - .../data/test_tosca_security_groups.yaml | 46 - .../openstack/data/tosca_alarm_metadata.yaml | 60 - .../openstack/data/tosca_alarm_respawn.yaml | 58 - .../openstack/data/tosca_alarm_scale.yaml | 78 - .../openstack/data/tosca_block_storage.yaml | 57 - .../data/tosca_flavor_all_numa_count.yaml | 36 - .../data/tosca_flavor_all_numa_nodes.yaml | 44 - .../data/tosca_flavor_cpu_allocations.yaml | 34 - .../data/tosca_flavor_huge_pages.yaml | 29 - .../data/tosca_flavor_numa_nodes.yaml | 37 - .../data/tosca_flavor_numa_nodes_count.yaml | 38 - .../data/tosca_generic_mead_params.yaml | 86 - .../openstack/data/tosca_mgmt_sriov.yaml | 57 - .../data/tosca_monitoring_multi_vdu.yaml | 74 - .../openstack/data/tosca_nsd_template.yaml | 38 - .../openstack/data/tosca_scale.yaml | 45 - .../openstack/data/tosca_sriov.yaml | 59 - .../openstack/data/tosca_vnic_port.yaml | 58 - .../openstack/data/update_config_data.yaml | 11 - .../infra_drivers/openstack/test_openstack.py | 463 ------ .../openstack/test_openstack_driver.py | 41 - .../unit/mem/monitor_drivers/__init__.py | 0 .../mem/monitor_drivers/http_ping/__init__.py | 0 .../http_ping/test_http_ping.py | 56 - .../unit/mem/monitor_drivers/ping/__init__.py | 0 .../mem/monitor_drivers/ping/test_ping.py | 61 - apmec/tests/unit/mem/test_monitor.py | 130 -- apmec/tests/unit/mem/test_plugin.py | 474 ------ apmec/tests/unit/mem/test_vim_client.py | 39 - apmec/tests/unit/mem/tosca/__init__.py | 0 apmec/tests/unit/mem/tosca/test_utils.py | 268 --- apmec/tests/unit/meo/__init__.py | 0 apmec/tests/unit/meo/drivers/__init__.py | 0 apmec/tests/unit/meo/drivers/vim/__init__.py | 0 .../meo/drivers/vim/test_openstack_driver.py | 257 --- .../tests/unit/meo/drivers/vnffg/__init__.py | 0 .../meo/drivers/vnffg/sfc_drivers/__init__.py | 0 .../sfc_drivers/networking-sfc/__init__.py | 0 .../sfc_drivers/networking-sfc/test_n_sfc.py | 241 --- .../unit/meo/drivers/workflow/__init__.py | 0 .../workflow/test_workflow_generator.py | 172 -- apmec/tests/unit/meo/test_nfvo_plugin.py | 355 ---- apmec/tests/unit/test_alarm_receiver.py | 60 - apmec/tests/unit/test_api_api_common.py | 94 -- apmec/tests/unit/test_api_v2.py | 1449 ----------------- apmec/tests/unit/test_api_v2_extension.py | 114 -- apmec/tests/unit/test_api_v2_resource.py | 318 ---- apmec/tests/unit/test_attributes.py | 801 --------- apmec/tests/unit/test_auth.py | 100 -- apmec/tests/unit/test_common_log.py | 80 - .../tests/unit/test_common_services_plugin.py | 160 -- apmec/tests/unit/test_common_utils.py | 38 - apmec/tests/unit/test_config.py | 47 - apmec/tests/unit/test_db_migration.py | 157 -- apmec/tests/unit/test_db_purge_delete.py | 81 - .../unit/test_extension_extended_attribute.py | 117 -- apmec/tests/unit/test_extensions.py | 546 ------- apmec/tests/unit/test_policy.py | 557 ------- apmec/tests/unit/test_post_mortem_debug.py | 99 -- apmec/tests/unit/test_tacker_context.py | 141 -- .../test_tosca_templates_under_samples.py | 91 -- apmec/tests/unit/test_wsgi.py | 752 --------- apmec/tests/unit/testlib_api.py | 82 - devstack/lib/apmec | 26 +- devstack/plugin.sh | 8 +- doc/source/api/apmec._i18n.rst | 7 + doc/source/api/apmec.agent.linux.utils.rst | 7 + doc/source/api/apmec.alarm_receiver.rst | 7 + doc/source/api/apmec.api.api_common.rst | 7 + doc/source/api/apmec.api.extensions.rst | 7 + doc/source/api/apmec.api.v1.attributes.rst | 7 + doc/source/api/apmec.api.v1.base.rst | 7 + doc/source/api/apmec.api.v1.resource.rst | 7 + .../api/apmec.api.v1.resource_helper.rst | 7 + doc/source/api/apmec.api.v1.router.rst | 7 + doc/source/api/apmec.api.versions.rst | 7 + doc/source/api/apmec.api.views.versions.rst | 7 + doc/source/api/apmec.auth.rst | 7 + doc/source/api/apmec.catalogs.tosca.utils.rst | 7 + .../api/apmec.cmd.eventlet.apmec_server.rst | 7 + .../api/apmec.cmd.eventlet.conductor.rst | 7 + doc/source/api/apmec.common.clients.rst | 7 + doc/source/api/apmec.common.cmd_executer.rst | 7 + doc/source/api/apmec.common.config.rst | 7 + doc/source/api/apmec.common.constants.rst | 7 + .../api/apmec.common.driver_manager.rst | 7 + .../api/apmec.common.eventlet_utils.rst | 7 + doc/source/api/apmec.common.exceptions.rst | 7 + doc/source/api/apmec.common.log.rst | 7 + doc/source/api/apmec.common.rpc.rst | 7 + doc/source/api/apmec.common.test_lib.rst | 7 + doc/source/api/apmec.common.topics.rst | 7 + doc/source/api/apmec.common.utils.rst | 7 + .../api/apmec.conductor.conductor_server.rst | 7 + ...conductor.conductorrpc.vim_monitor_rpc.rst | 7 + doc/source/api/apmec.context.rst | 7 + doc/source/api/apmec.db.api.rst | 7 + ....db.common_services.common_services_db.rst | 7 + ...mon_services.common_services_db_plugin.rst | 7 + doc/source/api/apmec.db.db_base.rst | 7 + doc/source/api/apmec.db.mem.mem_db.rst | 7 + doc/source/api/apmec.db.meo.meo_db.rst | 7 + doc/source/api/apmec.db.meo.meo_db_plugin.rst | 7 + doc/source/api/apmec.db.meo.mes_db.rst | 7 + doc/source/api/apmec.db.migration.cli.rst | 7 + .../api/apmec.db.migration.models.head.rst | 7 + .../api/apmec.db.migration.purge_tables.rst | 7 + doc/source/api/apmec.db.model_base.rst | 7 + doc/source/api/apmec.db.models_v1.rst | 7 + doc/source/api/apmec.db.sqlalchemyutils.rst | 7 + doc/source/api/apmec.db.types.rst | 7 + .../api/apmec.extensions.common_services.rst | 7 + doc/source/api/apmec.extensions.mem.rst | 7 + doc/source/api/apmec.extensions.meo.rst | 7 + ...ec.extensions.meo_plugins.edge_service.rst | 7 + doc/source/api/apmec.hacking.checks.rst | 7 + .../api/apmec.keymgr.barbican_key_manager.rst | 7 + doc/source/api/apmec.keymgr.exception.rst | 7 + doc/source/api/apmec.keymgr.key_manager.rst | 7 + doc/source/api/apmec.manager.rst | 7 + ...pmec.mem.infra_drivers.abstract_driver.rst | 7 + .../api/apmec.mem.infra_drivers.noop.rst | 7 + ...em.infra_drivers.openstack.heat_client.rst | 7 + ....mem.infra_drivers.openstack.openstack.rst | 7 + ...a_drivers.openstack.translate_template.rst | 7 + .../apmec.mem.infra_drivers.scale_driver.rst | 7 + doc/source/api/apmec.mem.keystone.rst | 7 + ...apmec.mem.mgmt_drivers.abstract_driver.rst | 7 + .../api/apmec.mem.mgmt_drivers.constants.rst | 7 + .../api/apmec.mem.mgmt_drivers.noop.rst | 7 + ...apmec.mem.mgmt_drivers.openwrt.openwrt.rst | 7 + doc/source/api/apmec.mem.monitor.rst | 7 + ...ec.mem.monitor_drivers.abstract_driver.rst | 7 + ....monitor_drivers.ceilometer.ceilometer.rst | 7 + ...em.monitor_drivers.http_ping.http_ping.rst | 7 + .../apmec.mem.monitor_drivers.ping.ping.rst | 7 + .../api/apmec.mem.monitor_drivers.token.rst | 7 + doc/source/api/apmec.mem.plugin.rst | 7 + ...mec.mem.policy_actions.abstract_action.rst | 7 + ...policy_actions.autoscaling.autoscaling.rst | 7 + .../api/apmec.mem.policy_actions.log.log.rst | 7 + ...mec.mem.policy_actions.respawn.respawn.rst | 7 + doc/source/api/apmec.mem.vim_client.rst | 7 + ...ec.meo.drivers.vim.abstract_vim_driver.rst | 7 + ...apmec.meo.drivers.vim.openstack_driver.rst | 7 + ...eo.drivers.workflow.workflow_generator.rst | 7 + doc/source/api/apmec.meo.meo_plugin.rst | 7 + ...orkflows.vim_monitor.vim_monitor_utils.rst | 7 + ....workflows.vim_monitor.vim_ping_action.rst | 7 + ...rkflows.vim_monitor.workflow_generator.rst | 7 + .../apmec.mistral.actionrpc.kill_action.rst | 7 + .../api/apmec.mistral.mistral_client.rst | 7 + .../api/apmec.mistral.workflow_generator.rst | 7 + .../api/apmec.plugins.common.constants.rst | 7 + doc/source/api/apmec.plugins.common.utils.rst | 7 + ...common_services.common_services_plugin.rst | 7 + doc/source/api/apmec.policy.rst | 7 + doc/source/api/apmec.service.rst | 7 + .../api/apmec.services.service_base.rst | 7 + doc/source/api/apmec.version.rst | 7 + doc/source/api/apmec.wsgi.rst | 7 + doc/source/api/autoindex.rst | 99 ++ doc/source/user/mesd_usage_guide.rst | 256 --- requirements.txt | 6 +- test-requirements.txt | 3 +- tools/ostestr_compat_shim.sh | 8 - tox.ini | 15 +- 295 files changed, 950 insertions(+), 15987 deletions(-) create mode 100644 .coveragerc create mode 100644 .gitignore create mode 100644 .gitreview create mode 100644 .testr.conf delete mode 100644 apmec/nfv/__init__.py delete mode 100644 apmec/nfv/tacker_client.py delete mode 100644 apmec/tests/etc/samples/install_vnfc.sh delete mode 100644 apmec/tests/etc/samples/sample-tosca-alarm-respawn.yaml delete mode 100644 apmec/tests/etc/samples/sample-tosca-alarm-scale.yaml delete mode 100644 apmec/tests/etc/samples/sample-tosca-mea-values.yaml delete mode 100644 apmec/tests/etc/samples/sample-tosca-mead-block-storage.yaml delete mode 100644 apmec/tests/etc/samples/sample-tosca-mead-flavor.yaml delete mode 100644 apmec/tests/etc/samples/sample-tosca-mead-image.yaml delete mode 100644 apmec/tests/etc/samples/sample-tosca-mead-large-template.yaml delete mode 100644 apmec/tests/etc/samples/sample-tosca-mead-monitor.yaml delete mode 100644 apmec/tests/etc/samples/sample-tosca-mead-multi-vdu-monitoring.yaml delete mode 100644 apmec/tests/etc/samples/sample-tosca-mead-multi-vdu.yaml delete mode 100644 apmec/tests/etc/samples/sample-tosca-mead-param.yaml delete mode 100644 apmec/tests/etc/samples/sample-tosca-mead-static-ip.yaml delete mode 100644 apmec/tests/etc/samples/sample-tosca-mead.yaml delete mode 100644 apmec/tests/etc/samples/sample-tosca-scale-all.yaml delete mode 100644 apmec/tests/etc/samples/sample_tosca_assign_floatingip_to_vdu.yaml delete mode 100644 apmec/tests/etc/samples/sample_tosca_meac.yaml delete mode 100644 apmec/tests/etc/samples/test-ns-nsd.yaml delete mode 100644 apmec/tests/etc/samples/test-ns-vnfd1.yaml delete mode 100644 apmec/tests/etc/samples/test-ns-vnfd2.yaml delete mode 100644 apmec/tests/etc/samples/test-nsd-vnfd1.yaml delete mode 100644 apmec/tests/etc/samples/test-nsd-vnfd2.yaml delete mode 100644 apmec/tests/etc/samples/test-nsd.yaml delete mode 100644 apmec/tests/functional/mem/__init__.py delete mode 100644 apmec/tests/functional/mem/test_mea.py delete mode 100644 apmec/tests/functional/mem/test_mea_monitoring.py delete mode 100644 apmec/tests/functional/mem/test_mem_param.py delete mode 100644 apmec/tests/functional/mem/test_tosca_mea.py delete mode 100644 apmec/tests/functional/mem/test_tosca_mea_alarm.py delete mode 100644 apmec/tests/functional/mem/test_tosca_mea_block_storage.py delete mode 100644 apmec/tests/functional/mem/test_tosca_mea_floatingip.py delete mode 100644 apmec/tests/functional/mem/test_tosca_mea_multiple_vdu.py delete mode 100644 apmec/tests/functional/mem/test_tosca_mea_scale.py delete mode 100644 apmec/tests/functional/mem/test_tosca_meac.py delete mode 100644 apmec/tests/functional/mem/test_tosca_mead.py delete mode 100644 apmec/tests/functional/meo/__init__.py delete mode 100644 apmec/tests/functional/meo/test_meo.py delete mode 100644 apmec/tests/functional/meo/test_vim.py delete mode 100644 apmec/tests/unit/_test_rootwrap_exec.py delete mode 100644 apmec/tests/unit/base.py delete mode 100644 apmec/tests/unit/database_stubs.py delete mode 100644 apmec/tests/unit/db/__init__.py delete mode 100644 apmec/tests/unit/db/base.py delete mode 100644 apmec/tests/unit/db/utils.py delete mode 100644 apmec/tests/unit/extension_stubs.py delete mode 100644 apmec/tests/unit/extensions/__init__.py delete mode 100644 apmec/tests/unit/extensions/extendedattribute.py delete mode 100644 apmec/tests/unit/extensions/extensionattribute.py delete mode 100644 apmec/tests/unit/extensions/foxinsocks.py delete mode 100644 apmec/tests/unit/extensions/v2attributes.py delete mode 100644 apmec/tests/unit/mem/__init__.py delete mode 100644 apmec/tests/unit/mem/infra_drivers/__init__.py delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/__init__.py delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/config_data.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/hot_alarm_scale_custom.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/hot_flavor.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/hot_flavor_and_capabilities.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/hot_flavor_defaults.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/hot_flavor_no_units.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/hot_image_after_processed_image.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/hot_image_before_processed_image.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/hot_openwrt.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/hot_openwrt_ipparams.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/hot_openwrt_params.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/hot_scale_custom.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/hot_scale_main.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_alarm_metadata.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_alarm_respawn.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_alarm_scale.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_allowed_address_pairs.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_flavor_all_numa_count.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_flavor_all_numa_nodes.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_flavor_cpu_allocations.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_flavor_huge_pages.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_flavor_numa_nodes.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_flavor_numa_nodes_count.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_generic_vnfd_params.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_image.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_mac_ip.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_mgmt_sriov.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_monitoring_multi_vdu.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_openwrt.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_openwrt_kilo.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_openwrt_userdata.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_security_groups.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_sriov.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_vnfc.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_vnic_normal.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/test_tosca_allowed_address_pairs.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/test_tosca_flavor.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/test_tosca_flavor_and_capabilities.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/test_tosca_flavor_defaults.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/test_tosca_flavor_no_units.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/test_tosca_image.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/test_tosca_mac_ip.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/test_tosca_meac.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/test_tosca_mead_alarm_multi_actions.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/test_tosca_mead_alarm_respawn.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/test_tosca_mead_alarm_scale.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/test_tosca_openwrt.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/test_tosca_openwrt_userdata.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/test_tosca_security_groups.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_alarm_metadata.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_alarm_respawn.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_alarm_scale.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_block_storage.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_flavor_all_numa_count.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_flavor_all_numa_nodes.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_flavor_cpu_allocations.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_flavor_huge_pages.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_flavor_numa_nodes.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_flavor_numa_nodes_count.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_generic_mead_params.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_mgmt_sriov.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_monitoring_multi_vdu.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_nsd_template.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_scale.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_sriov.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_vnic_port.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/data/update_config_data.yaml delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/test_openstack.py delete mode 100644 apmec/tests/unit/mem/infra_drivers/openstack/test_openstack_driver.py delete mode 100644 apmec/tests/unit/mem/monitor_drivers/__init__.py delete mode 100644 apmec/tests/unit/mem/monitor_drivers/http_ping/__init__.py delete mode 100644 apmec/tests/unit/mem/monitor_drivers/http_ping/test_http_ping.py delete mode 100644 apmec/tests/unit/mem/monitor_drivers/ping/__init__.py delete mode 100644 apmec/tests/unit/mem/monitor_drivers/ping/test_ping.py delete mode 100644 apmec/tests/unit/mem/test_monitor.py delete mode 100644 apmec/tests/unit/mem/test_plugin.py delete mode 100644 apmec/tests/unit/mem/test_vim_client.py delete mode 100644 apmec/tests/unit/mem/tosca/__init__.py delete mode 100644 apmec/tests/unit/mem/tosca/test_utils.py delete mode 100644 apmec/tests/unit/meo/__init__.py delete mode 100644 apmec/tests/unit/meo/drivers/__init__.py delete mode 100644 apmec/tests/unit/meo/drivers/vim/__init__.py delete mode 100644 apmec/tests/unit/meo/drivers/vim/test_openstack_driver.py delete mode 100644 apmec/tests/unit/meo/drivers/vnffg/__init__.py delete mode 100644 apmec/tests/unit/meo/drivers/vnffg/sfc_drivers/__init__.py delete mode 100644 apmec/tests/unit/meo/drivers/vnffg/sfc_drivers/networking-sfc/__init__.py delete mode 100644 apmec/tests/unit/meo/drivers/vnffg/sfc_drivers/networking-sfc/test_n_sfc.py delete mode 100644 apmec/tests/unit/meo/drivers/workflow/__init__.py delete mode 100644 apmec/tests/unit/meo/drivers/workflow/test_workflow_generator.py delete mode 100644 apmec/tests/unit/meo/test_nfvo_plugin.py delete mode 100644 apmec/tests/unit/test_alarm_receiver.py delete mode 100644 apmec/tests/unit/test_api_api_common.py delete mode 100644 apmec/tests/unit/test_api_v2.py delete mode 100644 apmec/tests/unit/test_api_v2_extension.py delete mode 100644 apmec/tests/unit/test_api_v2_resource.py delete mode 100644 apmec/tests/unit/test_attributes.py delete mode 100644 apmec/tests/unit/test_auth.py delete mode 100644 apmec/tests/unit/test_common_log.py delete mode 100644 apmec/tests/unit/test_common_services_plugin.py delete mode 100644 apmec/tests/unit/test_common_utils.py delete mode 100644 apmec/tests/unit/test_config.py delete mode 100644 apmec/tests/unit/test_db_migration.py delete mode 100644 apmec/tests/unit/test_db_purge_delete.py delete mode 100644 apmec/tests/unit/test_extension_extended_attribute.py delete mode 100644 apmec/tests/unit/test_extensions.py delete mode 100644 apmec/tests/unit/test_policy.py delete mode 100644 apmec/tests/unit/test_post_mortem_debug.py delete mode 100644 apmec/tests/unit/test_tacker_context.py delete mode 100644 apmec/tests/unit/test_tosca_templates_under_samples.py delete mode 100644 apmec/tests/unit/test_wsgi.py delete mode 100644 apmec/tests/unit/testlib_api.py create mode 100644 doc/source/api/apmec._i18n.rst create mode 100644 doc/source/api/apmec.agent.linux.utils.rst create mode 100644 doc/source/api/apmec.alarm_receiver.rst create mode 100644 doc/source/api/apmec.api.api_common.rst create mode 100644 doc/source/api/apmec.api.extensions.rst create mode 100644 doc/source/api/apmec.api.v1.attributes.rst create mode 100644 doc/source/api/apmec.api.v1.base.rst create mode 100644 doc/source/api/apmec.api.v1.resource.rst create mode 100644 doc/source/api/apmec.api.v1.resource_helper.rst create mode 100644 doc/source/api/apmec.api.v1.router.rst create mode 100644 doc/source/api/apmec.api.versions.rst create mode 100644 doc/source/api/apmec.api.views.versions.rst create mode 100644 doc/source/api/apmec.auth.rst create mode 100644 doc/source/api/apmec.catalogs.tosca.utils.rst create mode 100644 doc/source/api/apmec.cmd.eventlet.apmec_server.rst create mode 100644 doc/source/api/apmec.cmd.eventlet.conductor.rst create mode 100644 doc/source/api/apmec.common.clients.rst create mode 100644 doc/source/api/apmec.common.cmd_executer.rst create mode 100644 doc/source/api/apmec.common.config.rst create mode 100644 doc/source/api/apmec.common.constants.rst create mode 100644 doc/source/api/apmec.common.driver_manager.rst create mode 100644 doc/source/api/apmec.common.eventlet_utils.rst create mode 100644 doc/source/api/apmec.common.exceptions.rst create mode 100644 doc/source/api/apmec.common.log.rst create mode 100644 doc/source/api/apmec.common.rpc.rst create mode 100644 doc/source/api/apmec.common.test_lib.rst create mode 100644 doc/source/api/apmec.common.topics.rst create mode 100644 doc/source/api/apmec.common.utils.rst create mode 100644 doc/source/api/apmec.conductor.conductor_server.rst create mode 100644 doc/source/api/apmec.conductor.conductorrpc.vim_monitor_rpc.rst create mode 100644 doc/source/api/apmec.context.rst create mode 100644 doc/source/api/apmec.db.api.rst create mode 100644 doc/source/api/apmec.db.common_services.common_services_db.rst create mode 100644 doc/source/api/apmec.db.common_services.common_services_db_plugin.rst create mode 100644 doc/source/api/apmec.db.db_base.rst create mode 100644 doc/source/api/apmec.db.mem.mem_db.rst create mode 100644 doc/source/api/apmec.db.meo.meo_db.rst create mode 100644 doc/source/api/apmec.db.meo.meo_db_plugin.rst create mode 100644 doc/source/api/apmec.db.meo.mes_db.rst create mode 100644 doc/source/api/apmec.db.migration.cli.rst create mode 100644 doc/source/api/apmec.db.migration.models.head.rst create mode 100644 doc/source/api/apmec.db.migration.purge_tables.rst create mode 100644 doc/source/api/apmec.db.model_base.rst create mode 100644 doc/source/api/apmec.db.models_v1.rst create mode 100644 doc/source/api/apmec.db.sqlalchemyutils.rst create mode 100644 doc/source/api/apmec.db.types.rst create mode 100644 doc/source/api/apmec.extensions.common_services.rst create mode 100644 doc/source/api/apmec.extensions.mem.rst create mode 100644 doc/source/api/apmec.extensions.meo.rst create mode 100644 doc/source/api/apmec.extensions.meo_plugins.edge_service.rst create mode 100644 doc/source/api/apmec.hacking.checks.rst create mode 100644 doc/source/api/apmec.keymgr.barbican_key_manager.rst create mode 100644 doc/source/api/apmec.keymgr.exception.rst create mode 100644 doc/source/api/apmec.keymgr.key_manager.rst create mode 100644 doc/source/api/apmec.manager.rst create mode 100644 doc/source/api/apmec.mem.infra_drivers.abstract_driver.rst create mode 100644 doc/source/api/apmec.mem.infra_drivers.noop.rst create mode 100644 doc/source/api/apmec.mem.infra_drivers.openstack.heat_client.rst create mode 100644 doc/source/api/apmec.mem.infra_drivers.openstack.openstack.rst create mode 100644 doc/source/api/apmec.mem.infra_drivers.openstack.translate_template.rst create mode 100644 doc/source/api/apmec.mem.infra_drivers.scale_driver.rst create mode 100644 doc/source/api/apmec.mem.keystone.rst create mode 100644 doc/source/api/apmec.mem.mgmt_drivers.abstract_driver.rst create mode 100644 doc/source/api/apmec.mem.mgmt_drivers.constants.rst create mode 100644 doc/source/api/apmec.mem.mgmt_drivers.noop.rst create mode 100644 doc/source/api/apmec.mem.mgmt_drivers.openwrt.openwrt.rst create mode 100644 doc/source/api/apmec.mem.monitor.rst create mode 100644 doc/source/api/apmec.mem.monitor_drivers.abstract_driver.rst create mode 100644 doc/source/api/apmec.mem.monitor_drivers.ceilometer.ceilometer.rst create mode 100644 doc/source/api/apmec.mem.monitor_drivers.http_ping.http_ping.rst create mode 100644 doc/source/api/apmec.mem.monitor_drivers.ping.ping.rst create mode 100644 doc/source/api/apmec.mem.monitor_drivers.token.rst create mode 100644 doc/source/api/apmec.mem.plugin.rst create mode 100644 doc/source/api/apmec.mem.policy_actions.abstract_action.rst create mode 100644 doc/source/api/apmec.mem.policy_actions.autoscaling.autoscaling.rst create mode 100644 doc/source/api/apmec.mem.policy_actions.log.log.rst create mode 100644 doc/source/api/apmec.mem.policy_actions.respawn.respawn.rst create mode 100644 doc/source/api/apmec.mem.vim_client.rst create mode 100644 doc/source/api/apmec.meo.drivers.vim.abstract_vim_driver.rst create mode 100644 doc/source/api/apmec.meo.drivers.vim.openstack_driver.rst create mode 100644 doc/source/api/apmec.meo.drivers.workflow.workflow_generator.rst create mode 100644 doc/source/api/apmec.meo.meo_plugin.rst create mode 100644 doc/source/api/apmec.meo.workflows.vim_monitor.vim_monitor_utils.rst create mode 100644 doc/source/api/apmec.meo.workflows.vim_monitor.vim_ping_action.rst create mode 100644 doc/source/api/apmec.meo.workflows.vim_monitor.workflow_generator.rst create mode 100644 doc/source/api/apmec.mistral.actionrpc.kill_action.rst create mode 100644 doc/source/api/apmec.mistral.mistral_client.rst create mode 100644 doc/source/api/apmec.mistral.workflow_generator.rst create mode 100644 doc/source/api/apmec.plugins.common.constants.rst create mode 100644 doc/source/api/apmec.plugins.common.utils.rst create mode 100644 doc/source/api/apmec.plugins.common_services.common_services_plugin.rst create mode 100644 doc/source/api/apmec.policy.rst create mode 100644 doc/source/api/apmec.service.rst create mode 100644 doc/source/api/apmec.services.service_base.rst create mode 100644 doc/source/api/apmec.version.rst create mode 100644 doc/source/api/apmec.wsgi.rst create mode 100644 doc/source/api/autoindex.rst delete mode 100644 doc/source/user/mesd_usage_guide.rst delete mode 100755 tools/ostestr_compat_shim.sh diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..279a9fb --- /dev/null +++ b/.coveragerc @@ -0,0 +1,7 @@ +[run] +branch = True +source = apmec +omit = apmec/tests/* + +[report] +ignore_errors = True diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2607df2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,34 @@ +AUTHORS +api-ref/build/ +build/* +build-stamp +ChangeLog +cover/ +.coverage +covhtml/ +dist/ +doc/build +*.DS_Store +*.pyc +apmec.egg-info/ +apmec/vcsversion.py +apmec/versioninfo +pbr*.egg/ +run_tests.err.log +run_tests.log +setuptools*.egg/ +subunit.log +.testrepository +.idea/ +.tox/ +.venv/ +*.mo +*.sw? +*~ +.eggs/ +.stestr/ +SP1_res.yaml + +releasenotes/build +etc/apmec/apmec.conf.sample +doc/source/contributor/api diff --git a/.gitreview b/.gitreview new file mode 100644 index 0000000..1ed14b4 --- /dev/null +++ b/.gitreview @@ -0,0 +1,4 @@ +[gerrit] +host=review.openstack.org +port=29418 +project=openstack/apmec.git diff --git a/.testr.conf b/.testr.conf new file mode 100644 index 0000000..57088e7 --- /dev/null +++ b/.testr.conf @@ -0,0 +1,4 @@ +[DEFAULT] +test_command=OS_STDOUT_CAPTURE=1 OS_STDERR_CAPTURE=1 OS_LOG_CAPTURE=1 ${PYTHON:-python} -m subunit.run discover -t ./ ${OS_TEST_PATH:-./apmec/tests/unit} $LISTOPT $IDOPTION +test_id_option=--load-list $IDFILE +test_list_option=--list diff --git a/apmec/alarm_receiver.py b/apmec/alarm_receiver.py index 8fdea8d..ce4fe24 100644 --- a/apmec/alarm_receiver.py +++ b/apmec/alarm_receiver.py @@ -11,12 +11,15 @@ # 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 apmec.mem.monitor_drivers.token import Token +from apmec import wsgi + from oslo_config import cfg from oslo_log import log as logging from oslo_serialization import jsonutils from six.moves.urllib import parse -from apmec.mem.monitor_drivers.token import Token -from apmec import wsgi + # check alarm url with db --> move to plugin diff --git a/apmec/catalogs/tosca/utils.py b/apmec/catalogs/tosca/utils.py index 9f75fec..c3cd2d6 100644 --- a/apmec/catalogs/tosca/utils.py +++ b/apmec/catalogs/tosca/utils.py @@ -17,14 +17,14 @@ import re import sys import yaml -from oslo_log import log as logging -from toscaparser import properties -from toscaparser.utils import yamlparser - from apmec.common import log from apmec.common import utils from apmec.extensions import mem +from oslo_log import log as logging +from toscaparser import properties +from toscaparser.utils import yamlparser + from collections import OrderedDict FAILURE = 'tosca.policies.apmec.Failure' @@ -66,17 +66,17 @@ FLAVOR_EXTRA_SPECS_LIST = ('cpu_allocation', 'numa_nodes') delpropmap = {APMECVDU: ('mgmt_driver', 'config', 'service_type', - 'placement_policy', 'monitoring_policy', - 'metadata', 'failure_policy'), + 'placement_policy', 'monitoring_policy', + 'metadata', 'failure_policy'), APMECCP: ('management',)} convert_prop = {APMECCP: {'anti_spoofing_protection': - 'port_security_enabled', - 'type': - 'binding:vnic_type'}} + 'port_security_enabled', + 'type': + 'binding:vnic_type'}} convert_prop_values = {APMECCP: {'type': {'sriov': 'direct', - 'vnic': 'normal'}}} + 'vnic': 'normal'}}} deletenodes = (MONITORING, FAILURE, PLACEMENT) diff --git a/apmec/cmd/eventlet/apmec_server.py b/apmec/cmd/eventlet/apmec_server.py index 4091a36..dadd254 100644 --- a/apmec/cmd/eventlet/apmec_server.py +++ b/apmec/cmd/eventlet/apmec_server.py @@ -16,7 +16,8 @@ # under the License. # If ../apmec/__init__.py exists, add ../ to Python search path, so that -# it will override what happens to be installed in /usr/(local/)tosca_lib/python... +# it will override what happens to be installed in +# /usr/(local/)tosca_lib/python... import sys diff --git a/apmec/common/clients.py b/apmec/common/clients.py index 2dcfac1..6e996d4 100644 --- a/apmec/common/clients.py +++ b/apmec/common/clients.py @@ -10,8 +10,8 @@ # License for the specific language governing permissions and limitations # under the License. -from heatclient import client as heatclient from apmec.mem import keystone +from heatclient import client as heatclient class OpenstackClients(object): diff --git a/apmec/db/meo/meo_db_plugin.py b/apmec/db/meo/meo_db_plugin.py index d22e1d6..c17d758 100644 --- a/apmec/db/meo/meo_db_plugin.py +++ b/apmec/db/meo/meo_db_plugin.py @@ -10,6 +10,15 @@ # License for the specific language governing permissions and limitations # under the License. +from apmec.common import exceptions +from apmec.db.common_services import common_services_db_plugin +from apmec.db import db_base +from apmec.db.mem import mem_db +from apmec.db.meo import meo_db +from apmec.extensions import meo +from apmec import manager +from apmec.plugins.common import constants + from datetime import datetime from oslo_db.exception import DBDuplicateEntry @@ -19,15 +28,6 @@ from oslo_utils import uuidutils from sqlalchemy.orm import exc as orm_exc from sqlalchemy import sql -from apmec.common import exceptions -from apmec.db.common_services import common_services_db_plugin -from apmec.db import db_base -from apmec.db.meo import meo_db -from apmec.db.mem import mem_db -from apmec.extensions import meo -from apmec import manager -from apmec.plugins.common import constants - VIM_ATTRIBUTES = ('id', 'type', 'tenant_id', 'name', 'description', 'placement_attr', 'shared', 'is_default', diff --git a/apmec/db/migration/alembic_migrations/versions/12a57080b278_alter_devices.py b/apmec/db/migration/alembic_migrations/versions/12a57080b278_alter_devices.py index 72acd31..1cee4d7 100644 --- a/apmec/db/migration/alembic_migrations/versions/12a57080b278_alter_devices.py +++ b/apmec/db/migration/alembic_migrations/versions/12a57080b278_alter_devices.py @@ -26,8 +26,8 @@ revision = '12a57080b278' down_revision = '12a57080b277' from alembic import op -from sqlalchemy.dialects import mysql from apmec.db import migration +from sqlalchemy.dialects import mysql def upgrade(active_plugins=None, options=None): diff --git a/apmec/db/migration/alembic_migrations/versions/e8918cda6433_add_attributes_to_vnffg.py b/apmec/db/migration/alembic_migrations/versions/e8918cda6433_add_attributes_to_vnffg.py index 559f32a..d3e331d 100644 --- a/apmec/db/migration/alembic_migrations/versions/e8918cda6433_add_attributes_to_vnffg.py +++ b/apmec/db/migration/alembic_migrations/versions/e8918cda6433_add_attributes_to_vnffg.py @@ -26,8 +26,8 @@ revision = 'e8918cda6433' down_revision = '000632983ada' from alembic import op -import sqlalchemy as sa from apmec.db.types import Json +import sqlalchemy as sa def upgrade(active_plugins=None, options=None): diff --git a/apmec/mem/infra_drivers/openstack/openstack.py b/apmec/mem/infra_drivers/openstack/openstack.py index 390914b..3260320 100644 --- a/apmec/mem/infra_drivers/openstack/openstack.py +++ b/apmec/mem/infra_drivers/openstack/openstack.py @@ -342,7 +342,7 @@ class OpenStack(abstract_driver.DeviceAbstractDriver, 'error': str(e)} LOG.warning(error_reason) raise mem.MEAScaleWaitFailed(mea_id=policy['mea']['id'], - reason=error_reason) + reason=error_reason) if stack_retries == 0: metadata = heatclient.resource_metadata(stack_id, policy_name) @@ -360,7 +360,7 @@ class OpenStack(abstract_driver.DeviceAbstractDriver, self.STACK_RETRY_WAIT} LOG.warning(error_reason) raise mem.MEAScaleWaitFailed(mea_id=policy['mea']['id'], - reason=error_reason) + reason=error_reason) stack_retries -= 1 def _fill_scaling_group_name(): diff --git a/apmec/mem/infra_drivers/openstack/translate_template.py b/apmec/mem/infra_drivers/openstack/translate_template.py index 7b9046e..201a63a 100644 --- a/apmec/mem/infra_drivers/openstack/translate_template.py +++ b/apmec/mem/infra_drivers/openstack/translate_template.py @@ -10,6 +10,11 @@ # License for the specific language governing permissions and limitations # under the License. +from apmec.catalogs.tosca import utils as toscautils +from apmec.common import log +from apmec.extensions import common_services as cs +from apmec.extensions import mem + from oslo_config import cfg from oslo_log import log as logging from oslo_serialization import jsonutils @@ -18,11 +23,6 @@ from toscaparser.utils import yamlparser from translator.hot import tosca_translator import yaml -from apmec.common import log -from apmec.extensions import common_services as cs -from apmec.extensions import mem -from apmec.catalogs.tosca import utils as toscautils - LOG = logging.getLogger(__name__) CONF = cfg.CONF diff --git a/apmec/mem/monitor_drivers/ceilometer/ceilometer.py b/apmec/mem/monitor_drivers/ceilometer/ceilometer.py index 4919f78..3e1accc 100644 --- a/apmec/mem/monitor_drivers/ceilometer/ceilometer.py +++ b/apmec/mem/monitor_drivers/ceilometer/ceilometer.py @@ -12,12 +12,13 @@ # under the License. # +from apmec.common import utils +from apmec.mem.monitor_drivers import abstract_driver + from oslo_config import cfg from oslo_log import log as logging import random import string -from apmec.common import utils -from apmec.mem.monitor_drivers import abstract_driver LOG = logging.getLogger(__name__) diff --git a/apmec/mem/plugin.py b/apmec/mem/plugin.py index 0399895..64cd7df 100644 --- a/apmec/mem/plugin.py +++ b/apmec/mem/plugin.py @@ -19,11 +19,6 @@ import six import yaml import eventlet -from oslo_config import cfg -from oslo_log import log as logging -from oslo_utils import excutils -from oslo_utils import uuidutils -from toscaparser.tosca_template import ToscaTemplate from apmec.api.v1 import attributes from apmec.common import driver_manager @@ -31,12 +26,18 @@ from apmec.common import exceptions from apmec.common import utils from apmec.db.mem import mem_db from apmec.extensions import mem -from apmec.plugins.common import constants + +from apmec.catalogs.tosca import utils as toscautils from apmec.mem.mgmt_drivers import constants as mgmt_constants from apmec.mem import monitor from apmec.mem import vim_client +from apmec.plugins.common import constants -from apmec.catalogs.tosca import utils as toscautils +from oslo_config import cfg +from oslo_log import log as logging +from oslo_utils import excutils +from oslo_utils import uuidutils +from toscaparser.tosca_template import ToscaTemplate LOG = logging.getLogger(__name__) CONF = cfg.CONF @@ -865,4 +866,4 @@ class MEMPlugin(mem_db.MEMPluginDb, MEMMgmtMixin): # Raise exception when MEA.status != ACTIVE else: raise mem.MEAInactive(mea_id=mea_id, - message=_(' Cannot fetch details')) + message=_(' Cannot fetch details')) diff --git a/apmec/mem/policy_actions/autoscaling/autoscaling.py b/apmec/mem/policy_actions/autoscaling/autoscaling.py index dca57b1..70b699b 100644 --- a/apmec/mem/policy_actions/autoscaling/autoscaling.py +++ b/apmec/mem/policy_actions/autoscaling/autoscaling.py @@ -12,13 +12,13 @@ # under the License. # +from apmec.db.common_services import common_services_db_plugin +from apmec.mem.policy_actions import abstract_action +from apmec.plugins.common import constants + from oslo_log import log as logging from oslo_utils import timeutils -from apmec.db.common_services import common_services_db_plugin -from apmec.plugins.common import constants -from apmec.mem.policy_actions import abstract_action - LOG = logging.getLogger(__name__) diff --git a/apmec/mem/policy_actions/log/log.py b/apmec/mem/policy_actions/log/log.py index 54a40e0..4a3cf81 100644 --- a/apmec/mem/policy_actions/log/log.py +++ b/apmec/mem/policy_actions/log/log.py @@ -12,13 +12,13 @@ # under the License. # +from apmec.db.common_services import common_services_db_plugin +from apmec.mem.policy_actions import abstract_action +from apmec.plugins.common import constants + from oslo_log import log as logging from oslo_utils import timeutils -from apmec.db.common_services import common_services_db_plugin -from apmec.plugins.common import constants -from apmec.mem.policy_actions import abstract_action - LOG = logging.getLogger(__name__) diff --git a/apmec/mem/policy_actions/respawn/respawn.py b/apmec/mem/policy_actions/respawn/respawn.py index 29ae0b9..627ee7f 100644 --- a/apmec/mem/policy_actions/respawn/respawn.py +++ b/apmec/mem/policy_actions/respawn/respawn.py @@ -12,14 +12,14 @@ # under the License. # -from oslo_log import log as logging -from oslo_utils import timeutils - from apmec.db.common_services import common_services_db_plugin -from apmec.plugins.common import constants from apmec.mem.infra_drivers.openstack import heat_client as hc from apmec.mem.policy_actions import abstract_action from apmec.mem import vim_client +from apmec.plugins.common import constants + +from oslo_log import log as logging +from oslo_utils import timeutils LOG = logging.getLogger(__name__) diff --git a/apmec/mem/vim_client.py b/apmec/mem/vim_client.py index c738954..b04dab8 100644 --- a/apmec/mem/vim_client.py +++ b/apmec/mem/vim_client.py @@ -49,7 +49,7 @@ class VimClient(object): else: try: vim_info = meo_plugin.get_vim(context, vim_id, - mask_password=False) + mask_password=False) except Exception: raise meo.VimNotFoundException(vim_id=vim_id) LOG.debug('VIM info found for vim id %s', vim_id) diff --git a/apmec/meo/drivers/vim/openstack_driver.py b/apmec/meo/drivers/vim/openstack_driver.py index 1b6b7cf..02559b4 100644 --- a/apmec/meo/drivers/vim/openstack_driver.py +++ b/apmec/meo/drivers/vim/openstack_driver.py @@ -18,26 +18,25 @@ import os import six import yaml +from apmec._i18n import _ +from apmec.common import log +from apmec.extensions import meo +from apmec.keymgr import API as KEYMGR_API +from apmec.mem import keystone +from apmec.meo.drivers.vim import abstract_vim_driver +from apmec.meo.drivers.workflow import workflow_generator +from apmec.mistral import mistral_client + + from keystoneauth1 import exceptions from keystoneauth1 import identity from keystoneauth1.identity import v2 from keystoneauth1.identity import v3 from keystoneauth1 import session -from neutronclient.common import exceptions as nc_exceptions from neutronclient.v2_0 import client as neutron_client from oslo_config import cfg from oslo_log import log as logging -from apmec._i18n import _ -from apmec.common import log -from apmec.extensions import meo -from apmec.keymgr import API as KEYMGR_API -from apmec.mistral import mistral_client -from apmec.meo.drivers.vim import abstract_vim_driver -from apmec.meo.drivers.workflow import workflow_generator -from apmec.mem import keystone - - LOG = logging.getLogger(__name__) CONF = cfg.CONF @@ -382,4 +381,4 @@ class NeutronClient(object): def __init__(self, auth_attr): auth = identity.Password(**auth_attr) sess = session.Session(auth=auth) - self.client = neutron_client.Client(session=sess) \ No newline at end of file + self.client = neutron_client.Client(session=sess) diff --git a/apmec/meo/meo_plugin.py b/apmec/meo/meo_plugin.py index ec758e7..0e7569b 100644 --- a/apmec/meo/meo_plugin.py +++ b/apmec/meo/meo_plugin.py @@ -19,16 +19,6 @@ import os import time import yaml -from cryptography import fernet -import eventlet -from oslo_config import cfg -from oslo_log import log as logging -from oslo_utils import excutils -from oslo_utils import strutils -from oslo_utils import uuidutils -from tempfile import mkstemp -from toscaparser.tosca_template import ToscaTemplate - from apmec._i18n import _ from apmec.common import driver_manager from apmec.common import log @@ -39,12 +29,22 @@ from apmec.extensions import common_services as cs from apmec.extensions import meo from apmec.keymgr import API as KEYMGR_API from apmec import manager -from apmec.meo.workflows.vim_monitor import vim_monitor_utils -from apmec.plugins.common import constants from apmec.mem import vim_client -from apmec.nfv.tacker_client import TackerClient as tackerclient +from apmec.meo.workflows.vim_monitor import vim_monitor_utils from apmec.catalogs.tosca import utils as toscautils +from cryptography import fernet +import eventlet + +from oslo_config import cfg +from oslo_log import log as logging +from oslo_utils import excutils +from oslo_utils import strutils +from oslo_utils import uuidutils +from tempfile import mkstemp +from toscaparser.tosca_template import ToscaTemplate + + from toscaparser import tosca_template LOG = logging.getLogger(__name__) @@ -325,14 +325,6 @@ class MeoPlugin(meo_db_plugin.MeoPluginDb, mes_db.MESPluginDb): inner_mesd_dict = yaml.safe_load(mesd_yaml) mesd['meads'] = dict() LOG.debug('mesd_dict: %s', inner_mesd_dict) - # From import we can deploy both NS and MEC Application - nsd_imports = inner_mesd_dict['imports'].get('nsds') - vnffg_imports = inner_mesd_dict['imports'].get('vnffgds') - if nsd_imports: - mesd_dict['attributes']['nsds'] = nsd_imports - if vnffg_imports: - mesd_dict['attributes']['vnffgds'] = vnffg_imports - # Deploy MEC applications mem_plugin = manager.ApmecManager.get_service_plugins()['MEM'] mead_imports = inner_mesd_dict['imports']['meads'] @@ -422,29 +414,6 @@ class MeoPlugin(meo_db_plugin.MeoPluginDb, mes_db.MESPluginDb): if not mes['mes']['vim_id']: mes['mes']['vim_id'] = vim_res['vim_id'] - nsds = mesd['attributes'].get('nsds') - if nsds: - for nsd in nsds: - vim_obj = self.get_vim(context, mes['mes']['vim_id'], mask_password=False) - self._build_vim_auth(context, vim_obj) - client = tackerclient(vim_obj['auth_cred']) - ns_name = nsd + name - nsd_instance = client.nsd_get(nsd) - ns_arg = {'ns': {'nsd_id': nsd_instance, 'name': ns_name}} - ns_instance = client.ns_create(ns_arg) - - vnffgds = mesd['attributes'].get('vnffgds') - if vnffgds: - for vnffgd in vnffgds: - vim_obj = self.get_vim(context, mes['mes']['vim_id'], mask_password=False) - self._build_vim_auth(context, vim_obj) - client = tackerclient(vim_obj['auth_cred']) - vnffgd_name = vnffgd + name - vnffgd_instance = client.vnffgd_get(vnffgd) - vnffg_arg = {'vnffg': {'vnffgd_id': vnffgd_instance, 'name': vnffgd_name}} - time.sleep(300) - vnffg_instance = client.vnffg_create(vnffg_arg) - # Step-1 param_values = mes['mes']['attributes'].get('param_values', {}) if 'get_input' in str(mesd_dict): diff --git a/apmec/meo/workflows/vim_monitor/vim_monitor_utils.py b/apmec/meo/workflows/vim_monitor/vim_monitor_utils.py index a841f1f..840b6b8 100644 --- a/apmec/meo/workflows/vim_monitor/vim_monitor_utils.py +++ b/apmec/meo/workflows/vim_monitor/vim_monitor_utils.py @@ -12,15 +12,14 @@ import yaml -from oslo_config import cfg -from oslo_log import log as logging - from apmec.common import rpc +from apmec.mem import keystone +from apmec.meo.workflows.vim_monitor import workflow_generator from apmec.mistral.actionrpc import kill_action as killaction from apmec.mistral import mistral_client -from apmec.meo.workflows.vim_monitor import workflow_generator -from apmec.mem import keystone +from oslo_config import cfg +from oslo_log import log as logging LOG = logging.getLogger(__name__) diff --git a/apmec/meo/workflows/vim_monitor/workflow_generator.py b/apmec/meo/workflows/vim_monitor/workflow_generator.py index 4b80772..2726c58 100644 --- a/apmec/meo/workflows/vim_monitor/workflow_generator.py +++ b/apmec/meo/workflows/vim_monitor/workflow_generator.py @@ -10,10 +10,9 @@ # License for the specific language governing permissions and limitations # under the License. -from oslo_log import log as logging - -from apmec.mistral import workflow_generator from apmec.meo.workflows import vim_monitor +from apmec.mistral import workflow_generator +from oslo_log import log as logging LOG = logging.getLogger(__name__) diff --git a/apmec/nfv/__init__.py b/apmec/nfv/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/apmec/nfv/tacker_client.py b/apmec/nfv/tacker_client.py deleted file mode 100644 index dc8854d..0000000 --- a/apmec/nfv/tacker_client.py +++ /dev/null @@ -1,104 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, 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. -from keystoneauth1 import identity -from keystoneauth1 import session -from tackerclient.v1_0 import client as tacker_client - - -class TackerClient(object): - """Tacker Client class for VNFM and NFVO negotiation""" - - def __init__(self, auth_attr): - auth = identity.Password(**auth_attr) - sess = session.Session(auth=auth) - self.client = tacker_client.Client(session=sess) - - def nsd_create(self, nsd_dict): - nsd_instance = self.client.create_nsd(body=nsd_dict) - if nsd_instance: - return nsd_instance['nsd']['id'] - else: - return None - - def nsd_get(self, nsd_name): - nsd_dict = self.client.list_nsds() - nsd_list = nsd_dict['nsds'] - nsd_id = None - for nsd in nsd_list: - if nsd['name'] == nsd_name: - nsd_id = nsd['id'] - return nsd_id - - def ns_create(self, ns_dict): - ns_instance = self.client.create_ns(body=ns_dict) - if ns_instance: - return ns_instance['ns']['id'] - else: - return None - - def ns_get(self, ns_name): - ns_dict = self.client.list_nsds() - ns_list = ns_dict['nss'] - ns_id = None - for ns in ns_list: - if ns['name'] == ns_name: - ns_id = ns['id'] - return ns_id - - def ns_delete(self, ns_name): - nsd_id = self.ns_get(ns_name) - if nsd_id: - self.client.delete_ns(nsd_id) - - def vnfd_create(self, vnfd_dict): - vnfd_instance = self.client.create_vnfd(body=vnfd_dict) - if vnfd_instance: - return vnfd_instance['vnf']['id'] - else: - return None - - def vnf_create(self, vnf_dict): - vnf_instance = self.client.create_vnf(body=vnf_dict) - if vnf_instance: - return vnf_instance['vnf']['id'] - else: - return None - - def vnffgd_get(self, vnffgd_name): - vnffgd_dict = self.client.list_vnffgds() - vnffgd_list = vnffgd_dict['vnffgds'] - vnffgd_id = None - for vnffgd in vnffgd_list: - if vnffgd['name'] == vnffgd_name: - vnffgd_id = vnffgd['id'] - return vnffgd_id - - def vnffg_create(self, vnffgd_dict): - vnffg_instance = self.client.create_vnffg(body=vnffgd_dict) - if vnffg_instance: - return vnffg_instance['vnffg']['id'] - else: - return None - - def vnffg_get(self, vnffg_name): - vnffg_dict = self.client.list_vnffgs() - vnffg_list = vnffg_dict['vnffgs'] - vnffg_id = None - for vnffg in vnffg_list: - if vnffg['name'] == vnffg_name: - vnffg_id = vnffg['id'] - return vnffg_id - - def vnffg_delete(self, vnffg_name): - vnffg_id = self.vnffg_get(vnffg_name) - if vnffg_id: - self.client.delete_vnffg(vnffg_id) \ No newline at end of file diff --git a/apmec/tests/constants.py b/apmec/tests/constants.py index 7e374ad..5a36c54 100644 --- a/apmec/tests/constants.py +++ b/apmec/tests/constants.py @@ -19,6 +19,6 @@ MEA_CIRROS_DEAD_TIMEOUT = 500 ACTIVE_SLEEP_TIME = 3 DEAD_SLEEP_TIME = 1 SCALE_WINDOW_SLEEP_TIME = 120 -NS_CREATE_TIMEOUT = 400 -NS_DELETE_TIMEOUT = 300 +MES_CREATE_TIMEOUT = 400 +MES_DELETE_TIMEOUT = 300 NOVA_CLIENT_VERSION = 2 diff --git a/apmec/tests/etc/samples/install_vnfc.sh b/apmec/tests/etc/samples/install_vnfc.sh deleted file mode 100644 index 1842a8b..0000000 --- a/apmec/tests/etc/samples/install_vnfc.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -echo "Successfully installed MEAC" > /apmec diff --git a/apmec/tests/etc/samples/sample-tosca-alarm-respawn.yaml b/apmec/tests/etc/samples/sample-tosca-alarm-respawn.yaml deleted file mode 100644 index 7090eb1..0000000 --- a/apmec/tests/etc/samples/sample-tosca-alarm-respawn.yaml +++ /dev/null @@ -1,57 +0,0 @@ -tosca_definitions_version: tosca_simple_profile_for_mec_1_0_0 -description: Demo example - -metadata: - template_name: sample-tosca-mead - -topology_template: - node_templates: - VDU1: - type: tosca.nodes.mec.VDU.Apmec - capabilities: - mec_compute: - properties: - disk_size: 1 GB - mem_size: 512 MB - num_cpus: 2 - properties: - image: cirros-0.3.5-x86_64-disk - mgmt_driver: noop - availability_zone: nova - metadata: {metering.mea: VDU1} - - CP1: - type: tosca.nodes.mec.CP.Apmec - properties: - management: true - anti_spoofing_protection: false - requirements: - - virtualLink: - node: VL1 - - virtualBinding: - node: VDU1 - - VL1: - type: tosca.nodes.mec.VL - properties: - network_name: net_mgmt - vendor: Apmec - - policies: - - vdu1_cpu_usage_monitoring_policy: - type: tosca.policies.apmec.Alarming - triggers: - vdu_hcpu_usage_respawning: - event_type: - type: tosca.events.resource.utilization - implementation: ceilometer - meter_name: cpu_util - condition: - threshold: 50 - constraint: utilization greater_than 50% - period: 600 - evaluations: 1 - method: average - comparison_operator: gt - metadata: VDU1 - action: [respawn] diff --git a/apmec/tests/etc/samples/sample-tosca-alarm-scale.yaml b/apmec/tests/etc/samples/sample-tosca-alarm-scale.yaml deleted file mode 100644 index 81c3d91..0000000 --- a/apmec/tests/etc/samples/sample-tosca-alarm-scale.yaml +++ /dev/null @@ -1,82 +0,0 @@ -tosca_definitions_version: tosca_simple_profile_for_mec_1_0_0 -description: Demo example - -metadata: - template_name: sample-tosca-mead - -topology_template: - node_templates: - VDU1: - type: tosca.nodes.mec.VDU.Apmec - capabilities: - mec_compute: - properties: - disk_size: 1 GB - mem_size: 512 MB - num_cpus: 2 - properties: - image: cirros-0.3.5-x86_64-disk - mgmt_driver: noop - availability_zone: nova - metadata: {metering.mea: SG1} - - CP1: - type: tosca.nodes.mec.CP.Apmec - properties: - management: true - anti_spoofing_protection: false - requirements: - - virtualLink: - node: VL1 - - virtualBinding: - node: VDU1 - - VL1: - type: tosca.nodes.mec.VL - properties: - network_name: net_mgmt - vendor: Apmec - - policies: - - SP1: - type: tosca.policies.apmec.Scaling - targets: [VDU1] - properties: - increment: 1 - cooldown: 60 - min_instances: 1 - max_instances: 3 - default_instances: 2 - - - vdu_cpu_usage_monitoring_policy: - type: tosca.policies.apmec.Alarming - triggers: - vdu_hcpu_usage_scaling_out: - event_type: - type: tosca.events.resource.utilization - implementation: ceilometer - meter_name: cpu_util - condition: - threshold: 50 - constraint: utilization greater_than 50% - period: 600 - evaluations: 1 - method: average - comparison_operator: gt - metadata: SG1 - action: [SP1] - - vdu_hcpu_usage_scaling_in: - event_type: - type: tosca.events.resource.utilization - implementation: ceilometer - meter_name: cpu_util - condition: - threshold: 10 - constraint: utilization less_than 10% - period: 600 - evaluations: 1 - method: average - comparison_operator: lt - metadata: SG1 - action: [SP1] diff --git a/apmec/tests/etc/samples/sample-tosca-mea-values.yaml b/apmec/tests/etc/samples/sample-tosca-mea-values.yaml deleted file mode 100644 index dd73de4..0000000 --- a/apmec/tests/etc/samples/sample-tosca-mea-values.yaml +++ /dev/null @@ -1,10 +0,0 @@ -{ - image_name: 'cirros-0.3.5-x86_64-disk', - flavor: 'm1.tiny', - zone: 'nova', - network: 'net_mgmt', - management: 'true', - pkt_in_network: 'net0', - pkt_out_network: 'net1', - vendor: 'apmec' -} diff --git a/apmec/tests/etc/samples/sample-tosca-mead-block-storage.yaml b/apmec/tests/etc/samples/sample-tosca-mead-block-storage.yaml deleted file mode 100644 index 84712e6..0000000 --- a/apmec/tests/etc/samples/sample-tosca-mead-block-storage.yaml +++ /dev/null @@ -1,59 +0,0 @@ -tosca_definitions_version: tosca_simple_profile_for_mec_1_0_0 - -description: Demo example - -metadata: - template_name: sample-tosca-mead - -topology_template: - node_templates: - VDU1: - type: tosca.nodes.mec.VDU.Apmec - capabilities: - mec_compute: - properties: - num_cpus: 1 - mem_size: 512 MB - disk_size: 1 GB - properties: - name: test-vdu-block-storage - image: cirros-0.3.5-x86_64-disk - availability_zone: nova - mgmt_driver: noop - config: | - param0: key1 - param1: key2 - - CP1: - type: tosca.nodes.mec.CP.Apmec - properties: - name: test-cp - management: true - order: 0 - anti_spoofing_protection: false - requirements: - - virtualLink: - node: VL1 - - virtualBinding: - node: VDU1 - - VB1: - type: tosca.nodes.BlockStorage.Apmec - properties: - size: 1 GB - image: cirros-0.3.5-x86_64-disk - - CB1: - type: tosca.nodes.BlockStorageAttachment - properties: - location: /dev/vdb - requirements: - - virtualBinding: - node: VDU1 - - virtualAttachment: - node: VB1 - VL1: - type: tosca.nodes.mec.VL - properties: - network_name: net_mgmt - vendor: Apmec diff --git a/apmec/tests/etc/samples/sample-tosca-mead-flavor.yaml b/apmec/tests/etc/samples/sample-tosca-mead-flavor.yaml deleted file mode 100644 index 22b5a31..0000000 --- a/apmec/tests/etc/samples/sample-tosca-mead-flavor.yaml +++ /dev/null @@ -1,68 +0,0 @@ -tosca_definitions_version: tosca_simple_profile_for_mec_1_0_0 - -description: Demo example - -metadata: - template_name: sample-tosca-mead - -topology_template: - node_templates: - VDU1_flavor_func: - type: tosca.nodes.mec.VDU.Apmec - capabilities: - mec_compute: - properties: - num_cpus: 1 - disk_size: 1 GB - mem_size: 512 MB - properties: - image: cirros-0.3.5-x86_64-disk - availability_zone: nova - mgmt_driver: noop - config: | - param0: key1 - param1: key2 - - CP1: - type: tosca.nodes.mec.CP.Apmec - properties: - management: true - requirements: - - virtualLink: - node: VL1 - - virtualBinding: - node: VDU1_flavor_func - - CP2: - type: tosca.nodes.mec.CP.Apmec - requirements: - - virtualLink: - node: VL2 - - virtualBinding: - node: VDU1_flavor_func - - CP3: - type: tosca.nodes.mec.CP.Apmec - requirements: - - virtualLink: - node: VL3 - - virtualBinding: - node: VDU1_flavor_func - - VL1: - type: tosca.nodes.mec.VL - properties: - network_name: net_mgmt - vendor: Apmec - - VL2: - type: tosca.nodes.mec.VL - properties: - network_name: net0 - vendor: Apmec - - VL3: - type: tosca.nodes.mec.VL - properties: - network_name: net1 - vendor: Apmec diff --git a/apmec/tests/etc/samples/sample-tosca-mead-image.yaml b/apmec/tests/etc/samples/sample-tosca-mead-image.yaml deleted file mode 100644 index 02bc814..0000000 --- a/apmec/tests/etc/samples/sample-tosca-mead-image.yaml +++ /dev/null @@ -1,71 +0,0 @@ -tosca_definitions_version: tosca_simple_profile_for_mec_1_0_0 - -description: Demo example with auto image creation - -metadata: - template_name: sample-tosca-mead-image - -topology_template: - node_templates: - VDU1_image_func: - type: tosca.nodes.mec.VDU.Apmec - properties: - flavor: m1.tiny - availability_zone: nova - mgmt_driver: noop - config: | - param0: key1 - param1: key2 - artifacts: - MEAImage_image_func: - type: tosca.artifacts.Deployment.Image.VM - file: http://download.cirros-cloud.net/0.3.5/cirros-0.3.5-x86_64-disk.img - - CP1: - type: tosca.nodes.mec.CP.Apmec - properties: - management: true - anti_spoofing_protection: false - requirements: - - virtualLink: - node: VL1 - - virtualBinding: - node: VDU1_image_func - - CP2: - type: tosca.nodes.mec.CP.Apmec - properties: - anti_spoofing_protection: false - requirements: - - virtualLink: - node: VL2 - - virtualBinding: - node: VDU1_image_func - - CP3: - type: tosca.nodes.mec.CP.Apmec - properties: - anti_spoofing_protection: false - requirements: - - virtualLink: - node: VL3 - - virtualBinding: - node: VDU1_image_func - - VL1: - type: tosca.nodes.mec.VL - properties: - network_name: net_mgmt - vendor: Apmec - - VL2: - type: tosca.nodes.mec.VL - properties: - network_name: net0 - vendor: Apmec - - VL3: - type: tosca.nodes.mec.VL - properties: - network_name: net1 - vendor: Apmec diff --git a/apmec/tests/etc/samples/sample-tosca-mead-large-template.yaml b/apmec/tests/etc/samples/sample-tosca-mead-large-template.yaml deleted file mode 100644 index 0e4e744..0000000 --- a/apmec/tests/etc/samples/sample-tosca-mead-large-template.yaml +++ /dev/null @@ -1,137 +0,0 @@ -tosca_definitions_version: tosca_simple_profile_for_mec_1_0_0 - -description: Demo example - -metadata: - template_name: sample-tosca-mead-large-template - -topology_template: - node_templates: - VDU1: - type: tosca.nodes.mec.VDU.Apmec - properties: - image: cirros-0.3.5-x86_64-disk - flavor: m1.tiny - availability_zone: nova - mgmt_driver: noop - config: | - param0: key1 - param1: key2 - user_data_format: RAW - user_data: | - #!/bin/sh - echo "my hostname is `hostname`" > /tmp/hostname - echo "my hostname is `hostname`" > /tmp/hostname - echo "my hostname is `hostname`" > /tmp/hostname - echo "my hostname is `hostname`" > /tmp/hostname - echo "my hostname is `hostname`" > /tmp/hostname - echo "my hostname is `hostname`" > /tmp/hostname - echo "my hostname is `hostname`" > /tmp/hostname - echo "my hostname is `hostname`" > /tmp/hostname - echo "my hostname is `hostname`" > /tmp/hostname - echo "my hostname is `hostname`" > /tmp/hostname - echo "my hostname is `hostname`" > /tmp/hostname - echo "my hostname is `hostname`" > /tmp/hostname - echo "my hostname is `hostname`" > /tmp/hostname - echo "my hostname is `hostname`" > /tmp/hostname - echo "my hostname is `hostname`" > /tmp/hostname - echo "my hostname is `hostname`" > /tmp/hostname - echo "my hostname is `hostname`" > /tmp/hostname - echo "my hostname is `hostname`" > /tmp/hostname - echo "my hostname is `hostname`" > /tmp/hostname - echo "my hostname is `hostname`" > /tmp/hostname - echo "my hostname is `hostname`" > /tmp/hostname - echo "my hostname is `hostname`" > /tmp/hostname - echo "my hostname is `hostname`" > /tmp/hostname - echo "my hostname is `hostname`" > /tmp/hostname - echo "my hostname is `hostname`" > /tmp/hostname - - CP11: - type: tosca.nodes.mec.CP.Apmec - properties: - management: true - anti_spoofing_protection: false - requirements: - - virtualLink: - node: VL1 - - virtualBinding: - node: VDU1 - - CP12: - type: tosca.nodes.mec.CP.Apmec - properties: - anti_spoofing_protection: false - requirements: - - virtualLink: - node: VL2 - - virtualBinding: - node: VDU1 - - VDU2: - type: tosca.nodes.mec.VDU.Apmec - properties: - image: cirros-0.3.5-x86_64-disk - flavor: m1.medium - availability_zone: nova - mgmt_driver: noop - config: | - param0: key1 - param1: key2 - user_data_format: RAW - user_data: | - #!/bin/sh - echo "my hostname is `hostname`" > /tmp/hostname - echo "my hostname is `hostname`" > /tmp/hostname - echo "my hostname is `hostname`" > /tmp/hostname - echo "my hostname is `hostname`" > /tmp/hostname - echo "my hostname is `hostname`" > /tmp/hostname - echo "my hostname is `hostname`" > /tmp/hostname - echo "my hostname is `hostname`" > /tmp/hostname - echo "my hostname is `hostname`" > /tmp/hostname - echo "my hostname is `hostname`" > /tmp/hostname - echo "my hostname is `hostname`" > /tmp/hostname - echo "my hostname is `hostname`" > /tmp/hostname - echo "my hostname is `hostname`" > /tmp/hostname - echo "my hostname is `hostname`" > /tmp/hostname - echo "my hostname is `hostname`" > /tmp/hostname - echo "my hostname is `hostname`" > /tmp/hostname - echo "my hostname is `hostname`" > /tmp/hostname - echo "my hostname is `hostname`" > /tmp/hostname - echo "my hostname is `hostname`" > /tmp/hostname - echo "my hostname is `hostname`" > /tmp/hostname - echo "my hostname is `hostname`" > /tmp/hostname - echo "my hostname is `hostname`" > /tmp/hostname - echo "my hostname is `hostname`" > /tmp/hostname - echo "my hostname is `hostname`" > /tmp/hostname - echo "my hostname is `hostname`" > /tmp/hostname - echo "my hostname is `hostname`" > /tmp/hostname - - CP21: - type: tosca.nodes.mec.CP.Apmec - properties: - management: true - requirements: - - virtualLink: - node: VL1 - - virtualBinding: - node: VDU2 - - CP22: - type: tosca.nodes.mec.CP.Apmec - requirements: - - virtualLink: - node: VL2 - - virtualBinding: - node: VDU2 - - VL1: - type: tosca.nodes.mec.VL - properties: - network_name: net_mgmt - vendor: Apmec - - VL2: - type: tosca.nodes.mec.VL - properties: - network_name: net0 - vendor: Apmec diff --git a/apmec/tests/etc/samples/sample-tosca-mead-monitor.yaml b/apmec/tests/etc/samples/sample-tosca-mead-monitor.yaml deleted file mode 100644 index 61c2107..0000000 --- a/apmec/tests/etc/samples/sample-tosca-mead-monitor.yaml +++ /dev/null @@ -1,52 +0,0 @@ -tosca_definitions_version: tosca_simple_profile_for_mec_1_0_0 - -description: MEAD With Ping Monitor - -metadata: - template_name: sample-tosca-mead-monitor - -topology_template: - node_templates: - - VDU1: - type: tosca.nodes.mec.VDU.Apmec - properties: - image: cirros-0.3.5-x86_64-disk - flavor: m1.tiny - config: | - param0: key1 - param1: key2 - monitoring_policy: - name: ping - actions: - failure: respawn - parameters: - count: 3 - interval: 10 - monitoring_delay: 45 - timeout: 2 - config_drive: true - user_data_format: RAW - user_data: | - #!/bin/sh - echo "my hostname is `hostname`" > /tmp/hostname - df -h > /tmp/test.txt - sleep 90 - sudo ifdown eth0 - - CP1: - type: tosca.nodes.mec.CP.Apmec - properties: - management: true - anti_spoofing_protection: false - requirements: - - virtualLink: - node: VL1 - - virtualBinding: - node: VDU1 - - VL1: - type: tosca.nodes.mec.VL - properties: - network_name: net_mgmt - vendor: ACME diff --git a/apmec/tests/etc/samples/sample-tosca-mead-multi-vdu-monitoring.yaml b/apmec/tests/etc/samples/sample-tosca-mead-multi-vdu-monitoring.yaml deleted file mode 100644 index 563dec0..0000000 --- a/apmec/tests/etc/samples/sample-tosca-mead-multi-vdu-monitoring.yaml +++ /dev/null @@ -1,175 +0,0 @@ -tosca_definitions_version: tosca_simple_profile_for_mec_1_0_0 - -description: Multi VDU monitoring example - -metadata: - template_name: sample-tosca-multi-vdu-monitoring - -topology_template: - node_templates: - VDU1: - type: tosca.nodes.mec.VDU.Apmec - properties: - image: cirros-0.3.5-x86_64-disk - flavor: m1.tiny - availability_zone: nova - mgmt_driver: noop - config: | - param0: key1 - param1: key2 - mgmt_driver: noop - monitoring_policy: - name: ping - actions: - failure: respawn - parameters: - count: 3 - interval: 10 - monitoring_delay: 45 - timeout: 2 - - CP11: - type: tosca.nodes.mec.CP.Apmec - properties: - management: true - anti_spoofing_protection: True - requirements: - - virtualLink: - node: VL1 - - virtualBinding: - node: VDU1 - - CP12: - type: tosca.nodes.mec.CP.Apmec - properties: - anti_spoofing_protection: false - requirements: - - virtualLink: - node: VL2 - - virtualBinding: - node: VDU1 - - CP13: - type: tosca.nodes.mec.CP.Apmec - properties: - anti_spoofing_protection: false - requirements: - - virtualLink: - node: VL3 - - virtualBinding: - node: VDU1 - - VDU2: - type: tosca.nodes.mec.VDU.Apmec - properties: - image: cirros-0.3.5-x86_64-disk - flavor: m1.tiny - availability_zone: nova - mgmt_driver: noop - config: | - param0: key1 - param1: key2 - monitoring_policy: - name: ping - actions: - failure: respawn - parameters: - count: 3 - interval: 10 - monitoring_delay: 45 - timeout: 2 - - CP21: - type: tosca.nodes.mec.CP.Apmec - properties: - management: true - requirements: - - virtualLink: - node: VL1 - - virtualBinding: - node: VDU2 - - CP22: - type: tosca.nodes.mec.CP.Apmec - requirements: - - virtualLink: - node: VL2 - - virtualBinding: - node: VDU2 - - CP23: - type: tosca.nodes.mec.CP.Apmec - requirements: - - virtualLink: - node: VL3 - - virtualBinding: - node: VDU2 - - VDU3: - type: tosca.nodes.mec.VDU.Apmec - properties: - image: cirros-0.3.5-x86_64-disk - flavor: m1.tiny - availability_zone: nova - mgmt_driver: noop - monitoring_policy: - name: ping - actions: - failure: respawn - parameters: - count: 3 - interval: 10 - monitoring_delay: 45 - timeout: 2 - config_drive: true - user_data_format: RAW - user_data: | - #!/bin/sh - echo "my hostname is `hostname`" > /tmp/hostname - df -h > /home/cirros/diskinfo - sleep 90 - sudo ifdown eth0 - - CP31: - type: tosca.nodes.mec.CP.Apmec - properties: - management: true - requirements: - - virtualLink: - node: VL1 - - virtualBinding: - node: VDU3 - - CP32: - type: tosca.nodes.mec.CP.Apmec - requirements: - - virtualLink: - node: VL2 - - virtualBinding: - node: VDU3 - - CP33: - type: tosca.nodes.mec.CP.Apmec - requirements: - - virtualLink: - node: VL3 - - virtualBinding: - node: VDU3 - - VL1: - type: tosca.nodes.mec.VL - properties: - network_name: net_mgmt - vendor: Apmec - - VL2: - type: tosca.nodes.mec.VL - properties: - network_name: net0 - vendor: Apmec - - VL3: - type: tosca.nodes.mec.VL - properties: - network_name: net1 - vendor: Apmec diff --git a/apmec/tests/etc/samples/sample-tosca-mead-multi-vdu.yaml b/apmec/tests/etc/samples/sample-tosca-mead-multi-vdu.yaml deleted file mode 100644 index 2555167..0000000 --- a/apmec/tests/etc/samples/sample-tosca-mead-multi-vdu.yaml +++ /dev/null @@ -1,152 +0,0 @@ -tosca_definitions_version: tosca_simple_profile_for_mec_1_0_0 - -description: Demo example - -metadata: - template_name: sample-tosca-mead - -topology_template: - node_templates: - VDU1: - type: tosca.nodes.mec.VDU.Apmec - properties: - image: cirros-0.3.5-x86_64-disk - flavor: m1.tiny - availability_zone: nova - mgmt_driver: noop - config: | - param0: key1 - param1: key2 - - CP11: - type: tosca.nodes.mec.CP.Apmec - properties: - management: true - anti_spoofing_protection: false - requirements: - - virtualLink: - node: VL1 - - virtualBinding: - node: VDU1 - - CP12: - type: tosca.nodes.mec.CP.Apmec - properties: - anti_spoofing_protection: false - requirements: - - virtualLink: - node: VL2 - - virtualBinding: - node: VDU1 - - CP13: - type: tosca.nodes.mec.CP.Apmec - properties: - anti_spoofing_protection: false - requirements: - - virtualLink: - node: VL3 - - virtualBinding: - node: VDU1 - - VDU2: - type: tosca.nodes.mec.VDU.Apmec - properties: - image: cirros-0.3.5-x86_64-disk - flavor: m1.medium - availability_zone: nova - mgmt_driver: noop - config: | - param0: key1 - param1: key2 - - CP21: - type: tosca.nodes.mec.CP.Apmec - properties: - management: true - anti_spoofing_protection: false - requirements: - - virtualLink: - node: VL1 - - virtualBinding: - node: VDU2 - - CP22: - type: tosca.nodes.mec.CP.Apmec - properties: - anti_spoofing_protection: false - requirements: - - virtualLink: - node: VL2 - - virtualBinding: - node: VDU2 - - CP23: - type: tosca.nodes.mec.CP.Apmec - properties: - anti_spoofing_protection: false - requirements: - - virtualLink: - node: VL3 - - virtualBinding: - node: VDU2 - - VDU3: - type: tosca.nodes.mec.VDU.Apmec - properties: - image: cirros-0.3.5-x86_64-disk - flavor: m1.tiny - availability_zone: nova - mgmt_driver: noop - config: | - param0: key1 - param1: key2 - - CP31: - type: tosca.nodes.mec.CP.Apmec - properties: - management: true - anti_spoofing_protection: false - requirements: - - virtualLink: - node: VL1 - - virtualBinding: - node: VDU3 - - CP32: - type: tosca.nodes.mec.CP.Apmec - properties: - anti_spoofing_protection: false - requirements: - - virtualLink: - node: VL2 - - virtualBinding: - node: VDU3 - - CP33: - type: tosca.nodes.mec.CP.Apmec - properties: - anti_spoofing_protection: false - requirements: - - virtualLink: - node: VL3 - - virtualBinding: - node: VDU3 - - VL1: - type: tosca.nodes.mec.VL - properties: - network_name: net_mgmt - vendor: Apmec - - VL2: - type: tosca.nodes.mec.VL - properties: - network_name: net0 - vendor: Apmec - - VL3: - type: tosca.nodes.mec.VL - properties: - network_name: net1 - vendor: Apmec diff --git a/apmec/tests/etc/samples/sample-tosca-mead-param.yaml b/apmec/tests/etc/samples/sample-tosca-mead-param.yaml deleted file mode 100644 index eae5e62..0000000 --- a/apmec/tests/etc/samples/sample-tosca-mead-param.yaml +++ /dev/null @@ -1,101 +0,0 @@ -tosca_definitions_version: tosca_simple_profile_for_mec_1_0_0 - -description: MEA TOSCA template with input parameters - -metadata: - template_name: sample-tosca-mead - -topology_template: - inputs: - image_name: - type: string - description: Image Name - - flavor: - type: string - description: Flavor Information - - zone: - type: string - description: Zone Information - - network: - type: string - description: mgmt network - - management: - type: string - description: management network - - pkt_in_network: - type: string - description: In network - - pkt_out_network: - type: string - description: Out network - - vendor: - type: string - description: Vendor information - - node_templates: - VDU1: - type: tosca.nodes.mec.VDU.Apmec - properties: - image: { get_input: image_name} - flavor: {get_input: flavor} - availability_zone: { get_input: zone } - mgmt_driver: noop - config: | - param0: key1 - param1: key2 - - CP1: - type: tosca.nodes.mec.CP.Apmec - properties: - management: { get_input: management } - anti_spoofing_protection: false - requirements: - - virtualLink: - node: VL1 - - virtualBinding: - node: VDU1 - - CP2: - type: tosca.nodes.mec.CP.Apmec - properties: - anti_spoofing_protection: false - requirements: - - virtualLink: - node: VL2 - - virtualBinding: - node: VDU1 - - CP3: - type: tosca.nodes.mec.CP.Apmec - properties: - anti_spoofing_protection: false - requirements: - - virtualLink: - node: VL3 - - virtualBinding: - node: VDU1 - - VL1: - type: tosca.nodes.mec.VL - properties: - network_name: { get_input: network } - vendor: {get_input: vendor} - - VL2: - type: tosca.nodes.mec.VL - properties: - network_name: { get_input: pkt_in_network } - vendor: {get_input: vendor} - - VL3: - type: tosca.nodes.mec.VL - properties: - network_name: { get_input: pkt_out_network } - vendor: {get_input: vendor} diff --git a/apmec/tests/etc/samples/sample-tosca-mead-static-ip.yaml b/apmec/tests/etc/samples/sample-tosca-mead-static-ip.yaml deleted file mode 100644 index 84b55bc..0000000 --- a/apmec/tests/etc/samples/sample-tosca-mead-static-ip.yaml +++ /dev/null @@ -1,72 +0,0 @@ -tosca_definitions_version: tosca_simple_profile_for_mec_1_0_0 - -description: MEAD with predefined properties. - -topology_template: - node_templates: - - VDU1: - type: tosca.nodes.mec.VDU.Apmec - capabilities: - mec_compute: - properties: - num_cpus: 1 - mem_size: 512 MB - disk_size: 1 GB - properties: - image: cirros-0.3.5-x86_64-disk - availability_zone: nova - mgmt_driver: noop - config: | - param0: key1 - param1: key2 - - CP1: - type: tosca.nodes.mec.CP.Apmec - properties: - management: true - ip_address: 192.168.120.225 - anti_spoofing_protection: true - requirements: - - virtualLink: - node: VL1 - - virtualBinding: - node: VDU1 - - CP2: - type: tosca.nodes.mec.CP.Apmec - properties: - anti_spoofing_protection: false - requirements: - - virtualLink: - node: VL2 - - virtualBinding: - node: VDU1 - - CP3: - type: tosca.nodes.mec.CP.Apmec - properties: - anti_spoofing_protection: true - requirements: - - virtualLink: - node: VL3 - - virtualBinding: - node: VDU1 - - VL1: - type: tosca.nodes.mec.VL - properties: - vendor: ACME - network_name: net_mgmt - - VL2: - type: tosca.nodes.mec.VL - properties: - network_name: net0 - vendor: Apmec - - VL3: - type: tosca.nodes.mec.VL - properties: - network_name: net1 - vendor: Apmec diff --git a/apmec/tests/etc/samples/sample-tosca-mead.yaml b/apmec/tests/etc/samples/sample-tosca-mead.yaml deleted file mode 100644 index 48fb885..0000000 --- a/apmec/tests/etc/samples/sample-tosca-mead.yaml +++ /dev/null @@ -1,82 +0,0 @@ -tosca_definitions_version: tosca_simple_profile_for_mec_1_0_0 - -description: Demo example - -metadata: - template_name: sample-tosca-mead - -topology_template: - inputs: - vdu-name: - type: string - description: Vdu name - default: test-vdu - cp-name: - type: string - description: Cp name - default: test-cp - node_templates: - VDU1: - type: tosca.nodes.mec.VDU.Apmec - properties: - name: {get_input : vdu-name} - image: cirros-0.3.5-x86_64-disk - flavor: m1.tiny - key_name: userKey - availability_zone: nova - mgmt_driver: noop - config: | - param0: key1 - param1: key2 - - CP1: - type: tosca.nodes.mec.CP.Apmec - properties: - name: {get_input : cp-name} - management: true - anti_spoofing_protection: true - security_groups: - - test_secgrp - requirements: - - virtualLink: - node: VL1 - - virtualBinding: - node: VDU1 - - CP2: - type: tosca.nodes.mec.CP.Apmec - properties: - anti_spoofing_protection: false - requirements: - - virtualLink: - node: VL2 - - virtualBinding: - node: VDU1 - - CP3: - type: tosca.nodes.mec.CP.Apmec - properties: - anti_spoofing_protection: false - requirements: - - virtualLink: - node: VL3 - - virtualBinding: - node: VDU1 - - VL1: - type: tosca.nodes.mec.VL - properties: - network_name: net_mgmt - vendor: Apmec - - VL2: - type: tosca.nodes.mec.VL - properties: - network_name: net0 - vendor: Apmec - - VL3: - type: tosca.nodes.mec.VL - properties: - network_name: net1 - vendor: Apmec diff --git a/apmec/tests/etc/samples/sample-tosca-scale-all.yaml b/apmec/tests/etc/samples/sample-tosca-scale-all.yaml deleted file mode 100644 index 06427a9..0000000 --- a/apmec/tests/etc/samples/sample-tosca-scale-all.yaml +++ /dev/null @@ -1,50 +0,0 @@ - -tosca_definitions_version: tosca_simple_profile_for_mec_1_0_0 - -description: sample-tosca-mead-scaling - -metadata: - template_name: sample-tosca-mead-scaling - -topology_template: - node_templates: - VDU1: - type: tosca.nodes.mec.VDU.Apmec - capabilities: - mec_compute: - properties: - num_cpus: 1 - mem_size: 512 MB - disk_size: 1 GB - properties: - image: cirros-0.3.5-x86_64-disk - mgmt_driver: noop - availability_zone: nova - - CP1: - type: tosca.nodes.mec.CP.Apmec - properties: - management: true - anti_spoofing_protection: false - requirements: - - virtualLink: - node: VL1 - - virtualBinding: - node: VDU1 - - VL1: - type: tosca.nodes.mec.VL - properties: - network_name: net_mgmt - vendor: Apmec - - policies: - - SP1: - type: tosca.policies.apmec.Scaling - targets: [VDU1] - properties: - increment: 1 - cooldown: 60 - min_instances: 1 - max_instances: 3 - default_instances: 2 diff --git a/apmec/tests/etc/samples/sample_tosca_assign_floatingip_to_vdu.yaml b/apmec/tests/etc/samples/sample_tosca_assign_floatingip_to_vdu.yaml deleted file mode 100644 index 49d97ca..0000000 --- a/apmec/tests/etc/samples/sample_tosca_assign_floatingip_to_vdu.yaml +++ /dev/null @@ -1,44 +0,0 @@ -tosca_definitions_version: tosca_simple_profile_for_mec_1_0_0 - -description: Example Floating IP - Allocate one IP from floating network and attach to CP. - -metadata: - template_name: sample-tosca-mead-test-fip-with-floating-network - -topology_template: - node_templates: - VDU1: - type: tosca.nodes.mec.VDU.Apmec - capabilities: - mec_compute: - properties: - disk_size: 1 GB - mem_size: 512 MB - num_cpus: 1 - properties: - image: cirros-0.3.5-x86_64-disk - mgmt_driver: noop - - CP1: - type: tosca.nodes.mec.CP.Apmec - properties: - management: true - requirements: - - virtualLink: - node: VL1 - - virtualBinding: - node: VDU1 - - VL1: - type: tosca.nodes.mec.VL - properties: - network_name: net_mgmt - vendor: Apmec - - FIP1: - type: tosca.nodes.network.FloatingIP - properties: - floating_network: public - requirements: - - link: - node: CP1 \ No newline at end of file diff --git a/apmec/tests/etc/samples/sample_tosca_meac.yaml b/apmec/tests/etc/samples/sample_tosca_meac.yaml deleted file mode 100644 index 63b4d22..0000000 --- a/apmec/tests/etc/samples/sample_tosca_meac.yaml +++ /dev/null @@ -1,42 +0,0 @@ -tosca_definitions_version: tosca_simple_profile_for_mec_1_0_0 -metadata: - template_name: sample-tosca-mead-for-meac - -topology_template: - node_templates: - firewall_meac: - type: tosca.nodes.mec.MEAC.Apmec - requirements: - - host: VDU1 - interfaces: - Standard: - create: install_meac.sh - - VDU1: - type: tosca.nodes.mec.VDU.Apmec - properties: - flavor: m1.small - mgmt_driver: noop - config: | - param0: key1 - param1: key2 - artifacts: - fedora: - type: tosca.artifacts.Deployment.Image.VM - file: https://github.com/bharaththiruveedula/dotfiles/raw/master/fedora-sw.qcow2 - CP1: - type: tosca.nodes.mec.CP.Apmec - properties: - management: true - anti_spoofing_protection: false - requirements: - - virtualLink: - node: VL1 - - virtualBinding: - node: VDU1 - - VL1: - type: tosca.nodes.mec.VL - properties: - network_name: private - vendor: Apmec diff --git a/apmec/tests/etc/samples/test-ns-nsd.yaml b/apmec/tests/etc/samples/test-ns-nsd.yaml deleted file mode 100644 index d298982..0000000 --- a/apmec/tests/etc/samples/test-ns-nsd.yaml +++ /dev/null @@ -1,37 +0,0 @@ -tosca_definitions_version: tosca_simple_profile_for_mec_1_0_0 -imports: - - test-mes-mead1 - - test-mes-mead2 - -topology_template: - inputs: - vl1_name: - type: string - description: name of VL1 virtuallink - default: net_mgmt - vl2_name: - type: string - description: name of VL2 virtuallink - default: net0 - node_templates: - MEA1: - type: tosca.nodes.mec.MEA1 - requirements: - - virtualLink1: VL1 - - virtualLink2: VL2 - - MEA2: - type: tosca.nodes.mec.MEA2 - - VL1: - type: tosca.nodes.mec.VL - properties: - network_name: {get_input: vl1_name} - vendor: apmec - - VL2: - type: tosca.nodes.mec.VL - properties: - network_name: {get_input: vl2_name} - vendor: apmec - diff --git a/apmec/tests/etc/samples/test-ns-vnfd1.yaml b/apmec/tests/etc/samples/test-ns-vnfd1.yaml deleted file mode 100644 index f6c78b9..0000000 --- a/apmec/tests/etc/samples/test-ns-vnfd1.yaml +++ /dev/null @@ -1,98 +0,0 @@ -tosca_definitions_version: tosca_simple_profile_for_mec_1_0_0 - -description: Demo example -node_types: - tosca.nodes.mec.MEA1: - requirements: - - virtualLink1: - type: tosca.nodes.mec.VL - required: true - - virtualLink2: - type: tosca.nodes.mec.VL - required: true - capabilities: - forwader1: - type: tosca.capabilities.mec.Forwarder - forwader2: - type: tosca.capabilities.mec.Forwarder - -topology_template: - substitution_mappings: - node_type: tosca.nodes.mec.MEA1 - requirements: - virtualLink1: [CP11, virtualLink] - virtualLink2: [CP14, virtualLink] - capabilities: - forwarder1: [CP11, forwarder] - forwarder2: [CP14, forwarder] - - node_templates: - VDU1: - type: tosca.nodes.mec.VDU.Apmec - properties: - image: cirros-0.3.5-x86_64-disk - flavor: m1.tiny - availability_zone: nova - mgmt_driver: noop - config: | - param0: key1 - param1: key2 - - CP11: - type: tosca.nodes.mec.CP.Apmec - properties: - management: true - anti_spoofing_protection: false - requirements: - - virtualBinding: - node: VDU1 - - CP12: - type: tosca.nodes.mec.CP.Apmec - properties: - anti_spoofing_protection: false - requirements: - - virtualLink: - node: VL2 - - virtualBinding: - node: VDU1 - - VDU2: - type: tosca.nodes.mec.VDU.Apmec - properties: - image: cirros-0.3.5-x86_64-disk - flavor: m1.medium - availability_zone: nova - mgmt_driver: noop - config: | - param0: key1 - param1: key2 - - CP13: - type: tosca.nodes.mec.CP.Apmec - properties: - management: true - requirements: - - virtualLink: - node: VL1 - - virtualBinding: - node: VDU2 - - CP14: - type: tosca.nodes.mec.CP.Apmec - requirements: - - virtualBinding: - node: VDU2 - - VL1: - type: tosca.nodes.mec.VL - properties: - network_name: net_mgmt - vendor: Apmec - - VL2: - type: tosca.nodes.mec.VL - properties: - network_name: net0 - vendor: Apmec - diff --git a/apmec/tests/etc/samples/test-ns-vnfd2.yaml b/apmec/tests/etc/samples/test-ns-vnfd2.yaml deleted file mode 100644 index dedeb49..0000000 --- a/apmec/tests/etc/samples/test-ns-vnfd2.yaml +++ /dev/null @@ -1,68 +0,0 @@ -tosca_definitions_version: tosca_simple_profile_for_mec_1_0_0 - -description: Demo example - -node_types: - tosca.nodes.mec.MEA2: - capabilities: - forwarder1: - type: tosca.capabilities.mec.Forwarder -topology_template: - substitution_mappings: - node_type: tosca.nodes.mec.MEA2 - capabilities: - forwarder1: [CP21, forwarder] - node_templates: - VDU1: - type: tosca.nodes.mec.VDU.Apmec - properties: - image: cirros-0.3.5-x86_64-disk - flavor: m1.tiny - availability_zone: nova - mgmt_driver: noop - config: | - param0: key1 - param1: key2 - - CP21: - type: tosca.nodes.mec.CP.Apmec - properties: - management: true - anti_spoofing_protection: false - requirements: - - virtualLink: - node: VL1 - - virtualBinding: - node: VDU1 - - VDU2: - type: tosca.nodes.mec.VDU.Apmec - properties: - image: cirros-0.3.5-x86_64-disk - flavor: m1.medium - availability_zone: nova - mgmt_driver: noop - config: | - param0: key1 - param1: key2 - - CP22: - type: tosca.nodes.mec.CP.Apmec - requirements: - - virtualLink: - node: VL2 - - virtualBinding: - node: VDU2 - - VL1: - type: tosca.nodes.mec.VL - properties: - network_name: net_mgmt - vendor: Apmec - - VL2: - type: tosca.nodes.mec.VL - properties: - network_name: net0 - vendor: Apmec - diff --git a/apmec/tests/etc/samples/test-nsd-vnfd1.yaml b/apmec/tests/etc/samples/test-nsd-vnfd1.yaml deleted file mode 100644 index f6c78b9..0000000 --- a/apmec/tests/etc/samples/test-nsd-vnfd1.yaml +++ /dev/null @@ -1,98 +0,0 @@ -tosca_definitions_version: tosca_simple_profile_for_mec_1_0_0 - -description: Demo example -node_types: - tosca.nodes.mec.MEA1: - requirements: - - virtualLink1: - type: tosca.nodes.mec.VL - required: true - - virtualLink2: - type: tosca.nodes.mec.VL - required: true - capabilities: - forwader1: - type: tosca.capabilities.mec.Forwarder - forwader2: - type: tosca.capabilities.mec.Forwarder - -topology_template: - substitution_mappings: - node_type: tosca.nodes.mec.MEA1 - requirements: - virtualLink1: [CP11, virtualLink] - virtualLink2: [CP14, virtualLink] - capabilities: - forwarder1: [CP11, forwarder] - forwarder2: [CP14, forwarder] - - node_templates: - VDU1: - type: tosca.nodes.mec.VDU.Apmec - properties: - image: cirros-0.3.5-x86_64-disk - flavor: m1.tiny - availability_zone: nova - mgmt_driver: noop - config: | - param0: key1 - param1: key2 - - CP11: - type: tosca.nodes.mec.CP.Apmec - properties: - management: true - anti_spoofing_protection: false - requirements: - - virtualBinding: - node: VDU1 - - CP12: - type: tosca.nodes.mec.CP.Apmec - properties: - anti_spoofing_protection: false - requirements: - - virtualLink: - node: VL2 - - virtualBinding: - node: VDU1 - - VDU2: - type: tosca.nodes.mec.VDU.Apmec - properties: - image: cirros-0.3.5-x86_64-disk - flavor: m1.medium - availability_zone: nova - mgmt_driver: noop - config: | - param0: key1 - param1: key2 - - CP13: - type: tosca.nodes.mec.CP.Apmec - properties: - management: true - requirements: - - virtualLink: - node: VL1 - - virtualBinding: - node: VDU2 - - CP14: - type: tosca.nodes.mec.CP.Apmec - requirements: - - virtualBinding: - node: VDU2 - - VL1: - type: tosca.nodes.mec.VL - properties: - network_name: net_mgmt - vendor: Apmec - - VL2: - type: tosca.nodes.mec.VL - properties: - network_name: net0 - vendor: Apmec - diff --git a/apmec/tests/etc/samples/test-nsd-vnfd2.yaml b/apmec/tests/etc/samples/test-nsd-vnfd2.yaml deleted file mode 100644 index dedeb49..0000000 --- a/apmec/tests/etc/samples/test-nsd-vnfd2.yaml +++ /dev/null @@ -1,68 +0,0 @@ -tosca_definitions_version: tosca_simple_profile_for_mec_1_0_0 - -description: Demo example - -node_types: - tosca.nodes.mec.MEA2: - capabilities: - forwarder1: - type: tosca.capabilities.mec.Forwarder -topology_template: - substitution_mappings: - node_type: tosca.nodes.mec.MEA2 - capabilities: - forwarder1: [CP21, forwarder] - node_templates: - VDU1: - type: tosca.nodes.mec.VDU.Apmec - properties: - image: cirros-0.3.5-x86_64-disk - flavor: m1.tiny - availability_zone: nova - mgmt_driver: noop - config: | - param0: key1 - param1: key2 - - CP21: - type: tosca.nodes.mec.CP.Apmec - properties: - management: true - anti_spoofing_protection: false - requirements: - - virtualLink: - node: VL1 - - virtualBinding: - node: VDU1 - - VDU2: - type: tosca.nodes.mec.VDU.Apmec - properties: - image: cirros-0.3.5-x86_64-disk - flavor: m1.medium - availability_zone: nova - mgmt_driver: noop - config: | - param0: key1 - param1: key2 - - CP22: - type: tosca.nodes.mec.CP.Apmec - requirements: - - virtualLink: - node: VL2 - - virtualBinding: - node: VDU2 - - VL1: - type: tosca.nodes.mec.VL - properties: - network_name: net_mgmt - vendor: Apmec - - VL2: - type: tosca.nodes.mec.VL - properties: - network_name: net0 - vendor: Apmec - diff --git a/apmec/tests/etc/samples/test-nsd.yaml b/apmec/tests/etc/samples/test-nsd.yaml deleted file mode 100644 index d6fa35f..0000000 --- a/apmec/tests/etc/samples/test-nsd.yaml +++ /dev/null @@ -1,37 +0,0 @@ -tosca_definitions_version: tosca_simple_profile_for_mec_1_0_0 -imports: - - test-mesd-mead1 - - test-mesd-mead2 - -topology_template: - inputs: - vl1_name: - type: string - description: name of VL1 virtuallink - default: net_mgmt - vl2_name: - type: string - description: name of VL2 virtuallink - default: net0 - node_templates: - MEA1: - type: tosca.nodes.mec.MEA1 - requirements: - - virtualLink1: VL1 - - virtualLink2: VL2 - - MEA2: - type: tosca.nodes.mec.MEA2 - - VL1: - type: tosca.nodes.mec.VL - properties: - network_name: {get_input: vl1_name} - vendor: apmec - - VL2: - type: tosca.nodes.mec.VL - properties: - network_name: {get_input: vl2_name} - vendor: apmec - diff --git a/apmec/tests/functional/clients.py b/apmec/tests/functional/clients.py index e0d8928..5c9c3f0 100644 --- a/apmec/tests/functional/clients.py +++ b/apmec/tests/functional/clients.py @@ -10,8 +10,8 @@ # License for the specific language governing permissions and limitations # under the License. -from heatclient import client as heatclient from apmec.tests.functional import keystone +from heatclient import client as heatclient class OpenstackClients(object): diff --git a/apmec/tests/functional/mem/__init__.py b/apmec/tests/functional/mem/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/apmec/tests/functional/mem/test_mea.py b/apmec/tests/functional/mem/test_mea.py deleted file mode 100644 index 07970e2..0000000 --- a/apmec/tests/functional/mem/test_mea.py +++ /dev/null @@ -1,106 +0,0 @@ -# Copyright 2015 Brocade Communications System, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, 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. - -from oslo_config import cfg - -from apmec.plugins.common import constants as evt_constants -from apmec.tests import constants -from apmec.tests.functional import base -from apmec.tests.utils import read_file - -CONF = cfg.CONF -MEA_CIRROS_CREATE_TIMEOUT = 120 - - -class MeaTestCreate(base.BaseApmecTest): - def _test_create_delete_mea(self, mea_name, mead_name, vim_id=None): - data = dict() - data['tosca'] = read_file('sample-tosca-mead-no-monitor.yaml') - toscal = data['tosca'] - tosca_arg = {'mead': {'name': mead_name, - 'attributes': {'mead': toscal}}} - - # Create mead with tosca template - mead_instance = self.client.create_mead(body=tosca_arg) - self.assertIsNotNone(mead_instance) - - # Create mea with mead_id - mead_id = mead_instance['mead']['id'] - mea_arg = {'mea': {'mead_id': mead_id, 'name': mea_name}} - if vim_id: - mea_arg['mea']['vim_id'] = vim_id - mea_instance = self.client.create_mea(body=mea_arg) - self.validate_mea_instance(mead_instance, mea_instance) - - mea_id = mea_instance['mea']['id'] - self.wait_until_mea_active( - mea_id, - constants.MEA_CIRROS_CREATE_TIMEOUT, - constants.ACTIVE_SLEEP_TIME) - self.assertIsNotNone(self.client.show_mea(mea_id)['mea']['mgmt_url']) - if vim_id: - self.assertEqual(vim_id, mea_instance['mea']['vim_id']) - - # Get mea details when mea is in active state - mea_details = self.client.list_mea_resources(mea_id)['resources'][0] - self.assertIn('name', mea_details) - self.assertIn('id', mea_details) - self.assertIn('type', mea_details) - - self.verify_mea_crud_events( - mea_id, evt_constants.RES_EVT_CREATE, - evt_constants.PENDING_CREATE, cnt=2) - self.verify_mea_crud_events( - mea_id, evt_constants.RES_EVT_CREATE, evt_constants.ACTIVE) - - # update VIM name when MEAs are active. - # check for exception. - vim0_id = mea_instance['mea']['vim_id'] - msg = "VIM %s is still in use by MEA" % vim0_id - try: - update_arg = {'vim': {'name': "mea_vim"}} - self.client.update_vim(vim0_id, update_arg) - except Exception as err: - self.assertEqual(err.message, msg) - else: - self.assertTrue( - False, - "Name of vim(s) with active mea(s) should not be changed!") - - # Delete mea_instance with mea_id - try: - self.client.delete_mea(mea_id) - except Exception: - assert False, "mea Delete failed" - - self.wait_until_mea_delete(mea_id, - constants.MEA_CIRROS_DELETE_TIMEOUT) - self.verify_mea_crud_events(mea_id, evt_constants.RES_EVT_DELETE, - evt_constants.PENDING_DELETE, cnt=2) - - # Delete mead_instance - self.addCleanup(self.client.delete_mead, mead_id) - - def test_create_delete_mea_with_default_vim(self): - self._test_create_delete_mea( - mea_name='test_mea_with_cirros_no_monitoring_default_vim', - mead_name='sample_cirros_mea_no_monitoring_default_vim') - - def test_create_delete_mea_with_vim_id(self): - vim_list = self.client.list_vims() - vim0_id = self.get_vim(vim_list, 'VIM0')['id'] - self._test_create_delete_mea( - vim_id=vim0_id, - mea_name='test_mea_with_cirros_vim_id', - mead_name='sample_cirros_mea_no_monitoring_vim_id') diff --git a/apmec/tests/functional/mem/test_mea_monitoring.py b/apmec/tests/functional/mem/test_mea_monitoring.py deleted file mode 100644 index 38b20d0..0000000 --- a/apmec/tests/functional/mem/test_mea_monitoring.py +++ /dev/null @@ -1,67 +0,0 @@ -# Copyright 2015 Brocade Communications System, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, 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. - -from apmec.plugins.common import constants as evt_constants -from apmec.tests import constants -from apmec.tests.functional import base -from apmec.tests.utils import read_file - - -class MeaTestPingMonitor(base.BaseApmecTest): - - def _test_mea_with_monitoring(self, mead_file, mea_name): - data = dict() - data['tosca'] = read_file(mead_file) - toscal = data['tosca'] - tosca_arg = {'mead': {'name': mea_name, - 'attributes': {'mead': toscal}}} - - # Create mead with tosca template - mead_instance = self.client.create_mead(body=tosca_arg) - self.assertIsNotNone(mead_instance) - - # Create mea with mead_id - mead_id = mead_instance['mead']['id'] - mea_arg = {'mea': {'mead_id': mead_id, 'name': mea_name}} - mea_instance = self.client.create_mea(body=mea_arg) - - # Verify mea goes from ACTIVE->DEAD->ACTIVE states - self.verify_mea_restart(mead_instance, mea_instance) - - # Delete mea_instance with mea_id - mea_id = mea_instance['mea']['id'] - try: - self.client.delete_mea(mea_id) - except Exception: - assert False, ("Failed to delete mea %s after the monitor test" % - mea_id) - - # Verify MEA monitor events captured for states, ACTIVE and DEAD - mea_state_list = [evt_constants.ACTIVE, evt_constants.DEAD] - self.verify_mea_monitor_events(mea_id, mea_state_list) - - # Delete mead_instance - self.addCleanup(self.client.delete_mead, mead_id) - self.addCleanup(self.wait_until_mea_delete, mea_id, - constants.MEA_CIRROS_DELETE_TIMEOUT) - - def test_create_delete_mea_monitoring_tosca_template(self): - self._test_mea_with_monitoring( - 'sample-tosca-mead-monitor.yaml', - 'ping monitor mea with tosca template') - - def test_create_delete_mea_multi_vdu_monitoring_tosca_template(self): - self._test_mea_with_monitoring( - 'sample-tosca-mead-multi-vdu-monitoring.yaml', - 'ping monitor multi vdu mea with tosca template') diff --git a/apmec/tests/functional/mem/test_mem_param.py b/apmec/tests/functional/mem/test_mem_param.py deleted file mode 100644 index a2cb433..0000000 --- a/apmec/tests/functional/mem/test_mem_param.py +++ /dev/null @@ -1,129 +0,0 @@ -# Copyright 2015 Brocade Communications System, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, 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 yaml - -from apmec.plugins.common import constants as evt_constants -from apmec.tests import constants -from apmec.tests.functional import base -from apmec.tests.utils import read_file - - -class MemTestParam(base.BaseApmecTest): - def _test_mead_create(self, mead_file, mead_name): - yaml_input = read_file(mead_file) - req_dict = {'mead': {'name': mead_name, - 'attributes': {'mead': yaml_input}}} - - # Create mead - mead_instance = self.client.create_mead(body=req_dict) - self.assertIsNotNone(mead_instance) - mead_id = mead_instance['mead']['id'] - self.assertIsNotNone(mead_id) - self.verify_mead_events( - mead_id, evt_constants.RES_EVT_CREATE, - evt_constants.RES_EVT_ONBOARDED) - return mead_instance - - def _test_mead_delete(self, mead_instance): - # Delete mead - mead_id = mead_instance['mead']['id'] - self.assertIsNotNone(mead_id) - try: - self.client.delete_mead(mead_id) - except Exception: - assert False, "mead Delete failed" - self.verify_mead_events(mead_id, evt_constants.RES_EVT_DELETE, - evt_constants.RES_EVT_NA_STATE) - try: - mead_d = self.client.show_mead(mead_id) - except Exception: - assert True, "Mead Delete success" + str(mead_d) + str(Exception) - - def _test_mea_create(self, mead_instance, mea_name, param_values): - # Create the mea with values - mead_id = mead_instance['mead']['id'] - # Create mea with values file - mea_dict = dict() - mea_dict = {'mea': {'mead_id': mead_id, 'name': mea_name, - 'attributes': {'param_values': param_values}}} - mea_instance = self.client.create_mea(body=mea_dict) - - self.validate_mea_instance(mead_instance, mea_instance) - mea_id = mea_instance['mea']['id'] - self.wait_until_mea_active( - mea_id, - constants.MEA_CIRROS_CREATE_TIMEOUT, - constants.ACTIVE_SLEEP_TIME) - self.assertIsNotNone(self.client.show_mea(mea_id)['mea']['mgmt_url']) - mea_instance = self.client.show_mea(mea_id) - - self.verify_mea_crud_events( - mea_id, evt_constants.RES_EVT_CREATE, - evt_constants.PENDING_CREATE, cnt=2) - self.verify_mea_crud_events( - mea_id, evt_constants.RES_EVT_CREATE, evt_constants.ACTIVE) - - # Verify values dictionary is same as param values from mea_show - - param_values = mea_instance['mea']['attributes']['param_values'] - param_values_dict = yaml.safe_load(param_values) - - return mea_instance, param_values_dict - - def _test_mea_delete(self, mea_instance): - # Delete Mea - mea_id = mea_instance['mea']['id'] - try: - self.client.delete_mea(mea_id) - except Exception: - assert False, "mea Delete failed" - self.wait_until_mea_delete(mea_id, - constants.MEA_CIRROS_DELETE_TIMEOUT) - self.verify_mea_crud_events(mea_id, evt_constants.RES_EVT_DELETE, - evt_constants.PENDING_DELETE, cnt=2) - - try: - mea_d = self.client.show_mea(mea_id) - except Exception: - assert True, "Mea Delete success" + str(mea_d) + str(Exception) - - def test_mead_param_tosca_template(self): - mead_name = 'sample_cirros_mead_tosca' - mead_instance = self._test_mead_create( - 'sample-tosca-mead-param.yaml', mead_name) - self._test_mead_delete(mead_instance) - - def test_mea_param_tosca_template(self): - mead_name = 'cirros_mead_tosca_param' - mead_instance = self._test_mead_create( - 'sample-tosca-mead-param.yaml', mead_name) - values_str = read_file('sample-tosca-mea-values.yaml') - values_dict = yaml.safe_load(values_str) - mea_instance, param_values_dict = self._test_mea_create(mead_instance, - 'test_mea_with_parameters_tosca_template', - values_dict) - self.assertEqual(values_dict, param_values_dict) - self._test_mea_delete(mea_instance) - mea_id = mea_instance['mea']['id'] - self.verify_mea_crud_events( - mea_id, evt_constants.RES_EVT_CREATE, - evt_constants.PENDING_CREATE, cnt=2) - self.verify_mea_crud_events( - mea_id, evt_constants.RES_EVT_CREATE, evt_constants.ACTIVE) - self.wait_until_mea_delete(mea_id, - constants.MEA_CIRROS_DELETE_TIMEOUT) - self.verify_mea_crud_events(mea_id, evt_constants.RES_EVT_DELETE, - evt_constants.PENDING_DELETE, cnt=2) - self.addCleanup(self.client.delete_mead, mead_instance['mead']['id']) diff --git a/apmec/tests/functional/mem/test_tosca_mea.py b/apmec/tests/functional/mem/test_tosca_mea.py deleted file mode 100644 index e5f175e..0000000 --- a/apmec/tests/functional/mem/test_tosca_mea.py +++ /dev/null @@ -1,282 +0,0 @@ -# Copyright 2016 Brocade Communications System, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, 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 time -import unittest -import yaml - -from novaclient import exceptions -from oslo_config import cfg - -from apmec.plugins.common import constants as evt_constants -from apmec.tests import constants -from apmec.tests.functional import base -from apmec.tests.utils import read_file - - -CONF = cfg.CONF -MEA_CIRROS_CREATE_TIMEOUT = 120 - - -class MeaTestToscaCreate(base.BaseApmecTest): - def _test_create_mea(self, mead_file, mea_name, - template_source="onboarded"): - data = dict() - values_str = read_file(mead_file) - data['tosca'] = values_str - toscal = data['tosca'] - tosca_arg = {'mead': {'name': mea_name, - 'attributes': {'mead': toscal}}} - - if template_source == "onboarded": - # Create mead with tosca template - mead_instance = self.client.create_mead(body=tosca_arg) - self.assertIsNotNone(mead_instance) - - # Create mea with mead_id - mead_id = mead_instance['mead']['id'] - mea_arg = {'mea': {'mead_id': mead_id, 'name': mea_name}} - mea_instance = self.client.create_mea(body=mea_arg) - self.validate_mea_instance(mead_instance, mea_instance) - - if template_source == 'inline': - # create mea directly from template - template = yaml.safe_load(values_str) - mea_arg = {'mea': {'mead_template': template, 'name': mea_name}} - mea_instance = self.client.create_mea(body=mea_arg) - mead_id = mea_instance['mea']['mead_id'] - - mea_id = mea_instance['mea']['id'] - self.wait_until_mea_active( - mea_id, - constants.MEA_CIRROS_CREATE_TIMEOUT, - constants.ACTIVE_SLEEP_TIME) - mea_show_out = self.client.show_mea(mea_id)['mea'] - self.assertIsNotNone(mea_show_out['mgmt_url']) - - input_dict = yaml.safe_load(values_str) - prop_dict = input_dict['topology_template']['node_templates'][ - 'CP1']['properties'] - - # Verify if ip_address is static, it is same as in show_mea - if prop_dict.get('ip_address'): - mgmt_url_input = prop_dict.get('ip_address') - mgmt_info = yaml.safe_load( - mea_show_out['mgmt_url']) - self.assertEqual(mgmt_url_input, mgmt_info['VDU1']) - - # Verify anti spoofing settings - stack_id = mea_show_out['instance_id'] - template_dict = input_dict['topology_template']['node_templates'] - for field in template_dict.keys(): - prop_dict = template_dict[field]['properties'] - if prop_dict.get('anti_spoofing_protection'): - self.verify_antispoofing_in_stack(stack_id=stack_id, - resource_name=field) - - self.verify_mea_crud_events( - mea_id, evt_constants.RES_EVT_CREATE, - evt_constants.PENDING_CREATE, cnt=2) - self.verify_mea_crud_events( - mea_id, evt_constants.RES_EVT_CREATE, evt_constants.ACTIVE) - return mead_id, mea_id - - def _test_delete_mea(self, mea_id): - # Delete mea_instance with mea_id - try: - self.client.delete_mea(mea_id) - except Exception: - assert False, "mea Delete failed" - - self.wait_until_mea_delete(mea_id, - constants.MEA_CIRROS_DELETE_TIMEOUT) - self.verify_mea_crud_events(mea_id, evt_constants.RES_EVT_DELETE, - evt_constants.PENDING_DELETE, cnt=2) - - def _test_cleanup_mead(self, mead_id, mea_id): - # Delete mead_instance - self.addCleanup(self.client.delete_mead, mead_id) - self.addCleanup(self.wait_until_mea_delete, mea_id, - constants.MEA_CIRROS_DELETE_TIMEOUT) - - def _test_create_delete_mea_tosca(self, mead_file, mea_name, - template_source): - mead_id, mea_id = self._test_create_mea(mead_file, mea_name, - template_source) - servers = self.novaclient().servers.list() - vdus = [] - for server in servers: - vdus.append(server.name) - self.assertIn('test-vdu', vdus) - - port_list = self.neutronclient().list_ports()['ports'] - vdu_ports = [] - for port in port_list: - vdu_ports.append(port['name']) - self.assertIn('test-cp', vdu_ports) - self._test_delete_mea(mea_id) - if template_source == "onboarded": - self._test_cleanup_mead(mead_id, mea_id) - - def test_create_delete_mea_tosca_from_mead(self): - self._test_create_delete_mea_tosca('sample-tosca-mead.yaml', - 'test_tosca_mea_with_cirros', - 'onboarded') - - def test_create_delete_mea_from_template(self): - self._test_create_delete_mea_tosca('sample-tosca-mead.yaml', - 'test_tosca_mea_with_cirros_inline', - 'inline') - - def test_re_create_delete_mea(self): - self._test_create_delete_mea_tosca('sample-tosca-mead.yaml', - 'test_mea', - 'inline') - time.sleep(1) - self._test_create_delete_mea_tosca('sample-tosca-mead.yaml', - 'test_mea', - 'inline') - - def test_create_delete_mea_static_ip(self): - mead_id, mea_id = self._test_create_mea( - 'sample-tosca-mead-static-ip.yaml', - 'test_tosca_mea_with_cirros_no_monitoring') - self._test_delete_mea(mea_id) - self._test_cleanup_mead(mead_id, mea_id) - - -class MeaTestToscaCreateFlavorCreation(base.BaseApmecTest): - def test_create_delete_mea_tosca_no_monitoring(self): - mead_name = 'tosca_mead_with_auto_flavor' - input_yaml = read_file('sample-tosca-mead-flavor.yaml') - tosca_dict = yaml.safe_load(input_yaml) - tosca_arg = {'mead': {'name': mead_name, 'attributes': {'mead': - tosca_dict}}} - - # Create mead with tosca template - mead_instance = self.client.create_mead(body=tosca_arg) - self.assertIsNotNone(mead_instance) - - # Create mea with mead_id - mea_name = 'tosca_mea_with_auto_flavor' - mead_id = mead_instance['mead']['id'] - mea_arg = {'mea': {'mead_id': mead_id, 'name': mea_name}} - mea_instance = self.client.create_mea(body=mea_arg) - - self.validate_mea_instance(mead_instance, mea_instance) - - mea_id = mea_instance['mea']['id'] - self.wait_until_mea_active( - mea_id, - constants.MEA_CIRROS_CREATE_TIMEOUT, - constants.ACTIVE_SLEEP_TIME) - self.assertIsNotNone(self.client.show_mea(mea_id)['mea']['mgmt_url']) - - self.verify_mea_crud_events( - mea_id, evt_constants.RES_EVT_CREATE, - evt_constants.PENDING_CREATE, cnt=2) - self.verify_mea_crud_events( - mea_id, evt_constants.RES_EVT_CREATE, evt_constants.ACTIVE) - - servers = self.novaclient().servers.list() - vdu_server = None - for server in servers: - if 'VDU1_flavor_func' in server.name: - vdu_server = server - break - self.assertIsNotNone(vdu_server) - flavor_id = server.flavor["id"] - nova_flavors = self.novaclient().flavors - flavor = nova_flavors.get(flavor_id) - self.assertIsNotNone(flavor) - self.assertEqual(True, "VDU1_flavor_func_flavor" in flavor.name) - # Delete mea_instance with mea_id - try: - self.client.delete_mea(mea_id) - except Exception: - assert False, "mea Delete failed" - - self.wait_until_mea_delete(mea_id, - constants.MEA_CIRROS_DELETE_TIMEOUT) - self.verify_mea_crud_events(mea_id, evt_constants.RES_EVT_DELETE, - evt_constants.PENDING_DELETE, cnt=2) - - # Delete mead_instance - self.addCleanup(self.client.delete_mead, mead_id) - self.assertRaises(exceptions.NotFound, nova_flavors.delete, - [flavor_id]) - - -class MeaTestToscaCreateImageCreation(base.BaseApmecTest): - - @unittest.skip("Until BUG 1673099") - def test_create_delete_mea_tosca_no_monitoring(self): - mead_name = 'tosca_mead_with_auto_image' - input_yaml = read_file('sample-tosca-mead-image.yaml') - tosca_dict = yaml.safe_load(input_yaml) - tosca_arg = {'mead': {'name': mead_name, 'attributes': {'mead': - tosca_dict}}} - - # Create mead with tosca template - mead_instance = self.client.create_mead(body=tosca_arg) - self.assertIsNotNone(mead_instance) - - # Create mea with mead_id - mead_id = mead_instance['mead']['id'] - mea_name = 'tosca_mea_with_auto_image' - mea_arg = {'mea': {'mead_id': mead_id, 'name': mea_name}} - mea_instance = self.client.create_mea(body=mea_arg) - - self.validate_mea_instance(mead_instance, mea_instance) - - mea_id = mea_instance['mea']['id'] - self.wait_until_mea_active( - mea_id, - constants.MEA_CIRROS_CREATE_TIMEOUT, - constants.ACTIVE_SLEEP_TIME) - self.assertIsNotNone(self.client.show_mea(mea_id)['mea']['mgmt_url']) - - self.verify_mea_crud_events( - mea_id, evt_constants.RES_EVT_CREATE, - evt_constants.PENDING_CREATE, cnt=2) - self.verify_mea_crud_events( - mea_id, evt_constants.RES_EVT_CREATE, evt_constants.ACTIVE) - - servers = self.novaclient().servers.list() - vdu_server = None - for server in servers: - if 'VDU1_image_func' in server.name: - vdu_server = server - break - self.assertIsNotNone(vdu_server) - image_id = vdu_server.image["id"] - nova_images = self.novaclient().images - image = nova_images.get(image_id) - self.assertIsNotNone(image) - self.assertEqual(True, "MEAImage_image_func" in image.name) - # Delete mea_instance with mea_id - try: - self.client.delete_mea(mea_id) - except Exception: - assert False, "mea Delete failed" - - self.wait_until_mea_delete(mea_id, - constants.MEA_CIRROS_DELETE_TIMEOUT) - self.verify_mea_crud_events(mea_id, evt_constants.RES_EVT_DELETE, - evt_constants.PENDING_DELETE, cnt=2) - - # Delete mead_instance - self.addCleanup(self.client.delete_mead, mead_id) - self.assertRaises(exceptions.NotFound, nova_images.delete, - [image_id]) diff --git a/apmec/tests/functional/mem/test_tosca_mea_alarm.py b/apmec/tests/functional/mem/test_tosca_mea_alarm.py deleted file mode 100644 index 539d89e..0000000 --- a/apmec/tests/functional/mem/test_tosca_mea_alarm.py +++ /dev/null @@ -1,151 +0,0 @@ -# -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, 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 json -import time -import unittest - -from apmec.plugins.common import constants as evt_constants -from apmec.tests import constants -from apmec.tests.functional import base -from apmec.tests.utils import read_file - -import yaml - - -class MeaTestAlarmMonitor(base.BaseApmecTest): - - def _test_mea_tosca_alarm(self, mead_file, mea_name): - mea_trigger_path = '/meas/%s/triggers' - data = dict() - data['tosca'] = read_file(mead_file) - tosca_dict = yaml.safe_load(data['tosca']) - toscal = data['tosca'] - tosca_arg = {'mead': {'name': mea_name, - 'attributes': {'mead': toscal}}} - - # Create mead with tosca template - mead_instance = self.client.create_mead(body=tosca_arg) - self.assertIsNotNone(mead_instance) - - # Create mea with mead_id - mead_id = mead_instance['mead']['id'] - mea_arg = {'mea': {'mead_id': mead_id, 'name': mea_name}} - mea_instance = self.client.create_mea(body=mea_arg) - - self.validate_mea_instance(mead_instance, mea_instance) - - mea_id = mea_instance['mea']['id'] - - def _waiting_time(count): - self.wait_until_mea_active( - mea_id, - constants.MEA_CIRROS_CREATE_TIMEOUT, - constants.ACTIVE_SLEEP_TIME) - mea = self.client.show_mea(mea_id)['mea'] - # {"VDU1": ["10.0.0.14", "10.0.0.5"]} - self.assertEqual(count, len(json.loads(mea['mgmt_url'])['VDU1'])) - - def trigger_mea(mea, policy_name, policy_action): - credential = 'g0jtsxu9' - body = {"trigger": {'policy_name': policy_name, - 'action_name': policy_action, - 'params': { - 'data': {'alarm_id': '35a80852-e24f-46ed-bd34-e2f831d00172', 'current': 'alarm'}, # noqa - 'credential': credential} - } - } - self.client.post(mea_trigger_path % mea, body) - - def _inject_monitoring_policy(mead_dict): - polices = mead_dict['topology_template'].get('policies', []) - mon_policy = dict() - for policy_dict in polices: - for name, policy in policy_dict.items(): - if policy['type'] == constants.POLICY_ALARMING: - triggers = policy['triggers'] - for trigger_name, trigger_dict in triggers.items(): - policy_action_list = trigger_dict['action'] - for policy_action_name in policy_action_list: - mon_policy[trigger_name] = policy_action_name - return mon_policy - - def verify_policy(policy_dict, kw_policy): - for name, action in policy_dict.items(): - if kw_policy in name: - return name - - # trigger alarm - monitoring_policy = _inject_monitoring_policy(tosca_dict) - for mon_policy_name, mon_policy_action in monitoring_policy.items(): - if mon_policy_action in constants.DEFAULT_ALARM_ACTIONS: - self.wait_until_mea_active( - mea_id, - constants.MEA_CIRROS_CREATE_TIMEOUT, - constants.ACTIVE_SLEEP_TIME) - trigger_mea(mea_id, mon_policy_name, mon_policy_action) - else: - if 'scaling_out' in mon_policy_name: - _waiting_time(2) - time.sleep(constants.SCALE_WINDOW_SLEEP_TIME) - # scaling-out backend action - scaling_out_action = mon_policy_action + '-out' - trigger_mea(mea_id, mon_policy_name, scaling_out_action) - - _waiting_time(3) - - scaling_in_name = verify_policy(monitoring_policy, - kw_policy='scaling_in') - if scaling_in_name: - time.sleep(constants.SCALE_WINDOW_SLEEP_TIME) - # scaling-in backend action - scaling_in_action = mon_policy_action + '-in' - trigger_mea(mea_id, scaling_in_name, scaling_in_action) - - _waiting_time(2) - - self.verify_mea_crud_events( - mea_id, evt_constants.RES_EVT_SCALE, - evt_constants.ACTIVE, cnt=2) - self.verify_mea_crud_events( - mea_id, evt_constants.RES_EVT_SCALE, - evt_constants.PENDING_SCALE_OUT, cnt=1) - self.verify_mea_crud_events( - mea_id, evt_constants.RES_EVT_SCALE, - evt_constants.PENDING_SCALE_IN, cnt=1) - # Delete mea_instance with mea_id - try: - self.client.delete_mea(mea_id) - except Exception: - assert False, ("Failed to delete mea %s after the monitor test" % - mea_id) - - # Verify MEA monitor events captured for states, ACTIVE and DEAD - mea_state_list = [evt_constants.ACTIVE, evt_constants.DEAD] - self.verify_mea_monitor_events(mea_id, mea_state_list) - - # Delete mead_instance - self.addCleanup(self.client.delete_mead, mead_id) - self.addCleanup(self.wait_until_mea_delete, mea_id, - constants.MEA_CIRROS_DELETE_TIMEOUT) - - def test_mea_alarm_respawn(self): - self._test_mea_tosca_alarm( - 'sample-tosca-alarm-respawn.yaml', - 'alarm and respawn mea') - - @unittest.skip("Skip and wait for releasing Heat Translator") - def test_mea_alarm_scale(self): - self._test_mea_tosca_alarm( - 'sample-tosca-alarm-scale.yaml', - 'alarm and scale mea') diff --git a/apmec/tests/functional/mem/test_tosca_mea_block_storage.py b/apmec/tests/functional/mem/test_tosca_mea_block_storage.py deleted file mode 100644 index ec1bd44..0000000 --- a/apmec/tests/functional/mem/test_tosca_mea_block_storage.py +++ /dev/null @@ -1,134 +0,0 @@ -# Copyright 2016 Brocade Communications System, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, 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 yaml - -from oslo_config import cfg - -from apmec.plugins.common import constants as evt_constants -from apmec.tests import constants -from apmec.tests.functional import base -from apmec.tests.utils import read_file - - -CONF = cfg.CONF -MEA_CIRROS_CREATE_TIMEOUT = 120 - - -class MeaBlockStorageTestToscaCreate(base.BaseApmecTest): - def _test_create_mea(self, mead_file, mea_name, - template_source="onboarded"): - data = dict() - values_str = read_file(mead_file) - data['tosca'] = values_str - toscal = data['tosca'] - tosca_arg = {'mead': {'name': mea_name, - 'attributes': {'mead': toscal}}} - - if template_source == "onboarded": - # Create mead with tosca template - mead_instance = self.client.create_mead(body=tosca_arg) - self.assertIsNotNone(mead_instance) - - # Create mea with mead_id - mead_id = mead_instance['mead']['id'] - mea_arg = {'mea': {'mead_id': mead_id, 'name': mea_name}} - mea_instance = self.client.create_mea(body=mea_arg) - self.validate_mea_instance(mead_instance, mea_instance) - - if template_source == 'inline': - # create mea directly from template - template = yaml.safe_load(values_str) - mea_arg = {'mea': {'mead_template': template, 'name': mea_name}} - mea_instance = self.client.create_mea(body=mea_arg) - mead_id = mea_instance['mea']['mead_id'] - - mea_id = mea_instance['mea']['id'] - self.wait_until_mea_active( - mea_id, - constants.MEA_CIRROS_CREATE_TIMEOUT, - constants.ACTIVE_SLEEP_TIME) - mea_show_out = self.client.show_mea(mea_id)['mea'] - self.assertIsNotNone(mea_show_out['mgmt_url']) - - input_dict = yaml.safe_load(values_str) - prop_dict = input_dict['topology_template']['node_templates'][ - 'CP1']['properties'] - - # Verify if ip_address is static, it is same as in show_mea - if prop_dict.get('ip_address'): - mgmt_url_input = prop_dict.get('ip_address') - mgmt_info = yaml.safe_load( - mea_show_out['mgmt_url']) - self.assertEqual(mgmt_url_input, mgmt_info['VDU1']) - - # Verify anti spoofing settings - stack_id = mea_show_out['instance_id'] - template_dict = input_dict['topology_template']['node_templates'] - for field in template_dict.keys(): - prop_dict = template_dict[field]['properties'] - if prop_dict.get('anti_spoofing_protection'): - self.verify_antispoofing_in_stack(stack_id=stack_id, - resource_name=field) - - self.verify_mea_crud_events( - mea_id, evt_constants.RES_EVT_CREATE, - evt_constants.PENDING_CREATE, cnt=2) - self.verify_mea_crud_events( - mea_id, evt_constants.RES_EVT_CREATE, evt_constants.ACTIVE) - return mead_id, mea_id - - def _test_delete_mea(self, mea_id): - # Delete mea_instance with mea_id - try: - self.client.delete_mea(mea_id) - except Exception: - assert False, "mea Delete failed" - - self.wait_until_mea_delete(mea_id, - constants.MEA_CIRROS_DELETE_TIMEOUT) - self.verify_mea_crud_events(mea_id, evt_constants.RES_EVT_DELETE, - evt_constants.PENDING_DELETE, cnt=2) - - def _test_cleanup_mead(self, mead_id, mea_id): - # Delete mead_instance - self.addCleanup(self.client.delete_mead, mead_id) - self.addCleanup(self.wait_until_mea_delete, mea_id, - constants.MEA_CIRROS_DELETE_TIMEOUT) - - def _test_create_delete_mea_tosca(self, mead_file, mea_name, - template_source): - mead_id, mea_id = self._test_create_mea(mead_file, mea_name, - template_source) - servers = self.novaclient().servers.list() - vdus = [] - for server in servers: - vdus.append(server.name) - self.assertIn('test-vdu-block-storage', vdus) - - for server in servers: - if server.name == 'test-vdu-block-storage': - server_id = server.id - server_volumes = self.novaclient().volumes\ - .get_server_volumes(server_id) - self.assertTrue(len(server_volumes) > 0) - self._test_delete_mea(mea_id) - if template_source == "onboarded": - self._test_cleanup_mead(mead_id, mea_id) - - def test_create_delete_mea_tosca_from_mead(self): - self._test_create_delete_mea_tosca( - 'sample-tosca-mead-block-storage.yaml', - 'test_tosca_mea_with_cirros', - 'onboarded') diff --git a/apmec/tests/functional/mem/test_tosca_mea_floatingip.py b/apmec/tests/functional/mem/test_tosca_mea_floatingip.py deleted file mode 100644 index fae924d..0000000 --- a/apmec/tests/functional/mem/test_tosca_mea_floatingip.py +++ /dev/null @@ -1,98 +0,0 @@ -# Copyright 2017 OpenStack Foundation -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, 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 yaml - -from apmec.tests import constants -from apmec.tests.functional import base -from apmec.tests.utils import read_file - - -class MeaTestToscaFloatingIp(base.BaseApmecTest): - - def get_heat_stack_resource(self, stack_id, resource_name): - resource_types = self.h_client.resources - resource_details = resource_types.get(stack_id=stack_id, - resource_name=resource_name) - resource_dict = resource_details.to_dict() - return resource_dict - - def connect_public_and_private_nw_with_router(self): - public_nw = 'public' - private_nw = 'net_mgmt' - private_nw_subnet = 'subnet_mgmt' - public_nw_id = None - private_nw_id = None - private_nw_subnet_id = None - neutronclient = self.neutronclient() - networks = neutronclient.list_networks()['networks'] - for nw in networks: - if nw['name'] == public_nw: - public_nw_id = nw['id'] - if nw['name'] == private_nw: - private_nw_id = nw['id'] - if public_nw_id and private_nw_id: - break - self.assertIsNotNone(public_nw_id) - self.assertIsNotNone(private_nw_id) - subnets = neutronclient.list_subnets()['subnets'] - for subnet in subnets: - if subnet['network_id'] == private_nw_id\ - and subnet['name'] == private_nw_subnet: - private_nw_subnet_id = subnet['id'] - break - self.assertIsNotNone(private_nw_subnet_id) - router_id = neutronclient.create_router( - {'router': {'name': 'fip_test_router'}})['router']['id'] - self.assertIsNotNone(router_id) - self.addCleanup(self.neutronclient().delete_router, router_id) - rt_gw_id = neutronclient.add_gateway_router( - router_id, {'network_id': public_nw_id})['router']['id'] - self.assertIsNotNone(rt_gw_id) - self.addCleanup(self.neutronclient().remove_gateway_router, - router_id) - rt_int = neutronclient.add_interface_router( - router_id, {'subnet_id': private_nw_subnet_id})['id'] - self.assertIsNotNone(rt_int) - self.addCleanup(self.neutronclient().remove_interface_router, - router_id, {'subnet_id': private_nw_subnet_id}) - - def test_assign_floatingip_to_vdu(self): - mead_file = 'sample_tosca_assign_floatingip_to_vdu.yaml' - mea_name = 'Assign Floating IP to VDU' - values_str = read_file(mead_file) - template = yaml.safe_load(values_str) - mea_arg = {'mea': {'mead_template': template, 'name': mea_name}} - self.connect_public_and_private_nw_with_router() - mea_instance = self.client.create_mea(body=mea_arg) - mea_id = mea_instance['mea']['id'] - self.addCleanup(self.wait_until_mea_delete, mea_id, - constants.MEA_CIRROS_DELETE_TIMEOUT) - self.addCleanup(self.client.delete_mea, mea_id) - self.wait_until_mea_active( - mea_id, - constants.MEA_CIRROS_CREATE_TIMEOUT, - constants.ACTIVE_SLEEP_TIME) - mea_show_out = self.client.show_mea(mea_id)['mea'] - self.assertIsNotNone(mea_show_out['mgmt_url']) - - stack_id = mea_show_out['instance_id'] - fip_res = self.get_heat_stack_resource(stack_id, 'FIP1') - floating_ip_address = fip_res['attributes']['floating_ip_address'] - self.assertIsNotNone(floating_ip_address) - fip_port_id = fip_res['attributes']['port_id'] - port_res = self.get_heat_stack_resource(stack_id, 'CP1') - port_id = port_res['attributes']['id'] - self.assertEqual(fip_port_id, port_id) diff --git a/apmec/tests/functional/mem/test_tosca_mea_multiple_vdu.py b/apmec/tests/functional/mem/test_tosca_mea_multiple_vdu.py deleted file mode 100644 index c9c11e0..0000000 --- a/apmec/tests/functional/mem/test_tosca_mea_multiple_vdu.py +++ /dev/null @@ -1,90 +0,0 @@ -# Copyright 2016 Brocade Communications System, Inc. -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, 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. - -from oslo_config import cfg -from toscaparser import tosca_template -import yaml - -from apmec.common import utils -from apmec.plugins.common import constants as evt_constants -from apmec.tests import constants -from apmec.tests.functional import base -from apmec.tests.utils import read_file -from apmec.catalogs.tosca import utils as toscautils - -CONF = cfg.CONF - - -class MeaTestToscaMultipleVDU(base.BaseApmecTest): - def test_create_delete_tosca_mea_with_multiple_vdus(self): - input_yaml = read_file('sample-tosca-mead-multi-vdu.yaml') - tosca_dict = yaml.safe_load(input_yaml) - mead_name = 'sample-tosca-mead-multi-vdu' - tosca_arg = {'mead': {'name': mead_name, - 'attributes': {'mead': tosca_dict}}} - - # Create mead with tosca template - mead_instance = self.client.create_mead(body=tosca_arg) - self.assertIsNotNone(mead_instance) - - # Create mea with mead_id - mead_id = mead_instance['mead']['id'] - mea_arg = {'mea': {'mead_id': mead_id, 'name': - "test_tosca_mea_with_multiple_vdus"}} - mea_instance = self.client.create_mea(body=mea_arg) - - mea_id = mea_instance['mea']['id'] - self.wait_until_mea_active(mea_id, - constants.MEA_CIRROS_CREATE_TIMEOUT, - constants.ACTIVE_SLEEP_TIME) - self.assertEqual('ACTIVE', - self.client.show_mea(mea_id)['mea']['status']) - self.validate_mea_instance(mead_instance, mea_instance) - - self.verify_mea_crud_events( - mea_id, evt_constants.RES_EVT_CREATE, - evt_constants.PENDING_CREATE, cnt=2) - self.verify_mea_crud_events( - mea_id, evt_constants.RES_EVT_CREATE, evt_constants.ACTIVE) - - # Validate mgmt_url with input yaml file - mgmt_url = self.client.show_mea(mea_id)['mea']['mgmt_url'] - self.assertIsNotNone(mgmt_url) - mgmt_dict = yaml.safe_load(str(mgmt_url)) - - input_dict = yaml.safe_load(input_yaml) - toscautils.updateimports(input_dict) - - tosca = tosca_template.ToscaTemplate(parsed_params={}, a_file=False, - yaml_dict_tpl=input_dict) - - vdus = toscautils.findvdus(tosca) - - self.assertEqual(len(vdus), len(mgmt_dict.keys())) - for vdu in vdus: - self.assertIsNotNone(mgmt_dict[vdu.name]) - self.assertEqual(True, utils.is_valid_ipv4(mgmt_dict[vdu.name])) - - # Delete mea_instance with mea_id - try: - self.client.delete_mea(mea_id) - except Exception: - assert False, "mea Delete of test_mea_with_multiple_vdus failed" - - self.wait_until_mea_delete(mea_id, - constants.MEA_CIRROS_DELETE_TIMEOUT) - self.verify_mea_crud_events(mea_id, evt_constants.RES_EVT_DELETE, - evt_constants.PENDING_DELETE, cnt=2) - - # Delete mead_instance - self.addCleanup(self.client.delete_mead, mead_id) diff --git a/apmec/tests/functional/mem/test_tosca_mea_scale.py b/apmec/tests/functional/mem/test_tosca_mea_scale.py deleted file mode 100644 index 4dfb3ea..0000000 --- a/apmec/tests/functional/mem/test_tosca_mea_scale.py +++ /dev/null @@ -1,107 +0,0 @@ -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, 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 json -import time -import unittest - -from oslo_config import cfg - -from apmec.plugins.common import constants as evt_constants -from apmec.tests import constants -from apmec.tests.functional import base -from apmec.tests.utils import read_file - - -CONF = cfg.CONF - - -class MeaTestToscaScale(base.BaseApmecTest): - @unittest.skip("Skip and wait for releasing Heat Translator") - def test_mea_tosca_scale(self): - data = dict() - data['tosca'] = read_file('sample-tosca-scale-all.yaml') - mead_name = 'test_tosca_mea_scale_all' - toscal = data['tosca'] - tosca_arg = {'mead': {'name': mead_name, - 'attributes': {'mead': toscal}}} - - # Create mead with tosca template - mead_instance = self.client.create_mead(body=tosca_arg) - self.assertIsNotNone(mead_instance) - - # Create mea with mead_id - mead_id = mead_instance['mead']['id'] - mea_name = 'test_tosca_mea_scale_all' - mea_arg = {'mea': {'mead_id': mead_id, 'name': mea_name}} - mea_instance = self.client.create_mea(body=mea_arg) - - self.validate_mea_instance(mead_instance, mea_instance) - - mea_id = mea_instance['mea']['id'] - - # TODO(kanagaraj-manickam) once load-balancer support is enabled, - # update this logic to validate the scaling - def _wait(count): - self.wait_until_mea_active( - mea_id, - constants.MEA_CIRROS_CREATE_TIMEOUT, - constants.ACTIVE_SLEEP_TIME) - mea = self.client.show_mea(mea_id)['mea'] - - # {"VDU1": ["10.0.0.14", "10.0.0.5"]} - self.assertEqual(count, len(json.loads(mea['mgmt_url'])['VDU1'])) - - _wait(2) - # Get nested resources when mea is in active state - mea_details = self.client.list_mea_resources(mea_id)['resources'] - resources_list = list() - for mea_detail in mea_details: - resources_list.append(mea_detail['name']) - self.assertIn('VDU1', resources_list) - - self.assertIn('CP1', resources_list) - self.assertIn('SP1_group', resources_list) - - def _scale(type, count): - body = {"scale": {'type': type, 'policy': 'SP1'}} - self.client.scale_mea(mea_id, body) - _wait(count) - - # scale out - time.sleep(constants.SCALE_WINDOW_SLEEP_TIME) - _scale('out', 3) - - # scale in - time.sleep(constants.SCALE_WINDOW_SLEEP_TIME) - _scale('in', 2) - - # Verifying that as part of SCALE OUT, MEA states PENDING_SCALE_OUT - # and ACTIVE occurs and as part of SCALE IN, MEA states - # PENDING_SCALE_IN and ACTIVE occur. - self.verify_mea_crud_events(mea_id, evt_constants.RES_EVT_SCALE, - evt_constants.ACTIVE, cnt=2) - self.verify_mea_crud_events(mea_id, evt_constants.RES_EVT_SCALE, - evt_constants.PENDING_SCALE_OUT, cnt=1) - self.verify_mea_crud_events(mea_id, evt_constants.RES_EVT_SCALE, - evt_constants.PENDING_SCALE_IN, cnt=1) - # Delete mea_instance with mea_id - try: - self.client.delete_mea(mea_id) - except Exception: - assert False, "mea Delete failed" - - # Delete mead_instance - self.addCleanup(self.client.delete_mead, mead_id) - self.addCleanup(self.wait_until_mea_delete, mea_id, - constants.MEA_CIRROS_DELETE_TIMEOUT) diff --git a/apmec/tests/functional/mem/test_tosca_meac.py b/apmec/tests/functional/mem/test_tosca_meac.py deleted file mode 100644 index e073638..0000000 --- a/apmec/tests/functional/mem/test_tosca_meac.py +++ /dev/null @@ -1,115 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, 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 os - -from oslo_config import cfg -from toscaparser import tosca_template -import unittest -import yaml - - -from apmec.common import utils -from apmec.plugins.common import constants as evt_constants -from apmec.tests import constants -from apmec.tests.functional import base -from apmec.tests.utils import read_file -from apmec.catalogs.tosca import utils as toscautils - -CONF = cfg.CONF -SOFTWARE_DEPLOYMENT = 'OS::Heat::SoftwareDeployment' - - -class MeaTestToscaMEAC(base.BaseApmecTest): - - @unittest.skip("Until BUG 1673012") - def test_create_delete_tosca_meac(self): - input_yaml = read_file('sample_tosca_meac.yaml') - tosca_dict = yaml.safe_load(input_yaml) - path = os.path.abspath(os.path.join( - os.path.dirname(__file__), "../../etc/samples")) - mead_name = 'sample-tosca-meac' - tosca_dict['topology_template']['node_templates' - ]['firewall_meac' - ]['interfaces' - ]['Standard']['create'] = path \ - + '/install_meac.sh' - tosca_arg = {'mead': {'name': mead_name, - 'attributes': {'mead': tosca_dict}}} - - # Create mead with tosca template - mead_instance = self.client.create_mead(body=tosca_arg) - self.assertIsNotNone(mead_instance) - - # Create mea with mead_id - mead_id = mead_instance['mead']['id'] - mea_arg = {'mea': {'mead_id': mead_id, 'name': - "test_tosca_meac"}} - mea_instance = self.client.create_mea(body=mea_arg) - - mea_id = mea_instance['mea']['id'] - self.wait_until_mea_active(mea_id, - constants.MEAC_CREATE_TIMEOUT, - constants.ACTIVE_SLEEP_TIME) - self.assertEqual('ACTIVE', - self.client.show_mea(mea_id)['mea']['status']) - self.validate_mea_instance(mead_instance, mea_instance) - - self.verify_mea_crud_events( - mea_id, evt_constants.RES_EVT_CREATE, evt_constants.PENDING_CREATE, - cnt=2) - self.verify_mea_crud_events( - mea_id, evt_constants.RES_EVT_CREATE, evt_constants.ACTIVE) - - # Validate mgmt_url with input yaml file - mgmt_url = self.client.show_mea(mea_id)['mea']['mgmt_url'] - self.assertIsNotNone(mgmt_url) - mgmt_dict = yaml.safe_load(str(mgmt_url)) - - input_dict = yaml.safe_load(input_yaml) - toscautils.updateimports(input_dict) - - tosca = tosca_template.ToscaTemplate(parsed_params={}, a_file=False, - yaml_dict_tpl=input_dict) - - vdus = toscautils.findvdus(tosca) - - self.assertEqual(len(vdus), len(mgmt_dict.keys())) - for vdu in vdus: - self.assertIsNotNone(mgmt_dict[vdu.name]) - self.assertEqual(True, utils.is_valid_ipv4(mgmt_dict[vdu.name])) - - # Check the status of SoftwareDeployment - heat_stack_id = self.client.show_mea(mea_id)['mea']['instance_id'] - resource_types = self.h_client.resources - resources = resource_types.list(stack_id=heat_stack_id) - for resource in resources: - resource = resource.to_dict() - if resource['resource_type'] == \ - SOFTWARE_DEPLOYMENT: - self.assertEqual('CREATE_COMPLETE', - resource['resource_status']) - break - - # Delete mea_instance with mea_id - try: - self.client.delete_mea(mea_id) - except Exception: - assert False, "mea Delete of test_mea_with_multiple_vdus failed" - - self.wait_until_mea_delete(mea_id, - constants.MEA_CIRROS_DELETE_TIMEOUT) - self.verify_mea_crud_events(mea_id, evt_constants.RES_EVT_DELETE, - evt_constants.PENDING_DELETE, cnt=2) - - # Delete mead_instance - self.addCleanup(self.client.delete_mead, mead_id) diff --git a/apmec/tests/functional/mem/test_tosca_mead.py b/apmec/tests/functional/mem/test_tosca_mead.py deleted file mode 100644 index 6f1dfee..0000000 --- a/apmec/tests/functional/mem/test_tosca_mead.py +++ /dev/null @@ -1,65 +0,0 @@ -# Copyright 2016 Brocade Communications System, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, 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 time - -from oslo_config import cfg -import yaml - -from apmec.plugins.common import constants as evt_constants -from apmec.tests.functional import base -from apmec.tests.utils import read_file - -CONF = cfg.CONF - - -class MeadTestCreate(base.BaseApmecTest): - def _test_create_list_delete_tosca_mead(self, tosca_mead_file, mead_name): - input_yaml = read_file(tosca_mead_file) - tosca_dict = yaml.safe_load(input_yaml) - tosca_arg = {'mead': {'name': mead_name, - 'attributes': {'mead': tosca_dict}}} - mead_instance = self.client.create_mead(body=tosca_arg) - self.assertIsNotNone(mead_instance) - - meads = self.client.list_meads().get('meads') - self.assertIsNotNone(meads, "List of meads are Empty after Creation") - - mead_id = mead_instance['mead']['id'] - self.verify_mead_events( - mead_id, evt_constants.RES_EVT_CREATE, - evt_constants.RES_EVT_ONBOARDED) - - try: - self.client.delete_mead(mead_id) - except Exception: - assert False, "mead Delete failed" - self.verify_mead_events(mead_id, evt_constants.RES_EVT_DELETE, - evt_constants.RES_EVT_NA_STATE) - - def test_tosca_mead(self): - self._test_create_list_delete_tosca_mead('sample-tosca-mead.yaml', - 'sample-tosca-mead-template') - - def test_tosca_large_mead(self): - self._test_create_list_delete_tosca_mead( - 'sample-tosca-mead-large-template.yaml', - 'sample-tosca-mead-large-template') - - def test_tosca_re_create_delete_mead(self): - self._test_create_list_delete_tosca_mead('sample-tosca-mead.yaml', - 'test_mead') - time.sleep(1) - self._test_create_list_delete_tosca_mead('sample-tosca-mead.yaml', - 'test_mead') diff --git a/apmec/tests/functional/meo/__init__.py b/apmec/tests/functional/meo/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/apmec/tests/functional/meo/test_meo.py b/apmec/tests/functional/meo/test_meo.py deleted file mode 100644 index 9566a0e..0000000 --- a/apmec/tests/functional/meo/test_meo.py +++ /dev/null @@ -1,178 +0,0 @@ -# Copyright 2016 Brocade Communications System, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, 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 yaml - -from oslo_config import cfg -from apmecclient.common import exceptions - -from apmec.plugins.common import constants as evt_constants -from apmec.tests import constants -from apmec.tests.functional import base -from apmec.tests.utils import read_file - -import time -CONF = cfg.CONF - - -class MesdTestCreate(base.BaseApmecTest): - def _test_create_tosca_mead(self, tosca_mead_file, mead_name): - input_yaml = read_file(tosca_mead_file) - tosca_dict = yaml.safe_load(input_yaml) - tosca_arg = {'mead': {'name': mead_name, - 'attributes': {'mead': tosca_dict}}} - mead_instance = self.client.create_mead(body=tosca_arg) - self.assertEqual(mead_instance['mead']['name'], mead_name) - self.assertIsNotNone(mead_instance) - - meads = self.client.list_meads().get('meads') - self.assertIsNotNone(meads, "List of meads are Empty after Creation") - return mead_instance['mead']['id'] - - def _test_create_mesd(self, tosca_mesd_file, mesd_name): - input_yaml = read_file(tosca_mesd_file) - tosca_dict = yaml.safe_load(input_yaml) - tosca_arg = {'mesd': {'name': mesd_name, - 'attributes': {'mesd': tosca_dict}}} - mesd_instance = self.client.create_mesd(body=tosca_arg) - self.assertIsNotNone(mesd_instance) - return mesd_instance['mesd']['id'] - - def _test_delete_mesd(self, mesd_id): - try: - self.client.delete_mesd(mesd_id) - except Exception: - assert False, "mesd Delete failed" - - def _test_delete_mead(self, mead_id, timeout=constants.MES_DELETE_TIMEOUT): - start_time = int(time.time()) - while True: - try: - self.client.delete_mead(mead_id) - except exceptions.Conflict: - time.sleep(2) - except Exception: - assert False, "mead Delete failed" - else: - break - if (int(time.time()) - start_time) > timeout: - assert False, "mead still in use" - self.verify_mead_events(mead_id, evt_constants.RES_EVT_DELETE, - evt_constants.RES_EVT_NA_STATE) - - def _wait_until_mes_status(self, mes_id, target_status, timeout, - sleep_interval): - start_time = int(time.time()) - while True: - mes_result = self.client.show_mes(mes_id) - status = mes_result['mes']['status'] - if (status == target_status) or ( - (int(time.time()) - start_time) > timeout): - break - time.sleep(sleep_interval) - - self.assertEqual(status, target_status, - "mes %(mes_id)s with status %(status)s is" - " expected to be %(target)s" % - {"mes_id": mes_id, "status": status, - "target": target_status}) - - def _wait_until_mes_delete(self, mes_id, timeout): - start_time = int(time.time()) - while True: - try: - mes_result = self.client.show_mes(mes_id) - time.sleep(2) - except Exception: - return - status = mes_result['mes']['status'] - if (status != 'PENDING_DELETE') or (( - int(time.time()) - start_time) > timeout): - raise Exception("Failed with status: %s" % status) - - def _test_create_delete_mes(self, mesd_file, mes_name, - template_source='onboarded'): - mead1_id = self._test_create_tosca_mead( - 'test-mes-mead1.yaml', - 'test-mes-mead1') - mead2_id = self._test_create_tosca_mead( - 'test-mes-mead2.yaml', - 'test-mes-mead2') - - if template_source == 'onboarded': - mesd_id = self._test_create_mesd( - mesd_file, - 'test-mes-mesd') - mes_arg = {'mes': { - 'mesd_id': mesd_id, - 'name': mes_name, - 'attributes': {"param_values": { - "mesd": { - "vl2_name": "net0", - "vl1_name": "net_mgmt"}}}}} - mes_instance = self.client.create_mes(body=mes_arg) - mes_id = mes_instance['mes']['id'] - - if template_source == 'inline': - input_yaml = read_file(mesd_file) - template = yaml.safe_load(input_yaml) - mes_arg = {'mes': { - 'name': mes_name, - 'attributes': {"param_values": { - "mesd": { - "vl2_name": "net0", - "vl1_name": "net_mgmt"}}}, - 'mesd_template': template}} - mes_instance = self.client.create_mes(body=mes_arg) - mes_id = mes_instance['mes']['id'] - - self._wait_until_mes_status(mes_id, 'ACTIVE', - constants.MES_CREATE_TIMEOUT, - constants.ACTIVE_SLEEP_TIME) - mes_show_out = self.client.show_mes(mes_id)['mes'] - self.assertIsNotNone(mes_show_out['mgmt_urls']) - - try: - self.client.delete_mes(mes_id) - except Exception as e: - print("Exception:", e) - assert False, "mes Delete failed" - if template_source == 'onboarded': - self._wait_until_mes_delete(mes_id, constants.NS_DELETE_TIMEOUT) - self._test_delete_mesd(mesd_id) - self._test_delete_mead(mead1_id) - self._test_delete_mead(mead2_id) - - def test_create_delete_mesd(self): - mead1_id = self._test_create_tosca_mead( - 'test-mesd-mead1.yaml', - 'test-mesd-mead1') - mead2_id = self._test_create_tosca_mead( - 'test-mesd-mead2.yaml', - 'test-mesd-mead2') - mesd_id = self._test_create_mesd( - 'test-mesd.yaml', - 'test-mesd') - self._test_delete_mesd(mesd_id) - self._test_delete_mead(mead1_id) - self._test_delete_mead(mead2_id) - - def test_create_delete_network_service(self): - self._test_create_delete_mes('test-mes-mesd.yaml', - 'test-mes-onboarded', - template_source='onboarded') - time.sleep(1) - self._test_create_delete_mes('test-mes-mesd.yaml', - 'test-mes-inline', - template_source='inline') diff --git a/apmec/tests/functional/meo/test_vim.py b/apmec/tests/functional/meo/test_vim.py deleted file mode 100644 index 7f9acf1..0000000 --- a/apmec/tests/functional/meo/test_vim.py +++ /dev/null @@ -1,191 +0,0 @@ -# Copyright 2016 Brocade Communications System, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, 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 time -import yaml - -from apmec.plugins.common import constants as evt_constants -from apmec.tests.functional import base -from apmec.tests.utils import read_file - -from apmecclient.common import exceptions - -SECRET_PASSWORD = '***' - - -class VimTestCreate(base.BaseApmecTest): - - def _test_create_delete_vim(self, vim_file, name, description, vim_type, - version=None): - - data, vim_arg = self._generate_vim_data( - 'local-vim.yaml', name, description, vim_type, version) - # updated args - new_name = "fake %s" % name - new_desc = "fake %s" % description - update_vim_arg = {'vim': {'name': new_name, - 'description': new_desc}} - - # Register vim - vim_res = self.client.create_vim(vim_arg) - vim_obj = vim_res['vim'] - vim_id = vim_obj['id'] - self.verify_vim(vim_obj, data, name, description, version) - self.verify_vim_events(vim_id, evt_constants.RES_EVT_CREATE) - - # Read vim - vim_show_res = self.client.show_vim(vim_id) - self.verify_vim(vim_show_res['vim'], data, name, description, version) - - # Update vim - vim_update = self.client.update_vim(vim_id, update_vim_arg) - vim_obj = vim_update['vim'] - self.verify_vim(vim_obj, data, new_name, new_desc, version) - self.verify_vim_events(vim_id, evt_constants.RES_EVT_UPDATE) - - # With the updated name above, create another VIM with the - # same name and check for Duplicate name exception. - vim_arg['vim']['name'] = update_vim_arg['vim']['name'] - msg = "vim already exist with given ['tenant_id', 'name', "\ - "'deleted_at']" - try: - self.client.create_vim(vim_arg) - except Exception as err: - self.assertEqual(err.message, msg) - - # Since there already exists a DEFAULT VM, Verify that a update - # to is_default to TRUE for another VIM raises an exception. - update_arg = {'vim': {'is_default': True}} - msg = "Default VIM already exists." - self.assertRaisesRegex(exceptions.InternalServerError, msg, - self.client.update_vim, - vim_id, update_arg) - - # Delete vim - try: - self.client.delete_vim(vim_id) - except Exception: - self.assertFalse(True, "Failed to delete vim %s" % vim_id) - self.verify_vim_events(vim_id, evt_constants.RES_EVT_DELETE) - - def verify_vim(self, vim_instance, config_data, name, description, - version): - expected_regions = ['RegionOne'] - self.assertIsNotNone(vim_instance) - self.assertEqual(description, vim_instance['description']) - self.assertEqual(name, vim_instance['name']) - self.assertIsNotNone(vim_instance['tenant_id']) - self.assertIsNotNone(vim_instance['id']) - self.assertEqual(config_data['username'], - vim_instance['auth_cred']['username']) - self.assertEqual(SECRET_PASSWORD, - vim_instance['auth_cred']['password']) - self.assertEqual(expected_regions, - vim_instance['placement_attr']['regions']) - if version: - method_name = 'verify_vim_' + version - getattr(self, method_name)(vim_instance, config_data) - - def verify_vim_events(self, vim_id, evt_type, tstamp=None, cnt=1): - params = {'resource_id': vim_id, - 'resource_type': evt_constants.RES_TYPE_VIM, - 'event_type': evt_type} - if tstamp: - params['timestamp'] = tstamp - - vim_evt_list = self.client.list_vim_events(**params) - - self.assertIsNotNone(vim_evt_list['vim_events'], - "List of VIM events are Empty") - self.assertEqual(cnt, len(vim_evt_list['vim_events'])) - - def verify_vim_v2(self, vim_instance, config_data): - self.assertEqual(config_data['project_name'], - vim_instance['auth_cred']['tenant_name']) - - def verify_vim_v3(self, vim_instance, config_data): - self.assertEqual(config_data['project_name'], - vim_instance['auth_cred']['project_name']) - - def test_create_delete_local_vim(self): - name = 'Default vim' - description = 'Local vim description' - vim_type = 'openstack' - ks_version = 'v3' - self._test_create_delete_vim('local-vim.yaml', name, description, - vim_type, ks_version) - - def _generate_vim_data(self, vim_file, name, description, vim_type, - version=None): - - data = yaml.safe_load(read_file(vim_file)) - password = data['password'] - username = data['username'] - project_name = data['project_name'] - auth_url = data['auth_url'] - if version: - if ('v2' == version and (not auth_url.endswith("/v2.0") or - not auth_url.endswith("/v2.0/"))): - auth_url += "/v2.0" - elif (not auth_url.endswith("/v3") or - not auth_url.endswith("/v3/")): - auth_url += "/v3" - domain_name = data.get('domain_name', None) - vim_arg = {'vim': {'name': name, 'description': description, - 'type': vim_type, - 'auth_url': auth_url, - 'auth_cred': {'username': username, - 'password': password, - 'user_domain_name': domain_name}, - 'vim_project': {'name': project_name, - 'project_domain_name': - domain_name}, - 'is_default': False}} - return data, vim_arg - - def test_re_create_delete_local_vim(self): - name = 'test_vim' - description = 'Test vim description' - vim_type = 'openstack' - ks_version = 'v3' - self._test_create_delete_vim('local-vim.yaml', name, description, - vim_type, ks_version) - time.sleep(1) - self._test_create_delete_vim('local-vim.yaml', name, description, - vim_type, ks_version) - - def test_duplicate_vim(self): - name = 'test_duplicate_vim' - description = 'Test duplicate vim description' - vim_type = 'openstack' - version = 'v3' - data, vim_arg = self._generate_vim_data( - 'local-vim.yaml', name, description, vim_type, version) - - # Register vim - vim_res = self.client.create_vim(vim_arg) - vim_obj = vim_res['vim'] - vim_id = vim_obj['id'] - - # Read vim - vim_show_res = self.client.show_vim(vim_id) - self.verify_vim(vim_show_res['vim'], data, name, description, version) - msg = "vim already exist with given ['tenant_id', 'name', "\ - "'deleted_at']" - err_msg = None - try: - self.client.create_vim(vim_arg) - except Exception as err: - err_msg = err.message - self.assertEqual(err_msg, msg) diff --git a/apmec/tests/unit/_test_rootwrap_exec.py b/apmec/tests/unit/_test_rootwrap_exec.py deleted file mode 100644 index 3e96af7..0000000 --- a/apmec/tests/unit/_test_rootwrap_exec.py +++ /dev/null @@ -1,82 +0,0 @@ -# Copyright (c) 2012 OpenStack Foundation -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, 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 os - -import fixtures -from oslo_log import log as logging - -from apmec.agent.linux import utils -from apmec.tests import base - - -LOG = logging.getLogger(__name__) - - -class RootwrapTestExec(base.BaseTestCase): - """Simple unit test to test the basic rootwrap mechanism - - Essentially hello-world. Just run a command as root and check that - it actually *did* run as root, and generated the right output. - - NB that this is named _test_rootwrap so as not to get run by default - from scripts like tox. That's because it actually executes a sudo'ed - command, and that won't work in the automated test environment, at - least as it stands today. To run this, rename it to - test_rootwrap.py, or run it by hand. - """ - - def setUp(self): - super(RootwrapTestExec, self).setUp() - self.cwd = os.getcwd() + "/../../.." - # stuff a stupid bash script into /tmp, so that the next - # method can execute it. - self.test_file = self.useFixture( - fixtures.TempDir()).join("rootwrap-test.sh") - with open(self.test_file, 'w') as f: - f.write('#!/bin/bash\n') - f.write('ID=`id | sed \'s/uid=//\' | sed \'s/(.*//\' `\n') - f.write("echo $ID $1\ -\" Now is the time for all good men to come \ -to the aid of their party.\"\n") - # we need a temporary conf file, pointing into pwd for the filter - # specs. there's probably a better way to do this, but I couldn't - # figure it out. 08/15/12 -- jrd - self.conf_file = self.useFixture( - fixtures.TempDir()).join("rootwrap.conf") - with open(self.conf_file, 'w') as f: - f.write("# temporary conf file for rootwrap-test, " + - "generated by test_rootwrap.py\n") - f.write("[DEFAULT]\n") - f.write("filters_path=" + self.cwd + - "/apmec/tests/etc/rootwrap.d/") - # now set the root helper to sudo our rootwrap script, - # with the new conf - self.root_helper = "sudo " + self.cwd + "/bin/apmec-rootwrap " - self.root_helper += self.conf_file - - def runTest(self): - try: - result = utils.execute(["bash", self.test_file, 'arg'], - self.root_helper) - self.assertEqual("0 arg Now is the time for all good men to \ -come to the aid of their party.", result) - except Exception: - LOG.exception("Losing in rootwrap test") - - def tearDown(self): - os.remove(self.test_file) - os.remove(self.conf_file) - super(RootwrapTestExec, self).tearDown() diff --git a/apmec/tests/unit/base.py b/apmec/tests/unit/base.py deleted file mode 100644 index 44a6183..0000000 --- a/apmec/tests/unit/base.py +++ /dev/null @@ -1,33 +0,0 @@ -# Copyright 2016 Brocade Communications System, Inc. -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, 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 mock -from oslo_config import cfg -from oslo_config import fixture as config_fixture -from oslotest import base - -CONF = cfg.CONF - - -class TestCase(base.BaseTestCase): - - def setUp(self): - super(TestCase, self).setUp() - self.config_fixture = self.useFixture(config_fixture.Config(CONF)) - - def _mock(self, target, new=mock.DEFAULT): - patcher = mock.patch(target, new) - return patcher.start() diff --git a/apmec/tests/unit/database_stubs.py b/apmec/tests/unit/database_stubs.py deleted file mode 100644 index d890c9c..0000000 --- a/apmec/tests/unit/database_stubs.py +++ /dev/null @@ -1,184 +0,0 @@ -# Copyright 2011, Cisco Systems, Inc. -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, 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. - -"""stubs.py provides interface methods for the database test cases""" - -from oslo_log import log as logging - -from apmec.db import api as db - -LOG = logging.getLogger(__name__) - - -class ApmecDB(object): - """Class conisting of methods to call Apmec db methods.""" - def get_all_networks(self, tenant_id): - """Get all networks.""" - nets = [] - try: - for net in db.network_list(tenant_id): - LOG.debug("Getting network: %s", net.uuid) - net_dict = {} - net_dict["tenant_id"] = net.tenant_id - net_dict["id"] = str(net.uuid) - net_dict["name"] = net.name - nets.append(net_dict) - except Exception as exc: - LOG.error("Failed to get all networks: %s", str(exc)) - return nets - - def get_network(self, network_id): - """Get a network.""" - net = [] - try: - for net in db.network_get(network_id): - LOG.debug("Getting network: %s", net.uuid) - net_dict = {} - net_dict["tenant_id"] = net.tenant_id - net_dict["id"] = str(net.uuid) - net_dict["name"] = net.name - net.append(net_dict) - except Exception as exc: - LOG.error("Failed to get network: %s", str(exc)) - return net - - def create_network(self, tenant_id, net_name): - """Create a network.""" - net_dict = {} - try: - res = db.network_create(tenant_id, net_name) - LOG.debug("Created network: %s", res.uuid) - net_dict["tenant_id"] = res.tenant_id - net_dict["id"] = str(res.uuid) - net_dict["name"] = res.name - return net_dict - except Exception as exc: - LOG.error("Failed to create network: %s", str(exc)) - - def delete_network(self, net_id): - """Delete a network.""" - try: - net = db.network_destroy(net_id) - LOG.debug("Deleted network: %s", net.uuid) - net_dict = {} - net_dict["id"] = str(net.uuid) - return net_dict - except Exception as exc: - LOG.error("Failed to delete network: %s", str(exc)) - - def update_network(self, tenant_id, net_id, param_data): - """Rename a network.""" - try: - net = db.network_update(net_id, tenant_id, **param_data) - LOG.debug("Updated network: %s", net.uuid) - net_dict = {} - net_dict["id"] = str(net.uuid) - net_dict["name"] = net.name - return net_dict - except Exception as exc: - LOG.error("Failed to update network: %s", str(exc)) - - def get_all_ports(self, net_id): - """Get all ports.""" - ports = [] - try: - for port in db.port_list(net_id): - LOG.debug("Getting port: %s", port.uuid) - port_dict = {} - port_dict["id"] = str(port.uuid) - port_dict["net-id"] = str(port.network_id) - port_dict["attachment"] = port.interface_id - port_dict["state"] = port.state - ports.append(port_dict) - return ports - except Exception as exc: - LOG.error("Failed to get all ports: %s", str(exc)) - - def get_port(self, net_id, port_id): - """Get a port.""" - port_list = [] - port = db.port_get(port_id, net_id) - try: - LOG.debug("Getting port: %s", port.uuid) - port_dict = {} - port_dict["id"] = str(port.uuid) - port_dict["net-id"] = str(port.network_id) - port_dict["attachment"] = port.interface_id - port_dict["state"] = port.state - port_list.append(port_dict) - return port_list - except Exception as exc: - LOG.error("Failed to get port: %s", str(exc)) - - def create_port(self, net_id): - """Add a port.""" - port_dict = {} - try: - port = db.port_create(net_id) - LOG.debug("Creating port %s", port.uuid) - port_dict["id"] = str(port.uuid) - port_dict["net-id"] = str(port.network_id) - port_dict["attachment"] = port.interface_id - port_dict["state"] = port.state - return port_dict - except Exception as exc: - LOG.error("Failed to create port: %s", str(exc)) - - def delete_port(self, net_id, port_id): - """Delete a port.""" - try: - port = db.port_destroy(port_id, net_id) - LOG.debug("Deleted port %s", port.uuid) - port_dict = {} - port_dict["id"] = str(port.uuid) - return port_dict - except Exception as exc: - LOG.error("Failed to delete port: %s", str(exc)) - - def update_port(self, net_id, port_id, **kwargs): - """Update a port.""" - try: - port = db.port_update(port_id, net_id, **kwargs) - LOG.debug("Updated port %s", port.uuid) - port_dict = {} - port_dict["id"] = str(port.uuid) - port_dict["net-id"] = str(port.network_id) - port_dict["attachment"] = port.interface_id - port_dict["state"] = port.state - return port_dict - except Exception as exc: - LOG.error("Failed to update port state: %s", str(exc)) - - def plug_interface(self, net_id, port_id, int_id): - """Plug interface to a port.""" - try: - port = db.port_set_attachment(port_id, net_id, int_id) - LOG.debug("Attached interface to port %s", port.uuid) - port_dict = {} - port_dict["id"] = str(port.uuid) - port_dict["net-id"] = str(port.network_id) - port_dict["attachment"] = port.interface_id - port_dict["state"] = port.state - return port_dict - except Exception as exc: - LOG.error("Failed to plug interface: %s", str(exc)) - - def unplug_interface(self, net_id, port_id): - """Unplug interface to a port.""" - try: - db.port_unset_attachment(port_id, net_id) - LOG.debug("Detached interface from port %s", port_id) - except Exception as exc: - LOG.error("Failed to unplug interface: %s", str(exc)) diff --git a/apmec/tests/unit/db/__init__.py b/apmec/tests/unit/db/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/apmec/tests/unit/db/base.py b/apmec/tests/unit/db/base.py deleted file mode 100644 index de327b5..0000000 --- a/apmec/tests/unit/db/base.py +++ /dev/null @@ -1,51 +0,0 @@ -# Copyright 2015 Brocade Communications System, Inc. -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, 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 fixtures - -from apmec.common import config -from apmec.db import api as db_api -from apmec.db import model_base -from apmec.tests.unit import base - - -class SqlFixture(fixtures.Fixture): - - # flag to indicate that the models have been loaded - _TABLES_ESTABLISHED = False - - def setUp(self): - super(SqlFixture, self).setUp() - # Register all data models - engine = db_api.get_engine() - if not SqlFixture._TABLES_ESTABLISHED: - model_base.BASE.metadata.create_all(engine) - SqlFixture._TABLES_ESTABLISHED = True - - def clear_tables(): - with engine.begin() as conn: - for table in reversed( - model_base.BASE.metadata.sorted_tables): - conn.execute(table.delete()) - - self.addCleanup(clear_tables) - - -class SqlTestCase(base.TestCase): - - def setUp(self): - config.set_db_defaults() - super(SqlTestCase, self).setUp() - self.useFixture(SqlFixture()) diff --git a/apmec/tests/unit/db/utils.py b/apmec/tests/unit/db/utils.py deleted file mode 100644 index f944658..0000000 --- a/apmec/tests/unit/db/utils.py +++ /dev/null @@ -1,202 +0,0 @@ -# Copyright 2015 Brocade Communications System, Inc. -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, 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 codecs -from datetime import datetime -import os -import yaml - - -DUMMY_mes_2_NAME = 'dummy_mes_2' - - -def _get_template(name): - filename = os.path.join( - os.path.dirname(os.path.abspath(__file__)), - "../mem/infra_drivers/openstack/data/", name) - f = codecs.open(filename, encoding='utf-8', errors='strict') - return f.read() - -tosca_mead_openwrt = _get_template('test_tosca_openwrt.yaml') -config_data = _get_template('config_data.yaml') -update_config_data = _get_template('update_config_data.yaml') -mead_scale_tosca_template = _get_template('tosca_scale.yaml') -mead_alarm_respawn_tosca_template = _get_template( - 'test_tosca_mead_alarm_respawn.yaml') -mead_alarm_scale_tosca_template = _get_template( - 'test_tosca_mead_alarm_scale.yaml') -mead_alarm_multi_actions_tosca_template = _get_template( - 'test_tosca_mead_alarm_multi_actions.yaml') -mesd_tosca_template = yaml.safe_load(_get_template('tosca_mesd_template.yaml')) - - -def get_dummy_mead_obj(): - return {u'mead': {u'service_types': [{u'service_type': u'mead'}], - 'name': 'dummy_mead', - 'tenant_id': u'ad7ebc56538745a08ef7c5e97f8bd437', - u'attributes': {u'mead': yaml.safe_load( - tosca_mead_openwrt)}, - 'description': 'dummy_mead_description', - 'template_source': 'onboarded', - u'auth': {u'tenantName': u'admin', u'passwordCredentials': { - u'username': u'admin', u'password': u'devstack'}}}} - - -def get_dummy_mead_obj_inline(): - return {u'mead': {u'service_types': [{u'service_type': u'mead'}], - 'name': 'tmpl-koeak4tqgoqo8cr4-dummy_inline_mea', - 'tenant_id': u'ad7ebc56538745a08ef7c5e97f8bd437', - u'attributes': {u'mead': yaml.safe_load( - tosca_mead_openwrt)}, - 'template_source': 'inline', - u'auth': {u'tenantName': u'admin', u'passwordCredentials': { - u'username': u'admin', u'password': u'devstack'}}}} - - -def get_dummy_inline_mea_obj(): - return {'mea': {'description': 'dummy_inline_mea_description', - 'mead_template': yaml.safe_load(tosca_mead_openwrt), - 'vim_id': u'6261579e-d6f3-49ad-8bc3-a9cb974778ff', - 'tenant_id': u'ad7ebc56538745a08ef7c5e97f8bd437', - 'name': 'dummy_inline_mea', - 'attributes': {}, - 'mead_id': None}} - - -def get_dummy_mea_obj(): - return {'mea': {'description': 'dummy_mea_description', - 'mead_id': u'eb094833-995e-49f0-a047-dfb56aaf7c4e', - 'vim_id': u'6261579e-d6f3-49ad-8bc3-a9cb974778ff', - 'tenant_id': u'ad7ebc56538745a08ef7c5e97f8bd437', - 'name': 'dummy_mea', - 'deleted_at': datetime.min, - 'attributes': {}, - 'mead_template': None}} - - -def get_dummy_mea_config_obj(): - return {'mea': {u'attributes': {u'config': {'vdus': {'vdu1': { - 'config': {'firewall': 'dummy_firewall_values'}}}}}}} - - -def get_dummy_device_obj(): - return {'status': 'PENDING_CREATE', 'instance_id': None, 'name': - u'test_openwrt', 'tenant_id': u'ad7ebc56538745a08ef7c5e97f8bd437', - 'mead_id': u'eb094833-995e-49f0-a047-dfb56aaf7c4e', - 'mead': { - 'service_types': [{'service_type': u'mead', - 'id': u'4a4c2d44-8a52-4895-9a75-9d1c76c3e738'}], - 'description': u'OpenWRT with services', - 'tenant_id': u'ad7ebc56538745a08ef7c5e97f8bd437', - 'mgmt_driver': u'openwrt', - 'attributes': {u'mead': tosca_mead_openwrt}, - 'id': u'fb048660-dc1b-4f0f-bd89-b023666650ec', - 'name': u'openwrt_services'}, - 'mgmt_url': None, 'service_context': [], - 'attributes': {u'param_values': u''}, - 'id': 'eb84260e-5ff7-4332-b032-50a14d6c1123', - 'description': u'OpenWRT with services'} - - -def get_dummy_mea_config_attr(): - return {'status': 'PENDING_CREATE', 'instance_id': None, 'name': - u'test_openwrt', 'tenant_id': u'ad7ebc56538745a08ef7c5e97f8bd437', - 'mead_id': u'eb094833-995e-49f0-a047-dfb56aaf7c4e', - 'mead': {'service_types': [{'service_type': u'mead', - 'id': u'4a4c2d44-8a52-4895-9a75-9d1c76c3e738'}], - 'description': u'OpenWRT with services', - 'tenant_id': u'ad7ebc56538745a08ef7c5e97f8bd437', - 'mgmt_driver': u'openwrt', - 'attributes': {u'mead': tosca_mead_openwrt}, - 'id': u'fb048660-dc1b-4f0f-bd89-b023666650ec', 'name': - u'openwrt_services'}, 'mgmt_url': None, 'service_context': [], - 'attributes': {u'config': config_data}, - 'id': 'eb84260e-5ff7-4332-b032-50a14d6c1123', - 'description': u'OpenWRT with services'} - - -def get_dummy_mea_update_config(): - return {'mea': {'attributes': {'config': update_config_data}}} - - -def get_vim_obj(): - return {'vim': {'type': 'openstack', 'auth_url': - 'http://localhost:5000', 'vim_project': {'name': - 'test_project'}, 'auth_cred': {'username': 'test_user', - 'password': - 'test_password'}, - 'name': 'VIM0', - 'tenant_id': 'test-project'}} - - -def get_vim_auth_obj(): - return {'username': 'test_user', - 'password': 'test_password', - 'project_id': None, - 'project_name': 'test_project', - 'auth_url': 'http://localhost:5000/v3', - 'user_domain_name': 'default', - 'project_domain_name': 'default'} - -def get_dummy_mesd_obj(): - return {'mesd': {'description': 'dummy_mesd_description', - 'name': 'dummy_MESD', - 'tenant_id': u'8819a1542a5948b68f94d4be0fd50496', - 'attributes': {u'mesd': mesd_tosca_template}, - 'template_source': 'onboarded'}} - - -def get_dummy_mesd_obj_inline(): - return {'mesd': {'description': 'dummy_mesd_description_inline', - 'name': 'dummy_MESD_inline', - 'tenant_id': u'8819a1542a5948b68f94d4be0fd50496', - 'attributes': {u'mesd': mesd_tosca_template}, - 'template_source': 'inline'}} - - -def get_dummy_mes_obj(): - return {'mes': {'description': 'dummy_mes_description', - 'id': u'ba6bf017-f6f7-45f1-a280-57b073bf78ea', - 'mesd_id': u'eb094833-995e-49f0-a047-dfb56aaf7c4e', - 'vim_id': u'6261579e-d6f3-49ad-8bc3-a9cb974778ff', - 'tenant_id': u'ad7ebc56538745a08ef7c5e97f8bd437', - 'name': 'dummy_mes', - 'attributes': { - 'param_values': {'mesd': {'vl1_name': 'net_mgmt', - 'vl2_name': 'net0'}}}}} - - -def get_dummy_mes_obj_inline(): - return {'mes': {'description': 'dummy_mes_description_inline', - 'id': u'ff35e3f0-0a11-4071-bce6-279fdf1c8bf9', - 'vim_id': u'6261579e-d6f3-49ad-8bc3-a9cb974778ff', - 'tenant_id': u'ad7ebc56538745a08ef7c5e97f8bd437', - 'name': 'dummy_mes_inline', - 'attributes': { - 'param_values': {'mesd': {'vl1_name': 'net_mgmt', - 'vl2_name': 'net0'}}}, - 'mesd_template': mesd_tosca_template}} - - -def get_dummy_mes_obj_2(): - return {'mes': {'description': 'dummy_mes_description', - 'id': u'ba6bf017-f6f7-45f1-a280-57b073bf78ea', - 'mesd_id': u'eb094833-995e-49f0-a047-dfb56aaf7c4e', - 'vim_id': u'6261579e-d6f3-49ad-8bc3-a9cb974778ff', - 'tenant_id': u'ad7ebc56538745a08ef7c5e97f8bd437', - 'name': DUMMY_mes_2_NAME, - 'attributes': { - 'param_values': {'mesd': {'vl1_name': 'net_mgmt', - 'vl2_name': 'net0'}}}}} diff --git a/apmec/tests/unit/extension_stubs.py b/apmec/tests/unit/extension_stubs.py deleted file mode 100644 index ae0d373..0000000 --- a/apmec/tests/unit/extension_stubs.py +++ /dev/null @@ -1,77 +0,0 @@ -# Copyright 2011 OpenStack Foundation. -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, 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 abc - -from apmec.api import extensions -from apmec import wsgi - - -class StubExtension(object): - - def __init__(self, alias="stub_extension"): - self.alias = alias - - def get_name(self): - return "Stub Extension" - - def get_alias(self): - return self.alias - - def get_description(self): - return "" - - def get_namespace(self): - return "" - - def get_updated(self): - return "" - - -class StubPlugin(object): - - def __init__(self, supported_extensions=None): - self.supported_extension_aliases = supported_extensions \ - if supported_extensions else [] - - -class ExtensionExpectingPluginInterface(StubExtension): - """Expect plugin to implement all methods in StubPluginInterface. - - This extension expects plugin to implement all the methods defined - in StubPluginInterface. - """ - - def get_plugin_interface(self): - return StubPluginInterface - - -class StubPluginInterface(extensions.PluginInterface): - - @abc.abstractmethod - def get_foo(self, bar=None): - pass - - -class StubBaseAppController(wsgi.Controller): - - def index(self, request): - return "base app index" - - def show(self, request, id): - return {'fort': 'knox'} - - def update(self, request, id): - return {'uneditable': 'original_value'} diff --git a/apmec/tests/unit/extensions/__init__.py b/apmec/tests/unit/extensions/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/apmec/tests/unit/extensions/extendedattribute.py b/apmec/tests/unit/extensions/extendedattribute.py deleted file mode 100644 index 8c7bd83..0000000 --- a/apmec/tests/unit/extensions/extendedattribute.py +++ /dev/null @@ -1,54 +0,0 @@ -# Copyright 2013 VMware, Inc. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, 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. - -from apmec.api import extensions - -EXTENDED_ATTRIBUTE = 'extended_attribute' -EXTENDED_ATTRIBUTES_2_0 = { - 'ext_test_resources': { - EXTENDED_ATTRIBUTE: {'allow_post': True, 'allow_put': False, - 'validate': {'type:uuid_or_none': None}, - 'default': None, 'is_visible': True}, - } -} - - -class Extendedattribute(extensions.ExtensionDescriptor): - """Extension class supporting extended attribute for router.""" - - @classmethod - def get_name(cls): - return "Extended Extension Attributes" - - @classmethod - def get_alias(cls): - return "extended-ext-attr" - - @classmethod - def get_description(cls): - return "Provides extended_attr attribute to router" - - @classmethod - def get_namespace(cls): - return "" - - @classmethod - def get_updated(cls): - return "2013-02-05T00:00:00-00:00" - - def get_extended_resources(self, version): - if version == "2.0": - return EXTENDED_ATTRIBUTES_2_0 - else: - return {} diff --git a/apmec/tests/unit/extensions/extensionattribute.py b/apmec/tests/unit/extensions/extensionattribute.py deleted file mode 100644 index e55dd0e..0000000 --- a/apmec/tests/unit/extensions/extensionattribute.py +++ /dev/null @@ -1,102 +0,0 @@ -# Copyright 2013 VMware, Inc. -# All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, 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 abc - -from apmec.api import extensions -from apmec.api.v1 import base -from apmec import manager - - -# Attribute Map -RESOURCE_ATTRIBUTE_MAP = { - 'ext_test_resources': { - 'id': {'allow_post': False, 'allow_put': False, - 'validate': {'type:uuid': None}, - 'is_visible': True}, - 'name': {'allow_post': True, 'allow_put': True, - 'validate': {'type:string': None}, - 'is_visible': True, 'default': ''}, - 'tenant_id': {'allow_post': True, 'allow_put': False, - 'required_by_policy': True, - 'validate': {'type:string': None}, - 'is_visible': True}, - } -} - - -class Extensionattribute(extensions.ExtensionDescriptor): - - @classmethod - def get_name(cls): - return "Extension Test Resource" - - @classmethod - def get_alias(cls): - return "ext-obj-test" - - @classmethod - def get_description(cls): - return "Extension Test Resource" - - @classmethod - def get_namespace(cls): - return "" - - @classmethod - def get_updated(cls): - return "2013-02-05T10:00:00-00:00" - - def update_attributes_map(self, attributes): - super(Extensionattribute, self).update_attributes_map( - attributes, extension_attrs_map=RESOURCE_ATTRIBUTE_MAP) - - @classmethod - def get_resources(cls): - """Returns Ext Resources.""" - exts = [] - plugin = manager.ApmecManager.get_plugin() - resource_name = 'ext_test_resource' - collection_name = resource_name + "s" - params = RESOURCE_ATTRIBUTE_MAP.get(collection_name, dict()) - - controller = base.create_resource(collection_name, - resource_name, - plugin, params, - member_actions={}) - - ex = extensions.ResourceExtension(collection_name, - controller, - member_actions={}) - exts.append(ex) - - return exts - - def get_extended_resources(self, version): - if version == "2.0": - return RESOURCE_ATTRIBUTE_MAP - else: - return {} - - -class ExtensionObjectTestPluginBase(object): - - @abc.abstractmethod - def create_ext_test_resource(self, context, router): - pass - - @abc.abstractmethod - def get_ext_test_resource(self, context, id, fields=None): - pass diff --git a/apmec/tests/unit/extensions/foxinsocks.py b/apmec/tests/unit/extensions/foxinsocks.py deleted file mode 100644 index 6547e55..0000000 --- a/apmec/tests/unit/extensions/foxinsocks.py +++ /dev/null @@ -1,109 +0,0 @@ -# Copyright 2011 OpenStack Foundation. -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, 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 abc - -from oslo_serialization import jsonutils - -from apmec.api import extensions -from apmec import wsgi - - -class FoxInSocksController(wsgi.Controller): - - def index(self, request): - return "Try to say this Mr. Knox, sir..." - - -class FoxInSocksPluginInterface(extensions.PluginInterface): - - @abc.abstractmethod - def method_to_support_foxnsox_extension(self): - pass - - -class Foxinsocks(object): - - def __init__(self): - pass - - def get_plugin_interface(self): - return FoxInSocksPluginInterface - - def get_name(self): - return "Fox In Socks" - - def get_alias(self): - return "FOXNSOX" - - def get_description(self): - return "The Fox In Socks Extension" - - def get_namespace(self): - return "http://www.fox.in.socks/api/ext/pie/v1.0" - - def get_updated(self): - return "2011-01-22T13:25:27-06:00" - - def get_resources(self): - resources = [] - resource = extensions.ResourceExtension('foxnsocks', - FoxInSocksController()) - resources.append(resource) - return resources - - def get_actions(self): - return [extensions.ActionExtension('dummy_resources', - 'FOXNSOX:add_tweedle', - self._add_tweedle_handler), - extensions.ActionExtension('dummy_resources', - 'FOXNSOX:delete_tweedle', - self._delete_tweedle_handler)] - - def get_request_extensions(self): - request_exts = [] - - def _goose_handler(req, res): - # NOTE: This only handles JSON responses. - # You can use content type header to test for XML. - data = jsonutils.loads(res.body) - data['FOXNSOX:googoose'] = req.GET.get('chewing') - res.body = jsonutils.dumps(data) - return res - - req_ext1 = extensions.RequestExtension('GET', '/dummy_resources/:(id)', - _goose_handler) - request_exts.append(req_ext1) - - def _bands_handler(req, res): - # NOTE: This only handles JSON responses. - # You can use content type header to test for XML. - data = jsonutils.loads(res.body) - data['FOXNSOX:big_bands'] = 'Pig Bands!' - res.body = jsonutils.dumps(data) - return res - - req_ext2 = extensions.RequestExtension('GET', '/dummy_resources/:(id)', - _bands_handler) - request_exts.append(req_ext2) - return request_exts - - def _add_tweedle_handler(self, input_dict, req, id): - return "Tweedle {0} Added.".format( - input_dict['FOXNSOX:add_tweedle']['name']) - - def _delete_tweedle_handler(self, input_dict, req, id): - return "Tweedle {0} Deleted.".format( - input_dict['FOXNSOX:delete_tweedle']['name']) diff --git a/apmec/tests/unit/extensions/v2attributes.py b/apmec/tests/unit/extensions/v2attributes.py deleted file mode 100644 index ab40f26..0000000 --- a/apmec/tests/unit/extensions/v2attributes.py +++ /dev/null @@ -1,48 +0,0 @@ -# Copyright (c) 2012 OpenStack Foundation. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# 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. - -EXTENDED_ATTRIBUTES_2_0 = { - 'networks': { - 'v2attrs:something': {'allow_post': False, - 'allow_put': False, - 'is_visible': True}, - 'v2attrs:something_else': {'allow_post': True, - 'allow_put': False, - 'is_visible': False}, - } -} - - -class V2attributes(object): - def get_name(self): - return "V2 Extended Attributes Example" - - def get_alias(self): - return "v2attrs" - - def get_description(self): - return "Demonstrates extended attributes on V2 core resources" - - def get_namespace(self): - return "http://docs.openstack.org/ext/examples/v2attributes/api/v1.0" - - def get_updated(self): - return "2012-07-18T10:00:00-00:00" - - def get_extended_resources(self, version): - if version == "2.0": - return EXTENDED_ATTRIBUTES_2_0 - else: - return {} diff --git a/apmec/tests/unit/mem/__init__.py b/apmec/tests/unit/mem/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/apmec/tests/unit/mem/infra_drivers/__init__.py b/apmec/tests/unit/mem/infra_drivers/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/__init__.py b/apmec/tests/unit/mem/infra_drivers/openstack/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/config_data.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/config_data.yaml deleted file mode 100644 index 5468f9c..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/config_data.yaml +++ /dev/null @@ -1,12 +0,0 @@ -vdus: - vdu1: - config: - firewall: | - package firewall - - config defaults - option syn_flood '1' - option input 'ACCEPT' - option output 'ACCEPT' - option forward 'REJECT' - diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_alarm_scale_custom.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_alarm_scale_custom.yaml deleted file mode 100644 index 2a55e02..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_alarm_scale_custom.yaml +++ /dev/null @@ -1,26 +0,0 @@ - -outputs: - mgmt_ip-VDU1: - value: - get_attr: [CP1, fixed_ips, 0, ip_address] -resources: - VDU1: - type: OS::Nova::Server - properties: - availability_zone: nova - user_data_format: SOFTWARE_CONFIG - config_drive: false - networks: - - port: { get_resource: CP1 } - image: cirros-0.3.5-x86_64-disk - flavor: m1.tiny - metadata: {metering.mea: SG1} - VL1: - type: OS::Neutron::Net - CP1: - type: OS::Neutron::Port - properties: - network: net_mgmt - port_security_enabled: false -heat_template_version: 2013-05-23 -description: Apmec Scaling template \ No newline at end of file diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_flavor.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_flavor.yaml deleted file mode 100644 index f5112d6..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_flavor.yaml +++ /dev/null @@ -1,32 +0,0 @@ -heat_template_version: 2013-05-23 - -description: > - OpenWRT with services - -outputs: - mgmt_ip-VDU1: - value: - get_attr: [CP1, fixed_ips, 0, ip_address] - -parameters: {} -resources: - VDU1: - type: OS::Nova::Server - properties: - config_drive: false - flavor: {get_resource: VDU1_flavor} - image: OpenWRT - networks: - - port: - get_resource: CP1 - user_data_format: SOFTWARE_CONFIG - CP1: - type: OS::Neutron::Port - properties: - network: existing_network_1 - VDU1_flavor: - type: OS::Nova::Flavor - properties: - disk: 10 - ram: 512 - vcpus: 2 diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_flavor_and_capabilities.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_flavor_and_capabilities.yaml deleted file mode 100644 index 1d03ab7..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_flavor_and_capabilities.yaml +++ /dev/null @@ -1,26 +0,0 @@ -heat_template_version: 2013-05-23 - -description: > - OpenWRT with services - -outputs: - mgmt_ip-VDU1: - value: - get_attr: [CP1, fixed_ips, 0, ip_address] - -parameters: {} -resources: - VDU1: - type: OS::Nova::Server - properties: - config_drive: false - flavor: m1.nano - image: OpenWRT - networks: - - port: - get_resource: CP1 - user_data_format: SOFTWARE_CONFIG - CP1: - type: OS::Neutron::Port - properties: - network: existing_network_1 diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_flavor_defaults.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_flavor_defaults.yaml deleted file mode 100644 index b33bf16..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_flavor_defaults.yaml +++ /dev/null @@ -1,32 +0,0 @@ -heat_template_version: 2013-05-23 - -description: > - OpenWRT with services - -outputs: - mgmt_ip-VDU1: - value: - get_attr: [CP1, fixed_ips, 0, ip_address] - -parameters: {} -resources: - VDU1: - type: OS::Nova::Server - properties: - config_drive: false - flavor: {get_resource: VDU1_flavor} - image: OpenWRT - networks: - - port: - get_resource: CP1 - user_data_format: SOFTWARE_CONFIG - CP1: - type: OS::Neutron::Port - properties: - network: existing_network_1 - VDU1_flavor: - type: OS::Nova::Flavor - properties: - disk: 10 - ram: 512 - vcpus: 1 diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_flavor_no_units.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_flavor_no_units.yaml deleted file mode 100644 index 817854c..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_flavor_no_units.yaml +++ /dev/null @@ -1,33 +0,0 @@ -heat_template_version: 2013-05-23 - -description: > - OpenWRT with services - -outputs: - mgmt_ip-VDU1: - value: - get_attr: [CP1, fixed_ips, 0, ip_address] - -parameters: {} -resources: - VDU1: - type: OS::Nova::Server - properties: - config_drive: false - flavor: {get_resource: VDU1_flavor} - image: OpenWRT - networks: - - port: - get_resource: CP1 - user_data_format: SOFTWARE_CONFIG - CP1: - type: OS::Neutron::Port - properties: - network: existing_network_1 - - VDU1_flavor: - type: OS::Nova::Flavor - properties: - disk: 2 - ram: 512 - vcpus: 2 diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_image_after_processed_image.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_image_after_processed_image.yaml deleted file mode 100644 index 19d9e52..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_image_after_processed_image.yaml +++ /dev/null @@ -1,16 +0,0 @@ -heat_template_version: 2013-05-23 -description: OpenWRT with services -outputs: {} -resources: - VDU1: - properties: - config_drive: true - flavor: m1.tiny - image: {get_resource: VDU1_image} - VDU1_image: - type: OS::Glance::Image - properties: - location: http://URL/v1/openwrt.qcow2 - container_format: bare - disk_format: raw - diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_image_before_processed_image.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_image_before_processed_image.yaml deleted file mode 100644 index f0dd37c..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_image_before_processed_image.yaml +++ /dev/null @@ -1,9 +0,0 @@ -heat_template_version: 2013-05-23 -description: OpenWRT with services -outputs: {} -resources: - VDU1: - properties: - config_drive: true - flavor: m1.tiny - image: cirros-0.3.5-x86_64-disk diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_openwrt.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_openwrt.yaml deleted file mode 100644 index 03a809c..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_openwrt.yaml +++ /dev/null @@ -1,26 +0,0 @@ -description: OpenWRT with services -heat_template_version: 2013-05-23 -outputs: - mgmt_ip-vdu1: - description: management ip address - value: - get_attr: [vdu1-net_mgmt-port, fixed_ips, 0, ip_address] -resources: - vdu1: - properties: - availability_zone: nova - config_drive: true - flavor: m1.tiny - image: cirros-0.3.5-x86_64-disk - metadata: {param0: key0, param1: key1} - networks: - - port: {get_resource: vdu1-net_mgmt-port} - - {network: net0} - - {network: net1} - type: OS::Nova::Server - vdu1-net_mgmt-port: - properties: - fixed_ips: [] - network: net_mgmt - port_security_enabled: false - type: OS::Neutron::Port diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_openwrt_ipparams.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_openwrt_ipparams.yaml deleted file mode 100644 index ac9a4a4..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_openwrt_ipparams.yaml +++ /dev/null @@ -1,41 +0,0 @@ -description: Parameterized MEA descriptor for IP addresses -heat_template_version: 2013-05-23 -outputs: - mgmt_ip-vdu1: - description: management ip address - value: - get_attr: [vdu1-net_mgmt-port, fixed_ips, 0, ip_address] -resources: - vdu1: - properties: - availability_zone: nova - config_drive: true - flavor: m1.tiny - image: cirros-0.3.5-x86_64-disk - metadata: {param0: key0, param1: key1} - networks: - - port: {get_resource: vdu1-net_mgmt-port} - - port: {get_resource: vdu1-net0-port} - - port: {get_resource: vdu1-net1-port} - type: OS::Nova::Server - vdu1-net0-port: - properties: - fixed_ips: - - {ip_address: 10.10.0.98} - network: net0 - port_security_enabled: false - type: OS::Neutron::Port - vdu1-net1-port: - properties: - fixed_ips: - - {ip_address: 10.10.1.98} - network: net1 - port_security_enabled: false - type: OS::Neutron::Port - vdu1-net_mgmt-port: - properties: - fixed_ips: - - {ip_address: 192.168.120.98} - network: net_mgmt - port_security_enabled: false - type: OS::Neutron::Port diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_openwrt_params.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_openwrt_params.yaml deleted file mode 100644 index 6c56fe4..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_openwrt_params.yaml +++ /dev/null @@ -1,35 +0,0 @@ -description: Parameterized MEA descriptor -heat_template_version: 2013-05-23 -outputs: - mgmt_ip-vdu1: - description: management ip address - value: - get_attr: [vdu1-net_mgmt-port, fixed_ips, 0, ip_address] -resources: - vdu1: - properties: - availability_zone: nova - config_drive: true - flavor: m1.tiny - image: cirros-0.3.5-x86_64-disk - key_name: keyName - metadata: {param0: key0, param1: key1} - networks: - - port: {get_resource: vdu1-net_mgmt-port} - - {network: net0} - - {network: net1} - user_data: '#!/bin/sh - - echo "my hostname is `hostname`" > /tmp/hostname - - df -h > /home/cirros/diskinfo - - ' - user_data_format: RAW - type: OS::Nova::Server - vdu1-net_mgmt-port: - properties: - fixed_ips: [] - network: net_mgmt - port_security_enabled: false - type: OS::Neutron::Port diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_scale_custom.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_scale_custom.yaml deleted file mode 100644 index a4561aa..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_scale_custom.yaml +++ /dev/null @@ -1,25 +0,0 @@ - -outputs: - mgmt_ip-VDU1: - value: - get_attr: [CP1, fixed_ips, 0, ip_address] -resources: - VDU1: - type: OS::Nova::Server - properties: - availability_zone: nova - user_data_format: SOFTWARE_CONFIG - config_drive: false - networks: - - port: { get_resource: CP1 } - image: cirros-0.3.5-x86_64-disk - flavor: m1.tiny - VL1: - type: OS::Neutron::Net - CP1: - type: OS::Neutron::Port - properties: - network: net_mgmt - port_security_enabled: false -heat_template_version: 2013-05-23 -description: Apmec Scaling template \ No newline at end of file diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_scale_main.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_scale_main.yaml deleted file mode 100644 index 96049ee..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_scale_main.yaml +++ /dev/null @@ -1,30 +0,0 @@ -heat_template_version: 2013-05-23 -description: 'sample-tosca-mead-scaling - -' - -parameters: {} -outputs: {} -resources: - SP1_group: - properties: - desired_capacity: 2 - max_size: 3 - min_size: 1 - cooldown: 60 - resource: {type: SP1_res.yaml} - type: OS::Heat::AutoScalingGroup - SP1_scale_in: - properties: - adjustment_type: change_in_capacity - auto_scaling_group_id: {get_resource: SP1_group} - cooldown: 60 - scaling_adjustment: -1 - type: OS::Heat::ScalingPolicy - SP1_scale_out: - properties: - adjustment_type: change_in_capacity - auto_scaling_group_id: {get_resource: SP1_group} - cooldown: 60 - scaling_adjustment: 1 - type: OS::Heat::ScalingPolicy diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_alarm_metadata.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_alarm_metadata.yaml deleted file mode 100644 index 452512a..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_alarm_metadata.yaml +++ /dev/null @@ -1,41 +0,0 @@ -heat_template_version: 2013-05-23 -description: 'An exception will be raised when having the mismatched metadata -(metadata is described in monitoring policy but unavailable in VDU properties). -' - -outputs: - mgmt_ip-VDU1: - value: - get_attr: [CP1, fixed_ips, 0, ip_address] -parameters: {} -resources: - VDU1: - properties: - availability_zone: nova - config_drive: false - flavor: {get_resource: VDU1_flavor} - image: cirros-0.3.5-x86_64-disk - networks: - - port: {get_resource: CP1} - user_data_format: SOFTWARE_CONFIG - type: OS::Nova::Server - CP1: - properties: {network: net_mgmt, port_security_enabled: false} - type: OS::Neutron::Port - VDU1_flavor: - type: OS::Nova::Flavor - properties: - disk: 1 - ram: 512 - vcpus: 2 - vdu_hcpu_usage_respawning: - type: OS::Aodh::Alarm - properties: - description: utilization greater_than 50% - meter_name: cpu_util - threshold: 50 - period: 60 - statistic: avg - evaluation_periods: 1 - comparison_operator: gt - 'matching_metadata': {'metadata.user_metadata.mea': 'VDU1'} diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_alarm_respawn.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_alarm_respawn.yaml deleted file mode 100644 index d61494a..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_alarm_respawn.yaml +++ /dev/null @@ -1,42 +0,0 @@ -heat_template_version: 2013-05-23 -description: 'Demo example - -' - -outputs: - mgmt_ip-VDU1: - value: - get_attr: [CP1, fixed_ips, 0, ip_address] -parameters: {} -resources: - VDU1: - properties: - availability_zone: nova - config_drive: false - flavor: {get_resource: VDU1_flavor} - image: cirros-0.3.5-x86_64-disk - networks: - - port: {get_resource: CP1} - user_data_format: SOFTWARE_CONFIG - metadata: {'metering.mea': 'VDU1'} - type: OS::Nova::Server - CP1: - properties: {network: net_mgmt, port_security_enabled: false} - type: OS::Neutron::Port - VDU1_flavor: - type: OS::Nova::Flavor - properties: - disk: 1 - ram: 512 - vcpus: 2 - vdu_hcpu_usage_respawning: - type: OS::Aodh::Alarm - properties: - description: utilization greater_than 50% - meter_name: cpu_util - threshold: 50 - period: 60 - statistic: avg - evaluation_periods: 1 - comparison_operator: gt - 'matching_metadata': {'metadata.user_metadata.mea': 'VDU1'} diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_alarm_scale.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_alarm_scale.yaml deleted file mode 100644 index 0d1ed30..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_alarm_scale.yaml +++ /dev/null @@ -1,53 +0,0 @@ -heat_template_version: 2013-05-23 -description: 'sample-tosca-mead-scaling - -' - -parameters: {} -outputs: {} -resources: - SP1_group: - properties: - cooldown: 60 - desired_capacity: 2 - max_size: 3 - min_size: 1 - resource: {type: SP1_res.yaml} - type: OS::Heat::AutoScalingGroup - SP1_scale_in: - properties: - adjustment_type: change_in_capacity - auto_scaling_group_id: {get_resource: SP1_group} - cooldown: 60 - scaling_adjustment: -1 - type: OS::Heat::ScalingPolicy - SP1_scale_out: - properties: - adjustment_type: change_in_capacity - auto_scaling_group_id: {get_resource: SP1_group} - cooldown: 60 - scaling_adjustment: 1 - type: OS::Heat::ScalingPolicy - - vdu_hcpu_usage_scaling_out: - type: OS::Aodh::Alarm - properties: - description: utilization greater_than 50% - meter_name: cpu_util - statistic: avg - period: 600 - evaluation_periods: 1 - threshold: 50 - matching_metadata: {'metadata.user_metadata.mea': SG1} - comparison_operator: gt - vdu_lcpu_usage_scaling_in: - type: OS::Aodh::Alarm - properties: - description: utilization less_than 10% - meter_name: cpu_util - statistic: avg - period: 600 - evaluation_periods: 1 - threshold: 10 - matching_metadata: {'metadata.user_metadata.mea': SG1} - comparison_operator: lt diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_allowed_address_pairs.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_allowed_address_pairs.yaml deleted file mode 100644 index 312de13..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_allowed_address_pairs.yaml +++ /dev/null @@ -1,88 +0,0 @@ -heat_template_version: 2013-05-23 - -description: > - VIP Template - -outputs: - mgmt_ip-VDU1: - value: - get_attr: [CP2, fixed_ips, 0, ip_address] - -parameters: {} -resources: - VDU1: - type: OS::Nova::Server - properties: - config_drive: false - flavor: m1.nano - image: {get_resource: VDU1_image} - networks: - - port: - get_resource: CP1 - - port: - get_resource: CP2 - user_data_format: SOFTWARE_CONFIG - CP1: - type: OS::Neutron::Port - properties: - fixed_ips: - - ip_address: 10.10.1.11 - allowed_address_pairs: - - ip_address: 10.10.1.12 - network: existing_network_1 - port_security_enabled: true - security_groups: - - default - - VCP1: - type: OS::Neutron::Port - properties: - fixed_ips: - - ip_address: 10.10.1.12 - network: existing_network_1 - port_security_enabled: true - security_groups: - - default - - CP2: - type: OS::Neutron::Port - properties: - fixed_ips: - - ip_address: 10.10.2.21 - allowed_address_pairs: - - ip_address: 10.10.2.22 - - ip_address: 10.10.2.23 - mac_address: fe:1a:29:d9:36:45 - mac_address: fe:1a:29:d9:36:45 - network: existing_network_2 - port_security_enabled: true - security_groups: - - default - - VCP2: - type: OS::Neutron::Port - properties: - fixed_ips: - - ip_address: 10.10.2.22 - network: existing_network_2 - port_security_enabled: true - security_groups: - - default - - VCP3: - type: OS::Neutron::Port - properties: - fixed_ips: - - ip_address: 10.10.2.23 - network: existing_network_2 - port_security_enabled: true - security_groups: - - default - - VDU1_image: - type: OS::Glance::Image - properties: - container_format: bare - disk_format: raw - location: http://URL/vRouterMEA.qcow2 - name: vm_image diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_flavor_all_numa_count.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_flavor_all_numa_count.yaml deleted file mode 100644 index 100f340..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_flavor_all_numa_count.yaml +++ /dev/null @@ -1,22 +0,0 @@ -heat_template_version: 2013-05-23 - -description: > - OpenWRT with services - -parameters: {} -resources: - VDU1: - type: OS::Nova::Server - properties: - config_drive: false - flavor: {get_resource: VDU1_flavor} - image: OpenWRT - user_data_format: SOFTWARE_CONFIG - VDU1_flavor: - type: OS::Nova::Flavor - properties: - disk: 10 - ram: 4096 - vcpus: 8 - extra_specs: {'hw:cpu_policy': 'dedicated', 'hw:mem_page_size': 'any', 'hw:cpu_sockets': 2, 'hw:cpu_threads': 2, 'hw:numa_nodes': 2, 'hw:cpu_cores': 2, 'hw:cpu_threads_policy': 'avoid'} -outputs: {} diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_flavor_all_numa_nodes.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_flavor_all_numa_nodes.yaml deleted file mode 100644 index b921622..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_flavor_all_numa_nodes.yaml +++ /dev/null @@ -1,22 +0,0 @@ -heat_template_version: 2013-05-23 - -description: > - OpenWRT with services - -parameters: {} -resources: - VDU1: - type: OS::Nova::Server - properties: - config_drive: false - flavor: {get_resource: VDU1_flavor} - image: OpenWRT - user_data_format: SOFTWARE_CONFIG - VDU1_flavor: - type: OS::Nova::Flavor - properties: - disk: 40 - ram: 4096 - vcpus: 6 - extra_specs: {'hw:cpu_policy': 'dedicated', 'hw:mem_page_size': 'any', 'hw:cpu_sockets': 2, 'hw:cpu_threads': 2, 'hw:numa_mem.1': 3072, 'hw:numa_mem.0': 1024, 'hw:numa_cpus.0': '0,1', 'hw:numa_cpus.1': '2,3,4,5', 'hw:cpu_cores': 2, 'hw:cpu_threads_policy': 'avoid', 'hw:numa_nodes': 2} -outputs: {} diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_flavor_cpu_allocations.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_flavor_cpu_allocations.yaml deleted file mode 100644 index 4d593b5..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_flavor_cpu_allocations.yaml +++ /dev/null @@ -1,22 +0,0 @@ -heat_template_version: 2013-05-23 - -description: > - OpenWRT with services - -parameters: {} -resources: - VDU1: - type: OS::Nova::Server - properties: - config_drive: false - flavor: {get_resource: VDU1_flavor} - image: OpenWRT - user_data_format: SOFTWARE_CONFIG - VDU1_flavor: - type: OS::Nova::Flavor - properties: - disk: 40 - ram: 4096 - vcpus: 6 - extra_specs: {'hw:cpu_policy': 'dedicated', 'hw:cpu_sockets': 2, 'hw:cpu_threads': 2, 'hw:cpu_cores': 2, 'hw:cpu_threads_policy': 'avoid'} -outputs: {} diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_flavor_huge_pages.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_flavor_huge_pages.yaml deleted file mode 100644 index e22afe4..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_flavor_huge_pages.yaml +++ /dev/null @@ -1,22 +0,0 @@ -heat_template_version: 2013-05-23 - -description: > - OpenWRT with services - -parameters: {} -resources: - VDU1: - type: OS::Nova::Server - properties: - config_drive: false - flavor: {get_resource: VDU1_flavor} - image: OpenWRT - user_data_format: SOFTWARE_CONFIG - VDU1_flavor: - type: OS::Nova::Flavor - properties: - disk: 40 - ram: 4096 - vcpus: 6 - extra_specs: {'hw:mem_page_size': 'any'} -outputs: {} diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_flavor_numa_nodes.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_flavor_numa_nodes.yaml deleted file mode 100644 index a89ed8c..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_flavor_numa_nodes.yaml +++ /dev/null @@ -1,22 +0,0 @@ -heat_template_version: 2013-05-23 - -description: > - OpenWRT with services - -parameters: {} -resources: - VDU1: - type: OS::Nova::Server - properties: - config_drive: false - flavor: {get_resource: VDU1_flavor} - image: OpenWRT - user_data_format: SOFTWARE_CONFIG - VDU1_flavor: - type: OS::Nova::Flavor - properties: - disk: 40 - ram: 4096 - vcpus: 6 - extra_specs: { 'hw:numa_mem.1': 3072, 'hw:numa_mem.0': 1024, 'hw:numa_cpus.0': '0,1', 'hw:numa_cpus.1': '2,3,4,5', 'hw:numa_nodes': 2} -outputs: {} diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_flavor_numa_nodes_count.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_flavor_numa_nodes_count.yaml deleted file mode 100644 index e2e657e..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_flavor_numa_nodes_count.yaml +++ /dev/null @@ -1,22 +0,0 @@ -heat_template_version: 2013-05-23 - -description: > - OpenWRT with services - -parameters: {} -resources: - VDU1: - type: OS::Nova::Server - properties: - config_drive: false - flavor: {get_resource: VDU1_flavor} - image: OpenWRT - user_data_format: SOFTWARE_CONFIG - VDU1_flavor: - type: OS::Nova::Flavor - properties: - disk: 40 - ram: 4096 - vcpus: 6 - extra_specs: {'hw:numa_nodes': 2 } -outputs: {} diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_generic_vnfd_params.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_generic_vnfd_params.yaml deleted file mode 100644 index 317ddb7..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_generic_vnfd_params.yaml +++ /dev/null @@ -1,45 +0,0 @@ -description: > - Generic VDU with parameterized image and flavor - -heat_template_version: 2013-05-23 -outputs: - mgmt_ip-VDU1: - value: {get_attr: [CP1, fixed_ips, 0, ip_address]} -parameters: - flavor: - constraints: - - allowed_values: [m1.tiny, m1.small, m1.medium, m1.large, m1.large] - default: m1.large - description: Flavor name for the server - type: string - image: - default: cirros - description: Image name for the server - type: string -resources: - CP1: - properties: - network: net_mgmt - port_security_enabled: False - type: OS::Neutron::Port - CP2: - properties: - network: pkt_in - port_security_enabled: False - type: OS::Neutron::Port - CP3: - properties: - network: pkt_out - port_security_enabled: False - type: OS::Neutron::Port - VDU1: - properties: - config_drive: False - flavor: { get_param: flavor } - image: { get_param: image } - networks: - - port: { get_resource: CP1 } - - port: { get_resource: CP2 } - - port: { get_resource: CP3 } - user_data_format: SOFTWARE_CONFIG - type: OS::Nova::Server diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_image.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_image.yaml deleted file mode 100644 index 6e6ddff..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_image.yaml +++ /dev/null @@ -1,34 +0,0 @@ -heat_template_version: 2013-05-23 - -description: > - OpenWRT with services - -outputs: - mgmt_ip-VDU1: - value: - get_attr: [CP1, fixed_ips, 0, ip_address] - -parameters: {} -resources: - VDU1: - type: OS::Nova::Server - properties: - config_drive: false - flavor: m1.nano - image: {get_resource: VDU1_image} - networks: - - port: - get_resource: CP1 - user_data_format: SOFTWARE_CONFIG - CP1: - type: OS::Neutron::Port - properties: - network: existing_network_1 - - VDU1_image: - type: OS::Glance::Image - properties: - container_format: bare - disk_format: raw - location: http://URL/vRouterMEA.qcow2 - name: vm_image diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_mac_ip.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_mac_ip.yaml deleted file mode 100644 index 935bb9c..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_mac_ip.yaml +++ /dev/null @@ -1,37 +0,0 @@ -heat_template_version: 2013-05-23 - -description: > - SecurityGroup Template - -outputs: - mgmt_ip-VDU1: - value: - get_attr: [CP1, fixed_ips, 0, ip_address] - -parameters: {} -resources: - VDU1: - type: OS::Nova::Server - properties: - config_drive: false - flavor: m1.nano - image: {get_resource: VDU1_image} - networks: - - port: - get_resource: CP1 - user_data_format: SOFTWARE_CONFIG - CP1: - type: OS::Neutron::Port - properties: - network: existing_network_1 - port_security_enabled: true - mac_address: fe:1a:29:d9:36:43 - fixed_ips: - - ip_address: 10.10.1.12 - VDU1_image: - type: OS::Glance::Image - properties: - container_format: bare - disk_format: raw - location: http://URL/vRouterMEA.qcow2 - name: vm_image diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_mgmt_sriov.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_mgmt_sriov.yaml deleted file mode 100644 index 3451f31..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_mgmt_sriov.yaml +++ /dev/null @@ -1,28 +0,0 @@ -heat_template_version: 2013-05-23 - -description: > - SRIOV and management port example - -outputs: - mgmt_ip-VDU1: - value: - get_attr: [CP1, fixed_ips, 0, ip_address] -parameters: {} -resources: - CP1: - properties: {'binding:vnic_type': direct, network: net-mgmt} - type: OS::Neutron::Port - CP2: - properties: {network: net0} - type: OS::Neutron::Port - VDU1: - properties: - availability_zone: nova - config_drive: false - flavor: numa-sriov - image: OpenWRT - user_data_format: SOFTWARE_CONFIG - networks: - - port: {get_resource: CP1} - - port: {get_resource: CP2} - type: OS::Nova::Server diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_monitoring_multi_vdu.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_monitoring_multi_vdu.yaml deleted file mode 100644 index 3a668b3..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_monitoring_multi_vdu.yaml +++ /dev/null @@ -1,43 +0,0 @@ -heat_template_version: 2013-05-23 -description: 'Monitoring for multiple VDUs - -' -outputs: - mgmt_ip-VDU1: - value: - get_attr: [CP1, fixed_ips, 0, ip_address] - mgmt_ip-VDU2: - value: - get_attr: [CP2, fixed_ips, 0, ip_address] - -parameters: {} -resources: - VDU1: - properties: - availability_zone: nova - config_drive: false - flavor: m1.tiny - image: cirros-0.3.5-x86_64-disk - networks: - - port: {get_resource: CP1} - user_data_format: SOFTWARE_CONFIG - type: OS::Nova::Server - - CP1: - properties: {network: net_mgmt, port_security_enabled: false} - type: OS::Neutron::Port - - VDU2: - properties: - availability_zone: nova - config_drive: false - flavor: m1.tiny - image: cirros-0.3.5-x86_64-disk - networks: - - port: {get_resource: CP2} - user_data_format: SOFTWARE_CONFIG - type: OS::Nova::Server - - CP2: - properties: {network: net_mgmt, port_security_enabled: false} - type: OS::Neutron::Port diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_openwrt.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_openwrt.yaml deleted file mode 100644 index 75dbdb0..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_openwrt.yaml +++ /dev/null @@ -1,25 +0,0 @@ -heat_template_version: 2013-05-23 -description: 'OpenWRT with services - - ' -parameters: {} -resources: - VDU1: - type: OS::Nova::Server - properties: - config_drive: false - flavor: m1.tiny - image: OpenWRT - networks: - - port: - get_resource: CP1 - user_data_format: SOFTWARE_CONFIG - CP1: - type: OS::Neutron::Port - properties: - network: existing_network_1 - port_security_enabled: false -outputs: - mgmt_ip-VDU1: - value: - get_attr: [CP1, fixed_ips, 0, ip_address] diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_openwrt_kilo.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_openwrt_kilo.yaml deleted file mode 100644 index 7d42cfa..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_openwrt_kilo.yaml +++ /dev/null @@ -1,25 +0,0 @@ -heat_template_version: 2013-05-23 -description: 'OpenWRT with services - - ' -parameters: {} -resources: - VDU1: - type: OS::Nova::Server - properties: - config_drive: false - flavor: m1.tiny - image: OpenWRT - networks: - - port: - get_resource: CP1 - user_data_format: SOFTWARE_CONFIG - CP1: - type: OS::Neutron::Port - properties: - network: existing_network_1 - value_specs: {port_security_enabled: false} -outputs: - mgmt_ip-VDU1: - value: - get_attr: [CP1, fixed_ips, 0, ip_address] diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_openwrt_userdata.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_openwrt_userdata.yaml deleted file mode 100644 index b10c0d9..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_openwrt_userdata.yaml +++ /dev/null @@ -1,29 +0,0 @@ -heat_template_version: 2013-05-23 -description: 'OpenWRT with services - - ' -parameters: {} -resources: - VDU1: - type: OS::Nova::Server - properties: - config_drive: false - flavor: m1.tiny - image: OpenWRT - networks: - - port: - get_resource: CP1 - user_data_format: RAW - user_data: | - #!/bin/sh - echo "my hostname is `hostname`" > /tmp/hostname - df -h > /home/openwrt/diskinfo - CP1: - type: OS::Neutron::Port - properties: - network: existing_network_1 - port_security_enabled: false -outputs: - mgmt_ip-VDU1: - value: - get_attr: [CP1, fixed_ips, 0, ip_address] diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_security_groups.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_security_groups.yaml deleted file mode 100644 index c59d41b..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_security_groups.yaml +++ /dev/null @@ -1,38 +0,0 @@ -heat_template_version: 2013-05-23 - -description: > - SecurityGroup Template - -outputs: - mgmt_ip-VDU1: - value: - get_attr: [CP1, fixed_ips, 0, ip_address] - -parameters: {} -resources: - VDU1: - type: OS::Nova::Server - properties: - config_drive: false - flavor: m1.nano - image: {get_resource: VDU1_image} - networks: - - port: - get_resource: CP1 - user_data_format: SOFTWARE_CONFIG - CP1: - type: OS::Neutron::Port - properties: - network: existing_network_1 - port_security_enabled: true - security_groups: - - default - - test_secgrp - - VDU1_image: - type: OS::Glance::Image - properties: - container_format: bare - disk_format: raw - location: http://URL/vRouterMEA.qcow2 - name: vm_image diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_sriov.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_sriov.yaml deleted file mode 100644 index d10c8fc..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_sriov.yaml +++ /dev/null @@ -1,28 +0,0 @@ -heat_template_version: 2013-05-23 - -description: > - SRIOV example - -outputs: - mgmt_ip-VDU1: - value: - get_attr: [CP1, fixed_ips, 0, ip_address] -parameters: {} -resources: - CP1: - properties: {name: sriov, network: net-mgmt} - type: OS::Neutron::Port - CP2: - properties: {'binding:vnic_type': direct, network: sr3010} - type: OS::Neutron::Port - VDU1: - properties: - availability_zone: nova - config_drive: false - flavor: numa-sriov - image: OpenWRT - user_data_format: SOFTWARE_CONFIG - networks: - - port: {get_resource: CP1} - - port: {get_resource: CP2} - type: OS::Nova::Server diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_vnfc.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_vnfc.yaml deleted file mode 100644 index 1bb38e9..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_vnfc.yaml +++ /dev/null @@ -1,36 +0,0 @@ -heat_template_version: 2013-05-23 -parameters: {} -resources: - VDU1: - type: OS::Nova::Server - properties: - config_drive: false - flavor: m1.small - image: Fedora - networks: - - port: - get_resource: CP1 - user_data_format: SOFTWARE_CONFIG - CP1: - type: OS::Neutron::Port - properties: - network: existing_network_1 - port_security_enabled: false - firewall_meac_create_config: - type: OS::Heat::SoftwareConfig - properties: - config: 'echo "Test case for Apmec";' - group: script - firewall_meac_create_deploy: - type: OS::Heat::SoftwareDeployment - properties: - config: {get_resource: firewall_meac_create_config} - server: {get_resource: VDU1} - depends_on: - - VDU1 - -outputs: - mgmt_ip-VDU1: - value: - get_attr: [CP1, fixed_ips, 0, ip_address] - diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_vnic_normal.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_vnic_normal.yaml deleted file mode 100644 index cf9eb92..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/hot_tosca_vnic_normal.yaml +++ /dev/null @@ -1,28 +0,0 @@ -heat_template_version: 2013-05-23 - -description: > - VNIC Normal Port example - -outputs: - mgmt_ip-VDU1: - value: - get_attr: [CP1, fixed_ips, 0, ip_address] -parameters: {} -resources: - CP1: - properties: {network: net-mgmt} - type: OS::Neutron::Port - CP2: - properties: {'binding:vnic_type': normal, network: net0} - type: OS::Neutron::Port - VDU1: - properties: - availability_zone: nova - config_drive: false - flavor: m1.small - image: OpenWRT - user_data_format: SOFTWARE_CONFIG - networks: - - port: {get_resource: CP1} - - port: {get_resource: CP2} - type: OS::Nova::Server diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/test_tosca_allowed_address_pairs.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/test_tosca_allowed_address_pairs.yaml deleted file mode 100644 index 9331861..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/test_tosca_allowed_address_pairs.yaml +++ /dev/null @@ -1,105 +0,0 @@ -tosca_definitions_version: tosca_simple_profile_for_mec_1_0_0 - -description: VIP Template - -metadata: - template_name: vipTemplate - -topology_template: - node_templates: - - VDU1: - type: tosca.nodes.mec.VDU.Apmec - artifacts: - vm_image: - type: tosca.artifacts.Deployment.Image.VM - file: http://URL/vRouterMEA.qcow2 - properties: - flavor: m1.nano - mgmt_driver: noop - monitoring_policy: - name: ping - actions: - failure: respawn - parameters: - count: 3 - interval: 10 - - CP1: - type: tosca.nodes.mec.CP.Apmec - properties: - management: true - ip_address: 10.10.1.11 - anti_spoofing_protection: true - allowed_address_pairs: - - ip_address: 10.10.1.12 - security_groups: - - default - requirements: - - virtualLink: - node: VL1 - - virtualBinding: - node: VDU1 - VCP1: - type: tosca.nodes.mec.CP.Apmec - properties: - management: true - ip_address: 10.10.1.12 - anti_spoofing_protection: true - security_groups: - - default - requirements: - - virtualLink: - node: VL1 - CP2: - type: tosca.nodes.mec.CP.Apmec - properties: - management: true - mac_address: fe:1a:29:d9:36:45 - ip_address: 10.10.2.21 - anti_spoofing_protection: true - allowed_address_pairs: - - ip_address: 10.10.2.22 - - ip_address: 10.10.2.23 - mac_address: fe:1a:29:d9:36:45 - security_groups: - - default - requirements: - - virtualLink: - node: VL2 - - virtualBinding: - node: VDU1 - VCP2: - type: tosca.nodes.mec.CP.Apmec - properties: - management: true - ip_address: 10.10.2.22 - anti_spoofing_protection: true - security_groups: - - default - requirements: - - virtualLink: - node: VL2 - VCP3: - type: tosca.nodes.mec.CP.Apmec - properties: - management: true - ip_address: 10.10.2.23 - anti_spoofing_protection: true - security_groups: - - default - requirements: - - virtualLink: - node: VL2 - - VL1: - type: tosca.nodes.mec.VL - properties: - network_name: existing_network_1 - vendor: Apmec - - VL2: - type: tosca.nodes.mec.VL - properties: - network_name: existing_network_2 - vendor: Apmec diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/test_tosca_flavor.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/test_tosca_flavor.yaml deleted file mode 100644 index f3c0dec..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/test_tosca_flavor.yaml +++ /dev/null @@ -1,44 +0,0 @@ -tosca_definitions_version: tosca_simple_profile_for_mec_1_0_0 - -description: OpenWRT with services - -metadata: - template_name: OpenWRT - -topology_template: - node_templates: - - VDU1: - type: tosca.nodes.mec.VDU.Apmec - capabilities: - mec_compute: - properties: - num_cpus: 2 - disk_size: 10 GB - mem_size: 512 MB - properties: - image: OpenWRT - mgmt_driver: openwrt - monitoring_policy: - name: ping - actions: - failure: respawn - parameters: - count: 3 - interval: 10 - - CP1: - type: tosca.nodes.mec.CP.Apmec - properties: - management: true - requirements: - - virtualLink: - node: VL1 - - virtualBinding: - node: VDU1 - - VL1: - type: tosca.nodes.mec.VL - properties: - network_name: existing_network_1 - vendor: ACME diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/test_tosca_flavor_and_capabilities.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/test_tosca_flavor_and_capabilities.yaml deleted file mode 100644 index 6cae5a3..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/test_tosca_flavor_and_capabilities.yaml +++ /dev/null @@ -1,44 +0,0 @@ -tosca_definitions_version: tosca_simple_profile_for_mec_1_0_0 - -description: OpenWRT with services - -metadata: - template_name: OpenWRT - -topology_template: - node_templates: - - VDU1: - type: tosca.nodes.mec.VDU.Apmec - capabilities: - mec_compute: - properties: - num_cpus: 2 - disk_size: 10 GB - mem_size: 512 MB - properties: - image: OpenWRT - mgmt_driver: openwrt - flavor: m1.nano - monitoring_policy: - name: ping - actions: - failure: respawn - parameters: - count: 3 - interval: 10 - CP1: - type: tosca.nodes.mec.CP.Apmec - properties: - management: true - requirements: - - virtualLink: - node: VL1 - - virtualBinding: - node: VDU1 - - VL1: - type: tosca.nodes.mec.VL - properties: - network_name: existing_network_1 - vendor: ACME diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/test_tosca_flavor_defaults.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/test_tosca_flavor_defaults.yaml deleted file mode 100644 index 486c041..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/test_tosca_flavor_defaults.yaml +++ /dev/null @@ -1,41 +0,0 @@ -tosca_definitions_version: tosca_simple_profile_for_mec_1_0_0 - -description: OpenWRT with services - -metadata: - template_name: OpenWRT - -topology_template: - node_templates: - - VDU1: - type: tosca.nodes.mec.VDU.Apmec - capabilities: - mec_compute: - properties: - disk_size: 10 GB - properties: - image: OpenWRT - mgmt_driver: openwrt - monitoring_policy: - name: ping - actions: - failure: respawn - parameters: - count: 3 - interval: 10 - CP1: - type: tosca.nodes.mec.CP.Apmec - properties: - management: true - requirements: - - virtualLink: - node: VL1 - - virtualBinding: - node: VDU1 - - VL1: - type: tosca.nodes.mec.VL - properties: - network_name: existing_network_1 - vendor: ACME diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/test_tosca_flavor_no_units.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/test_tosca_flavor_no_units.yaml deleted file mode 100644 index 63c2dc4..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/test_tosca_flavor_no_units.yaml +++ /dev/null @@ -1,43 +0,0 @@ -tosca_definitions_version: tosca_simple_profile_for_mec_1_0_0 - -description: OpenWRT with services - -metadata: - template_name: OpenWRT - -topology_template: - node_templates: - - VDU1: - type: tosca.nodes.mec.VDU.Apmec - capabilities: - mec_compute: - properties: - num_cpus: 2 - disk_size: 2048 - mem_size: 512 - properties: - image: OpenWRT - mgmt_driver: openwrt - monitoring_policy: - name: ping - actions: - failure: respawn - parameters: - count: 3 - interval: 10 - CP1: - type: tosca.nodes.mec.CP.Apmec - properties: - management: true - requirements: - - virtualLink: - node: VL1 - - virtualBinding: - node: VDU1 - - VL1: - type: tosca.nodes.mec.VL - properties: - network_name: existing_network_1 - vendor: ACME diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/test_tosca_image.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/test_tosca_image.yaml deleted file mode 100644 index 5be51b6..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/test_tosca_image.yaml +++ /dev/null @@ -1,42 +0,0 @@ -tosca_definitions_version: tosca_simple_profile_for_mec_1_0_0 - -description: OpenWRT with services - -metadata: - template_name: OpenWRT - -topology_template: - node_templates: - - VDU1: - type: tosca.nodes.mec.VDU.Apmec - artifacts: - vm_image: - type: tosca.artifacts.Deployment.Image.VM - file: http://URL/vRouterMEA.qcow2 - properties: - flavor: m1.nano - mgmt_driver: noop - monitoring_policy: - name: ping - actions: - failure: respawn - parameters: - count: 3 - interval: 10 - - CP1: - type: tosca.nodes.mec.CP.Apmec - properties: - management: true - requirements: - - virtualLink: - node: VL1 - - virtualBinding: - node: VDU1 - - VL1: - type: tosca.nodes.mec.VL - properties: - network_name: existing_network_1 - vendor: ACME diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/test_tosca_mac_ip.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/test_tosca_mac_ip.yaml deleted file mode 100644 index 277b688..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/test_tosca_mac_ip.yaml +++ /dev/null @@ -1,45 +0,0 @@ -tosca_definitions_version: tosca_simple_profile_for_mec_1_0_0 - -description: SecurityGroup Template - -metadata: - template_name: SecurityGroup - -topology_template: - node_templates: - - VDU1: - type: tosca.nodes.mec.VDU.Apmec - artifacts: - vm_image: - type: tosca.artifacts.Deployment.Image.VM - file: http://URL/vRouterMEA.qcow2 - properties: - flavor: m1.nano - mgmt_driver: noop - monitoring_policy: - name: ping - actions: - failure: respawn - parameters: - count: 3 - interval: 10 - - CP1: - type: tosca.nodes.mec.CP.Apmec - properties: - management: true - anti_spoofing_protection: true - mac_address: fe:1a:29:d9:36:43 - ip_address: 10.10.1.12 - requirements: - - virtualLink: - node: VL1 - - virtualBinding: - node: VDU1 - - VL1: - type: tosca.nodes.mec.VL - properties: - network_name: existing_network_1 - vendor: ACME diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/test_tosca_meac.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/test_tosca_meac.yaml deleted file mode 100644 index 5f13b82..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/test_tosca_meac.yaml +++ /dev/null @@ -1,39 +0,0 @@ -tosca_definitions_version: tosca_simple_profile_for_mec_1_0_0 -metadata: - template_name: sample-tosca-mead-for-meac - -topology_template: - node_templates: - firewall_meac: - type: tosca.nodes.mec.MEAC.Apmec - requirements: - - host: VDU1 - interfaces: - Standard: - create: install_meac.sh - - VDU1: - type: tosca.nodes.mec.VDU.Apmec - properties: - image: Fedora - flavor: m1.small - mgmt_driver: noop - config: | - param0: key1 - param1: key2 - - CP1: - type: tosca.nodes.mec.CP.Apmec - properties: - management: true - anti_spoofing_protection: false - requirements: - - virtualLink: - node: VL1 - - virtualBinding: - node: VDU1 - VL1: - type: tosca.nodes.mec.VL - properties: - network_name: net1 - vendor: Apmec diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/test_tosca_mead_alarm_multi_actions.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/test_tosca_mead_alarm_multi_actions.yaml deleted file mode 100644 index 425181f..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/test_tosca_mead_alarm_multi_actions.yaml +++ /dev/null @@ -1,57 +0,0 @@ -tosca_definitions_version: tosca_simple_profile_for_mec_1_0_0 -description: Demo example - -metadata: - template_name: sample-tosca-mead - -topology_template: - node_templates: - VDU1: - type: tosca.nodes.mec.VDU.Apmec - capabilities: - mec_compute: - properties: - disk_size: 1 GB - mem_size: 512 MB - num_cpus: 2 - properties: - image: cirros-0.3.5-x86_64-disk - mgmt_driver: noop - availability_zone: nova - metadata: {metering.mea: VDU1} - - CP1: - type: tosca.nodes.mec.CP.Apmec - properties: - management: true - anti_spoofing_protection: false - requirements: - - virtualLink: - node: VL1 - - virtualBinding: - node: VDU1 - - VL1: - type: tosca.nodes.mec.VL - properties: - network_name: net_mgmt - vendor: Apmec - - policies: - - vdu1_cpu_usage_monitoring_policy: - type: tosca.policies.apmec.Alarming - triggers: - mon_policy_multi_actions: - event_type: - type: tosca.events.resource.utilization - implementation: ceilometer - meter_name: cpu_util - condition: - threshold: 50 - constraint: utilization greater_than 50% - period: 600 - evaluations: 1 - method: average - comparison_operator: gt - metadata: VDU1 - actions: [respawn, log] diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/test_tosca_mead_alarm_respawn.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/test_tosca_mead_alarm_respawn.yaml deleted file mode 100644 index 7090eb1..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/test_tosca_mead_alarm_respawn.yaml +++ /dev/null @@ -1,57 +0,0 @@ -tosca_definitions_version: tosca_simple_profile_for_mec_1_0_0 -description: Demo example - -metadata: - template_name: sample-tosca-mead - -topology_template: - node_templates: - VDU1: - type: tosca.nodes.mec.VDU.Apmec - capabilities: - mec_compute: - properties: - disk_size: 1 GB - mem_size: 512 MB - num_cpus: 2 - properties: - image: cirros-0.3.5-x86_64-disk - mgmt_driver: noop - availability_zone: nova - metadata: {metering.mea: VDU1} - - CP1: - type: tosca.nodes.mec.CP.Apmec - properties: - management: true - anti_spoofing_protection: false - requirements: - - virtualLink: - node: VL1 - - virtualBinding: - node: VDU1 - - VL1: - type: tosca.nodes.mec.VL - properties: - network_name: net_mgmt - vendor: Apmec - - policies: - - vdu1_cpu_usage_monitoring_policy: - type: tosca.policies.apmec.Alarming - triggers: - vdu_hcpu_usage_respawning: - event_type: - type: tosca.events.resource.utilization - implementation: ceilometer - meter_name: cpu_util - condition: - threshold: 50 - constraint: utilization greater_than 50% - period: 600 - evaluations: 1 - method: average - comparison_operator: gt - metadata: VDU1 - action: [respawn] diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/test_tosca_mead_alarm_scale.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/test_tosca_mead_alarm_scale.yaml deleted file mode 100644 index d21f8d3..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/test_tosca_mead_alarm_scale.yaml +++ /dev/null @@ -1,67 +0,0 @@ -tosca_definitions_version: tosca_simple_profile_for_mec_1_0_0 -description: Demo example - -metadata: - template_name: sample-tosca-mead - -topology_template: - node_templates: - VDU1: - type: tosca.nodes.mec.VDU.Apmec - capabilities: - mec_compute: - properties: - disk_size: 1 GB - mem_size: 512 MB - num_cpus: 2 - properties: - image: cirros-0.3.5-x86_64-disk - mgmt_driver: noop - availability_zone: nova - metadata: {metering.mea: SG1} - - CP1: - type: tosca.nodes.mec.CP.Apmec - properties: - management: true - anti_spoofing_protection: false - requirements: - - virtualLink: - node: VL1 - - virtualBinding: - node: VDU1 - - VL1: - type: tosca.nodes.mec.VL - properties: - network_name: net_mgmt - vendor: Apmec - - policies: - - SP1: - type: tosca.policies.apmec.Scaling - properties: - increment: 1 - cooldown: 120 - min_instances: 1 - max_instances: 3 - default_instances: 2 - targets: [VDU1] - - - vdu1_cpu_usage_monitoring_policy: - type: tosca.policies.apmec.Alarming - triggers: - vdu_hcpu_usage_scaling_out: - event_type: - type: tosca.events.resource.utilization - implementation: ceilometer - meter_name: cpu_util - condition: - threshold: 50 - constraint: utilization greater_than 50% - period: 600 - evaluations: 1 - method: average - comparison_operator: gt - metadata: SG1 - action: [SP1] diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/test_tosca_openwrt.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/test_tosca_openwrt.yaml deleted file mode 100644 index 0a4e40a..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/test_tosca_openwrt.yaml +++ /dev/null @@ -1,44 +0,0 @@ -tosca_definitions_version: tosca_simple_profile_for_mec_1_0_0 - -description: OpenWRT with services - -metadata: - template_name: OpenWRT - -topology_template: - node_templates: - - VDU1: - type: tosca.nodes.mec.VDU.Apmec - properties: - image: OpenWRT - flavor: m1.tiny - config: | - param0: key1 - param1: key2 - mgmt_driver: openwrt - monitoring_policy: - name: ping - actions: - failure: respawn - parameters: - count: 3 - interval: 10 - - CP1: - type: tosca.nodes.mec.CP.Apmec - properties: - management: true - anti_spoofing_protection: false - requirements: - - virtualLink: - node: VL1 - - virtualBinding: - node: VDU1 - - VL1: - type: tosca.nodes.mec.VL - properties: - network_name: existing_network_1 - vendor: ACME - diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/test_tosca_openwrt_userdata.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/test_tosca_openwrt_userdata.yaml deleted file mode 100644 index 0385051..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/test_tosca_openwrt_userdata.yaml +++ /dev/null @@ -1,49 +0,0 @@ -tosca_definitions_version: tosca_simple_profile_for_mec_1_0_0 - -description: OpenWRT with services - -metadata: - template_name: OpenWRT - -topology_template: - node_templates: - - VDU1: - type: tosca.nodes.mec.VDU.Apmec - properties: - image: OpenWRT - flavor: m1.tiny - config: | - param0: key1 - param1: key2 - mgmt_driver: openwrt - monitoring_policy: - name: ping - actions: - failure: respawn - parameters: - count: 3 - interval: 10 - user_data_format: RAW - user_data: | - #!/bin/sh - echo "my hostname is `hostname`" > /tmp/hostname - df -h > /home/openwrt/diskinfo - - CP1: - type: tosca.nodes.mec.CP.Apmec - properties: - management: true - anti_spoofing_protection: false - requirements: - - virtualLink: - node: VL1 - - virtualBinding: - node: VDU1 - - VL1: - type: tosca.nodes.mec.VL - properties: - network_name: existing_network_1 - vendor: ACME - diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/test_tosca_security_groups.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/test_tosca_security_groups.yaml deleted file mode 100644 index 84ec89c..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/test_tosca_security_groups.yaml +++ /dev/null @@ -1,46 +0,0 @@ -tosca_definitions_version: tosca_simple_profile_for_mec_1_0_0 - -description: SecurityGroup Template - -metadata: - template_name: SecurityGroup - -topology_template: - node_templates: - - VDU1: - type: tosca.nodes.mec.VDU.Apmec - artifacts: - vm_image: - type: tosca.artifacts.Deployment.Image.VM - file: http://URL/vRouterMEA.qcow2 - properties: - flavor: m1.nano - mgmt_driver: noop - monitoring_policy: - name: ping - actions: - failure: respawn - parameters: - count: 3 - interval: 10 - - CP1: - type: tosca.nodes.mec.CP.Apmec - properties: - management: true - anti_spoofing_protection: true - security_groups: - - default - - test_secgrp - requirements: - - virtualLink: - node: VL1 - - virtualBinding: - node: VDU1 - - VL1: - type: tosca.nodes.mec.VL - properties: - network_name: existing_network_1 - vendor: ACME diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_alarm_metadata.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_alarm_metadata.yaml deleted file mode 100644 index af90732..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_alarm_metadata.yaml +++ /dev/null @@ -1,60 +0,0 @@ -tosca_definitions_version: tosca_simple_profile_for_mec_1_0_0 -description: > - An exception will be raised when having the mismatched metadata - (metadata is described in monitoring policy but unavailable in - VDU properties). - -metadata: - template_name: sample-tosca-mead - -topology_template: - node_templates: - VDU1: - type: tosca.nodes.mec.VDU.Apmec - capabilities: - mec_compute: - properties: - disk_size: 1 GB - mem_size: 512 MB - num_cpus: 2 - properties: - image: cirros-0.3.5-x86_64-disk - mgmt_driver: noop - availability_zone: nova - - - CP1: - type: tosca.nodes.mec.CP.Apmec - properties: - management: true - anti_spoofing_protection: false - requirements: - - virtualLink: - node: VL1 - - virtualBinding: - node: VDU1 - - VL1: - type: tosca.nodes.mec.VL - properties: - network_name: net_mgmt - vendor: Apmec - - policies: - - vdu1_cpu_usage_monitoring_policy: - type: tosca.policies.apmec.Alarming - triggers: - vdu_hcpu_usage_respawning: - event_type: - type: tosca.events.resource.utilization - implementation: Ceilometer - meter_name: cpu_util - condition: - threshold: 50 - constraint: utilization greater_than 50% - period: 60 - evaluations: 1 - method: average - comparison_operator: gt - metadata: VDU1 - action: '' diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_alarm_respawn.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_alarm_respawn.yaml deleted file mode 100644 index 7320426..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_alarm_respawn.yaml +++ /dev/null @@ -1,58 +0,0 @@ -tosca_definitions_version: tosca_simple_profile_for_mec_1_0_0 -description: Demo example - -metadata: - template_name: sample-tosca-mead - -topology_template: - node_templates: - VDU1: - type: tosca.nodes.mec.VDU.Apmec - capabilities: - mec_compute: - properties: - disk_size: 1 GB - mem_size: 512 MB - num_cpus: 2 - properties: - image: cirros-0.3.5-x86_64-disk - mgmt_driver: noop - availability_zone: nova - metadata: {metering.mea: VDU1} - - - CP1: - type: tosca.nodes.mec.CP.Apmec - properties: - management: true - anti_spoofing_protection: false - requirements: - - virtualLink: - node: VL1 - - virtualBinding: - node: VDU1 - - VL1: - type: tosca.nodes.mec.VL - properties: - network_name: net_mgmt - vendor: Apmec - - policies: - - vdu1_cpu_usage_monitoring_policy: - type: tosca.policies.apmec.Alarming - triggers: - vdu_hcpu_usage_respawning: - event_type: - type: tosca.events.resource.utilization - implementation: Ceilometer - meter_name: cpu_util - condition: - threshold: 50 - constraint: utilization greater_than 50% - period: 60 - evaluations: 1 - method: average - comparison_operator: gt - metadata: VDU1 - action: '' diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_alarm_scale.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_alarm_scale.yaml deleted file mode 100644 index d5a295b..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_alarm_scale.yaml +++ /dev/null @@ -1,78 +0,0 @@ -tosca_definitions_version: tosca_simple_profile_for_mec_1_0_0 - -description: sample-tosca-mead-scaling - -metadata: - template_name: sample-tosca-mead-scaling - -topology_template: - node_templates: - VDU1: - type: tosca.nodes.mec.VDU.Apmec - properties: - image: cirros-0.3.5-x86_64-disk - mgmt_driver: noop - availability_zone: nova - flavor: m1.tiny - metadata: {metering.mea: SG1} - - CP1: - type: tosca.nodes.mec.CP.Apmec - properties: - management: true - anti_spoofing_protection: false - requirements: - - virtualLink: - node: VL1 - - virtualBinding: - node: VDU1 - - VL1: - type: tosca.nodes.mec.VL - properties: - network_name: net_mgmt - vendor: Apmec - - policies: - - SP1: - type: tosca.policies.apmec.Scaling - targets: [VDU1] - properties: - increment: 1 - cooldown: 60 - min_instances: 1 - max_instances: 3 - default_instances: 2 - - - vdu_cpu_usage_monitoring_policy: - type: tosca.policies.apmec.Alarming - triggers: - vdu_hcpu_usage_scaling_out: - event_type: - type: tosca.events.resource.utilization - implementation: ceilometer - meter_name: cpu_util - condition: - threshold: 50 - constraint: utilization greater_than 50% - period: 600 - evaluations: 1 - method: average - comparison_operator: gt - metadata: SG1 - action: [SP1] - - vdu_lcpu_usage_scaling_in: - event_type: - type: tosca.events.resource.utilization - implementation: ceilometer - meter_name: cpu_util - condition: - threshold: 10 - constraint: utilization less_than 10% - period: 600 - evaluations: 1 - method: average - comparison_operator: lt - metadata: SG1 - action: [SP1] diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_block_storage.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_block_storage.yaml deleted file mode 100644 index 498bc41..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_block_storage.yaml +++ /dev/null @@ -1,57 +0,0 @@ -tosca_definitions_version: tosca_simple_profile_for_mec_1_0_0 - -description: Demo example - -metadata: - template_name: sample-tosca-mead - -topology_template: - node_templates: - VDU1: - type: tosca.nodes.mec.VDU.Apmec - capabilities: - mec_compute: - properties: - num_cpus: 1 - mem_size: 512 MB - disk_size: 1 GB - properties: - image: cirros-0.3.5-x86_64-disk - availability_zone: nova - mgmt_driver: noop - config: | - param0: key1 - param1: key2 - - CP1: - type: tosca.nodes.mec.CP.Apmec - properties: - management: true - order: 0 - anti_spoofing_protection: false - requirements: - - virtualLink: - node: VL1 - - virtualBinding: - node: VDU1 - - VB1: - type: tosca.nodes.BlockStorage.Apmec - properties: - size: 1 GB - image: cirros-0.3.5-x86_64-disk - - CB1: - type: tosca.nodes.BlockStorageAttachment - properties: - location: /dev/vdb - requirements: - - virtualBinding: - node: VDU1 - - virtualAttachment: - node: VB1 - VL1: - type: tosca.nodes.mec.VL - properties: - network_name: net_mgmt - vendor: Apmec diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_flavor_all_numa_count.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_flavor_all_numa_count.yaml deleted file mode 100644 index b683162..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_flavor_all_numa_count.yaml +++ /dev/null @@ -1,36 +0,0 @@ -tosca_definitions_version: tosca_simple_profile_for_mec_1_0_0 - -description: OpenWRT with services - -metadata: - template_name: OpenWRT - -topology_template: - node_templates: - - VDU1: - type: tosca.nodes.mec.VDU.Apmec - capabilities: - mec_compute: - properties: - num_cpus: 8 - disk_size: 10 GB - mem_size: 4096 MB - mem_page_size: any - numa_node_count: 2 - cpu_allocation: - cpu_affinity: dedicated - thread_allocation: avoid - socket_count: 2 - thread_count: 2 - core_count: 2 - properties: - image: OpenWRT - mgmt_driver: openwrt - monitoring_policy: - name: ping - actions: - failure: respawn - parameters: - count: 3 - interval: 10 diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_flavor_all_numa_nodes.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_flavor_all_numa_nodes.yaml deleted file mode 100644 index ab16750..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_flavor_all_numa_nodes.yaml +++ /dev/null @@ -1,44 +0,0 @@ -tosca_definitions_version: tosca_simple_profile_for_mec_1_0_0 - -description: OpenWRT with services - -metadata: - template_name: OpenWRT - -topology_template: - node_templates: - - VDU1: - type: tosca.nodes.mec.VDU.Apmec - capabilities: - mec_compute: - properties: - num_cpus: 6 - disk_size: 40 GB - mem_size: 4096 MB - mem_page_size: any - numa_nodes: - node0: - id: 0 - vcpus: [0, 1] - mem_size: 1024 - node1: - id: 1 - vcpus: [2,3,4,5] - mem_size: 3072 - cpu_allocation: - cpu_affinity: dedicated - thread_allocation: avoid - socket_count: 2 - thread_count: 2 - core_count: 2 - properties: - image: OpenWRT - mgmt_driver: openwrt - monitoring_policy: - name: ping - actions: - failure: respawn - parameters: - count: 3 - interval: 10 diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_flavor_cpu_allocations.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_flavor_cpu_allocations.yaml deleted file mode 100644 index 8cf2830..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_flavor_cpu_allocations.yaml +++ /dev/null @@ -1,34 +0,0 @@ -tosca_definitions_version: tosca_simple_profile_for_mec_1_0_0 - -description: OpenWRT with services - -metadata: - template_name: OpenWRT - -topology_template: - node_templates: - - VDU1: - type: tosca.nodes.mec.VDU.Apmec - capabilities: - mec_compute: - properties: - num_cpus: 6 - disk_size: 40 GB - mem_size: 4096 MB - cpu_allocation: - cpu_affinity: dedicated - thread_allocation: avoid - socket_count: 2 - thread_count: 2 - core_count: 2 - properties: - image: OpenWRT - mgmt_driver: openwrt - monitoring_policy: - name: ping - actions: - failure: respawn - parameters: - count: 3 - interval: 10 diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_flavor_huge_pages.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_flavor_huge_pages.yaml deleted file mode 100644 index 2e94cea..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_flavor_huge_pages.yaml +++ /dev/null @@ -1,29 +0,0 @@ -tosca_definitions_version: tosca_simple_profile_for_mec_1_0_0 - -description: OpenWRT with services - -metadata: - template_name: OpenWRT - -topology_template: - node_templates: - - VDU1: - type: tosca.nodes.mec.VDU.Apmec - capabilities: - mec_compute: - properties: - num_cpus: 6 - disk_size: 40 GB - mem_size: 4096 MB - mem_page_size: any - properties: - image: OpenWRT - mgmt_driver: openwrt - monitoring_policy: - name: ping - actions: - failure: respawn - parameters: - count: 3 - interval: 10 diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_flavor_numa_nodes.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_flavor_numa_nodes.yaml deleted file mode 100644 index 7911dcb..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_flavor_numa_nodes.yaml +++ /dev/null @@ -1,37 +0,0 @@ -tosca_definitions_version: tosca_simple_profile_for_mec_1_0_0 - -description: OpenWRT with services - -metadata: - template_name: OpenWRT - -topology_template: - node_templates: - - VDU1: - type: tosca.nodes.mec.VDU.Apmec - capabilities: - mec_compute: - properties: - num_cpus: 6 - disk_size: 40 GB - mem_size: 4096 MB - numa_nodes: - node0: - id: 0 - vcpus: [0, 1] - mem_size: 1024 - node1: - id: 1 - vcpus: [2,3,4,5] - mem_size: 3072 - properties: - image: OpenWRT - mgmt_driver: openwrt - monitoring_policy: - name: ping - actions: - failure: respawn - parameters: - count: 3 - interval: 10 diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_flavor_numa_nodes_count.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_flavor_numa_nodes_count.yaml deleted file mode 100644 index f70e688..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_flavor_numa_nodes_count.yaml +++ /dev/null @@ -1,38 +0,0 @@ -tosca_definitions_version: tosca_simple_profile_for_mec_1_0_0 - -description: OpenWRT with services - -metadata: - template_name: OpenWRT - -topology_template: - node_templates: - - VDU1: - type: tosca.nodes.mec.VDU.Apmec - capabilities: - mec_compute: - properties: - num_cpus: 6 - disk_size: 40 GB - mem_size: 4096 MB - numa_nodes: - node0: - id: 0 - vcpus: [0, 1] - mem_size: 1024 - node1: - id: 1 - vcpus: [2,3,4,5] - mem_size: 3072 - numa_node_count: 2 - properties: - image: OpenWRT - mgmt_driver: openwrt - monitoring_policy: - name: ping - actions: - failure: respawn - parameters: - count: 3 - interval: 10 diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_generic_mead_params.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_generic_mead_params.yaml deleted file mode 100644 index 40c0d9c..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_generic_mead_params.yaml +++ /dev/null @@ -1,86 +0,0 @@ -tosca_definitions_version: tosca_simple_profile_for_mec_1_0_0 - -description: Generic VDU with parameterized image and flavor - -metadata: - template_name: OpenWRT - -topology_template: - - inputs: - flavor: - type: string - description: Flavor name for the server - constraints: - - valid_values: [ m1.tiny, m1.small, m1.medium, m1.large, m1.large ] - default: m1.tiny - - image: - type: string - description: Image name for the server - default: OpenWRT - - node_templates: - - VDU1: - type: tosca.nodes.mec.VDU.Apmec - properties: - image: { get_input: image } - flavor: { get_input: flavor } - monitoring_policy: - name: ping - actions: - failure: respawn - parameters: - count: 3 - interval: 10 - - CP1: - type: tosca.nodes.mec.CP.Apmec - properties: - management: true - anti_spoofing_protection: false - requirements: - - virtualLink: - node: VL1 - - virtualBinding: - node: VDU1 - - CP2: - type: tosca.nodes.mec.CP.Apmec - properties: - anti_spoofing_protection: false - requirements: - - virtualLink: - node: VL2 - - virtualBinding: - node: VDU1 - - CP3: - type: tosca.nodes.mec.CP.Apmec - properties: - anti_spoofing_protection: false - requirements: - - virtualLink: - node: VL3 - - virtualBinding: - node: VDU1 - - VL1: - type: tosca.nodes.mec.VL - properties: - network_name: net_mgmt - vendor: Apmec - - VL2: - type: tosca.nodes.mec.VL - properties: - network_name: pkt_in - vendor: Apmec - - VL3: - type: tosca.nodes.mec.VL - properties: - network_name: pkt_out - vendor: Apmec - diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_mgmt_sriov.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_mgmt_sriov.yaml deleted file mode 100644 index c4a17ac..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_mgmt_sriov.yaml +++ /dev/null @@ -1,57 +0,0 @@ -tosca_definitions_version: tosca_simple_profile_for_mec_1_0_0 - -description: SRIOV and management port example - -metadata: - template_name: sample-SRIOV-mead - -topology_template: - node_templates: - VDU1: - type: tosca.nodes.mec.VDU.Apmec - properties: - image: OpenWRT - flavor: numa-sriov - availability_zone: nova - mgmt_driver: openwrt - monitoring_policy: - name: ping - actions: - failure: respawn - parameters: - count: 3 - interval: 10 - config: | - param0: key1 - param1: key2 - - CP1: - type: tosca.nodes.mec.CP.Apmec - properties: - management: true - type: sriov - requirements: - - virtualLink: - node: VL1 - - virtualBinding: - node: VDU1 - - CP2: - type: tosca.nodes.mec.CP.Apmec - requirements: - - virtualLink: - node: VL2 - - virtualBinding: - node: VDU1 - - VL1: - type: tosca.nodes.mec.VL - properties: - network_name: net-mgmt - vendor: Apmec - - VL2: - type: tosca.nodes.mec.VL - properties: - network_name: net0 - vendor: Apmec diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_monitoring_multi_vdu.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_monitoring_multi_vdu.yaml deleted file mode 100644 index 67f5c70..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_monitoring_multi_vdu.yaml +++ /dev/null @@ -1,74 +0,0 @@ -tosca_definitions_version: tosca_simple_profile_for_mec_1_0_0 - -description: Monitoring for multiple VDUs - -metadata: - template_name: sample-tosca-mead - -topology_template: - node_templates: - VDU1: - type: tosca.nodes.mec.VDU.Apmec - properties: - image: cirros-0.3.5-x86_64-disk - flavor: m1.tiny - availability_zone: nova - mgmt_driver: noop - config: | - param0: key1 - param1: key2 - monitoring_policy: - name: ping - actions: - failure: respawn - parameters: - count: 3 - interval: 10 - - CP1: - type: tosca.nodes.mec.CP.Apmec - properties: - management: true - order: 0 - anti_spoofing_protection: false - requirements: - - virtualLink: - node: VL1 - - virtualBinding: - node: VDU1 - - VDU2: - type: tosca.nodes.mec.VDU.Apmec - properties: - image: cirros-0.3.5-x86_64-disk - flavor: m1.tiny - availability_zone: nova - mgmt_driver: noop - config: | - param0: key1 - param1: key2 - monitoring_policy: - name: ping - actions: - failure: respawn - parameters: - count: 3 - interval: 10 - - CP2: - type: tosca.nodes.mec.CP.Apmec - properties: - management: true - order: 0 - anti_spoofing_protection: false - requirements: - - virtualLink: - node: VL1 - - virtualBinding: - node: VDU2 - - VL1: - type: tosca.nodes.mec.VL - properties: - network_name: net_mgmt - vendor: Apmec diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_nsd_template.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_nsd_template.yaml deleted file mode 100644 index d97b2d9..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_nsd_template.yaml +++ /dev/null @@ -1,38 +0,0 @@ -tosca_definitions_version: tosca_simple_profile_for_mec_1_0_0 -imports: - - MEA1 - - MEA2 - -topology_template: - inputs: - vl1_name: - type: string - description: name of VL1 virtuallink - default: net_mgmt - vl2_name: - type: string - description: name of VL2 virtuallink - default: net0 - - node_templates: - MEA1: - type: tosca.nodes.mec.MEA1 - requirements: - - virtualLink1: VL1 - - virtualLink2: VL2 - - MEA2: - type: tosca.nodes.mec.MEA2 - - VL1: - type: tosca.nodes.mec.VL - properties: - network_name: {get_input: vl1_name} - vendor: apmec - - VL2: - type: tosca.nodes.mec.VL - properties: - network_name: {get_input: vl2_name} - vendor: apmec - diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_scale.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_scale.yaml deleted file mode 100644 index 02ba990..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_scale.yaml +++ /dev/null @@ -1,45 +0,0 @@ -tosca_definitions_version: tosca_simple_profile_for_mec_1_0_0 - -description: sample-tosca-mead-scaling - -metadata: - template_name: sample-tosca-mead-scaling - -topology_template: - node_templates: - VDU1: - type: tosca.nodes.mec.VDU.Apmec - properties: - image: cirros-0.3.5-x86_64-disk - mgmt_driver: noop - availability_zone: nova - flavor: m1.tiny - - CP1: - type: tosca.nodes.mec.CP.Apmec - properties: - management: true - anti_spoofing_protection: false - requirements: - - virtualLink: - node: VL1 - - virtualBinding: - node: VDU1 - - VL1: - type: tosca.nodes.mec.VL - properties: - network_name: net_mgmt - vendor: Apmec - - policies: - - SP1: - type: tosca.policies.apmec.Scaling - targets: [VDU1] - properties: - increment: 1 - cooldown: 60 - min_instances: 1 - max_instances: 3 - default_instances: 2 - diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_sriov.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_sriov.yaml deleted file mode 100644 index 7bb5e33..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_sriov.yaml +++ /dev/null @@ -1,59 +0,0 @@ -tosca_definitions_version: tosca_simple_profile_for_mec_1_0_0 - -description: SRIOV example - -metadata: - template_name: sample-SRIOV-mead - -topology_template: - node_templates: - VDU1: - type: tosca.nodes.mec.VDU.Apmec - properties: - image: OpenWRT - flavor: numa-sriov - availability_zone: nova - mgmt_driver: openwrt - monitoring_policy: - name: ping - actions: - failure: respawn - parameters: - count: 3 - interval: 10 - config: | - param0: key1 - param1: key2 - - CP1: - type: tosca.nodes.mec.CP.Apmec - properties: - name: sriov - management: true - requirements: - - virtualLink: - node: VL1 - - virtualBinding: - node: VDU1 - - CP2: - type: tosca.nodes.mec.CP.Apmec - properties: - type: sriov - requirements: - - virtualLink: - node: VL2 - - virtualBinding: - node: VDU1 - - VL1: - type: tosca.nodes.mec.VL - properties: - network_name: net-mgmt - vendor: Apmec - - VL2: - type: tosca.nodes.mec.VL - properties: - network_name: sr3010 - vendor: Apmec diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_vnic_port.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_vnic_port.yaml deleted file mode 100644 index fd257f2..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/tosca_vnic_port.yaml +++ /dev/null @@ -1,58 +0,0 @@ -tosca_definitions_version: tosca_simple_profile_for_mec_1_0_0 - -description: VNIC Normal Port example - -metadata: - template_name: sample-vnic-normal-mead - -topology_template: - node_templates: - VDU1: - type: tosca.nodes.mec.VDU.Apmec - properties: - image: OpenWRT - flavor: m1.small - availability_zone: nova - mgmt_driver: openwrt - monitoring_policy: - name: ping - actions: - failure: respawn - parameters: - count: 3 - interval: 10 - config: | - param0: key1 - param1: key2 - - CP1: - type: tosca.nodes.mec.CP.Apmec - properties: - management: true - requirements: - - virtualLink: - node: VL1 - - virtualBinding: - node: VDU1 - - CP2: - type: tosca.nodes.mec.CP.Apmec - properties: - type: vnic - requirements: - - virtualLink: - node: VL2 - - virtualBinding: - node: VDU1 - - VL1: - type: tosca.nodes.mec.VL - properties: - network_name: net-mgmt - vendor: Apmec - - VL2: - type: tosca.nodes.mec.VL - properties: - network_name: net0 - vendor: Apmec diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/data/update_config_data.yaml b/apmec/tests/unit/mem/infra_drivers/openstack/data/update_config_data.yaml deleted file mode 100644 index 5d95165..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/data/update_config_data.yaml +++ /dev/null @@ -1,11 +0,0 @@ -vdus: - vdu1: - config: - firewall: | - package firewall - - config defaults - option syn_flood '3' - option input 'ACCEPT' - option output 'ACCEPT' - option forward 'ACCEPT' diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/test_openstack.py b/apmec/tests/unit/mem/infra_drivers/openstack/test_openstack.py deleted file mode 100644 index dc1c245..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/test_openstack.py +++ /dev/null @@ -1,463 +0,0 @@ -# Copyright 2015 Brocade Communications System, Inc. -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, 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 codecs -import json -import mock -import os -import yaml - -from apmec import context -from apmec.extensions import mem -from apmec.tests.unit import base -from apmec.tests.unit.db import utils -from apmec.mem.infra_drivers.openstack import openstack - - -class FakeHeatClient(mock.Mock): - - class Stack(mock.Mock): - stack_status = 'CREATE_COMPLETE' - outputs = [{u'output_value': u'192.168.120.31', u'description': - u'management ip address', u'output_key': u'mgmt_ip-vdu1'}] - - def create(self, *args, **kwargs): - return {'stack': {'id': '4a4c2d44-8a52-4895-9a75-9d1c76c3e738'}} - - def get(self, id): - return self.Stack() - - -def _get_template(name): - filename = os.path.join( - os.path.dirname(os.path.abspath(__file__)), "data/", name) - f = codecs.open(filename, encoding='utf-8', errors='strict') - return f.read() - - -class TestOpenStack(base.TestCase): - hot_template = _get_template('hot_openwrt.yaml') - hot_param_template = _get_template('hot_openwrt_params.yaml') - hot_ipparam_template = _get_template('hot_openwrt_ipparams.yaml') - tosca_mead_openwrt = _get_template('test_tosca_openwrt.yaml') - config_data = _get_template('config_data.yaml') - - def setUp(self): - super(TestOpenStack, self).setUp() - self.context = context.get_admin_context() - self.infra_driver = openstack.OpenStack() - self._mock_heat_client() - self.addCleanup(mock.patch.stopall) - - def _mock_heat_client(self): - self.heat_client = mock.Mock(wraps=FakeHeatClient()) - fake_heat_client = mock.Mock() - fake_heat_client.return_value = self.heat_client - self._mock( - 'apmec.mem.infra_drivers.openstack.heat_client.HeatClient', - fake_heat_client) - - def _mock(self, target, new=mock.DEFAULT): - patcher = mock.patch(target, new) - return patcher.start() - - def _get_mead(self, template): - return {'mead': {'attributes': {'mead': template}}} - - def _get_expected_mead(self, template): - return {'attributes': {'mead': template}, - 'description': 'OpenWRT with services', - 'mgmt_driver': 'openwrt', 'name': 'OpenWRT', - 'service_types': [{'service_type': 'mead', - 'id': '4a4c2d44-8a52-4895-9a75-9d1c76c3e738'}], - 'tenant_id': 'ad7ebc56538745a08ef7c5e97f8bd437', - 'id': 'fb048660-dc1b-4f0f-bd89-b023666650ec'} - - def _get_expected_fields(self): - return {'stack_name': - 'apmec.mem.infra_drivers.openstack.openstack_OpenStack' - '-eb84260e-5ff7-4332-b032-50a14d6c1123', 'template': - self.hot_template} - - def _get_expected_fields_user_data(self): - return {'stack_name': - 'apmec.mem.infra_drivers.openstack.openstack_OpenStack' - '-18685f68-2b2a-4185-8566-74f54e548811', - 'template': self.hot_param_template} - - def _get_expected_fields_ipaddr_data(self): - return {'stack_name': - 'apmec.mem.infra_drivers.openstack.openstack_OpenStack' - '-d1337add-d5a1-4fd4-9447-bb9243c8460b', - 'template': self.hot_ipparam_template} - - def _get_expected_mea_wait_obj(self, param_values=''): - return {'status': 'PENDING_CREATE', - 'instance_id': None, - 'name': u'test_openwrt', - 'tenant_id': u'ad7ebc56538745a08ef7c5e97f8bd437', - 'mead_id': u'eb094833-995e-49f0-a047-dfb56aaf7c4e', - 'mead': { - 'service_types': [{ - 'service_type': u'mead', - 'id': u'4a4c2d44-8a52-4895-9a75-9d1c76c3e738'}], - 'description': u'OpenWRT with services', - 'tenant_id': u'ad7ebc56538745a08ef7c5e97f8bd437', - 'mgmt_driver': u'openwrt', - 'attributes': {u'mead': self.tosca_mead_openwrt}, - 'id': u'fb048660-dc1b-4f0f-bd89-b023666650ec', - 'name': u'OpenWRT'}, - 'mgmt_url': '{"vdu1": "192.168.120.31"}', - 'service_context': [], - 'attributes': {u'param_values': param_values}, - 'id': 'eb84260e-5ff7-4332-b032-50a14d6c1123', - 'description': u'OpenWRT with services'} - - def _get_expected_mea_update_obj(self): - return {'status': 'PENDING_CREATE', 'instance_id': None, 'name': - u'test_openwrt', 'tenant_id': - u'ad7ebc56538745a08ef7c5e97f8bd437', 'mead_id': - u'eb094833-995e-49f0-a047-dfb56aaf7c4e', 'mead': { - 'service_types': [{'service_type': u'mead', 'id': - u'4a4c2d44-8a52-4895-9a75-9d1c76c3e738'}], 'description': - u'OpenWRT with services', 'tenant_id': - u'ad7ebc56538745a08ef7c5e97f8bd437', 'mgmt_driver': u'openwrt', - 'attributes': {u'mead': self.tosca_mead_openwrt}, - 'id': u'fb048660-dc1b-4f0f-bd89-b023666650ec', 'name': - u'openwrt_services'}, 'mgmt_url': None, 'service_context': [], - 'attributes': {'config': utils.update_config_data}, - 'id': 'eb84260e-5ff7-4332-b032-50a14d6c1123', 'description': - u'OpenWRT with services'} - - def _get_expected_active_mea(self): - return {'status': 'ACTIVE', - 'instance_id': None, - 'name': u'test_openwrt', - 'tenant_id': u'ad7ebc56538745a08ef7c5e97f8bd437', - 'mead_id': u'eb094833-995e-49f0-a047-dfb56aaf7c4e', - 'mead': { - 'service_types': [{ - 'service_type': u'mead', - 'id': u'4a4c2d44-8a52-4895-9a75-9d1c76c3e738'}], - 'description': u'OpenWRT with services', - 'tenant_id': u'ad7ebc56538745a08ef7c5e97f8bd437', - 'mgmt_driver': u'openwrt', - 'infra_driver': u'heat', - 'attributes': {u'mead': self.tosca_mead_openwrt}, - 'id': u'fb048660-dc1b-4f0f-bd89-b023666650ec', - 'name': u'openwrt_services'}, - 'mgmt_url': '{"vdu1": "192.168.120.31"}', - 'service_context': [], - 'id': 'eb84260e-5ff7-4332-b032-50a14d6c1123', - 'description': u'OpenWRT with services'} - - def test_delete(self): - mea_id = '4a4c2d44-8a52-4895-9a75-9d1c76c3e738' - self.infra_driver.delete(plugin=None, context=self.context, - mea_id=mea_id, - auth_attr=utils.get_vim_auth_obj()) - self.heat_client.delete.assert_called_once_with(mea_id) - - def test_update(self): - mea_obj = utils.get_dummy_mea_config_attr() - mea_config_obj = utils.get_dummy_mea_update_config() - expected_mea_update = self._get_expected_mea_update_obj() - mea_id = '4a4c2d44-8a52-4895-9a75-9d1c76c3e738' - self.infra_driver.update(plugin=None, context=self.context, - mea_id=mea_id, mea_dict=mea_obj, - mea=mea_config_obj, - auth_attr=utils.get_vim_auth_obj()) - expected_mea_update['attributes']['config'] = yaml.safe_load( - expected_mea_update['attributes']['config']) - mea_obj['attributes']['config'] = yaml.safe_load(mea_obj['attributes'][ - 'config']) - self.assertEqual(expected_mea_update, mea_obj) - - def _get_expected_fields_tosca(self, template): - return {'stack_name': - 'apmec.mem.infra_drivers.openstack.openstack_OpenStack' - '-eb84260e' - '-5ff7-4332-b032-50a14d6c1123', - 'template': _get_template(template)} - - def _get_expected_tosca_mea(self, - tosca_tpl_name, - hot_tpl_name, - param_values='', - is_monitor=True, - multi_vdus=False): - tosca_tpl = _get_template(tosca_tpl_name) - exp_tmpl = self._get_expected_mead(tosca_tpl) - tosca_hw_dict = yaml.safe_load(_get_template(hot_tpl_name)) - dvc = { - 'mead': exp_tmpl, - 'description': u'OpenWRT with services', - 'attributes': { - 'heat_template': tosca_hw_dict, - 'param_values': param_values - }, - 'id': 'eb84260e-5ff7-4332-b032-50a14d6c1123', - 'instance_id': None, - 'mgmt_url': None, - 'name': u'test_openwrt', - 'service_context': [], - 'status': 'PENDING_CREATE', - 'mead_id': u'eb094833-995e-49f0-a047-dfb56aaf7c4e', - 'tenant_id': u'ad7ebc56538745a08ef7c5e97f8bd437' - } - # Add monitoring attributes for those yaml, which are having it - if is_monitor: - if multi_vdus: - dvc['attributes'].update( - {'monitoring_policy': '{"vdus": {"VDU1": {"ping": ' - '{"name": "ping", "actions": ' - '{"failure": "respawn"}, ' - '"parameters": {"count": 3, ' - '"interval": 10}, ' - '"monitoring_params": ' - '{"count": 3, "interval": 10}}}, ' - '"VDU2": {"ping": {"name": "ping", ' - '"actions": {"failure": "respawn"}, ' - '"parameters": {"count": 3, ' - '"interval": 10}, ' - '"monitoring_params": {"count": 3, ' - '"interval": 10}}}}}'}) - else: - dvc['attributes'].update( - {'monitoring_policy': '{"vdus": {"VDU1": {"ping": ' - '{"name": "ping", "actions": ' - '{"failure": "respawn"}, ' - '"parameters": {"count": 3, ' - '"interval": 10}, ' - '"monitoring_params": ' - '{"count": 3, ' - '"interval": 10}}}}}'}) - - return dvc - - def _get_dummy_tosca_mea(self, template, input_params=''): - - tosca_template = _get_template(template) - mea = utils.get_dummy_device_obj() - dtemplate = self._get_expected_mead(tosca_template) - - mea['mead'] = dtemplate - mea['attributes'] = {} - mea['attributes']['param_values'] = input_params - return mea - - def _test_assert_equal_for_tosca_templates(self, - tosca_tpl_name, - hot_tpl_name, - input_params='', - files=None, - is_monitor=True, - multi_vdus=False): - mea = self._get_dummy_tosca_mea(tosca_tpl_name, input_params) - expected_result = '4a4c2d44-8a52-4895-9a75-9d1c76c3e738' - expected_fields = self._get_expected_fields_tosca(hot_tpl_name) - expected_mea = self._get_expected_tosca_mea(tosca_tpl_name, - hot_tpl_name, - input_params, - is_monitor, - multi_vdus) - result = self.infra_driver.create(plugin=None, context=self.context, - mea=mea, - auth_attr=utils.get_vim_auth_obj()) - actual_fields = self.heat_client.create.call_args[0][0] - actual_fields["template"] = yaml.safe_load(actual_fields["template"]) - expected_fields["template"] = \ - yaml.safe_load(expected_fields["template"]) - - if files: - for k, v in actual_fields["files"].items(): - actual_fields["files"][k] = yaml.safe_load(v) - - expected_fields["files"] = {} - for k, v in files.items(): - expected_fields["files"][k] = yaml.safe_load(_get_template(v)) - - self.assertEqual(expected_fields, actual_fields) - mea["attributes"]["heat_template"] = yaml.safe_load( - mea["attributes"]["heat_template"]) - self.heat_client.create.assert_called_once_with(expected_fields) - self.assertEqual(expected_result, result) - - if files: - expected_fields["files"] = {} - for k, v in files.items(): - expected_mea["attributes"][k] = yaml.safe_load( - _get_template(v)) - mea["attributes"][k] = yaml.safe_load( - mea["attributes"][k]) - expected_mea["attributes"]['scaling_group_names'] = { - 'SP1': 'SP1_group'} - mea["attributes"]['scaling_group_names'] = json.loads( - mea["attributes"]['scaling_group_names'] - ) - self.assertEqual(expected_mea, mea) - - def test_create_tosca(self): - # self.skipTest("Not ready yet") - self._test_assert_equal_for_tosca_templates('test_tosca_openwrt.yaml', - 'hot_tosca_openwrt.yaml') - - def test_create_tosca_with_userdata(self): - self._test_assert_equal_for_tosca_templates( - 'test_tosca_openwrt_userdata.yaml', - 'hot_tosca_openwrt_userdata.yaml') - - def test_create_tosca_with_new_flavor(self): - self._test_assert_equal_for_tosca_templates('test_tosca_flavor.yaml', - 'hot_flavor.yaml') - - def test_create_tosca_with_new_flavor_with_defaults(self): - self._test_assert_equal_for_tosca_templates( - 'test_tosca_flavor_defaults.yaml', - 'hot_flavor_defaults.yaml') - - def test_create_tosca_with_flavor_and_capabilities(self): - self._test_assert_equal_for_tosca_templates( - 'test_tosca_flavor_and_capabilities.yaml', - 'hot_flavor_and_capabilities.yaml') - - def test_create_tosca_with_flavor_no_units(self): - self._test_assert_equal_for_tosca_templates( - 'test_tosca_flavor_no_units.yaml', - 'hot_flavor_no_units.yaml') - - def test_create_tosca_with_flavor_extra_specs_all_numa_count(self): - self._test_assert_equal_for_tosca_templates( - 'tosca_flavor_all_numa_count.yaml', - 'hot_tosca_flavor_all_numa_count.yaml') - - def test_create_tosca_with_flavor_extra_specs_all_numa_nodes(self): - self._test_assert_equal_for_tosca_templates( - 'tosca_flavor_all_numa_nodes.yaml', - 'hot_tosca_flavor_all_numa_nodes.yaml') - - def test_create_tosca_with_flavor_extra_specs_numa_node_count_trumps(self): - self._test_assert_equal_for_tosca_templates( - 'tosca_flavor_numa_nodes_count.yaml', - 'hot_tosca_flavor_numa_nodes_count.yaml') - - def test_create_tosca_with_flavor_extra_specs_huge_pages(self): - self._test_assert_equal_for_tosca_templates( - 'tosca_flavor_huge_pages.yaml', - 'hot_tosca_flavor_huge_pages.yaml') - - def test_create_tosca_with_flavor_extra_specs_cpu_allocations(self): - self._test_assert_equal_for_tosca_templates( - 'tosca_flavor_cpu_allocations.yaml', - 'hot_tosca_flavor_cpu_allocations.yaml') - - def test_create_tosca_with_flavor_extra_specs_numa_nodes(self): - self._test_assert_equal_for_tosca_templates( - 'tosca_flavor_numa_nodes.yaml', - 'hot_tosca_flavor_numa_nodes.yaml') - - def test_create_tosca_with_new_image(self): - self._test_assert_equal_for_tosca_templates('test_tosca_image.yaml', - 'hot_tosca_image.yaml') - - def test_create_tosca_sriov(self): - self._test_assert_equal_for_tosca_templates( - 'tosca_sriov.yaml', - 'hot_tosca_sriov.yaml' - ) - - def test_create_tosca_vnic_normal(self): - self._test_assert_equal_for_tosca_templates( - 'tosca_vnic_port.yaml', - 'hot_tosca_vnic_normal.yaml' - ) - - def test_create_tosca_mgmt_sriov_port(self): - self._test_assert_equal_for_tosca_templates( - 'tosca_mgmt_sriov.yaml', - 'hot_tosca_mgmt_sriov.yaml' - ) - - def test_tosca_params(self): - input_params = 'image: cirros\nflavor: m1.large' - self._test_assert_equal_for_tosca_templates( - 'tosca_generic_mead_params.yaml', - 'hot_tosca_generic_mead_params.yaml', - input_params - ) - - def test_create_tosca_scale(self): - self._test_assert_equal_for_tosca_templates( - 'tosca_scale.yaml', - 'hot_scale_main.yaml', - files={'SP1_res.yaml': 'hot_scale_custom.yaml'}, - is_monitor=False - ) - - def test_get_resource_info(self): - mea_obj = self._get_expected_active_mea() - self.assertRaises(mem.InfraDriverUnreachable, - self.infra_driver.get_resource_info, - plugin=None, context=self.context, mea_info=mea_obj, - auth_attr=utils.get_vim_auth_obj(), - region_name=None) - - def test_create_port_with_security_groups(self): - self._test_assert_equal_for_tosca_templates( - 'test_tosca_security_groups.yaml', - 'hot_tosca_security_groups.yaml' - ) - - def test_create_port_with_allowed_address_pairs(self): - self._test_assert_equal_for_tosca_templates( - 'test_tosca_allowed_address_pairs.yaml', - 'hot_tosca_allowed_address_pairs.yaml' - ) - - def test_create_port_with_mac_and_ip(self): - self._test_assert_equal_for_tosca_templates( - 'test_tosca_mac_ip.yaml', - 'hot_tosca_mac_ip.yaml' - ) - - def test_create_tosca_alarm_respawn(self): - self._test_assert_equal_for_tosca_templates( - 'tosca_alarm_respawn.yaml', - 'hot_tosca_alarm_respawn.yaml', - is_monitor=False - ) - - def test_create_tosca_alarm_scale(self): - self._test_assert_equal_for_tosca_templates( - 'tosca_alarm_scale.yaml', - 'hot_tosca_alarm_scale.yaml', - files={'SP1_res.yaml': 'hot_alarm_scale_custom.yaml'}, - is_monitor=False - ) - - def test_create_tosca_with_alarm_monitoring_not_matched(self): - self.assertRaises(mem.MetadataNotMatched, - self._test_assert_equal_for_tosca_templates, - 'tosca_alarm_metadata.yaml', - 'hot_tosca_alarm_metadata.yaml', - is_monitor=False - ) - - def test_create_tosca_monitoring_multi_vdus(self): - self._test_assert_equal_for_tosca_templates( - 'tosca_monitoring_multi_vdu.yaml', - 'hot_tosca_monitoring_multi_vdu.yaml', - multi_vdus=True - ) diff --git a/apmec/tests/unit/mem/infra_drivers/openstack/test_openstack_driver.py b/apmec/tests/unit/mem/infra_drivers/openstack/test_openstack_driver.py deleted file mode 100644 index 7316cc3..0000000 --- a/apmec/tests/unit/mem/infra_drivers/openstack/test_openstack_driver.py +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright 2017 99cloud, Inc. -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, 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 mock - -from apmec.extensions import mem -from apmec.tests.unit import base -from apmec.mem.infra_drivers.openstack import openstack - - -class TestOpenStack(base.TestCase): - - @mock.patch("apmec.mem.infra_drivers.openstack.heat_client.HeatClient") - def test_create_wait_with_heat_connection_exception(self, mocked_hc): - stack = {"stack_status", "CREATE_IN_PROGRESS"} - mocked_hc.get.side_effect = [stack, Exception("any stuff")] - openstack_driver = openstack.OpenStack() - self.assertRaises(mem.MEACreateWaitFailed, - openstack_driver.create_wait, - None, None, {}, 'mea_id', None) - - @mock.patch("apmec.mem.infra_drivers.openstack.heat_client.HeatClient") - def test_delete_wait_with_heat_connection_exception(self, mocked_hc): - stack = {"stack_status", "DELETE_IN_PROGRESS"} - mocked_hc.get.side_effect = [stack, Exception("any stuff")] - openstack_driver = openstack.OpenStack() - self.assertRaises(mem.MEADeleteWaitFailed, - openstack_driver.delete_wait, - None, None, 'mea_id', None, None) diff --git a/apmec/tests/unit/mem/monitor_drivers/__init__.py b/apmec/tests/unit/mem/monitor_drivers/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/apmec/tests/unit/mem/monitor_drivers/http_ping/__init__.py b/apmec/tests/unit/mem/monitor_drivers/http_ping/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/apmec/tests/unit/mem/monitor_drivers/http_ping/test_http_ping.py b/apmec/tests/unit/mem/monitor_drivers/http_ping/test_http_ping.py deleted file mode 100644 index 8fc8591..0000000 --- a/apmec/tests/unit/mem/monitor_drivers/http_ping/test_http_ping.py +++ /dev/null @@ -1,56 +0,0 @@ -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, 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 mock -import six.moves.urllib.error as urlerr -import testtools - -from apmec.mem.monitor_drivers.http_ping import http_ping - - -class TestMEAMonitorHTTPPing(testtools.TestCase): - - def setUp(self): - super(TestMEAMonitorHTTPPing, self).setUp() - self.monitor_http_ping = http_ping.MEAMonitorHTTPPing() - - @mock.patch('six.moves.urllib.request.urlopen') - def test_monitor_call_for_success(self, mock_urlopen): - test_device = {} - test_kwargs = { - 'mgmt_ip': 'a.b.c.d' - } - self.monitor_http_ping.monitor_call(test_device, - test_kwargs) - mock_urlopen.assert_called_once_with('http://a.b.c.d:80', timeout=5) - - @mock.patch('six.moves.urllib.request.urlopen') - def test_monitor_call_for_failure(self, mock_urlopen): - mock_urlopen.side_effect = urlerr.URLError("MOCK Error") - test_device = {} - test_kwargs = { - 'mgmt_ip': 'a.b.c.d' - } - monitor_return = self.monitor_http_ping.monitor_call(test_device, - test_kwargs) - self.assertEqual('failure', monitor_return) - - def test_monitor_url(self): - test_device = { - 'monitor_url': 'a.b.c.d' - } - test_monitor_url = self.monitor_http_ping.monitor_url(mock.ANY, - mock.ANY, - test_device) - self.assertEqual('a.b.c.d', test_monitor_url) diff --git a/apmec/tests/unit/mem/monitor_drivers/ping/__init__.py b/apmec/tests/unit/mem/monitor_drivers/ping/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/apmec/tests/unit/mem/monitor_drivers/ping/test_ping.py b/apmec/tests/unit/mem/monitor_drivers/ping/test_ping.py deleted file mode 100644 index 1c6765e..0000000 --- a/apmec/tests/unit/mem/monitor_drivers/ping/test_ping.py +++ /dev/null @@ -1,61 +0,0 @@ -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, 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 mock -import testtools - -from apmec.mem.monitor_drivers.ping import ping - - -class TestMEAMonitorPing(testtools.TestCase): - - def setUp(self): - super(TestMEAMonitorPing, self).setUp() - self.monitor_ping = ping.MEAMonitorPing() - - @mock.patch('apmec.agent.linux.utils.execute') - def test_monitor_call_for_success(self, mock_utils_execute): - test_device = {} - test_kwargs = { - 'mgmt_ip': 'a.b.c.d' - } - mock_ping_cmd = ['ping', - '-c', 5, - '-W', 1, - '-i', '0.2', - 'a.b.c.d'] - self.monitor_ping.monitor_call(test_device, - test_kwargs) - mock_utils_execute.assert_called_once_with(mock_ping_cmd, - check_exit_code=True) - - @mock.patch('apmec.agent.linux.utils.execute') - def test_monitor_call_for_failure(self, mock_utils_execute): - mock_utils_execute.side_effect = RuntimeError() - test_device = {} - test_kwargs = { - 'mgmt_ip': 'a.b.c.d' - } - monitor_return = self.monitor_ping.monitor_call(test_device, - test_kwargs) - self.assertEqual('failure', monitor_return) - - def test_monitor_url(self): - test_device = { - 'monitor_url': 'a.b.c.d' - } - test_monitor_url = self.monitor_ping.monitor_url(mock.ANY, - mock.ANY, - test_device) - self.assertEqual('a.b.c.d', test_monitor_url) diff --git a/apmec/tests/unit/mem/test_monitor.py b/apmec/tests/unit/mem/test_monitor.py deleted file mode 100644 index c06074d..0000000 --- a/apmec/tests/unit/mem/test_monitor.py +++ /dev/null @@ -1,130 +0,0 @@ -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, 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 json - -import mock -from oslo_utils import timeutils -import testtools - -from apmec.db.common_services import common_services_db_plugin -from apmec.plugins.common import constants -from apmec.mem import monitor - -MOCK_DEVICE_ID = 'a737497c-761c-11e5-89c3-9cb6541d805d' -MOCK_MEA_DEVICE = { - 'id': MOCK_DEVICE_ID, - 'management_ip_addresses': { - 'vdu1': 'a.b.c.d' - }, - 'monitoring_policy': { - 'vdus': { - 'vdu1': { - 'ping': { - 'actions': { - 'failure': 'respawn' - }, - 'monitoring_params': { - 'count': 1, - 'monitoring_delay': 0, - 'interval': 0, - 'timeout': 2 - } - } - } - } - }, - 'boot_at': timeutils.utcnow(), - 'action_cb': mock.MagicMock() -} - - -class TestMEAMonitor(testtools.TestCase): - - def setUp(self): - super(TestMEAMonitor, self).setUp() - p = mock.patch('apmec.common.driver_manager.DriverManager') - self.mock_monitor_manager = p.start() - mock.patch('apmec.db.common_services.common_services_db_plugin.' - 'CommonServicesPluginDb.create_event' - ).start() - self._cos_db_plugin =\ - common_services_db_plugin.CommonServicesPluginDb() - self.addCleanup(p.stop) - - def test_to_hosting_mea(self): - test_device_dict = { - 'id': MOCK_DEVICE_ID, - 'mgmt_url': '{"vdu1": "a.b.c.d"}', - 'attributes': { - 'monitoring_policy': json.dumps( - MOCK_MEA_DEVICE['monitoring_policy']) - } - } - action_cb = mock.MagicMock() - expected_output = { - 'id': MOCK_DEVICE_ID, - 'action_cb': action_cb, - 'management_ip_addresses': { - 'vdu1': 'a.b.c.d' - }, - 'mea': test_device_dict, - 'monitoring_policy': MOCK_MEA_DEVICE['monitoring_policy'] - } - output_dict = monitor.MEAMonitor.to_hosting_mea(test_device_dict, - action_cb) - self.assertEqual(expected_output, output_dict) - - @mock.patch('apmec.mem.monitor.MEAMonitor.__run__') - def test_add_hosting_mea(self, mock_monitor_run): - test_device_dict = { - 'id': MOCK_DEVICE_ID, - 'mgmt_url': '{"vdu1": "a.b.c.d"}', - 'attributes': { - 'monitoring_policy': json.dumps( - MOCK_MEA_DEVICE['monitoring_policy']) - }, - 'status': 'ACTIVE' - } - action_cb = mock.MagicMock() - test_boot_wait = 30 - test_memonitor = monitor.MEAMonitor(test_boot_wait) - new_dict = test_memonitor.to_hosting_mea(test_device_dict, action_cb) - test_memonitor.add_hosting_mea(new_dict) - test_device_id = list(test_memonitor._hosting_meas.keys())[0] - self.assertEqual(MOCK_DEVICE_ID, test_device_id) - self._cos_db_plugin.create_event.assert_called_with( - mock.ANY, res_id=mock.ANY, res_type=constants.RES_TYPE_MEA, - res_state=mock.ANY, evt_type=constants.RES_EVT_MONITOR, - tstamp=mock.ANY, details=mock.ANY) - - @mock.patch('apmec.mem.monitor.MEAMonitor.__run__') - def test_run_monitor(self, mock_monitor_run): - test_hosting_mea = MOCK_MEA_DEVICE - test_hosting_mea['mea'] = {} - test_boot_wait = 30 - mock_kwargs = { - 'count': 1, - 'monitoring_delay': 0, - 'interval': 0, - 'mgmt_ip': 'a.b.c.d', - 'timeout': 2 - } - test_memonitor = monitor.MEAMonitor(test_boot_wait) - self.mock_monitor_manager.invoke = mock.MagicMock() - test_memonitor._monitor_manager = self.mock_monitor_manager - test_memonitor.run_monitor(test_hosting_mea) - self.mock_monitor_manager\ - .invoke.assert_called_once_with('ping', 'monitor_call', mea={}, - kwargs=mock_kwargs) diff --git a/apmec/tests/unit/mem/test_plugin.py b/apmec/tests/unit/mem/test_plugin.py deleted file mode 100644 index 3a9ab2f..0000000 --- a/apmec/tests/unit/mem/test_plugin.py +++ /dev/null @@ -1,474 +0,0 @@ -# Copyright 2015 Brocade Communications System, Inc. -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, 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. - -from datetime import datetime - -import mock -from mock import patch -from oslo_utils import uuidutils -import yaml - -from apmec import context -from apmec.db.common_services import common_services_db_plugin -from apmec.db.meo import meo_db -from apmec.db.mem import mem_db -from apmec.extensions import mem -from apmec.plugins.common import constants -from apmec.tests.unit.db import base as db_base -from apmec.tests.unit.db import utils -from apmec.mem import plugin - - -class FakeDriverManager(mock.Mock): - def invoke(self, *args, **kwargs): - if 'create' in args: - return uuidutils.generate_uuid() - - if 'get_resource_info' in args: - return {'resources': {'name': 'dummy_mea', - 'type': 'dummy', - 'id': uuidutils.generate_uuid()}} - - -class FakeMEAMonitor(mock.Mock): - pass - - -class FakeGreenPool(mock.Mock): - pass - - -class FakeVimClient(mock.Mock): - pass - - -class TestMEMPlugin(db_base.SqlTestCase): - def setUp(self): - super(TestMEMPlugin, self).setUp() - self.addCleanup(mock.patch.stopall) - self.context = context.get_admin_context() - self._mock_vim_client() - self._stub_get_vim() - self._mock_device_manager() - self._mock_mea_monitor() - self._mock_mea_alarm_monitor() - self._mock_green_pool() - self._insert_dummy_vim() - self.mem_plugin = plugin.MEMPlugin() - mock.patch('apmec.db.common_services.common_services_db_plugin.' - 'CommonServicesPluginDb.create_event' - ).start() - self._cos_db_plugin =\ - common_services_db_plugin.CommonServicesPluginDb() - - def _mock_device_manager(self): - self._device_manager = mock.Mock(wraps=FakeDriverManager()) - self._device_manager.__contains__ = mock.Mock( - return_value=True) - fake_device_manager = mock.Mock() - fake_device_manager.return_value = self._device_manager - self._mock( - 'apmec.common.driver_manager.DriverManager', fake_device_manager) - - def _mock_vim_client(self): - self.vim_client = mock.Mock(wraps=FakeVimClient()) - fake_vim_client = mock.Mock() - fake_vim_client.return_value = self.vim_client - self._mock( - 'apmec.mem.vim_client.VimClient', fake_vim_client) - - def _stub_get_vim(self): - vim_obj = {'vim_id': '6261579e-d6f3-49ad-8bc3-a9cb974778ff', - 'vim_name': 'fake_vim', 'vim_auth': - {'auth_url': 'http://localhost:5000', 'password': - 'test_pw', 'username': 'test_user', 'project_name': - 'test_project'}, 'vim_type': 'test_vim'} - self.vim_client.get_vim.return_value = vim_obj - - def _mock_green_pool(self): - self._pool = mock.Mock(wraps=FakeGreenPool()) - fake_green_pool = mock.Mock() - fake_green_pool.return_value = self._pool - self._mock( - 'eventlet.GreenPool', fake_green_pool) - - def _mock_mea_monitor(self): - self._mea_monitor = mock.Mock(wraps=FakeMEAMonitor()) - fake_mea_monitor = mock.Mock() - fake_mea_monitor.return_value = self._mea_monitor - self._mock( - 'apmec.mem.monitor.MEAMonitor', fake_mea_monitor) - - def _mock_mea_alarm_monitor(self): - self._mea_alarm_monitor = mock.Mock(wraps=FakeMEAMonitor()) - fake_mea_alarm_monitor = mock.Mock() - fake_mea_alarm_monitor.return_value = self._mea_alarm_monitor - self._mock( - 'apmec.mem.monitor.MEAAlarmMonitor', fake_mea_alarm_monitor) - - def _insert_dummy_device_template(self): - session = self.context.session - device_template = mem_db.MEAD( - id='eb094833-995e-49f0-a047-dfb56aaf7c4e', - tenant_id='ad7ebc56538745a08ef7c5e97f8bd437', - name='fake_template', - description='fake_template_description', - template_source='onboarded', - deleted_at=datetime.min) - session.add(device_template) - session.flush() - return device_template - - def _insert_dummy_device_template_inline(self): - session = self.context.session - device_template = mem_db.MEAD( - id='d58bcc4e-d0cf-11e6-bf26-cec0c932ce01', - tenant_id='ad7ebc56538745a08ef7c5e97f8bd437', - name='tmpl-koeak4tqgoqo8cr4-dummy_inline_mea', - description='inline_fake_template_description', - deleted_at=datetime.min, - template_source='inline') - session.add(device_template) - session.flush() - return device_template - - def _insert_dummy_mead_attributes(self, template): - session = self.context.session - mead_attr = mem_db.MEADAttribute( - id='eb094833-995e-49f0-a047-dfb56aaf7c4e', - mead_id='eb094833-995e-49f0-a047-dfb56aaf7c4e', - key='mead', - value=template) - session.add(mead_attr) - session.flush() - return mead_attr - - def _insert_dummy_device(self): - session = self.context.session - device_db = mem_db.MEA( - id='6261579e-d6f3-49ad-8bc3-a9cb974778fe', - tenant_id='ad7ebc56538745a08ef7c5e97f8bd437', - name='fake_device', - description='fake_device_description', - instance_id='da85ea1a-4ec4-4201-bbb2-8d9249eca7ec', - mead_id='eb094833-995e-49f0-a047-dfb56aaf7c4e', - vim_id='6261579e-d6f3-49ad-8bc3-a9cb974778ff', - placement_attr={'region': 'RegionOne'}, - status='ACTIVE', - deleted_at=datetime.min) - session.add(device_db) - session.flush() - return device_db - - def _insert_scaling_attributes_mea(self): - session = self.context.session - mea_attributes = mem_db.MEAAttribute( - id='7800cb81-7ed1-4cf6-8387-746468522651', - mea_id='6261579e-d6f3-49ad-8bc3-a9cb974778fe', - key='scaling_group_names', - value='{"SP1": "G1"}' - ) - session.add(mea_attributes) - session.flush() - return mea_attributes - - def _insert_scaling_attributes_mead(self): - session = self.context.session - mead_attributes = mem_db.MEADAttribute( - id='7800cb81-7ed1-4cf6-8387-746468522650', - mead_id='eb094833-995e-49f0-a047-dfb56aaf7c4e', - key='mead', - value=utils.mead_scale_tosca_template - ) - session.add(mead_attributes) - session.flush() - return mead_attributes - - def _insert_dummy_vim(self): - session = self.context.session - vim_db = meo_db.Vim( - id='6261579e-d6f3-49ad-8bc3-a9cb974778ff', - tenant_id='ad7ebc56538745a08ef7c5e97f8bd437', - name='fake_vim', - description='fake_vim_description', - type='test_vim', - status='Active', - deleted_at=datetime.min, - placement_attr={'regions': ['RegionOne']}) - vim_auth_db = meo_db.VimAuth( - vim_id='6261579e-d6f3-49ad-8bc3-a9cb974778ff', - password='encrypted_pw', - auth_url='http://localhost:5000', - vim_project={'name': 'test_project'}, - auth_cred={'username': 'test_user', 'user_domain_id': 'default', - 'project_domain_id': 'default'}) - session.add(vim_db) - session.add(vim_auth_db) - session.flush() - - @mock.patch('apmec.mem.plugin.toscautils.updateimports') - @mock.patch('apmec.mem.plugin.ToscaTemplate') - @mock.patch('apmec.mem.plugin.toscautils.get_mgmt_driver') - def test_create_mead(self, mock_get_mgmt_driver, mock_tosca_template, - mock_update_imports): - mock_get_mgmt_driver.return_value = 'dummy_mgmt_driver' - mock_tosca_template.return_value = mock.ANY - - mead_obj = utils.get_dummy_mead_obj() - result = self.mem_plugin.create_mead(self.context, mead_obj) - self.assertIsNotNone(result) - self.assertIn('id', result) - self.assertEqual('dummy_mead', result['name']) - self.assertEqual('dummy_mead_description', result['description']) - self.assertEqual('dummy_mgmt_driver', result['mgmt_driver']) - self.assertIn('service_types', result) - self.assertIn('attributes', result) - self.assertIn('created_at', result) - self.assertIn('updated_at', result) - self.assertIn('template_source', result) - yaml_dict = yaml.safe_load(utils.tosca_mead_openwrt) - mock_tosca_template.assert_called_once_with( - a_file=False, yaml_dict_tpl=yaml_dict) - mock_get_mgmt_driver.assert_called_once_with(mock.ANY) - mock_update_imports.assert_called_once_with(yaml_dict) - self._cos_db_plugin.create_event.assert_called_once_with( - self.context, evt_type=constants.RES_EVT_CREATE, res_id=mock.ANY, - res_state=constants.RES_EVT_ONBOARDED, - res_type=constants.RES_TYPE_MEAD, tstamp=mock.ANY) - - def test_create_mead_no_service_types(self): - mead_obj = utils.get_dummy_mead_obj() - mead_obj['mead'].pop('service_types') - self.assertRaises(mem.ServiceTypesNotSpecified, - self.mem_plugin.create_mead, - self.context, mead_obj) - - def test_create_mea_with_mead(self): - self._insert_dummy_device_template() - mea_obj = utils.get_dummy_mea_obj() - result = self.mem_plugin.create_mea(self.context, mea_obj) - self.assertIsNotNone(result) - self.assertIn('id', result) - self.assertIn('instance_id', result) - self.assertIn('status', result) - self.assertIn('attributes', result) - self.assertIn('mgmt_url', result) - self.assertIn('created_at', result) - self.assertIn('updated_at', result) - self._device_manager.invoke.assert_called_with('test_vim', - 'create', - plugin=mock.ANY, - context=mock.ANY, - mea=mock.ANY, - auth_attr=mock.ANY) - self._pool.spawn_n.assert_called_once_with(mock.ANY) - self._cos_db_plugin.create_event.assert_called_with( - self.context, evt_type=constants.RES_EVT_CREATE, res_id=mock.ANY, - res_state=mock.ANY, res_type=constants.RES_TYPE_MEA, - tstamp=mock.ANY, details=mock.ANY) - - @mock.patch('apmec.mem.plugin.MEMPlugin.create_mead') - def test_create_mea_from_template(self, mock_create_mead): - self._insert_dummy_device_template_inline() - mock_create_mead.return_value = {'id': - 'd58bcc4e-d0cf-11e6-bf26-cec0c932ce01'} - mea_obj = utils.get_dummy_inline_mea_obj() - result = self.mem_plugin.create_mea(self.context, mea_obj) - self.assertIsNotNone(result) - self.assertIn('id', result) - self.assertIn('instance_id', result) - self.assertIn('status', result) - self.assertIn('attributes', result) - self.assertIn('mgmt_url', result) - self.assertIn('created_at', result) - self.assertIn('updated_at', result) - mock_create_mead.assert_called_once_with(mock.ANY, mock.ANY) - self._device_manager.invoke.assert_called_with('test_vim', - 'create', - plugin=mock.ANY, - context=mock.ANY, - mea=mock.ANY, - auth_attr=mock.ANY) - self._pool.spawn_n.assert_called_once_with(mock.ANY) - self._cos_db_plugin.create_event.assert_called_with( - self.context, evt_type=constants.RES_EVT_CREATE, - res_id=mock.ANY, - res_state=mock.ANY, res_type=constants.RES_TYPE_MEA, - tstamp=mock.ANY, details=mock.ANY) - - def test_show_mea_details_mea_inactive(self): - self._insert_dummy_device_template() - mea_obj = utils.get_dummy_mea_obj() - result = self.mem_plugin.create_mea(self.context, mea_obj) - self.assertRaises(mem.MEAInactive, self.mem_plugin.get_mea_resources, - self.context, result['id']) - - def test_show_mea_details_mea_active(self): - self._insert_dummy_device_template() - active_mea = self._insert_dummy_device() - resources = self.mem_plugin.get_mea_resources(self.context, - active_mea['id'])[0] - self.assertIn('name', resources) - self.assertIn('type', resources) - self.assertIn('id', resources) - - def test_delete_mea(self): - self._insert_dummy_device_template() - dummy_device_obj = self._insert_dummy_device() - self.mem_plugin.delete_mea(self.context, dummy_device_obj[ - 'id']) - self._device_manager.invoke.assert_called_with('test_vim', 'delete', - plugin=mock.ANY, - context=mock.ANY, - mea_id=mock.ANY, - auth_attr=mock.ANY, - region_name=mock.ANY) - self._mea_monitor.delete_hosting_mea.assert_called_with(mock.ANY) - self._pool.spawn_n.assert_called_once_with(mock.ANY, mock.ANY, - mock.ANY, mock.ANY, - mock.ANY) - self._cos_db_plugin.create_event.assert_called_with( - self.context, evt_type=constants.RES_EVT_DELETE, res_id=mock.ANY, - res_state=mock.ANY, res_type=constants.RES_TYPE_MEA, - tstamp=mock.ANY, details=mock.ANY) - - def test_update_mea(self): - self._insert_dummy_device_template() - dummy_device_obj = self._insert_dummy_device() - mea_config_obj = utils.get_dummy_mea_config_obj() - result = self.mem_plugin.update_mea(self.context, dummy_device_obj[ - 'id'], mea_config_obj) - self.assertIsNotNone(result) - self.assertEqual(dummy_device_obj['id'], result['id']) - self.assertIn('instance_id', result) - self.assertIn('status', result) - self.assertIn('attributes', result) - self.assertIn('mgmt_url', result) - self.assertIn('updated_at', result) - self._pool.spawn_n.assert_called_once_with(mock.ANY, mock.ANY, - mock.ANY, mock.ANY, - mock.ANY) - self._cos_db_plugin.create_event.assert_called_with( - self.context, evt_type=constants.RES_EVT_UPDATE, res_id=mock.ANY, - res_state=mock.ANY, res_type=constants.RES_TYPE_MEA, - tstamp=mock.ANY) - - def _get_dummy_scaling_policy(self, type): - mea_scale = {} - mea_scale['scale'] = {} - mea_scale['scale']['type'] = type - mea_scale['scale']['policy'] = 'SP1' - return mea_scale - - def _test_scale_mea(self, type, scale_state): - # create mead - self._insert_dummy_device_template() - self._insert_scaling_attributes_mead() - - # create mea - dummy_device_obj = self._insert_dummy_device() - self._insert_scaling_attributes_mea() - - # scale mea - mea_scale = self._get_dummy_scaling_policy(type) - self.mem_plugin.create_mea_scale( - self.context, - dummy_device_obj['id'], - mea_scale) - - # validate - self._device_manager.invoke.assert_called_once_with( - mock.ANY, - 'scale', - plugin=mock.ANY, - context=mock.ANY, - auth_attr=mock.ANY, - policy=mock.ANY, - region_name=mock.ANY - ) - - self._pool.spawn_n.assert_called_once_with(mock.ANY) - - self._cos_db_plugin.create_event.assert_called_with( - self.context, - evt_type=constants.RES_EVT_SCALE, - res_id='6261579e-d6f3-49ad-8bc3-a9cb974778fe', - res_state=scale_state, - res_type=constants.RES_TYPE_MEA, - tstamp=mock.ANY) - - def test_scale_mea_out(self): - self._test_scale_mea('out', constants.PENDING_SCALE_OUT) - - def test_scale_mea_in(self): - self._test_scale_mea('in', constants.PENDING_SCALE_IN) - - def _get_dummy_active_mea(self, mead_template): - dummy_mea = utils.get_dummy_device_obj() - dummy_mea['mead']['attributes']['mead'] = mead_template - dummy_mea['status'] = 'ACTIVE' - dummy_mea['instance_id'] = '4c00108e-c69d-4624-842d-389c77311c1d' - dummy_mea['vim_id'] = '437ac8ef-a8fb-4b6e-8d8a-a5e86a376e8b' - return dummy_mea - - def _test_create_mea_trigger(self, policy_name, action_value): - mea_id = "6261579e-d6f3-49ad-8bc3-a9cb974778fe" - trigger_request = {"trigger": {"action_name": action_value, "params": { - "credential": "026kll6n", "data": {"current": "alarm", - 'alarm_id': - "b7fa9ffd-0a4f-4165-954b-5a8d0672a35f"}}, - "policy_name": policy_name}} - expected_result = {"action_name": action_value, "params": { - "credential": "026kll6n", "data": {"current": "alarm", - "alarm_id": "b7fa9ffd-0a4f-4165-954b-5a8d0672a35f"}}, - "policy_name": policy_name} - self._mea_alarm_monitor.process_alarm_for_mea.return_value = True - trigger_result = self.mem_plugin.create_mea_trigger( - self.context, mea_id, trigger_request) - self.assertEqual(expected_result, trigger_result) - - @patch('apmec.db.mem.mem_db.MEMPluginDb.get_mea') - def test_create_mea_trigger_respawn(self, mock_get_mea): - dummy_mea = self._get_dummy_active_mea( - utils.mead_alarm_respawn_tosca_template) - mock_get_mea.return_value = dummy_mea - self._test_create_mea_trigger(policy_name="vdu_hcpu_usage_respawning", - action_value="respawn") - - @patch('apmec.db.mem.mem_db.MEMPluginDb.get_mea') - def test_create_mea_trigger_scale(self, mock_get_mea): - dummy_mea = self._get_dummy_active_mea( - utils.mead_alarm_scale_tosca_template) - mock_get_mea.return_value = dummy_mea - self._test_create_mea_trigger(policy_name="vdu_hcpu_usage_scaling_out", - action_value="SP1-out") - - @patch('apmec.db.mem.mem_db.MEMPluginDb.get_mea') - def test_create_mea_trigger_multi_actions(self, mock_get_mea): - dummy_mea = self._get_dummy_active_mea( - utils.mead_alarm_multi_actions_tosca_template) - mock_get_mea.return_value = dummy_mea - self._test_create_mea_trigger(policy_name="mon_policy_multi_actions", - action_value="respawn&log") - - @patch('apmec.db.mem.mem_db.MEMPluginDb.get_mea') - def test_get_mea_policies(self, mock_get_mea): - mea_id = "6261579e-d6f3-49ad-8bc3-a9cb974778fe" - dummy_mea = self._get_dummy_active_mea( - utils.mead_alarm_respawn_tosca_template) - mock_get_mea.return_value = dummy_mea - policies = self.mem_plugin.get_mea_policies(self.context, mea_id, - filters={'name': 'vdu1_cpu_usage_monitoring_policy'}) - self.assertEqual(1, len(policies)) diff --git a/apmec/tests/unit/mem/test_vim_client.py b/apmec/tests/unit/mem/test_vim_client.py deleted file mode 100644 index 8130dc5..0000000 --- a/apmec/tests/unit/mem/test_vim_client.py +++ /dev/null @@ -1,39 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, 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 mock - -from sqlalchemy.orm import exc as orm_exc - -from apmec.extensions import meo -from apmec import manager -from apmec.tests.unit import base -from apmec.mem import vim_client - - -class TestVIMClient(base.TestCase): - - def setUp(self): - super(TestVIMClient, self).setUp() - self.vim_info = {'id': 'aaaa', 'name': 'VIM0', - 'auth_cred': {'password': '****'}, 'type': 'test_vim'} - - def test_get_vim_without_defined_default_vim(self): - vimclient = vim_client.VimClient() - service_plugins = mock.Mock() - meo_plugin = mock.Mock() - meo_plugin.get_default_vim.side_effect = \ - orm_exc.NoResultFound() - service_plugins.get.return_value = meo_plugin - with mock.patch.object(manager.ApmecManager, 'get_service_plugins', - return_value=service_plugins): - self.assertRaises(meo.VimDefaultNotDefined, - vimclient.get_vim, None) diff --git a/apmec/tests/unit/mem/tosca/__init__.py b/apmec/tests/unit/mem/tosca/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/apmec/tests/unit/mem/tosca/test_utils.py b/apmec/tests/unit/mem/tosca/test_utils.py deleted file mode 100644 index e4f620b..0000000 --- a/apmec/tests/unit/mem/tosca/test_utils.py +++ /dev/null @@ -1,268 +0,0 @@ -# Copyright 2016 - Nokia -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, 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 codecs -import os - -import testtools -import yaml - -from apmec.catalogs.tosca import utils as toscautils -from toscaparser import tosca_template -from translator.hot import tosca_translator - - -def _get_template(name): - filename = os.path.join( - os.path.dirname(os.path.abspath(__file__)), - "../infra_drivers/openstack/data/", name) - f = codecs.open(filename, encoding='utf-8', errors='strict') - return f.read() - - -class TestToscaUtils(testtools.TestCase): - tosca_openwrt = _get_template('test_tosca_openwrt.yaml') - mead_dict = yaml.safe_load(tosca_openwrt) - toscautils.updateimports(mead_dict) - tosca = tosca_template.ToscaTemplate(parsed_params={}, a_file=False, - yaml_dict_tpl=mead_dict) - tosca_flavor = _get_template('test_tosca_flavor.yaml') - - def setUp(self): - super(TestToscaUtils, self).setUp() - - def test_updateimport(self): - importspath = os.path.abspath('./apmec/tosca/lib/') - file1 = importspath + '/apmec_defs.yaml' - file2 = importspath + '/apmec_mec_defs.yaml' - expected_imports = [file1, file2] - self.assertEqual(expected_imports, self.mead_dict['imports']) - - def test_get_mgmt_driver(self): - expected_mgmt_driver = 'openwrt' - mgmt_driver = toscautils.get_mgmt_driver(self.tosca) - self.assertEqual(expected_mgmt_driver, mgmt_driver) - - def test_get_vdu_monitoring(self): - expected_monitoring = {'vdus': {'VDU1': {'ping': { - 'actions': - {'failure': 'respawn'}, - 'name': 'ping', - 'parameters': {'count': 3, - 'interval': 10}, - 'monitoring_params': {'count': 3, - 'interval': 10}}}}} - monitoring = toscautils.get_vdu_monitoring(self.tosca) - self.assertEqual(expected_monitoring, monitoring) - - def test_get_mgmt_ports(self): - expected_mgmt_ports = {'mgmt_ip-VDU1': 'CP1'} - mgmt_ports = toscautils.get_mgmt_ports(self.tosca) - self.assertEqual(expected_mgmt_ports, mgmt_ports) - - def test_post_process_template(self): - tosca2 = tosca_template.ToscaTemplate(parsed_params={}, a_file=False, - yaml_dict_tpl=self.mead_dict) - toscautils.post_process_template(tosca2) - invalidNodes = 0 - for nt in tosca2.nodetemplates: - if (nt.type_definition.is_derived_from(toscautils.MONITORING) or - nt.type_definition.is_derived_from(toscautils.FAILURE) or - nt.type_definition.is_derived_from(toscautils.PLACEMENT)): - invalidNodes += 1 - - self.assertEqual(0, invalidNodes) - - deletedProperties = 0 - if nt.type in toscautils.delpropmap.keys(): - for prop in toscautils.delpropmap[nt.type]: - for p in nt.get_properties_objects(): - if prop == p.name: - deletedProperties += 1 - - self.assertEqual(0, deletedProperties) - - convertedProperties = 0 - if nt.type in toscautils.convert_prop: - for prop in toscautils.convert_prop[nt.type].keys(): - for p in nt.get_properties_objects(): - if prop == p.name: - convertedProperties += 1 - - self.assertEqual(0, convertedProperties) - - def test_post_process_heat_template(self): - tosca1 = tosca_template.ToscaTemplate(parsed_params={}, a_file=False, - yaml_dict_tpl=self.mead_dict) - toscautils.post_process_template(tosca1) - translator = tosca_translator.TOSCATranslator(tosca1, {}) - heat_template_yaml = translator.translate() - expected_heat_tpl = _get_template('hot_tosca_openwrt.yaml') - mgmt_ports = toscautils.get_mgmt_ports(self.tosca) - heat_tpl = toscautils.post_process_heat_template( - heat_template_yaml, mgmt_ports, {}, {}, {}) - - heatdict = yaml.safe_load(heat_tpl) - expecteddict = yaml.safe_load(expected_heat_tpl) - self.assertEqual(expecteddict, heatdict) - - def test_findvdus(self): - vdus = toscautils.findvdus(self.tosca) - - self.assertEqual(1, len(vdus)) - - for vdu in vdus: - self.assertEqual(True, vdu.type_definition.is_derived_from( - toscautils.APMECVDU)) - - def test_get_flavor_dict(self): - mead_dict = yaml.safe_load(self.tosca_flavor) - toscautils.updateimports(mead_dict) - tosca = tosca_template.ToscaTemplate(a_file=False, - yaml_dict_tpl=mead_dict) - expected_flavor_dict = { - "VDU1": { - "vcpus": 2, - "disk": 10, - "ram": 512 - } - } - actual_flavor_dict = toscautils.get_flavor_dict(tosca) - self.assertEqual(expected_flavor_dict, actual_flavor_dict) - - def test_add_resources_tpl_for_flavor(self): - dummy_heat_dict = yaml.safe_load(_get_template( - 'hot_flavor_and_capabilities.yaml')) - expected_dict = yaml.safe_load(_get_template('hot_flavor.yaml')) - dummy_heat_res = { - "flavor": { - "VDU1": { - "vcpus": 2, - "ram": 512, - "disk": 10 - } - } - } - toscautils.add_resources_tpl(dummy_heat_dict, dummy_heat_res) - self.assertEqual(expected_dict, dummy_heat_dict) - - def test_get_flavor_dict_extra_specs_all_numa_count(self): - tosca_fes_all_numa_count = _get_template( - 'tosca_flavor_all_numa_count.yaml') - mead_dict = yaml.safe_load(tosca_fes_all_numa_count) - toscautils.updateimports(mead_dict) - tosca = tosca_template.ToscaTemplate(a_file=False, - yaml_dict_tpl=mead_dict) - expected_flavor_dict = { - "VDU1": { - "vcpus": 8, - "disk": 10, - "ram": 4096, - "extra_specs": { - 'hw:cpu_policy': 'dedicated', 'hw:mem_page_size': 'any', - 'hw:cpu_sockets': 2, 'hw:cpu_threads': 2, - 'hw:numa_nodes': 2, 'hw:cpu_cores': 2, - 'hw:cpu_threads_policy': 'avoid' - } - } - } - actual_flavor_dict = toscautils.get_flavor_dict(tosca) - self.assertEqual(expected_flavor_dict, actual_flavor_dict) - - def test_apmec_conf_heat_extra_specs_all_numa_count(self): - tosca_fes_all_numa_count = _get_template( - 'tosca_flavor_all_numa_count.yaml') - mead_dict = yaml.safe_load(tosca_fes_all_numa_count) - toscautils.updateimports(mead_dict) - tosca = tosca_template.ToscaTemplate(a_file=False, - yaml_dict_tpl=mead_dict) - expected_flavor_dict = { - "VDU1": { - "vcpus": 8, - "disk": 10, - "ram": 4096, - "extra_specs": { - 'hw:cpu_policy': 'dedicated', 'hw:mem_page_size': 'any', - 'hw:cpu_sockets': 2, 'hw:cpu_threads': 2, - 'hw:numa_nodes': 2, 'hw:cpu_cores': 2, - 'hw:cpu_threads_policy': 'avoid', - 'aggregate_instance_extra_specs:mec': 'true' - } - } - } - actual_flavor_dict = toscautils.get_flavor_dict( - tosca, {"aggregate_instance_extra_specs:mec": "true"}) - self.assertEqual(expected_flavor_dict, actual_flavor_dict) - - def test_add_resources_tpl_for_image(self): - dummy_heat_dict = yaml.safe_load(_get_template( - 'hot_image_before_processed_image.yaml')) - expected_dict = yaml.safe_load(_get_template( - 'hot_image_after_processed_image.yaml')) - dummy_heat_res = { - "image": { - "VDU1": { - "location": "http://URL/v1/openwrt.qcow2", - "container_format": "bare", - "disk_format": "raw" - } - } - } - toscautils.add_resources_tpl(dummy_heat_dict, dummy_heat_res) - self.assertEqual(expected_dict, dummy_heat_dict) - - def test_convert_unsupported_res_prop_kilo_ver(self): - unsupported_res_prop_dict = {'OS::Neutron::Port': { - 'port_security_enabled': 'value_specs', }, } - dummy_heat_dict = yaml.safe_load(_get_template( - 'hot_tosca_openwrt.yaml')) - expected_heat_dict = yaml.safe_load(_get_template( - 'hot_tosca_openwrt_kilo.yaml')) - toscautils.convert_unsupported_res_prop(dummy_heat_dict, - unsupported_res_prop_dict) - self.assertEqual(expected_heat_dict, dummy_heat_dict) - - def test_check_for_substitution_mappings(self): - tosca_sb_map = _get_template('../../../../../etc/samples/test-mesd-' - 'mead1.yaml') - param = {'substitution_mappings': { - 'VL2': {'type': 'tosca.nodes.mec.VL', 'properties': { - 'network_name': 'net0', 'vendor': 'apmec'}}, - 'VL1': {'type': 'tosca.nodes.mec.VL', 'properties': { - 'network_name': 'net_mgmt', 'vendor': 'apmec'}}, - 'requirements': {'virtualLink2': 'VL2', - 'virtualLink1': 'VL1'}}} - template = yaml.safe_load(tosca_sb_map) - toscautils.updateimports(template) - toscautils.check_for_substitution_mappings(template, param) - self.assertNotIn('substitution_mappings', param) - - def test_get_block_storage_details(self): - tosca_vol = _get_template('tosca_block_storage.yaml') - mead_dict = yaml.safe_load(tosca_vol) - expected_dict = { - 'volumes': { - 'VB1': { - 'image': 'cirros-0.3.5-x86_64-disk', - 'size': '1' - } - }, - 'volume_attachments': { - 'CB1': { - 'instance_uuid': {'get_resource': 'VDU1'}, - 'mountpoint': '/dev/vdb', - 'volume_id': {'get_resource': 'VB1'}} - } - } - volume_details = toscautils.get_block_storage_details(mead_dict) - self.assertEqual(expected_dict, volume_details) diff --git a/apmec/tests/unit/meo/__init__.py b/apmec/tests/unit/meo/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/apmec/tests/unit/meo/drivers/__init__.py b/apmec/tests/unit/meo/drivers/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/apmec/tests/unit/meo/drivers/vim/__init__.py b/apmec/tests/unit/meo/drivers/vim/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/apmec/tests/unit/meo/drivers/vim/test_openstack_driver.py b/apmec/tests/unit/meo/drivers/vim/test_openstack_driver.py deleted file mode 100644 index f864b19..0000000 --- a/apmec/tests/unit/meo/drivers/vim/test_openstack_driver.py +++ /dev/null @@ -1,257 +0,0 @@ -# Copyright 2016 Brocade Communications System, Inc. -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, 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. - -from keystoneauth1 import exceptions -import mock -from oslo_config import cfg - -from apmec.extensions import meo -from apmec.meo.drivers.vim import openstack_driver -from apmec.tests.unit import base -from apmec.tests.unit.db import utils - -OPTS = [cfg.StrOpt('user_domain_id', - default='default', - help='User Domain Id'), - cfg.StrOpt('project_domain_id', - default='default', - help='Project Domain Id'), - cfg.StrOpt('auth_url', - default='http://localhost:5000/v3', - help='Keystone endpoint')] - -cfg.CONF.register_opts(OPTS, 'keystone_authtoken') -CONF = cfg.CONF - - -class FakeKeystone(mock.Mock): - pass - - -class FakeNeutronClient(mock.Mock): - pass - - -class FakeKeymgrAPI(mock.Mock): - pass - - -class mock_dict(dict): - def __getattr__(self, item): - return self.get(item) - - __setattr__ = dict.__setitem__ - __delattr__ = dict.__delitem__ - - -class TestOpenstack_Driver(base.TestCase): - def setUp(self): - super(TestOpenstack_Driver, self).setUp() - self._mock_keystone() - self.keystone.create_key_dir.return_value = 'test_keys' - self.config_fixture.config(group='vim_keys', openstack='/tmp/') - self.config_fixture.config(group='vim_keys', use_barbican=False) - self.openstack_driver = openstack_driver.OpenStack_Driver() - self.vim_obj = self.get_vim_obj() - self.auth_obj = utils.get_vim_auth_obj() - self.addCleanup(mock.patch.stopall) - self._mock_keymgr() - - def _mock_keystone(self): - self.keystone = mock.Mock(wraps=FakeKeystone()) - fake_keystone = mock.Mock() - fake_keystone.return_value = self.keystone - self._mock( - 'apmec.mem.keystone.Keystone', fake_keystone) - - def _mock_keymgr(self): - self.keymgr = mock.Mock(wraps=FakeKeymgrAPI()) - fake_keymgr = mock.Mock() - fake_keymgr.return_value = self.keymgr - self._mock( - 'apmec.keymgr.barbican_key_manager.BarbicanKeyManager', - fake_keymgr) - - def get_vim_obj(self): - return {'id': '6261579e-d6f3-49ad-8bc3-a9cb974778ff', 'type': - 'openstack', 'auth_url': 'http://localhost:5000', - 'auth_cred': {'username': 'test_user', - 'password': 'test_password', - 'user_domain_name': 'default', - 'auth_url': 'http://localhost:5000'}, - 'name': 'VIM0', - 'vim_project': {'name': 'test_project', - 'project_domain_name': 'default'}} - - def get_vim_obj_barbican(self): - return {'id': '6261579e-d6f3-49ad-8bc3-a9cb974778ff', 'type': - 'openstack', 'auth_url': 'http://localhost:5000', - 'auth_cred': {'username': 'test_user', - 'password': 'test_password', - 'user_domain_name': 'default', - 'key_type': 'barbican_key', - 'secret_uuid': 'fake-secret-uuid', - 'auth_url': 'http://localhost:5000'}, - 'name': 'VIM0', - 'vim_project': {'name': 'test_project', - 'project_domain_name': 'default'}} - - def test_register_keystone_v3(self): - regions = [mock_dict({'id': 'RegionOne'})] - attrs = {'regions.list.return_value': regions} - keystone_version = 'v3' - mock_ks_client = mock.Mock(version=keystone_version, **attrs) - self.keystone.get_version.return_value = keystone_version - self._test_register_vim(self.vim_obj, mock_ks_client) - mock_ks_client.regions.list.assert_called_once_with() - self.keystone.initialize_client.assert_called_once_with( - version=keystone_version, **self.auth_obj) - - def test_register_keystone_v2(self): - services_list = [mock_dict({'type': 'orchestration', 'id': - 'test_id'})] - endpoints_regions = mock_dict({'region': 'RegionOne'}) - endpoints_list = [mock_dict({'service_id': 'test_id', 'regions': - endpoints_regions})] - attrs = {'endpoints.list.return_value': endpoints_list, - 'services.list.return_value': services_list} - keystone_version = 'v2.0' - mock_ks_client = mock.Mock(version='v2.0', **attrs) - self.keystone.get_version.return_value = keystone_version - auth_obj = {'tenant_name': 'test_project', 'username': 'test_user', - 'password': 'test_password', 'auth_url': - 'http://localhost:5000/v2.0', 'tenant_id': None} - self._test_register_vim(self.vim_obj, mock_ks_client) - self.keystone.initialize_client.assert_called_once_with( - version=keystone_version, **auth_obj) - - def _test_register_vim(self, vim_obj, mock_ks_client): - self.keystone.initialize_client.return_value = mock_ks_client - fernet_attrs = {'encrypt.return_value': 'encrypted_password'} - mock_fernet_obj = mock.Mock(**fernet_attrs) - mock_fernet_key = 'test_fernet_key' - self.keystone.create_fernet_key.return_value = (mock_fernet_key, - mock_fernet_obj) - file_mock = mock.mock_open() - with mock.patch('six.moves.builtins.open', file_mock, create=True): - self.openstack_driver.register_vim(None, vim_obj) - mock_fernet_obj.encrypt.assert_called_once_with(mock.ANY) - file_mock().write.assert_called_once_with('test_fernet_key') - - @mock.patch('apmec.meo.drivers.vim.openstack_driver.os.remove') - @mock.patch('apmec.meo.drivers.vim.openstack_driver.os.path' - '.join') - def test_deregister_vim(self, mock_os_path, mock_os_remove): - vim_obj = self.get_vim_obj() - vim_id = 'my_id' - vim_obj['id'] = vim_id - file_path = CONF.vim_keys.openstack + '/' + vim_id - mock_os_path.return_value = file_path - self.openstack_driver.deregister_vim(None, vim_obj) - mock_os_remove.assert_called_once_with(file_path) - - def test_deregister_vim_barbican(self): - self.keymgr.delete.return_value = None - vim_obj = self.get_vim_obj_barbican() - self.openstack_driver.deregister_vim(None, vim_obj) - self.keymgr.delete.assert_called_once_with( - None, 'fake-secret-uuid') - - def test_encode_vim_auth_barbican(self): - self.config_fixture.config(group='vim_keys', - use_barbican=True) - fernet_attrs = {'encrypt.return_value': 'encrypted_password'} - mock_fernet_obj = mock.Mock(**fernet_attrs) - mock_fernet_key = 'test_fernet_key' - self.keymgr.store.return_value = 'fake-secret-uuid' - self.keystone.create_fernet_key.return_value = (mock_fernet_key, - mock_fernet_obj) - - vim_obj = self.get_vim_obj() - self.openstack_driver.encode_vim_auth( - None, vim_obj['id'], vim_obj['auth_cred']) - - self.keymgr.store.assert_called_once_with( - None, 'test_fernet_key') - mock_fernet_obj.encrypt.assert_called_once_with(mock.ANY) - self.assertEqual(vim_obj['auth_cred']['key_type'], - 'barbican_key') - self.assertEqual(vim_obj['auth_cred']['secret_uuid'], - 'fake-secret-uuid') - - def test_register_vim_invalid_auth(self): - attrs = {'regions.list.side_effect': exceptions.Unauthorized} - self._test_register_vim_auth(attrs) - - def test_register_vim_missing_auth(self): - attrs = {'regions.list.side_effect': exceptions.BadRequest} - self._test_register_vim_auth(attrs) - - def _test_register_vim_auth(self, attrs): - keystone_version = 'v3' - mock_ks_client = mock.Mock(version=keystone_version, **attrs) - self.keystone.get_version.return_value = keystone_version - self.keystone.initialize_client.return_value = mock_ks_client - self.assertRaises(meo.VimUnauthorizedException, - self.openstack_driver.register_vim, - None, - self.vim_obj) - mock_ks_client.regions.list.assert_called_once_with() - self.keystone.initialize_client.assert_called_once_with( - version=keystone_version, **self.auth_obj) - - def test_get_vim_resource_id(self): - resource_type = 'network' - resource_name = 'net0' - fake_networks = {'networks': [{'id': 'fake-uuid', 'name': 'net0'}]} - fake_neutron_client = FakeNeutronClient() - fake_neutron_client.list_networks.return_value = fake_networks - self.openstack_driver._get_client = mock.Mock( - return_value=fake_neutron_client) - - self.openstack_driver.get_vim_resource_id( - self.vim_obj, resource_type, resource_name) - - self.openstack_driver._get_client.assert_called_once_with( - self.vim_obj, mock.ANY) - fake_neutron_client.list_networks.assert_called_once_with( - **{'name': 'net0'}) - - def test_get_vim_resource_id_name_not_unique(self): - resource_type = 'network' - resource_name = 'net0' - fake_networks = {'networks': [{'id': 'fake-uuid-1', 'name': 'net0'}, - {'id': 'fake-uuid-2', 'name': 'net0'}]} - fake_neutron_client = FakeNeutronClient() - fake_neutron_client.list_networks.return_value = fake_networks - self.openstack_driver._get_client = mock.Mock( - return_value=fake_neutron_client) - - self.assertRaises(meo.VimGetResourceNameNotUnique, - self.openstack_driver.get_vim_resource_id, - self.vim_obj, resource_type, resource_name) - - def test_get_vim_resource_id_name_not_exist(self): - resource_type = 'network' - resource_name = 'net0' - fake_networks = {'networks': []} - fake_neutron_client = FakeNeutronClient() - fake_neutron_client.list_networks.return_value = fake_networks - self.openstack_driver._get_client = mock.Mock( - return_value=fake_neutron_client) - - self.assertRaises(meo.VimGetResourceNotFoundException, - self.openstack_driver.get_vim_resource_id, - self.vim_obj, resource_type, resource_name) diff --git a/apmec/tests/unit/meo/drivers/vnffg/__init__.py b/apmec/tests/unit/meo/drivers/vnffg/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/apmec/tests/unit/meo/drivers/vnffg/sfc_drivers/__init__.py b/apmec/tests/unit/meo/drivers/vnffg/sfc_drivers/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/apmec/tests/unit/meo/drivers/vnffg/sfc_drivers/networking-sfc/__init__.py b/apmec/tests/unit/meo/drivers/vnffg/sfc_drivers/networking-sfc/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/apmec/tests/unit/meo/drivers/vnffg/sfc_drivers/networking-sfc/test_n_sfc.py b/apmec/tests/unit/meo/drivers/vnffg/sfc_drivers/networking-sfc/test_n_sfc.py deleted file mode 100644 index 83dcead..0000000 --- a/apmec/tests/unit/meo/drivers/vnffg/sfc_drivers/networking-sfc/test_n_sfc.py +++ /dev/null @@ -1,241 +0,0 @@ -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, 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 mock - -from oslo_utils import uuidutils - -from apmec import context -from apmec.meo.drivers.vim import openstack_driver -from apmec.tests.unit import base -from apmec.tests.unit.db import utils - - -class FakeNeutronClient(mock.Mock): - def __init__(self): - super(FakeNeutronClient, self).__init__() - self.__fc_dict = {} - self.__pp_dict = {} - self.__ppg_dict = {} - self.__chain_dict = {} - - def flow_classifier_create(self, fc_create_dict): - fc_id = uuidutils.generate_uuid() - self.__fc_dict[fc_id] = fc_create_dict - return fc_id - - def show_flow_classifier(self, fc_dict): - fc_name = fc_dict['name'] - for fc_id in self.__fc_dict: - fc = self.__fc_dict[fc_id] - if fc_name == fc['name']: - return {'id': fc_id} - - return None - - def flow_classifier_update(self, fc_id, fc_update_dict): - if fc_id not in self.__fc_dict: - return None - self.__fc_dict[fc_id] = fc_update_dict - return fc_update_dict - - def flow_classifier_delete(self, fc_id): - if fc_id not in self.__fc_dict: - raise ValueError('fc not found') - self.__fc_dict.pop(fc_id) - - def port_pair_create(self, port_pair): - pp_id = uuidutils.generate_uuid() - self.__pp_dict[pp_id] = port_pair - return pp_id - - def show_port_pair(self, port_pair_dict): - input_pp_name = port_pair_dict['name'] - for pp_id in self.__pp_dict: - port_pair = self.__pp_dict[pp_id] - if port_pair['name'] == input_pp_name: - return {'id': pp_id} - - return None - - def port_pair_group_create(self, port_pair_group): - ppg_id = uuidutils.generate_uuid() - self.__ppg_dict[ppg_id] = port_pair_group - return ppg_id - - def show_port_pair_group(self, port_pair_group_dict): - input_ppg_name = port_pair_group_dict['name'] - for ppg_id in self.__ppg_dict: - port_pair_group = self.__ppg_dict[ppg_id] - if port_pair_group['name'] == input_ppg_name: - return {'id': ppg_id} - - return None - - def port_chain_create(self, port_chain): - chain_id = uuidutils.generate_uuid() - self.__chain_dict[chain_id] = port_chain - return chain_id - - def show_port_chain(self, port_chain_dict): - input_chain_name = port_chain_dict['name'] - for chain_id in self.__chain_dict: - port_chain = self.__chain_dict[chain_id] - if port_chain['name'] == input_chain_name: - return {'id': chain_id} - return None - - def port_chain_delete(self, chain_id): - if chain_id not in self.__chain_dict: - raise ValueError('port chain delete failed') - self.__chain_dict.pop(chain_id) - - -class TestChainSFC(base.TestCase): - - def setUp(self): - super(TestChainSFC, self).setUp() - self.context = context.get_admin_context() - self.sfc_driver = openstack_driver.OpenStack_Driver() - self._mock_neutron_client() - self.addCleanup(mock.patch.stopall) - - def _mock_neutron_client(self): - self.neutron_client = mock.Mock(wraps=FakeNeutronClient()) - fake_neutron_client = mock.Mock() - fake_neutron_client.return_value = self.neutron_client - self._mock( - 'apmec.meo.drivers.vim.openstack_driver.' - 'NeutronClient', - fake_neutron_client) - - def _mock(self, target, new=mock.DEFAULT): - patcher = mock.patch(target, new) - return patcher.start() - - def test_create_flow_classifier(self): - flow_classifier = {'name': 'fake_fc', - 'source_port_range': '2005-2010', - 'ip_proto': 6, - 'destination_port_range': '80-180'} - result = self.sfc_driver.\ - create_flow_classifier(name='fake_ffg', fc=flow_classifier, - auth_attr=utils.get_vim_auth_obj()) - self.assertIsNotNone(result) - - def test_update_flow_classifier(self): - flow_classifier = {'name': 'next_fake_fc', - 'description': 'fake flow-classifier', - 'source_port_range': '2005-2010', - 'ip_proto': 6, - 'destination_port_range': '80-180'} - fc_id = self.sfc_driver.\ - create_flow_classifier(name='fake_ffg', fc=flow_classifier, - auth_attr=utils.get_vim_auth_obj()) - - self.assertIsNotNone(fc_id) - - flow_classifier['description'] = 'next fake flow-classifier' - - result = self.sfc_driver.\ - update_flow_classifier(fc_id=fc_id, - fc=flow_classifier, - auth_attr=utils.get_vim_auth_obj()) - self.assertIsNotNone(result) - - def test_delete_flow_classifier(self): - flow_classifier = {'name': 'another_fake_fc', - 'description': 'another flow-classifier', - 'source_port_range': '1999-2005', - 'ip_proto': 6, - 'destination_port_range': '80-100'} - fc_id = self.sfc_driver.\ - create_flow_classifier(name='fake_ffg', fc=flow_classifier, - auth_attr=utils.get_vim_auth_obj()) - - self.assertIsNotNone(fc_id) - - try: - self.sfc_driver.\ - delete_flow_classifier(fc_id=fc_id, - auth_attr=utils.get_vim_auth_obj()) - except Exception: - self.assertTrue(True) - - def test_create_chain(self): - auth_attr = utils.get_vim_auth_obj() - flow_classifier = {'name': 'test_create_chain_fc', - 'description': 'fc for testing create chain', - 'source_port_range': '1997-2008', - 'ip_proto': 6, - 'destination_port_range': '80-100'} - fc_id = self.sfc_driver.\ - create_flow_classifier(name='fake_ffg', fc=flow_classifier, - auth_attr=auth_attr) - - self.assertIsNotNone(fc_id) - - mea_1 = {'name': 'test_create_chain_mea_1', - 'connection_points': [uuidutils.generate_uuid(), - uuidutils.generate_uuid()]} - mea_2 = {'name': 'test_create_chain_mea_2', - 'connection_points': [uuidutils.generate_uuid(), - uuidutils.generate_uuid()]} - mea_3 = {'name': 'test_create_chain_mea_3', - 'connection_points': [uuidutils.generate_uuid(), - uuidutils.generate_uuid()]} - meas = [mea_1, mea_2, mea_3] - - result = self.sfc_driver.create_chain(name='fake_ffg', - fc_id=fc_id, - meas=meas, - auth_attr=auth_attr) - - self.assertIsNotNone(result) - - def test_delete_chain(self): - auth_attr = utils.get_vim_auth_obj() - flow_classifier = {'name': 'test_delete_chain_fc', - 'description': 'fc for testing delete chain', - 'source_port_range': '1000-2000', - 'ip_proto': 6, - 'destination_port_range': '80-180'} - fc_id = self.sfc_driver.\ - create_flow_classifier(name='fake_ffg', fc=flow_classifier, - auth_attr=auth_attr) - - self.assertIsNotNone(fc_id) - - mea_1 = {'name': 'test_delete_chain_mea_1', - 'connection_points': [uuidutils.generate_uuid(), - uuidutils.generate_uuid()]} - mea_2 = {'name': 'test_delete_chain_mea_2', - 'connection_points': [uuidutils.generate_uuid(), - uuidutils.generate_uuid()]} - mea_3 = {'name': 'test_delete_chain_mea_3', - 'connection_points': [uuidutils.generate_uuid(), - uuidutils.generate_uuid()]} - meas = [mea_1, mea_2, mea_3] - - chain_id = self.sfc_driver.create_chain(name='fake_ffg', - fc_id=fc_id, - meas=meas, - auth_attr=auth_attr) - - self.assertIsNotNone(chain_id) - - try: - self.sfc_driver.delete_chain(chain_id, - auth_attr=auth_attr) - except Exception: - self.assertTrue(True) diff --git a/apmec/tests/unit/meo/drivers/workflow/__init__.py b/apmec/tests/unit/meo/drivers/workflow/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/apmec/tests/unit/meo/drivers/workflow/test_workflow_generator.py b/apmec/tests/unit/meo/drivers/workflow/test_workflow_generator.py deleted file mode 100644 index 43ccce4..0000000 --- a/apmec/tests/unit/meo/drivers/workflow/test_workflow_generator.py +++ /dev/null @@ -1,172 +0,0 @@ -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, 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. - -from apmec import context -from apmec.meo.drivers.workflow import workflow_generator -from apmec.tests.unit import base - - -def get_dummy_mes(): - return {u'mes': {'description': '', - 'tenant_id': u'a81900a92bda40588c52699e1873a92f', - 'vim_id': u'96025dd5-ca16-49f3-9823-958eb04260c4', - 'mea_ids': '', u'attributes': {}, - u'mesd_id': u'b8587afb-6099-4f56-abce-572c62e3d61d', - u'name': u'test_create_mes'}, - 'mead_details': {u'mea1': {'instances': ['MEA1'], - 'id': u'dec09ed4-f355-4ec8-a00b-8548f6575a80'}, - u'mea2': {'instances': ['MEA2'], - 'id': u'9f8f2af7-6407-4f79-a6fe-302c56172231'}}, - 'placement_attr': {}} - - -def get_dummy_param(): - return {u'mea1': {'substitution_mappings': {u'VL1b8587afb-60': { - 'type': 'tosca.nodes.mec.VL', 'properties': { - 'network_name': u'net_mgmt', - 'vendor': 'apmec'}}, 'requirements': { - 'virtualLink2': u'VL2b8587afb-60', - 'virtualLink1': u'VL1b8587afb-60'}, u'VL2b8587afb-60': { - 'type': 'tosca.nodes.mec.VL', - 'properties': {'network_name': u'net0', - 'vendor': 'apmec'}}}}, - u'mesd': {u'vl2_name': u'net0', u'vl1_name': u'net_mgmt'}} - - -def get_dummy_create_workflow(): - return {'std.create_mea_dummy': {'input': ['mea'], - 'tasks': { - 'wait_mea_active_MEA2': { - 'action': 'apmec.show_mea mea=<% $.mea_id_MEA2 %>', - 'retry': {'count': 10, 'delay': 10, - 'continue-on': '<% $.status_MEA2 = ' - '"PENDING_CREATE" %>', - 'break-on': '<% $.status_MEA2 = "ERROR" %>'}, - 'publish': { - 'status_MEA2': '<% task(wait_mea_active_MEA2).' - 'result.mea.status %>', - 'mgmt_url_MEA2': ' <% task(wait_mea_active_MEA2).' - 'result.mea.mgmt_url %>'}, - 'on-success': [{ - 'delete_mea_MEA2': '<% $.status_MEA2=' - '"ERROR" %>'}]}, - 'create_mea_MEA2': { - 'action': 'apmec.create_mea body=<% $.mea.MEA2 %>', - 'input': {'body': '<% $.mea.MEA2 %>'}, - 'publish': { - 'status_MEA2': '<% task(create_mea_MEA2).' - 'result.mea.status %>', - 'vim_id_MEA2': '<% task(create_mea_MEA2).' - 'result.mea.vim_id %>', - 'mgmt_url_MEA2': '<% task(create_mea_MEA2).' - 'result.mea.mgmt_url %>', - 'mea_id_MEA2': '<% task(create_mea_MEA2)' - '.result.mea.id %>'}, - 'on-success': ['wait_mea_active_MEA2']}, - 'create_mea_MEA1': { - 'action': 'apmec.create_mea body=<% $.mea.MEA1 %>', - 'input': {'body': '<% $.mea.MEA1 %>'}, - 'publish': { - 'status_MEA1': '<% task(create_mea_MEA1).' - 'result.mea.status %>', - 'mea_id_MEA1': '<% task(create_mea_MEA1).' - 'result.mea.id %>', - 'mgmt_url_MEA1': '<% task(create_mea_MEA1).' - 'result.mea.mgmt_url %>', - 'vim_id_MEA1': '<% task(create_mea_MEA1).' - 'result.mea.vim_id %>'}, - 'on-success': ['wait_mea_active_MEA1']}, - 'wait_mea_active_MEA1': { - 'action': 'apmec.show_mea mea=<% $.mea_id_MEA1 %>', - 'retry': {'count': 10, 'delay': 10, - 'continue-on': '<% $.status_MEA1 = "PENDING_' - 'CREATE" %>', - 'break-on': '<% $.status_MEA1 = "ERROR" %>'}, - 'publish': { - 'status_MEA1': '<% task(wait_mea_active_MEA1).' - 'result.mea.status %>', - 'mgmt_url_MEA1': ' <% task(wait_mea_active_MEA1).' - 'result.mea.mgmt_url %>'}, - 'on-success': [{'delete_mea_MEA1': '<% $.status_MEA1=' - '"ERROR" %>'}]}, - 'delete_mea_MEA1': {'action': 'apmec.delete_mea mea=<% ' - '$.mea_id_MEA1%>'}, - 'delete_mea_MEA2': {'action': 'apmec.delete_mea mea=<% ' - '$.mea_id_MEA2%>'}}, - 'type': 'direct', 'output': { - 'status_MEA1': '<% $.status_MEA1 %>', - 'status_MEA2': '<% $.status_MEA2 %>', - 'mgmt_url_MEA2': '<% $.mgmt_url_MEA2 %>', - 'mgmt_url_MEA1': '<% $.mgmt_url_MEA1 %>', - 'vim_id_MEA2': '<% $.vim_id_MEA2 %>', - 'mea_id_MEA1': '<% $.mea_id_MEA1 %>', - 'mea_id_MEA2': '<% $.mea_id_MEA2 %>', - 'vim_id_MEA1': '<% $.vim_id_MEA1 %>'}}, - 'version': '2.0'} - - -def dummy_delete_mes_obj(): - return {'mea_ids': u"{'MEA1': '5de5eca6-3e21-4bbd-a9d7-86458de75f0c'}"} - - -def get_dummy_delete_workflow(): - return {'version': '2.0', - 'std.delete_mea_dummy': {'input': ['mea_id_MEA1'], - 'tasks': {'delete_mea_MEA1': { - 'action': 'apmec.delete_mea mea=<% $.mea_id_MEA1%>'}}, - 'type': 'direct'}} - - -class FakeMistral(object): - def __init__(self): - pass - - -class FakeMEOPlugin(object): - - def __init__(self, context, client, resource, action): - self.context = context - self.client = client - self.wg = workflow_generator.WorkflowGenerator(resource, action) - - def prepare_workflow(self, **kwargs): - self.wg.task(**kwargs) - - -class TestWorkflowGenerator(base.TestCase): - def setUp(self): - super(TestWorkflowGenerator, self).setUp() - self.mistral_client = FakeMistral() - - def test_prepare_workflow_create(self): - fPlugin = FakeMEOPlugin(context, self.mistral_client, - resource='mea', action='create') - fPlugin.prepare_workflow(mes=get_dummy_mes(), params=get_dummy_param()) - wf_def_values = [fPlugin.wg.definition[k] for - k in fPlugin.wg.definition] - self.assertIn(get_dummy_create_workflow()['std.create_mea_dummy'], - wf_def_values) - self.assertEqual(get_dummy_create_workflow()['version'], - fPlugin.wg.definition['version']) - - def test_prepare_workflow_delete(self): - fPlugin = FakeMEOPlugin(context, self.mistral_client, - resource='mea', action='delete') - fPlugin.prepare_workflow(mes=dummy_delete_mes_obj()) - wf_def_values = [fPlugin.wg.definition[k] for - k in fPlugin.wg.definition] - self.assertIn(get_dummy_delete_workflow()['std.delete_mea_dummy'], - wf_def_values) - self.assertEqual(get_dummy_delete_workflow()['version'], - fPlugin.wg.definition['version']) diff --git a/apmec/tests/unit/meo/test_nfvo_plugin.py b/apmec/tests/unit/meo/test_nfvo_plugin.py deleted file mode 100644 index 2ec9d30..0000000 --- a/apmec/tests/unit/meo/test_nfvo_plugin.py +++ /dev/null @@ -1,355 +0,0 @@ -# Copyright 2016 Brocade Communications System, Inc. -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, 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 codecs -from datetime import datetime -import mock -import os -from oslo_utils import uuidutils - -from mock import patch - -from apmec import context -from apmec.db.common_services import common_services_db_plugin -from apmec.db.meo import meo_db -from apmec.extensions import meo -from apmec.meo import meo_plugin -from apmec.plugins.common import constants -from apmec.tests.unit.db import base as db_base -from apmec.tests.unit.db import utils - -SECRET_PASSWORD = '***' -DUMMY_mes_2 = 'ba6bf017-f6f7-45f1-a280-57b073bf78ef' - - -def dummy_get_vim(*args, **kwargs): - vim_obj = dict() - vim_obj['auth_cred'] = utils.get_vim_auth_obj() - vim_obj['type'] = 'openstack' - return vim_obj - - -def _get_template(name): - filename = os.path.abspath(os.path.join(os.path.dirname(__file__), - '../../etc/samples/' + str(name))) - f = codecs.open(filename, encoding='utf-8', errors='strict') - return f.read() - - -class FakeDriverManager(mock.Mock): - def invoke(self, *args, **kwargs): - if any(x in ['create', 'create_chain', 'create_flow_classifier'] for - x in args): - return uuidutils.generate_uuid() - elif 'execute_workflow' in args: - mock_execution = mock.Mock() - mock_execution.id.return_value = \ - "ba6bf017-f6f7-45f1-a280-57b073bf78ea" - return mock_execution - elif ('prepare_and_create_workflow' in args and - 'delete' == kwargs['action'] and - DUMMY_mes_2 == kwargs['kwargs']['mes']['id']): - raise meo.NoTasksException() - elif ('prepare_and_create_workflow' in args and - 'create' == kwargs['action'] and - utils.DUMMY_mes_2_NAME == kwargs['kwargs']['mes']['mes']['name']): - raise meo.NoTasksException() - - -def get_by_name(): - return False - - -def get_by_id(): - return False - - -def dummy_get_vim_auth(*args, **kwargs): - return {'vim_auth': {u'username': u'admin', 'password': 'devstack', - u'project_name': u'mec', u'user_id': u'', - u'user_domain_name': u'Default', - u'auth_url': u'http://10.0.4.207/identity/v3', - u'project_id': u'', - u'project_domain_name': u'Default'}, - 'vim_id': u'96025dd5-ca16-49f3-9823-958eb04260c4', - 'vim_type': u'openstack', 'vim_name': u'VIM0'} - - -class FakeClient(mock.Mock): - def __init__(self, auth): - pass - - -class FakeMEMPlugin(mock.Mock): - - def __init__(self): - super(FakeMEMPlugin, self).__init__() - self.mea1_mead_id = 'eb094833-995e-49f0-a047-dfb56aaf7c4e' - self.mea1_mea_id = '91e32c20-6d1f-47a4-9ba7-08f5e5effe07' - self.mea3_mead_id = 'e4015e9f-1ef2-49fb-adb6-070791ad3c45' - self.mea2_mead_id = 'e4015e9f-1ef2-49fb-adb6-070791ad3c45' - self.mea3_mea_id = '7168062e-9fa1-4203-8cb7-f5c99ff3ee1b' - self.mea3_update_mea_id = '10f66bc5-b2f1-45b7-a7cd-6dd6ad0017f5' - - self.cp11_id = 'd18c8bae-898a-4932-bff8-d5eac981a9c9' - self.cp12_id = 'c8906342-3e30-4b2a-9401-a251a7a9b5dd' - self.cp32_id = '3d1bd2a2-bf0e-44d1-87af-a2c6b2cad3ed' - self.cp32_update_id = '064c0d99-5a61-4711-9597-2a44dc5da14b' - - def get_mead(self, *args, **kwargs): - if 'MEA1' in args: - return {'id': self.mea1_mead_id, - 'name': 'MEA1', - 'attributes': {'mead': _get_template( - 'test-mesd-mead1.yaml')}} - elif 'MEA2' in args: - return {'id': self.mea3_mead_id, - 'name': 'MEA2', - 'attributes': {'mead': _get_template( - 'test-mesd-mead2.yaml')}} - - def get_meads(self, *args, **kwargs): - if {'name': ['MEA1']} in args: - return [{'id': self.mea1_mead_id}] - elif {'name': ['MEA3']} in args: - return [{'id': self.mea3_mead_id}] - else: - return [] - - def get_meas(self, *args, **kwargs): - if {'mead_id': [self.mea1_mead_id]} in args: - return [{'id': self.mea1_mea_id}] - elif {'mead_id': [self.mea3_mead_id]} in args: - return [{'id': self.mea3_mea_id}] - else: - return None - - def get_mea(self, *args, **kwargs): - if self.mea1_mea_id in args: - return self.get_dummy_mea1() - elif self.mea3_mea_id in args: - return self.get_dummy_mea3() - elif self.mea3_update_mea_id in args: - return self.get_dummy_mea3_update() - - def get_mea_resources(self, *args, **kwargs): - if self.mea1_mea_id in args: - return self.get_dummy_mea1_details() - elif self.mea3_mea_id in args: - return self.get_dummy_mea3_details() - elif self.mea3_update_mea_id in args: - return self.get_dummy_mea3_update_details() - - def get_dummy_mea1_details(self): - return [{'name': 'CP11', 'id': self.cp11_id}, - {'name': 'CP12', 'id': self.cp12_id}] - - def get_dummy_mea3_details(self): - return [{'name': 'CP32', 'id': self.cp32_id}] - - def get_dummy_mea3_update_details(self): - return [{'name': 'CP32', 'id': self.cp32_update_id}] - - def get_dummy_mea1(self): - return {'description': 'dummy_mea_description', - 'mead_id': self.mea1_mead_id, - 'vim_id': u'6261579e-d6f3-49ad-8bc3-a9cb974778ff', - 'tenant_id': u'ad7ebc56538745a08ef7c5e97f8bd437', - 'name': 'dummy_mea1', - 'attributes': {}} - - def get_dummy_mea3(self): - return {'description': 'dummy_mea_description', - 'mead_id': self.mea3_mead_id, - 'vim_id': u'6261579e-d6f3-49ad-8bc3-a9cb974778ff', - 'tenant_id': u'ad7ebc56538745a08ef7c5e97f8bd437', - 'name': 'dummy_mea2', - 'attributes': {}} - - def get_dummy_mea3_update(self): - return {'description': 'dummy_mea_description', - 'mead_id': self.mea3_mead_id, - 'vim_id': u'6261579e-d6f3-49ad-8bc3-a9cb974778ff', - 'tenant_id': u'ad7ebc56538745a08ef7c5e97f8bd437', - 'name': 'dummy_mea_update', - 'attributes': {}} - - -class TestMeoPlugin(db_base.SqlTestCase): - def setUp(self): - super(TestMeoPlugin, self).setUp() - self.addCleanup(mock.patch.stopall) - self.context = context.get_admin_context() - self._mock_driver_manager() - mock.patch('apmec.meo.meo_plugin.MeoPlugin._get_vim_from_mea', - side_effect=dummy_get_vim).start() - self.meo_plugin = meo_plugin.MeoPlugin() - mock.patch('apmec.db.common_services.common_services_db_plugin.' - 'CommonServicesPluginDb.create_event' - ).start() - self._cos_db_plugin =\ - common_services_db_plugin.CommonServicesPluginDb() - - def _mock_driver_manager(self): - self._driver_manager = mock.Mock(wraps=FakeDriverManager()) - self._driver_manager.__contains__ = mock.Mock( - return_value=True) - fake_driver_manager = mock.Mock() - fake_driver_manager.return_value = self._driver_manager - self._mock( - 'apmec.common.driver_manager.DriverManager', fake_driver_manager) - - def _insert_dummy_vim(self): - session = self.context.session - vim_db = meo_db.Vim( - id='6261579e-d6f3-49ad-8bc3-a9cb974778ff', - tenant_id='ad7ebc56538745a08ef7c5e97f8bd437', - name='fake_vim', - description='fake_vim_description', - type='openstack', - status='Active', - deleted_at=datetime.min, - placement_attr={'regions': ['RegionOne']}) - vim_auth_db = meo_db.VimAuth( - vim_id='6261579e-d6f3-49ad-8bc3-a9cb974778ff', - password='encrypted_pw', - auth_url='http://localhost:5000', - vim_project={'name': 'test_project'}, - auth_cred={'username': 'test_user', 'user_domain_id': 'default', - 'project_domain_id': 'default', - 'key_type': 'fernet_key'}) - session.add(vim_db) - session.add(vim_auth_db) - session.flush() - - def _insert_dummy_vim_barbican(self): - session = self.context.session - vim_db = meo_db.Vim( - id='6261579e-d6f3-49ad-8bc3-a9cb974778ff', - tenant_id='ad7ebc56538745a08ef7c5e97f8bd437', - name='fake_vim', - description='fake_vim_description', - type='openstack', - status='Active', - deleted_at=datetime.min, - placement_attr={'regions': ['RegionOne']}) - vim_auth_db = meo_db.VimAuth( - vim_id='6261579e-d6f3-49ad-8bc3-a9cb974778ff', - password='encrypted_pw', - auth_url='http://localhost:5000', - vim_project={'name': 'test_project'}, - auth_cred={'username': 'test_user', 'user_domain_id': 'default', - 'project_domain_id': 'default', - 'key_type': 'barbican_key', - 'secret_uuid': 'fake-secret-uuid'}) - session.add(vim_db) - session.add(vim_auth_db) - session.flush() - - def test_create_vim(self): - vim_dict = utils.get_vim_obj() - vim_type = 'openstack' - res = self.meo_plugin.create_vim(self.context, vim_dict) - self._cos_db_plugin.create_event.assert_any_call( - self.context, evt_type=constants.RES_EVT_CREATE, res_id=mock.ANY, - res_state=mock.ANY, res_type=constants.RES_TYPE_VIM, - tstamp=mock.ANY) - self._driver_manager.invoke.assert_any_call( - vim_type, 'register_vim', - context=self.context, vim_obj=vim_dict['vim']) - self.assertIsNotNone(res) - self.assertEqual(SECRET_PASSWORD, res['auth_cred']['password']) - self.assertIn('id', res) - self.assertIn('placement_attr', res) - self.assertIn('created_at', res) - self.assertIn('updated_at', res) - - def test_delete_vim(self): - self._insert_dummy_vim() - vim_type = u'openstack' - vim_id = '6261579e-d6f3-49ad-8bc3-a9cb974778ff' - vim_obj = self.meo_plugin._get_vim(self.context, vim_id) - self.meo_plugin.delete_vim(self.context, vim_id) - self._driver_manager.invoke.assert_called_once_with( - vim_type, 'deregister_vim', - context=self.context, - vim_obj=vim_obj) - self._cos_db_plugin.create_event.assert_called_with( - self.context, evt_type=constants.RES_EVT_DELETE, res_id=mock.ANY, - res_state=mock.ANY, res_type=constants.RES_TYPE_VIM, - tstamp=mock.ANY) - - def test_update_vim(self): - vim_dict = {'vim': {'id': '6261579e-d6f3-49ad-8bc3-a9cb974778ff', - 'vim_project': {'name': 'new_project'}, - 'auth_cred': {'username': 'new_user', - 'password': 'new_password'}}} - vim_type = u'openstack' - vim_auth_username = vim_dict['vim']['auth_cred']['username'] - vim_project = vim_dict['vim']['vim_project'] - self._insert_dummy_vim() - res = self.meo_plugin.update_vim(self.context, vim_dict['vim']['id'], - vim_dict) - vim_obj = self.meo_plugin._get_vim( - self.context, vim_dict['vim']['id']) - vim_obj['updated_at'] = None - self._driver_manager.invoke.assert_called_with( - vim_type, 'register_vim', - context=self.context, - vim_obj=vim_obj) - self.assertIsNotNone(res) - self.assertIn('id', res) - self.assertIn('placement_attr', res) - self.assertEqual(vim_project, res['vim_project']) - self.assertEqual(vim_auth_username, res['auth_cred']['username']) - self.assertEqual(SECRET_PASSWORD, res['auth_cred']['password']) - self.assertIn('updated_at', res) - self._cos_db_plugin.create_event.assert_called_with( - self.context, evt_type=constants.RES_EVT_UPDATE, res_id=mock.ANY, - res_state=mock.ANY, res_type=constants.RES_TYPE_VIM, - tstamp=mock.ANY) - - def test_update_vim_barbican(self): - vim_dict = {'vim': {'id': '6261579e-d6f3-49ad-8bc3-a9cb974778ff', - 'vim_project': {'name': 'new_project'}, - 'auth_cred': {'username': 'new_user', - 'password': 'new_password'}}} - vim_type = u'openstack' - vim_auth_username = vim_dict['vim']['auth_cred']['username'] - vim_project = vim_dict['vim']['vim_project'] - self._insert_dummy_vim_barbican() - old_vim_obj = self.meo_plugin._get_vim( - self.context, vim_dict['vim']['id']) - res = self.meo_plugin.update_vim(self.context, vim_dict['vim']['id'], - vim_dict) - vim_obj = self.meo_plugin._get_vim( - self.context, vim_dict['vim']['id']) - vim_obj['updated_at'] = None - self._driver_manager.invoke.assert_called_with( - vim_type, 'delete_vim_auth', - context=self.context, - vim_id=vim_obj['id'], - auth=old_vim_obj['auth_cred']) - self.assertIsNotNone(res) - self.assertIn('id', res) - self.assertIn('placement_attr', res) - self.assertEqual(vim_project, res['vim_project']) - self.assertEqual(vim_auth_username, res['auth_cred']['username']) - self.assertEqual(SECRET_PASSWORD, res['auth_cred']['password']) - self.assertIn('updated_at', res) - self._cos_db_plugin.create_event.assert_called_with( - self.context, evt_type=constants.RES_EVT_UPDATE, res_id=mock.ANY, - res_state=mock.ANY, res_type=constants.RES_TYPE_VIM, - tstamp=mock.ANY) \ No newline at end of file diff --git a/apmec/tests/unit/test_alarm_receiver.py b/apmec/tests/unit/test_alarm_receiver.py deleted file mode 100644 index 9e98119..0000000 --- a/apmec/tests/unit/test_alarm_receiver.py +++ /dev/null @@ -1,60 +0,0 @@ -# Copyright 2015 Brocade Communications System, Inc. -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, 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 mock -from webob import Request - -from apmec.alarm_receiver import AlarmReceiver -from apmec.tests.unit import base - - -class TestAlarmReceiver(base.TestCase): - def setUp(self): - '''url: - - http://apmec:9896/v1.0/meas/mea-uuid/mon-policy-name/ - action-name/8ef785 - ''' - super(TestAlarmReceiver, self).setUp() - self.alarmrc = AlarmReceiver(None) - self.alarm_url = { - '00_base': 'http://apmec:9896/v1.0', - '01_url_base': '/meas/mea-uuid/', - '02_mea_id': 'mea-uuid', - '03_monitoring_policy_name': 'mon-policy-name', - '04_action_name': 'action-name', - '05_key': 'KEY' - } - self.mea_id = 'mea-uuid' - self.ordered_url = self._generate_alarm_url() - - def _generate_alarm_url(self): - return 'http://apmec:9896/v1.0/meas/mea-uuid/mon-policy-name/'\ - 'action-name/8ef785' - - def test_handle_url(self): - prefix_url, p, params = self.alarmrc.handle_url(self.ordered_url) - self.assertEqual(self.alarm_url['01_url_base'], prefix_url) - self.assertEqual(self.alarm_url['02_mea_id'], p[3]) - self.assertEqual(self.alarm_url['03_monitoring_policy_name'], p[4]) - self.assertEqual(self.alarm_url['04_action_name'], p[5]) - - @mock.patch('apmec.mem.monitor_drivers.token.Token.create_token') - def test_process_request(self, mock_token): - req = Request.blank(self.ordered_url) - req.method = 'POST' - self.alarmrc.process_request(req) - self.assertIsNotNone(req.body) - self.assertIn('triggers', req.environ['PATH_INFO']) diff --git a/apmec/tests/unit/test_api_api_common.py b/apmec/tests/unit/test_api_api_common.py deleted file mode 100644 index 0579142..0000000 --- a/apmec/tests/unit/test_api_api_common.py +++ /dev/null @@ -1,94 +0,0 @@ -# Copyright (c) 2013 Intel Corporation. -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, 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. - -from testtools import matchers -from webob import exc - -from apmec.api import api_common as common -from apmec.tests import base - - -class FakeController(common.ApmecController): - _resource_name = 'fake' - - -class APICommonTestCase(base.BaseTestCase): - def setUp(self): - super(APICommonTestCase, self).setUp() - self.controller = FakeController(None) - - def test_prepare_request_body(self): - body = { - 'fake': { - 'name': 'terminator', - 'model': 'T-800', - } - } - params = [ - {'param-name': 'name', - 'required': True}, - {'param-name': 'model', - 'required': True}, - {'param-name': 'quote', - 'required': False, - 'default-value': "i'll be back"}, - ] - expect = { - 'fake': { - 'name': 'terminator', - 'model': 'T-800', - 'quote': "i'll be back", - } - } - actual = self.controller._prepare_request_body(body, params) - self.assertThat(expect, matchers.Equals(actual)) - - def test_prepare_request_body_none(self): - body = None - params = [ - {'param-name': 'quote', - 'required': False, - 'default-value': "I'll be back"}, - ] - expect = { - 'fake': { - 'quote': "I'll be back", - } - } - actual = self.controller._prepare_request_body(body, params) - self.assertThat(expect, matchers.Equals(actual)) - - def test_prepare_request_body_keyerror(self): - body = {'t2': {}} - params = [] - self.assertRaises(exc.HTTPBadRequest, - self.controller._prepare_request_body, - body, - params) - - def test_prepare_request_param_value_none(self): - body = { - 'fake': { - 'name': None, - } - } - params = [ - {'param-name': 'name', - 'required': True}, - ] - self.assertRaises(exc.HTTPBadRequest, - self.controller._prepare_request_body, - body, - params) diff --git a/apmec/tests/unit/test_api_v2.py b/apmec/tests/unit/test_api_v2.py deleted file mode 100644 index fdd5ce7..0000000 --- a/apmec/tests/unit/test_api_v2.py +++ /dev/null @@ -1,1449 +0,0 @@ -# Copyright (c) 2012 OpenStack Foundation. -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, 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 os - -import mock -from oslo_config import cfg -from oslo_policy import policy as common_policy -from oslo_utils import uuidutils -import six -import six.moves.urllib.parse as urlparse -import webob -from webob import exc -import webtest - -from apmec.api import api_common -from apmec.api import extensions -from apmec.api.v1 import attributes -from apmec.api.v1 import base as v2_base -from apmec.api.v1 import router -from apmec.common import exceptions as n_exc -from apmec import context -from apmec import manager -from apmec import policy -from apmec.tests import base -from apmec.tests import fake_notifier -from apmec.tests.unit import testlib_api - - -ROOTDIR = os.path.dirname(os.path.dirname(__file__)) -EXTDIR = os.path.join(ROOTDIR, 'unit/extensions') - -_uuid = uuidutils.generate_uuid - - -def _get_path(resource, id=None, action=None, fmt=None): - path = '/%s' % resource - - if id is not None: - path = path + '/%s' % id - - if action is not None: - path = path + '/%s' % action - - if fmt is not None: - path = path + '.%s' % fmt - - return path - - -class ResourceIndexTestCase(base.BaseTestCase): - def test_index_json(self): - index = webtest.TestApp(router.Index({'foo': 'bar'})) - res = index.get('') - - self.assertIn('resources', res.json) - self.assertEqual(1, len(res.json['resources'])) - - resource = res.json['resources'][0] - self.assertIn('collection', resource) - self.assertEqual('bar', resource['collection']) - - self.assertIn('name', resource) - self.assertEqual('foo', resource['name']) - - self.assertIn('links', resource) - self.assertEqual(1, len(resource['links'])) - - link = resource['links'][0] - self.assertIn('href', link) - self.assertEqual('http://localhost/bar', link['href']) - self.assertIn('rel', link) - self.assertEqual('self', link['rel']) - - -class APIv2TestBase(base.BaseTestCase): - def setUp(self): - super(APIv2TestBase, self).setUp() - self.skip("Not ready yet") - plugin = 'apmec.apmec_plugin_base_v2.ApmecPluginBaseV2' - # Ensure existing ExtensionManager is not used - extensions.PluginAwareExtensionManager._instance = None - # Create the default configurations - self.config_parse() - # Update the plugin - self.setup_coreplugin(plugin) - cfg.CONF.set_override('allow_pagination', True) - cfg.CONF.set_override('allow_sorting', True) - self._plugin_patcher = mock.patch(plugin, autospec=True) - self.plugin = self._plugin_patcher.start() - instance = self.plugin.return_value - instance._ApmecPluginBaseV2__native_pagination_support = True - instance._ApmecPluginBaseV2__native_sorting_support = True - - api = router.APIRouter() - self.api = webtest.TestApp(api) - - -class _ArgMatcher(object): - """An adapter to assist mock assertions, used to custom compare.""" - - def __init__(self, cmp, obj): - self.cmp = cmp - self.obj = obj - - def __eq__(self, other): - return self.cmp(self.obj, other) - - def __ne__(self, other): - return not self.__eq__(other) - - -def _list_cmp(l1, l2): - return set(l1) == set(l2) - - -class APIv2TestCase(APIv2TestBase): - def _do_field_list(self, resource, base_fields): - attr_info = attributes.RESOURCE_ATTRIBUTE_MAP[resource] - policy_attrs = [name for (name, info) in attr_info.items() - if info.get('required_by_policy') or - info.get('primary_key')] - fields = base_fields - fields.extend(policy_attrs) - return fields - - def _get_collection_kwargs(self, skipargs=None, **kwargs): - args_list = ['filters', 'fields', 'sorts', 'limit', 'marker', - 'page_reverse'] - if skipargs is None: - skipargs = [] - args_dict = dict((arg, mock.ANY) - for arg in set(args_list) - set(skipargs)) - args_dict.update(kwargs) - return args_dict - - def test_fields(self): - instance = self.plugin.return_value - instance.get_networks.return_value = [] - - self.api.get(_get_path('networks'), {'fields': 'foo'}) - fields = self._do_field_list('networks', ['foo']) - kwargs = self._get_collection_kwargs(fields=fields) - instance.get_networks.assert_called_once_with(mock.ANY, **kwargs) - - def test_fields_multiple(self): - instance = self.plugin.return_value - instance.get_networks.return_value = [] - - fields = self._do_field_list('networks', ['foo', 'bar']) - self.api.get(_get_path('networks'), {'fields': ['foo', 'bar']}) - kwargs = self._get_collection_kwargs(fields=fields) - instance.get_networks.assert_called_once_with(mock.ANY, **kwargs) - - def test_fields_multiple_with_empty(self): - instance = self.plugin.return_value - instance.get_networks.return_value = [] - - fields = self._do_field_list('networks', ['foo']) - self.api.get(_get_path('networks'), {'fields': ['foo', '']}) - kwargs = self._get_collection_kwargs(fields=fields) - instance.get_networks.assert_called_once_with(mock.ANY, **kwargs) - - def test_fields_empty(self): - instance = self.plugin.return_value - instance.get_networks.return_value = [] - - self.api.get(_get_path('networks'), {'fields': ''}) - kwargs = self._get_collection_kwargs(fields=[]) - instance.get_networks.assert_called_once_with(mock.ANY, **kwargs) - - def test_fields_multiple_empty(self): - instance = self.plugin.return_value - instance.get_networks.return_value = [] - - self.api.get(_get_path('networks'), {'fields': ['', '']}) - kwargs = self._get_collection_kwargs(fields=[]) - instance.get_networks.assert_called_once_with(mock.ANY, **kwargs) - - def test_filters(self): - instance = self.plugin.return_value - instance.get_networks.return_value = [] - - self.api.get(_get_path('networks'), {'name': 'bar'}) - filters = {'name': ['bar']} - kwargs = self._get_collection_kwargs(filters=filters) - instance.get_networks.assert_called_once_with(mock.ANY, **kwargs) - - def test_filters_empty(self): - instance = self.plugin.return_value - instance.get_networks.return_value = [] - - self.api.get(_get_path('networks'), {'name': ''}) - filters = {} - kwargs = self._get_collection_kwargs(filters=filters) - instance.get_networks.assert_called_once_with(mock.ANY, **kwargs) - - def test_filters_multiple_empty(self): - instance = self.plugin.return_value - instance.get_networks.return_value = [] - - self.api.get(_get_path('networks'), {'name': ['', '']}) - filters = {} - kwargs = self._get_collection_kwargs(filters=filters) - instance.get_networks.assert_called_once_with(mock.ANY, **kwargs) - - def test_filters_multiple_with_empty(self): - instance = self.plugin.return_value - instance.get_networks.return_value = [] - - self.api.get(_get_path('networks'), {'name': ['bar', '']}) - filters = {'name': ['bar']} - kwargs = self._get_collection_kwargs(filters=filters) - instance.get_networks.assert_called_once_with(mock.ANY, **kwargs) - - def test_filters_multiple_values(self): - instance = self.plugin.return_value - instance.get_networks.return_value = [] - - self.api.get(_get_path('networks'), {'name': ['bar', 'bar2']}) - filters = {'name': ['bar', 'bar2']} - kwargs = self._get_collection_kwargs(filters=filters) - instance.get_networks.assert_called_once_with(mock.ANY, **kwargs) - - def test_filters_multiple(self): - instance = self.plugin.return_value - instance.get_networks.return_value = [] - - self.api.get(_get_path('networks'), {'name': 'bar', - 'tenant_id': 'bar2'}) - filters = {'name': ['bar'], 'tenant_id': ['bar2']} - kwargs = self._get_collection_kwargs(filters=filters) - instance.get_networks.assert_called_once_with(mock.ANY, **kwargs) - - def test_filters_with_fields(self): - instance = self.plugin.return_value - instance.get_networks.return_value = [] - - self.api.get(_get_path('networks'), {'name': 'bar', 'fields': 'foo'}) - filters = {'name': ['bar']} - fields = self._do_field_list('networks', ['foo']) - kwargs = self._get_collection_kwargs(filters=filters, fields=fields) - instance.get_networks.assert_called_once_with(mock.ANY, **kwargs) - - def test_filters_with_convert_to(self): - instance = self.plugin.return_value - instance.get_ports.return_value = [] - - self.api.get(_get_path('ports'), {'admin_state_up': 'true'}) - filters = {'admin_state_up': [True]} - kwargs = self._get_collection_kwargs(filters=filters) - instance.get_ports.assert_called_once_with(mock.ANY, **kwargs) - - def test_filters_with_convert_list_to(self): - instance = self.plugin.return_value - instance.get_ports.return_value = [] - - self.api.get(_get_path('ports'), - {'fixed_ips': ['ip_address=foo', 'subnet_id=bar']}) - filters = {'fixed_ips': {'ip_address': ['foo'], 'subnet_id': ['bar']}} - kwargs = self._get_collection_kwargs(filters=filters) - instance.get_ports.assert_called_once_with(mock.ANY, **kwargs) - - def test_limit(self): - instance = self.plugin.return_value - instance.get_networks.return_value = [] - - self.api.get(_get_path('networks'), - {'limit': '10'}) - kwargs = self._get_collection_kwargs(limit=10) - instance.get_networks.assert_called_once_with(mock.ANY, **kwargs) - - def test_limit_with_great_than_max_limit(self): - cfg.CONF.set_default('pagination_max_limit', '1000') - instance = self.plugin.return_value - instance.get_networks.return_value = [] - - self.api.get(_get_path('networks'), - {'limit': '1001'}) - kwargs = self._get_collection_kwargs(limit=1000) - instance.get_networks.assert_called_once_with(mock.ANY, **kwargs) - - def test_limit_with_zero(self): - cfg.CONF.set_default('pagination_max_limit', '1000') - instance = self.plugin.return_value - instance.get_networks.return_value = [] - - self.api.get(_get_path('networks'), {'limit': '0'}) - kwargs = self._get_collection_kwargs(limit=1000) - instance.get_networks.assert_called_once_with(mock.ANY, **kwargs) - - def test_limit_with_unspecific(self): - cfg.CONF.set_default('pagination_max_limit', '1000') - instance = self.plugin.return_value - instance.get_networks.return_value = [] - - self.api.get(_get_path('networks')) - kwargs = self._get_collection_kwargs(limit=1000) - instance.get_networks.assert_called_once_with(mock.ANY, **kwargs) - - def test_limit_with_negative_value(self): - cfg.CONF.set_default('pagination_max_limit', '1000') - instance = self.plugin.return_value - instance.get_networks.return_value = [] - - res = self.api.get(_get_path('networks'), {'limit': -1}, - expect_errors=True) - self.assertEqual(exc.HTTPBadRequest.code, res.status_int) - - def test_limit_with_non_integer(self): - instance = self.plugin.return_value - instance.get_networks.return_value = [] - - res = self.api.get(_get_path('networks'), - {'limit': 'abc'}, expect_errors=True) - self.assertEqual(exc.HTTPBadRequest.code, res.status_int) - - def test_limit_with_infinite_pagination_max_limit(self): - instance = self.plugin.return_value - instance.get_networks.return_value = [] - cfg.CONF.set_override('pagination_max_limit', 'Infinite') - self.api.get(_get_path('networks')) - kwargs = self._get_collection_kwargs(limit=None) - instance.get_networks.assert_called_once_with(mock.ANY, **kwargs) - - def test_limit_with_negative_pagination_max_limit(self): - instance = self.plugin.return_value - instance.get_networks.return_value = [] - cfg.CONF.set_default('pagination_max_limit', '-1') - self.api.get(_get_path('networks')) - kwargs = self._get_collection_kwargs(limit=None) - instance.get_networks.assert_called_once_with(mock.ANY, **kwargs) - - def test_limit_with_non_integer_pagination_max_limit(self): - instance = self.plugin.return_value - instance.get_networks.return_value = [] - cfg.CONF.set_default('pagination_max_limit', 'abc') - self.api.get(_get_path('networks')) - kwargs = self._get_collection_kwargs(limit=None) - instance.get_networks.assert_called_once_with(mock.ANY, **kwargs) - - def test_marker(self): - cfg.CONF.set_override('pagination_max_limit', '1000') - instance = self.plugin.return_value - instance.get_networks.return_value = [] - marker = _uuid() - self.api.get(_get_path('networks'), - {'marker': marker}) - kwargs = self._get_collection_kwargs(limit=1000, marker=marker) - instance.get_networks.assert_called_once_with(mock.ANY, **kwargs) - - def test_page_reverse(self): - calls = [] - instance = self.plugin.return_value - instance.get_networks.return_value = [] - self.api.get(_get_path('networks'), - {'page_reverse': 'True'}) - kwargs = self._get_collection_kwargs(page_reverse=True) - calls.append(mock.call.get_networks(mock.ANY, **kwargs)) - instance.get_networks.assert_called_once_with(mock.ANY, **kwargs) - - instance = self.plugin.return_value - instance.get_networks.return_value = [] - self.api.get(_get_path('networks'), - {'page_reverse': 'False'}) - kwargs = self._get_collection_kwargs(page_reverse=False) - calls.append(mock.call.get_networks(mock.ANY, **kwargs)) - - def test_page_reverse_with_non_bool(self): - instance = self.plugin.return_value - instance.get_networks.return_value = [] - - self.api.get(_get_path('networks'), - {'page_reverse': 'abc'}) - kwargs = self._get_collection_kwargs(page_reverse=False) - instance.get_networks.assert_called_once_with(mock.ANY, **kwargs) - - def test_page_reverse_with_unspecific(self): - instance = self.plugin.return_value - instance.get_networks.return_value = [] - - self.api.get(_get_path('networks')) - kwargs = self._get_collection_kwargs(page_reverse=False) - instance.get_networks.assert_called_once_with(mock.ANY, **kwargs) - - def test_sort(self): - instance = self.plugin.return_value - instance.get_networks.return_value = [] - - self.api.get(_get_path('networks'), - {'sort_key': ['name', 'admin_state_up'], - 'sort_dir': ['desc', 'asc']}) - kwargs = self._get_collection_kwargs(sorts=[('name', False), - ('admin_state_up', True), - ('id', True)]) - instance.get_networks.assert_called_once_with(mock.ANY, **kwargs) - - def test_sort_with_primary_key(self): - instance = self.plugin.return_value - instance.get_networks.return_value = [] - - self.api.get(_get_path('networks'), - {'sort_key': ['name', 'admin_state_up', 'id'], - 'sort_dir': ['desc', 'asc', 'desc']}) - kwargs = self._get_collection_kwargs(sorts=[('name', False), - ('admin_state_up', True), - ('id', False)]) - instance.get_networks.assert_called_once_with(mock.ANY, **kwargs) - - def test_sort_without_direction(self): - instance = self.plugin.return_value - instance.get_networks.return_value = [] - - res = self.api.get(_get_path('networks'), {'sort_key': ['name']}, - expect_errors=True) - self.assertEqual(exc.HTTPBadRequest.code, res.status_int) - - def test_sort_with_invalid_attribute(self): - instance = self.plugin.return_value - instance.get_networks.return_value = [] - - res = self.api.get(_get_path('networks'), - {'sort_key': 'abc', - 'sort_dir': 'asc'}, - expect_errors=True) - self.assertEqual(exc.HTTPBadRequest.code, res.status_int) - - def test_sort_with_invalid_dirs(self): - instance = self.plugin.return_value - instance.get_networks.return_value = [] - - res = self.api.get(_get_path('networks'), - {'sort_key': 'name', - 'sort_dir': 'abc'}, - expect_errors=True) - self.assertEqual(res.status_int, exc.HTTPBadRequest.code) - - def test_emulated_sort(self): - instance = self.plugin.return_value - instance._ApmecPluginBaseV2__native_pagination_support = False - instance._ApmecPluginBaseV2__native_sorting_support = False - instance.get_networks.return_value = [] - api = webtest.TestApp(router.APIRouter()) - api.get(_get_path('networks'), {'sort_key': ['name', 'status'], - 'sort_dir': ['desc', 'asc']}) - kwargs = self._get_collection_kwargs( - skipargs=['sorts', 'limit', 'marker', 'page_reverse']) - instance.get_networks.assert_called_once_with(mock.ANY, **kwargs) - - def test_emulated_sort_without_sort_field(self): - instance = self.plugin.return_value - instance._ApmecPluginBaseV2__native_pagination_support = False - instance._ApmecPluginBaseV2__native_sorting_support = False - instance.get_networks.return_value = [] - api = webtest.TestApp(router.APIRouter()) - api.get(_get_path('networks'), {'sort_key': ['name', 'status'], - 'sort_dir': ['desc', 'asc'], - 'fields': ['subnets']}) - kwargs = self._get_collection_kwargs( - skipargs=['sorts', 'limit', 'marker', 'page_reverse'], - fields=_ArgMatcher(_list_cmp, ['name', - 'status', - 'id', - 'subnets', - 'shared', - 'tenant_id'])) - instance.get_networks.assert_called_once_with(mock.ANY, **kwargs) - - def test_emulated_pagination(self): - instance = self.plugin.return_value - instance._ApmecPluginBaseV2__native_pagination_support = False - instance.get_networks.return_value = [] - api = webtest.TestApp(router.APIRouter()) - api.get(_get_path('networks'), {'limit': 10, - 'marker': 'foo', - 'page_reverse': False}) - kwargs = self._get_collection_kwargs(skipargs=['limit', - 'marker', - 'page_reverse']) - instance.get_networks.assert_called_once_with(mock.ANY, **kwargs) - - def test_native_pagination_without_native_sorting(self): - instance = self.plugin.return_value - instance._ApmecPluginBaseV2__native_sorting_support = False - self.assertRaises(n_exc.Invalid, router.APIRouter) - - def test_native_pagination_without_allow_sorting(self): - cfg.CONF.set_override('allow_sorting', False) - instance = self.plugin.return_value - instance.get_networks.return_value = [] - api = webtest.TestApp(router.APIRouter()) - api.get(_get_path('networks'), - {'sort_key': ['name', 'admin_state_up'], - 'sort_dir': ['desc', 'asc']}) - kwargs = self._get_collection_kwargs(sorts=[('name', False), - ('admin_state_up', True), - ('id', True)]) - instance.get_networks.assert_called_once_with(mock.ANY, **kwargs) - - -# Note: since all resources use the same controller and validation -# logic, we actually get really good coverage from testing just networks. -class JSONV2TestCase(APIv2TestBase, testlib_api.WebTestCase): - def setUp(self): - super(JSONV2TestCase, self).setUp() - self.skip("Not ready yet") - - def _test_list(self, req_tenant_id, real_tenant_id): - env = {} - if req_tenant_id: - env = {'apmec.context': context.Context('', req_tenant_id)} - input_dict = {'id': uuidutils.generate_uuid(), - 'name': 'net1', - 'admin_state_up': True, - 'status': "ACTIVE", - 'tenant_id': real_tenant_id, - 'shared': False, - 'subnets': []} - return_value = [input_dict] - instance = self.plugin.return_value - instance.get_networks.return_value = return_value - - res = self.api.get(_get_path('networks', - fmt=self.fmt), extra_environ=env) - res = self.deserialize(res) - self.assertIn('networks', res) - if not req_tenant_id or req_tenant_id == real_tenant_id: - # expect full list returned - self.assertEqual(1, len(res['networks'])) - output_dict = res['networks'][0] - input_dict['shared'] = False - self.assertEqual(len(input_dict), len(output_dict)) - for k, v in input_dict.items(): - self.assertEqual(v, output_dict[k]) - else: - # expect no results - self.assertEqual(0, len(res['networks'])) - - def test_list_noauth(self): - self._test_list(None, _uuid()) - - def test_list_keystone(self): - tenant_id = _uuid() - self._test_list(tenant_id, tenant_id) - - def test_list_keystone_bad(self): - tenant_id = _uuid() - self._test_list(tenant_id + "bad", tenant_id) - - def test_list_pagination(self): - id1 = str(_uuid()) - id2 = str(_uuid()) - input_dict1 = {'id': id1, - 'name': 'net1', - 'admin_state_up': True, - 'status': "ACTIVE", - 'tenant_id': '', - 'shared': False, - 'subnets': []} - input_dict2 = {'id': id2, - 'name': 'net2', - 'admin_state_up': True, - 'status': "ACTIVE", - 'tenant_id': '', - 'shared': False, - 'subnets': []} - return_value = [input_dict1, input_dict2] - instance = self.plugin.return_value - instance.get_networks.return_value = return_value - params = {'limit': ['2'], - 'marker': [str(_uuid())], - 'sort_key': ['name'], - 'sort_dir': ['asc']} - res = self.api.get(_get_path('networks'), - params=params).json - - self.assertEqual(2, len(res['networks'])) - self.assertEqual(sorted([id1, id2]), - sorted([res['networks'][0]['id'], - res['networks'][1]['id']])) - - self.assertIn('networks_links', res) - next_links = [] - previous_links = [] - for r in res['networks_links']: - if r['rel'] == 'next': - next_links.append(r) - if r['rel'] == 'previous': - previous_links.append(r) - self.assertEqual(1, len(next_links)) - self.assertEqual(1, len(previous_links)) - - url = urlparse.urlparse(next_links[0]['href']) - self.assertEqual(_get_path('networks'), url.path) - params['marker'] = [id2] - self.assertEqual(params, urlparse.parse_qs(url.query)) - - url = urlparse.urlparse(previous_links[0]['href']) - self.assertEqual(_get_path('networks'), url.path) - params['marker'] = [id1] - params['page_reverse'] = ['True'] - self.assertEqual(params, urlparse.parse_qs(url.query)) - - def test_list_pagination_with_last_page(self): - id = str(_uuid()) - input_dict = {'id': id, - 'name': 'net1', - 'admin_state_up': True, - 'status': "ACTIVE", - 'tenant_id': '', - 'shared': False, - 'subnets': []} - return_value = [input_dict] - instance = self.plugin.return_value - instance.get_networks.return_value = return_value - params = {'limit': ['2'], - 'marker': str(_uuid())} - res = self.api.get(_get_path('networks'), - params=params).json - - self.assertEqual(1, len(res['networks'])) - self.assertEqual(id, res['networks'][0]['id']) - - self.assertIn('networks_links', res) - previous_links = [] - for r in res['networks_links']: - self.assertNotEqual(r['rel'], 'next') - if r['rel'] == 'previous': - previous_links.append(r) - self.assertEqual(1, len(previous_links)) - - url = urlparse.urlparse(previous_links[0]['href']) - self.assertEqual(_get_path('networks'), url.path) - expect_params = params.copy() - expect_params['marker'] = [id] - expect_params['page_reverse'] = ['True'] - self.assertEqual(expect_params, urlparse.parse_qs(url.query)) - - def test_list_pagination_with_empty_page(self): - return_value = [] - instance = self.plugin.return_value - instance.get_networks.return_value = return_value - params = {'limit': ['2'], - 'marker': str(_uuid())} - res = self.api.get(_get_path('networks'), - params=params).json - - self.assertEqual([], res['networks']) - - previous_links = [] - if 'networks_links' in res: - for r in res['networks_links']: - self.assertNotEqual(r['rel'], 'next') - if r['rel'] == 'previous': - previous_links.append(r) - self.assertEqual(1, len(previous_links)) - - url = urlparse.urlparse(previous_links[0]['href']) - self.assertEqual(_get_path('networks'), url.path) - expect_params = params.copy() - del expect_params['marker'] - expect_params['page_reverse'] = ['True'] - self.assertEqual(expect_params, urlparse.parse_qs(url.query)) - - def test_list_pagination_reverse_with_last_page(self): - id = str(_uuid()) - input_dict = {'id': id, - 'name': 'net1', - 'admin_state_up': True, - 'status': "ACTIVE", - 'tenant_id': '', - 'shared': False, - 'subnets': []} - return_value = [input_dict] - instance = self.plugin.return_value - instance.get_networks.return_value = return_value - params = {'limit': ['2'], - 'marker': [str(_uuid())], - 'page_reverse': ['True']} - res = self.api.get(_get_path('networks'), - params=params).json - - self.assertEqual(1, len(res['networks'])) - self.assertEqual(id, res['networks'][0]['id']) - - self.assertIn('networks_links', res) - next_links = [] - for r in res['networks_links']: - self.assertNotEqual(r['rel'], 'previous') - if r['rel'] == 'next': - next_links.append(r) - self.assertEqual(1, len(next_links)) - - url = urlparse.urlparse(next_links[0]['href']) - self.assertEqual(_get_path('networks'), url.path) - expected_params = params.copy() - del expected_params['page_reverse'] - expected_params['marker'] = [id] - self.assertEqual(expected_params, - urlparse.parse_qs(url.query)) - - def test_list_pagination_reverse_with_empty_page(self): - return_value = [] - instance = self.plugin.return_value - instance.get_networks.return_value = return_value - params = {'limit': ['2'], - 'marker': [str(_uuid())], - 'page_reverse': ['True']} - res = self.api.get(_get_path('networks'), - params=params).json - self.assertEqual([], res['networks']) - - next_links = [] - if 'networks_links' in res: - for r in res['networks_links']: - self.assertNotEqual(r['rel'], 'previous') - if r['rel'] == 'next': - next_links.append(r) - self.assertEqual(1, len(next_links)) - - url = urlparse.urlparse(next_links[0]['href']) - self.assertEqual(_get_path('networks'), url.path) - expect_params = params.copy() - del expect_params['marker'] - del expect_params['page_reverse'] - self.assertEqual(expect_params, urlparse.parse_qs(url.query)) - - def test_create(self): - net_id = _uuid() - data = {'network': {'name': 'net1', 'admin_state_up': True, - 'tenant_id': _uuid()}} - return_value = {'subnets': [], 'status': "ACTIVE", - 'id': net_id} - return_value.update(data['network'].copy()) - - instance = self.plugin.return_value - instance.create_network.return_value = return_value - instance.get_networks_count.return_value = 0 - - res = self.api.post(_get_path('networks', fmt=self.fmt), - self.serialize(data), - content_type='application/' + self.fmt) - self.assertEqual(exc.HTTPCreated.code, res.status_int) - res = self.deserialize(res) - self.assertIn('network', res) - net = res['network'] - self.assertEqual(net_id, net['id']) - self.assertEqual("ACTIVE", net['status']) - - def test_create_use_defaults(self): - net_id = _uuid() - initial_input = {'network': {'name': 'net1', 'tenant_id': _uuid()}} - full_input = {'network': {'admin_state_up': True, - 'shared': False}} - full_input['network'].update(initial_input['network']) - - return_value = {'id': net_id, 'status': "ACTIVE"} - return_value.update(full_input['network']) - - instance = self.plugin.return_value - instance.create_network.return_value = return_value - instance.get_networks_count.return_value = 0 - - res = self.api.post(_get_path('networks', fmt=self.fmt), - self.serialize(initial_input), - content_type='application/' + self.fmt) - instance.create_network.assert_called_with(mock.ANY, - network=full_input) - self.assertEqual(exc.HTTPCreated.code, res.status_int) - res = self.deserialize(res) - self.assertIn('network', res) - net = res['network'] - self.assertEqual(net_id, net['id']) - self.assertEqual(True, net['admin_state_up']) - self.assertEqual("ACTIVE", net['status']) - - def test_create_no_keystone_env(self): - data = {'name': 'net1'} - res = self.api.post(_get_path('networks', fmt=self.fmt), - self.serialize(data), - content_type='application/' + self.fmt, - expect_errors=True) - self.assertEqual(exc.HTTPBadRequest.code, res.status_int) - - def test_create_with_keystone_env(self): - tenant_id = _uuid() - net_id = _uuid() - env = {'apmec.context': context.Context('', tenant_id)} - # tenant_id should be fetched from env - initial_input = {'network': {'name': 'net1'}} - full_input = {'network': {'admin_state_up': True, - 'shared': False, 'tenant_id': tenant_id}} - full_input['network'].update(initial_input['network']) - - return_value = {'id': net_id, 'status': "ACTIVE"} - return_value.update(full_input['network']) - - instance = self.plugin.return_value - instance.create_network.return_value = return_value - instance.get_networks_count.return_value = 0 - - res = self.api.post(_get_path('networks', fmt=self.fmt), - self.serialize(initial_input), - content_type='application/' + self.fmt, - extra_environ=env) - - instance.create_network.assert_called_with(mock.ANY, - network=full_input) - self.assertEqual(exc.HTTPCreated.code, res.status_int) - - def test_create_bad_keystone_tenant(self): - tenant_id = _uuid() - data = {'network': {'name': 'net1', 'tenant_id': tenant_id}} - env = {'apmec.context': context.Context('', tenant_id + "bad")} - res = self.api.post(_get_path('networks', fmt=self.fmt), - self.serialize(data), - content_type='application/' + self.fmt, - expect_errors=True, - extra_environ=env) - self.assertEqual(exc.HTTPBadRequest.code, res.status_int) - - def test_create_no_body(self): - data = {'whoa': None} - res = self.api.post(_get_path('networks', fmt=self.fmt), - self.serialize(data), - content_type='application/' + self.fmt, - expect_errors=True) - self.assertEqual(exc.HTTPBadRequest.code, res.status_int) - - def test_create_no_resource(self): - data = {} - res = self.api.post(_get_path('networks', fmt=self.fmt), - self.serialize(data), - content_type='application/' + self.fmt, - expect_errors=True) - self.assertEqual(exc.HTTPBadRequest.code, res.status_int) - - def test_create_missing_attr(self): - data = {'port': {'what': 'who', 'tenant_id': _uuid()}} - res = self.api.post(_get_path('ports', fmt=self.fmt), - self.serialize(data), - content_type='application/' + self.fmt, - expect_errors=True) - self.assertEqual(400, res.status_int) - - def test_create_readonly_attr(self): - data = {'network': {'name': 'net1', 'tenant_id': _uuid(), - 'status': "ACTIVE"}} - res = self.api.post(_get_path('networks', fmt=self.fmt), - self.serialize(data), - content_type='application/' + self.fmt, - expect_errors=True) - self.assertEqual(400, res.status_int) - - def test_create_bulk(self): - data = {'networks': [{'name': 'net1', - 'admin_state_up': True, - 'tenant_id': _uuid()}, - {'name': 'net2', - 'admin_state_up': True, - 'tenant_id': _uuid()}]} - - def side_effect(context, network): - net = network.copy() - net['network'].update({'subnets': []}) - return net['network'] - - instance = self.plugin.return_value - instance.create_network.side_effect = side_effect - instance.get_networks_count.return_value = 0 - res = self.api.post(_get_path('networks', fmt=self.fmt), - self.serialize(data), - content_type='application/' + self.fmt) - self.assertEqual(exc.HTTPCreated.code, res.status_int) - - def test_create_bulk_no_networks(self): - data = {'networks': []} - res = self.api.post(_get_path('networks', fmt=self.fmt), - self.serialize(data), - content_type='application/' + self.fmt, - expect_errors=True) - self.assertEqual(exc.HTTPBadRequest.code, res.status_int) - - def test_create_bulk_missing_attr(self): - data = {'ports': [{'what': 'who', 'tenant_id': _uuid()}]} - res = self.api.post(_get_path('ports', fmt=self.fmt), - self.serialize(data), - content_type='application/' + self.fmt, - expect_errors=True) - self.assertEqual(400, res.status_int) - - def test_create_bulk_partial_body(self): - data = {'ports': [{'device_id': 'device_1', - 'tenant_id': _uuid()}, - {'tenant_id': _uuid()}]} - res = self.api.post(_get_path('ports', fmt=self.fmt), - self.serialize(data), - content_type='application/' + self.fmt, - expect_errors=True) - self.assertEqual(400, res.status_int) - - def test_create_attr_not_specified(self): - net_id = _uuid() - tenant_id = _uuid() - device_id = _uuid() - initial_input = {'port': {'name': '', 'network_id': net_id, - 'tenant_id': tenant_id, - 'device_id': device_id, - 'admin_state_up': True}} - full_input = {'port': {'admin_state_up': True, - 'mac_address': attributes.ATTR_NOT_SPECIFIED, - 'fixed_ips': attributes.ATTR_NOT_SPECIFIED, - 'device_owner': ''}} - full_input['port'].update(initial_input['port']) - return_value = {'id': _uuid(), 'status': 'ACTIVE', - 'admin_state_up': True, - 'mac_address': 'ca:fe:de:ad:be:ef', - 'device_id': device_id, - 'device_owner': ''} - return_value.update(initial_input['port']) - - instance = self.plugin.return_value - instance.get_network.return_value = {'tenant_id': - six.text_type(tenant_id)} - instance.get_ports_count.return_value = 1 - instance.create_port.return_value = return_value - res = self.api.post(_get_path('ports', fmt=self.fmt), - self.serialize(initial_input), - content_type='application/' + self.fmt) - instance.create_port.assert_called_with(mock.ANY, port=full_input) - self.assertEqual(exc.HTTPCreated.code, res.status_int) - res = self.deserialize(res) - self.assertIn('port', res) - port = res['port'] - self.assertEqual(net_id, port['network_id']) - self.assertEqual('ca:fe:de:ad:be:ef', port['mac_address']) - - def test_create_return_extra_attr(self): - net_id = _uuid() - data = {'network': {'name': 'net1', 'admin_state_up': True, - 'tenant_id': _uuid()}} - return_value = {'subnets': [], 'status': "ACTIVE", - 'id': net_id, 'v2attrs:something': "123"} - return_value.update(data['network'].copy()) - - instance = self.plugin.return_value - instance.create_network.return_value = return_value - instance.get_networks_count.return_value = 0 - - res = self.api.post(_get_path('networks', fmt=self.fmt), - self.serialize(data), - content_type='application/' + self.fmt) - self.assertEqual(exc.HTTPCreated.code, res.status_int) - res = self.deserialize(res) - self.assertIn('network', res) - net = res['network'] - self.assertEqual(net_id, net['id']) - self.assertEqual("ACTIVE", net['status']) - self.assertNotIn('v2attrs:something', net) - - def test_fields(self): - return_value = {'name': 'net1', 'admin_state_up': True, - 'subnets': []} - - instance = self.plugin.return_value - instance.get_network.return_value = return_value - - self.api.get(_get_path('networks', - id=uuidutils.generate_uuid(), - fmt=self.fmt)) - - def _test_delete(self, req_tenant_id, real_tenant_id, expected_code, - expect_errors=False): - env = {} - if req_tenant_id: - env = {'apmec.context': context.Context('', req_tenant_id)} - instance = self.plugin.return_value - instance.get_network.return_value = {'tenant_id': real_tenant_id, - 'shared': False} - instance.delete_network.return_value = None - - res = self.api.delete(_get_path('networks', - id=uuidutils.generate_uuid(), - fmt=self.fmt), - extra_environ=env, - expect_errors=expect_errors) - self.assertEqual(expected_code, res.status_int) - - def test_delete_noauth(self): - self._test_delete(None, _uuid(), exc.HTTPNoContent.code) - - def test_delete_keystone(self): - tenant_id = _uuid() - self._test_delete(tenant_id, tenant_id, exc.HTTPNoContent.code) - - def test_delete_keystone_bad_tenant(self): - tenant_id = _uuid() - self._test_delete(tenant_id + "bad", tenant_id, - exc.HTTPNotFound.code, expect_errors=True) - - def _test_get(self, req_tenant_id, real_tenant_id, expected_code, - expect_errors=False): - env = {} - shared = False - if req_tenant_id: - env = {'apmec.context': context.Context('', req_tenant_id)} - if req_tenant_id.endswith('another'): - shared = True - env['apmec.context'].roles = ['tenant_admin'] - - data = {'tenant_id': real_tenant_id, 'shared': shared} - instance = self.plugin.return_value - instance.get_network.return_value = data - - res = self.api.get(_get_path('networks', - id=uuidutils.generate_uuid(), - fmt=self.fmt), - extra_environ=env, - expect_errors=expect_errors) - self.assertEqual(expected_code, res.status_int) - return res - - def test_get_noauth(self): - self._test_get(None, _uuid(), 200) - - def test_get_keystone(self): - tenant_id = _uuid() - self._test_get(tenant_id, tenant_id, 200) - - def test_get_keystone_bad_tenant(self): - tenant_id = _uuid() - self._test_get(tenant_id + "bad", tenant_id, - exc.HTTPNotFound.code, expect_errors=True) - - def test_get_keystone_shared_network(self): - tenant_id = _uuid() - self._test_get(tenant_id + "another", tenant_id, 200) - - def test_get_keystone_strip_admin_only_attribute(self): - tenant_id = _uuid() - # Inject rule in policy engine - policy.init() - common_policy._rules['get_network:name'] = common_policy.parse_rule( - "rule:admin_only") - res = self._test_get(tenant_id, tenant_id, 200) - res = self.deserialize(res) - try: - self.assertNotIn('name', res['network']) - finally: - del common_policy._rules['get_network:name'] - - def _test_update(self, req_tenant_id, real_tenant_id, expected_code, - expect_errors=False): - env = {} - if req_tenant_id: - env = {'apmec.context': context.Context('', req_tenant_id)} - # leave out 'name' field intentionally - data = {'network': {'admin_state_up': True}} - return_value = {'subnets': []} - return_value.update(data['network'].copy()) - - instance = self.plugin.return_value - instance.get_network.return_value = {'tenant_id': real_tenant_id, - 'shared': False} - instance.update_network.return_value = return_value - - res = self.api.put(_get_path('networks', - id=uuidutils.generate_uuid(), - fmt=self.fmt), - self.serialize(data), - extra_environ=env, - expect_errors=expect_errors) - # Ensure id attribute is included in fields returned by GET call - # in update procedure. - self.assertEqual(1, instance.get_network.call_count) - self.assertIn('id', instance.get_network.call_args[1]['fields']) - self.assertEqual(expected_code, res.status_int) - - def test_update_noauth(self): - self._test_update(None, _uuid(), 200) - - def test_update_keystone(self): - tenant_id = _uuid() - self._test_update(tenant_id, tenant_id, 200) - - def test_update_keystone_bad_tenant(self): - tenant_id = _uuid() - self._test_update(tenant_id + "bad", tenant_id, - exc.HTTPNotFound.code, expect_errors=True) - - def test_update_readonly_field(self): - data = {'network': {'status': "NANANA"}} - res = self.api.put(_get_path('networks', id=_uuid()), - self.serialize(data), - content_type='application/' + self.fmt, - expect_errors=True) - self.assertEqual(400, res.status_int) - - def test_invalid_attribute_field(self): - data = {'network': {'invalid_key1': "foo1", 'invalid_key2': "foo2"}} - res = self.api.put(_get_path('networks', id=_uuid()), - self.serialize(data), - content_type='application/' + self.fmt, - expect_errors=True) - self.assertEqual(res.status_int, 400) - - -class SubresourceTest(base.BaseTestCase): - def setUp(self): - super(SubresourceTest, self).setUp() - self.skip("Not ready yet") - - plugin = 'apmec.tests.unit.test_api_v2.TestSubresourcePlugin' - extensions.PluginAwareExtensionManager._instance = None - - # Save the global RESOURCE_ATTRIBUTE_MAP - self.saved_attr_map = {} - for resource, attrs in (attributes.RESOURCE_ATTRIBUTE_MAP).items(): - self.saved_attr_map[resource] = attrs.copy() - - self.config_parse() - self.setup_coreplugin(plugin) - - self._plugin_patcher = mock.patch(plugin, autospec=True) - self.plugin = self._plugin_patcher.start() - - router.SUB_RESOURCES['dummy'] = { - 'collection_name': 'dummies', - 'parent': {'collection_name': 'networks', - 'member_name': 'network'} - } - attributes.RESOURCE_ATTRIBUTE_MAP['dummies'] = { - 'foo': {'allow_post': True, 'allow_put': True, - 'validate': {'type:string': None}, - 'default': '', 'is_visible': True}, - 'tenant_id': {'allow_post': True, 'allow_put': False, - 'validate': {'type:string': None}, - 'required_by_policy': True, - 'is_visible': True} - } - api = router.APIRouter() - self.api = webtest.TestApp(api) - - def tearDown(self): - router.SUB_RESOURCES = {} - # Restore the global RESOURCE_ATTRIBUTE_MAP - attributes.RESOURCE_ATTRIBUTE_MAP = self.saved_attr_map - super(SubresourceTest, self).tearDown() - - def test_index_sub_resource(self): - instance = self.plugin.return_value - - self.api.get('/networks/id1/dummies') - instance.get_network_dummies.assert_called_once_with(mock.ANY, - filters=mock.ANY, - fields=mock.ANY, - network_id='id1') - - def test_show_sub_resource(self): - instance = self.plugin.return_value - - dummy_id = _uuid() - self.api.get('/networks/id1' + _get_path('dummies', id=dummy_id)) - instance.get_network_dummy.assert_called_once_with(mock.ANY, - dummy_id, - network_id='id1', - fields=mock.ANY) - - def test_create_sub_resource(self): - instance = self.plugin.return_value - - body = {'dummy': {'foo': 'bar', 'tenant_id': _uuid()}} - self.api.post_json('/networks/id1/dummies', body) - instance.create_network_dummy.assert_called_once_with(mock.ANY, - network_id='id1', - dummy=body) - - def test_update_sub_resource(self): - instance = self.plugin.return_value - - dummy_id = _uuid() - body = {'dummy': {'foo': 'bar'}} - self.api.put_json('/networks/id1' + _get_path('dummies', id=dummy_id), - body) - instance.update_network_dummy.assert_called_once_with(mock.ANY, - dummy_id, - network_id='id1', - dummy=body) - - def test_delete_sub_resource(self): - instance = self.plugin.return_value - - dummy_id = _uuid() - self.api.delete('/networks/id1' + _get_path('dummies', id=dummy_id)) - instance.delete_network_dummy.assert_called_once_with(mock.ANY, - dummy_id, - network_id='id1') - - -class V2Views(base.BaseTestCase): - - def setUp(self): - super(V2Views, self).setUp() - self.skip("Not ready yet") - - def _view(self, keys, collection, resource): - data = dict((key, 'value') for key in keys) - data['fake'] = 'value' - attr_info = attributes.RESOURCE_ATTRIBUTE_MAP[collection] - controller = v2_base.Controller(None, collection, resource, attr_info) - res = controller._view(context.get_admin_context(), data) - self.assertNotIn('fake', res) - for key in keys: - self.assertIn(key, res) - - def test_network(self): - keys = ('id', 'name', 'subnets', 'admin_state_up', 'status', - 'tenant_id') - self._view(keys, 'networks', 'network') - - def test_port(self): - keys = ('id', 'network_id', 'mac_address', 'fixed_ips', - 'device_id', 'admin_state_up', 'tenant_id', 'status') - self._view(keys, 'ports', 'port') - - def test_subnet(self): - keys = ('id', 'network_id', 'tenant_id', 'gateway_ip', - 'ip_version', 'cidr', 'enable_dhcp') - self._view(keys, 'subnets', 'subnet') - - -class NotificationTest(APIv2TestBase): - - def setUp(self): - super(NotificationTest, self).setUp() - self.skip("Not ready yet") - fake_notifier.reset() - - def _resource_op_notifier(self, opname, resource, expected_errors=False): - initial_input = {resource: {'name': 'myname'}} - instance = self.plugin.return_value - instance.get_networks.return_value = initial_input - instance.get_networks_count.return_value = 0 - expected_code = exc.HTTPCreated.code - if opname == 'create': - initial_input[resource]['tenant_id'] = _uuid() - res = self.api.post_json( - _get_path('networks'), - initial_input, expect_errors=expected_errors) - if opname == 'update': - res = self.api.put_json( - _get_path('networks', id=_uuid()), - initial_input, expect_errors=expected_errors) - expected_code = exc.HTTPOk.code - if opname == 'delete': - initial_input[resource]['tenant_id'] = _uuid() - res = self.api.delete( - _get_path('networks', id=_uuid()), - expect_errors=expected_errors) - expected_code = exc.HTTPNoContent.code - - expected_events = ('.'.join([resource, opname, "start"]), - '.'.join([resource, opname, "end"])) - self.assertEqual(len(expected_events), - len(fake_notifier.NOTIFICATIONS)) - for msg, event in zip(fake_notifier.NOTIFICATIONS, expected_events): - self.assertEqual('INFO', msg['priority']) - self.assertEqual(event, msg['event_type']) - - self.assertEqual(expected_code, res.status_int) - - def test_network_create_notifer(self): - self._resource_op_notifier('create', 'network') - - def test_network_delete_notifer(self): - self._resource_op_notifier('delete', 'network') - - def test_network_update_notifer(self): - self._resource_op_notifier('update', 'network') - - -class ExtensionTestCase(base.BaseTestCase): - def setUp(self): - super(ExtensionTestCase, self).setUp() - self.skip("Not ready yet") - plugin = 'apmec.apmec_plugin_base_v2.ApmecPluginBaseV2' - - # Ensure existing ExtensionManager is not used - extensions.PluginAwareExtensionManager._instance = None - - # Save the global RESOURCE_ATTRIBUTE_MAP - self.saved_attr_map = {} - for resource, attrs in (attributes.RESOURCE_ATTRIBUTE_MAP).items(): - self.saved_attr_map[resource] = attrs.copy() - - # Create the default configurations - self.config_parse() - - # Update the plugin and extensions path - self.setup_coreplugin(plugin) - cfg.CONF.set_override('api_extensions_path', EXTDIR) - - self._plugin_patcher = mock.patch(plugin, autospec=True) - self.plugin = self._plugin_patcher.start() - - # Instantiate mock plugin and enable the V2attributes extension - manager.ApmecManager.get_plugin().supported_extension_aliases = ( - ["v2attrs"]) - - api = router.APIRouter() - self.api = webtest.TestApp(api) - - def tearDown(self): - super(ExtensionTestCase, self).tearDown() - self.api = None - self.plugin = None - # Restore the global RESOURCE_ATTRIBUTE_MAP - attributes.RESOURCE_ATTRIBUTE_MAP = self.saved_attr_map - - def test_extended_create(self): - net_id = _uuid() - initial_input = {'network': {'name': 'net1', 'tenant_id': _uuid(), - 'v2attrs:something_else': "abc"}} - data = {'network': {'admin_state_up': True, 'shared': False}} - data['network'].update(initial_input['network']) - - return_value = {'subnets': [], 'status': "ACTIVE", - 'id': net_id, - 'v2attrs:something': "123"} - return_value.update(data['network'].copy()) - - instance = self.plugin.return_value - instance.create_network.return_value = return_value - instance.get_networks_count.return_value = 0 - - res = self.api.post_json(_get_path('networks'), initial_input) - - instance.create_network.assert_called_with(mock.ANY, - network=data) - self.assertEqual(exc.HTTPCreated.code, res.status_int) - self.assertIn('network', res.json) - net = res.json['network'] - self.assertEqual(net_id, net['id']) - self.assertEqual("ACTIVE", net['status']) - self.assertEqual("123", net['v2attrs:something']) - self.assertNotIn('v2attrs:something_else', net) - - -class TestSubresourcePlugin(object): - def get_network_dummies(self, context, network_id, - filters=None, fields=None): - return [] - - def get_network_dummy(self, context, id, network_id, - fields=None): - return {} - - def create_network_dummy(self, context, network_id, dummy): - return {} - - def update_network_dummy(self, context, id, network_id, dummy): - return {} - - def delete_network_dummy(self, context, id, network_id): - return - - -class ListArgsTestCase(base.BaseTestCase): - def test_list_args(self): - path = '/?fields=4&foo=3&fields=2&bar=1' - request = webob.Request.blank(path) - expect_val = ['2', '4'] - actual_val = api_common.list_args(request, 'fields') - self.assertEqual(expect_val, sorted(actual_val)) - - def test_list_args_with_empty(self): - path = '/?foo=4&bar=3&baz=2&qux=1' - request = webob.Request.blank(path) - self.assertEqual([], api_common.list_args(request, 'fields')) - - -class FiltersTestCase(base.BaseTestCase): - def setUp(self): - super(FiltersTestCase, self).setUp() - self.skip("Not ready yet") - - def test_all_skip_args(self): - path = '/?fields=4&fields=3&fields=2&fields=1' - request = webob.Request.blank(path) - self.assertEqual({}, api_common.get_filters(request, None, - ["fields"])) - - def test_blank_values(self): - path = '/?foo=&bar=&baz=&qux=' - request = webob.Request.blank(path) - self.assertEqual({}, api_common.get_filters(request, {})) - - def test_no_attr_info(self): - path = '/?foo=4&bar=3&baz=2&qux=1' - request = webob.Request.blank(path) - expect_val = {'foo': ['4'], 'bar': ['3'], 'baz': ['2'], 'qux': ['1']} - actual_val = api_common.get_filters(request, {}) - self.assertEqual(expect_val, actual_val) - - def test_attr_info_without_conversion(self): - path = '/?foo=4&bar=3&baz=2&qux=1' - request = webob.Request.blank(path) - attr_info = {'foo': {'key': 'val'}} - expect_val = {'foo': ['4'], 'bar': ['3'], 'baz': ['2'], 'qux': ['1']} - actual_val = api_common.get_filters(request, attr_info) - self.assertEqual(expect_val, actual_val) - - def test_attr_info_with_convert_list_to(self): - path = '/?foo=key=4&bar=3&foo=key=2&qux=1' - request = webob.Request.blank(path) - attr_info = { - 'foo': { - 'convert_list_to': attributes.convert_kvp_list_to_dict, - } - } - expect_val = {'foo': {'key': ['2', '4']}, 'bar': ['3'], 'qux': ['1']} - actual_val = api_common.get_filters(request, attr_info) - self.assertEqual(expect_val, actual_val) - - def test_attr_info_with_convert_to(self): - path = '/?foo=4&bar=3&baz=2&qux=1' - request = webob.Request.blank(path) - attr_info = {'foo': {'convert_to': attributes.convert_to_int}} - expect_val = {'foo': [4], 'bar': ['3'], 'baz': ['2'], 'qux': ['1']} - actual_val = api_common.get_filters(request, attr_info) - self.assertEqual(expect_val, actual_val) - - -class CreateResourceTestCase(base.BaseTestCase): - def test_resource_creation(self): - resource = v2_base.create_resource('fakes', 'fake', None, {}) - self.assertIsInstance(resource, webob.dec.wsgify) diff --git a/apmec/tests/unit/test_api_v2_extension.py b/apmec/tests/unit/test_api_v2_extension.py deleted file mode 100644 index 71bb019..0000000 --- a/apmec/tests/unit/test_api_v2_extension.py +++ /dev/null @@ -1,114 +0,0 @@ -# Copyright 2014 Intel Corporation. -# All Rights Reserved. -# -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, 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 mock -from oslo_config import cfg -from oslo_utils import uuidutils -from webob import exc -import webtest - -from apmec.api import extensions -from apmec.api.v1 import attributes -from apmec.tests.unit import test_api_v2 -from apmec.tests.unit import test_extensions -from apmec.tests.unit import testlib_api - - -class ExtensionTestCase(testlib_api.WebTestCase): - def _resotre_attr_map(self): - attributes.RESOURCE_ATTRIBUTE_MAP = self._saved_attr_map - - def _setUpExtension(self, plugin, service_type, - resource_attribute_map, extension_class, - resource_prefix, plural_mappings=None, - translate_resource_name=False, - allow_pagination=False, allow_sorting=False, - supported_extension_aliases=None, - ): - - self._resource_prefix = resource_prefix - self._plural_mappings = plural_mappings or {} - self._translate_resource_name = translate_resource_name - - # Ensure existing ExtensionManager is not used - extensions.PluginAwareExtensionManager._instance = None - - # Save the global RESOURCE_ATTRIBUTE_MAP - self._saved_attr_map = attributes.RESOURCE_ATTRIBUTE_MAP.copy() - # Restore the global RESOURCE_ATTRIBUTE_MAP - self.addCleanup(self._resotre_attr_map) - - # Create the default configurations - self.config_parse() - - # just stubbing core plugin with plugin - self.setup_coreplugin(plugin) - cfg.CONF.set_override('core_plugin', plugin) - if service_type: - cfg.CONF.set_override('service_plugins', [plugin]) - - self._plugin_patcher = mock.patch(plugin, autospec=True) - self.plugin = self._plugin_patcher.start() - instance = self.plugin.return_value - if service_type: - instance.get_plugin_type.return_value = service_type - if supported_extension_aliases is not None: - instance.supported_extension_aliases = supported_extension_aliases - if allow_pagination: - cfg.CONF.set_override('allow_pagination', True) - # instance.__native_pagination_support = True - native_pagination_attr_name = ("_%s__native_pagination_support" - % instance.__class__.__name__) - setattr(instance, native_pagination_attr_name, True) - if allow_sorting: - cfg.CONF.set_override('allow_sorting', True) - # instance.__native_sorting_support = True - native_sorting_attr_name = ("_%s__native_sorting_support" - % instance.__class__.__name__) - setattr(instance, native_sorting_attr_name, True) - - class ExtensionTestExtensionManager(object): - def get_resources(self): - # Add the resources to the global attribute map - # This is done here as the setup process won't - # initialize the main API router which extends - # the global attribute map - attributes.RESOURCE_ATTRIBUTE_MAP.update( - resource_attribute_map) - return extension_class.get_resources() - - def get_actions(self): - return [] - - def get_request_extensions(self): - return [] - - ext_mgr = ExtensionTestExtensionManager() - self.ext_mdw = test_extensions.setup_extensions_middleware(ext_mgr) - self.api = webtest.TestApp(self.ext_mdw) - - def _test_entity_delete(self, entity): - """Does the entity deletion based on naming convention.""" - entity_id = uuidutils.generate_uuid() - path = self._resource_prefix + '/' if self._resource_prefix else '' - path += self._plural_mappings.get(entity, entity + 's') - if self._translate_resource_name: - path = path.replace('_', '-') - res = self.api.delete( - test_api_v2._get_path(path, id=entity_id, fmt=self.fmt)) - delete_entity = getattr(self.plugin.return_value, "delete_" + entity) - delete_entity.assert_called_with(mock.ANY, entity_id) - self.assertEqual(exc.HTTPNoContent.code, res.status_int) diff --git a/apmec/tests/unit/test_api_v2_resource.py b/apmec/tests/unit/test_api_v2_resource.py deleted file mode 100644 index dc0b49e..0000000 --- a/apmec/tests/unit/test_api_v2_resource.py +++ /dev/null @@ -1,318 +0,0 @@ -# Copyright (c) 2012 Intel Corporation. -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, 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 mock -import oslo_i18n -from webob import exc -import webtest - -from apmec.api.v1 import resource as wsgi_resource -from apmec.common import exceptions as n_exc -from apmec import context -from apmec.tests import base -from apmec import wsgi - - -class RequestTestCase(base.BaseTestCase): - def setUp(self): - super(RequestTestCase, self).setUp() - self.req = wsgi_resource.Request({'foo': 'bar'}) - - def test_content_type_missing(self): - request = wsgi.Request.blank('/tests/123', method='POST') - request.body = b"" - self.assertIsNone(request.get_content_type()) - - def test_content_type_with_charset(self): - request = wsgi.Request.blank('/tests/123') - request.headers["Content-Type"] = "application/json; charset=UTF-8" - result = request.get_content_type() - self.assertEqual("application/json", result) - - def test_content_type_from_accept(self): - content_type = 'application/json' - request = wsgi.Request.blank('/tests/123') - request.headers["Accept"] = content_type - result = request.best_match_content_type() - self.assertEqual(result, content_type) - - def test_content_type_from_accept_best(self): - request = wsgi.Request.blank('/tests/123') - request.headers["Accept"] = "application/json" - result = request.best_match_content_type() - self.assertEqual("application/json", result) - - request = wsgi.Request.blank('/tests/123') - request.headers["Accept"] = ("application/json; q=0.3, ") - result = request.best_match_content_type() - self.assertEqual("application/json", result) - - def test_content_type_from_query_extension(self): - request = wsgi.Request.blank('/tests/123.json') - result = request.best_match_content_type() - self.assertEqual("application/json", result) - - request = wsgi.Request.blank('/tests/123.json') - result = request.best_match_content_type() - self.assertEqual("application/json", result) - - request = wsgi.Request.blank('/tests/123.invalid') - result = request.best_match_content_type() - self.assertEqual("application/json", result) - - def test_content_type_accept_and_query_extension(self): - request = wsgi.Request.blank('/tests/123.json') - request.headers["Accept"] = "application/json" - result = request.best_match_content_type() - self.assertEqual("application/json", result) - - def test_content_type_accept_default(self): - request = wsgi.Request.blank('/tests/123.unsupported') - request.headers["Accept"] = "application/unsupported1" - result = request.best_match_content_type() - self.assertEqual("application/json", result) - - def test_context_with_apmec_context(self): - self.skip("Not ready yet") - ctxt = context.Context('fake_user', 'fake_tenant') - self.req.environ['apmec.context'] = ctxt - self.assertEqual(ctxt, self.req.context) - - def test_context_without_apmec_context(self): - self.assertTrue(self.req.context.is_admin) - - def test_best_match_language(self): - # Test that we are actually invoking language negotiation by webop - request = wsgi.Request.blank('/') - oslo_i18n.get_available_languages = mock.MagicMock() - oslo_i18n.get_available_languages.return_value = [ - 'known-language', 'es', 'zh'] - request.headers['Accept-Language'] = 'known-language' - language = request.best_match_language() - self.assertEqual('known-language', language) - - # If the Accept-Leader is an unknown language, missing or empty, - # the best match locale should be None - request.headers['Accept-Language'] = 'unknown-language' - language = request.best_match_language() - self.assertIsNone(language) - request.headers['Accept-Language'] = '' - language = request.best_match_language() - self.assertIsNone(language) - request.headers.pop('Accept-Language') - language = request.best_match_language() - self.assertIsNone(language) - - -class ResourceTestCase(base.BaseTestCase): - - def test_unmapped_apmec_error_with_json(self): - msg = u'\u7f51\u7edc' - - class TestException(n_exc.ApmecException): - message = msg - expected_res = {'body': { - 'ApmecError': { - 'type': 'TestException', - 'message': msg, - 'detail': ''}}} - controller = mock.MagicMock() - controller.test.side_effect = TestException() - - resource = webtest.TestApp(wsgi_resource.Resource(controller)) - - environ = {'wsgiorg.routing_args': (None, {'action': 'test', - 'format': 'json'})} - res = resource.get('', extra_environ=environ, expect_errors=True) - self.assertEqual(exc.HTTPInternalServerError.code, res.status_int) - self.assertEqual(expected_res, - wsgi.JSONDeserializer().deserialize(res.body)) - - @mock.patch('oslo_i18n.translate') - def test_unmapped_apmec_error_localized(self, mock_translation): - msg_translation = 'Translated error' - mock_translation.return_value = msg_translation - msg = _('Unmapped error') - - class TestException(n_exc.ApmecException): - message = msg - - controller = mock.MagicMock() - controller.test.side_effect = TestException() - resource = webtest.TestApp(wsgi_resource.Resource(controller)) - - environ = {'wsgiorg.routing_args': (None, {'action': 'test', - 'format': 'json'})} - - res = resource.get('', extra_environ=environ, expect_errors=True) - self.assertEqual(exc.HTTPInternalServerError.code, res.status_int) - self.assertIn(msg_translation, - str(wsgi.JSONDeserializer().deserialize(res.body))) - - def test_mapped_apmec_error_with_json(self): - msg = u'\u7f51\u7edc' - - class TestException(n_exc.ApmecException): - message = msg - expected_res = {'body': { - 'ApmecError': { - 'type': 'TestException', - 'message': msg, - 'detail': ''}}} - controller = mock.MagicMock() - controller.test.side_effect = TestException() - - faults = {TestException: exc.HTTPGatewayTimeout} - resource = webtest.TestApp(wsgi_resource.Resource(controller, - faults=faults)) - - environ = {'wsgiorg.routing_args': (None, {'action': 'test', - 'format': 'json'})} - res = resource.get('', extra_environ=environ, expect_errors=True) - self.assertEqual(exc.HTTPGatewayTimeout.code, res.status_int) - self.assertEqual(expected_res, - wsgi.JSONDeserializer().deserialize(res.body)) - - @mock.patch('oslo_i18n.translate') - def test_mapped_apmec_error_localized(self, mock_translation): - msg_translation = 'Translated error' - mock_translation.return_value = msg_translation - msg = _('Unmapped error') - - class TestException(n_exc.ApmecException): - message = msg - - controller = mock.MagicMock() - controller.test.side_effect = TestException() - faults = {TestException: exc.HTTPGatewayTimeout} - resource = webtest.TestApp(wsgi_resource.Resource(controller, - faults=faults)) - - environ = {'wsgiorg.routing_args': (None, {'action': 'test', - 'format': 'json'})} - - res = resource.get('', extra_environ=environ, expect_errors=True) - self.assertEqual(exc.HTTPGatewayTimeout.code, res.status_int) - self.assertIn(msg_translation, - str(wsgi.JSONDeserializer().deserialize(res.body))) - - @staticmethod - def _make_request_with_side_effect(side_effect): - controller = mock.MagicMock() - controller.test.side_effect = side_effect - - resource = webtest.TestApp(wsgi_resource.Resource(controller)) - - routing_args = {'action': 'test'} - environ = {'wsgiorg.routing_args': (None, routing_args)} - res = resource.get('', extra_environ=environ, expect_errors=True) - return res - - def test_http_error(self): - res = self._make_request_with_side_effect(exc.HTTPGatewayTimeout()) - # verify that the exception structure is the one expected - # by the python-apmecclient - self.assertEqual(exc.HTTPGatewayTimeout().explanation, - res.json['ApmecError']['message']) - self.assertEqual('HTTPGatewayTimeout', - res.json['ApmecError']['type']) - self.assertEqual('', res.json['ApmecError']['detail']) - self.assertEqual(exc.HTTPGatewayTimeout.code, res.status_int) - - def test_unhandled_error_with_json(self): - expected_res = {'body': {'ApmecError': - {'detail': '', - 'message': - _('Request Failed: internal server error' - ' while processing your request.'), - 'type': 'HTTPInternalServerError'}}} - controller = mock.MagicMock() - controller.test.side_effect = Exception() - - resource = webtest.TestApp(wsgi_resource.Resource(controller)) - - environ = {'wsgiorg.routing_args': (None, {'action': 'test', - 'format': 'json'})} - res = resource.get('', extra_environ=environ, expect_errors=True) - self.assertEqual(exc.HTTPInternalServerError.code, res.status_int) - self.assertEqual(expected_res, - wsgi.JSONDeserializer().deserialize(res.body)) - - def test_status_200(self): - controller = mock.MagicMock() - controller.test = lambda request: {'foo': 'bar'} - - resource = webtest.TestApp(wsgi_resource.Resource(controller)) - - environ = {'wsgiorg.routing_args': (None, {'action': 'test'})} - res = resource.get('', extra_environ=environ) - self.assertEqual(200, res.status_int) - - def test_status_204(self): - controller = mock.MagicMock() - controller.test = lambda request: {'foo': 'bar'} - - resource = webtest.TestApp(wsgi_resource.Resource(controller)) - - environ = {'wsgiorg.routing_args': (None, {'action': 'delete'})} - res = resource.delete('', extra_environ=environ) - self.assertEqual(204, res.status_int) - - def _test_error_log_level(self, map_webob_exc, expect_log_info=False, - use_fault_map=True): - class TestException(n_exc.ApmecException): - message = 'Test Exception' - - controller = mock.MagicMock() - controller.test.side_effect = TestException() - faults = {TestException: map_webob_exc} if use_fault_map else {} - resource = webtest.TestApp(wsgi_resource.Resource(controller, faults)) - environ = {'wsgiorg.routing_args': (None, {'action': 'test'})} - with mock.patch.object(wsgi_resource, 'LOG') as log: - res = resource.get('', extra_environ=environ, expect_errors=True) - self.assertEqual(map_webob_exc.code, res.status_int) - self.assertEqual(expect_log_info, log.info.called) - self.assertNotEqual(expect_log_info, log.exception.called) - - def test_4xx_error_logged_info_level(self): - self._test_error_log_level(exc.HTTPNotFound, expect_log_info=True) - - def test_non_4xx_error_logged_exception_level(self): - self._test_error_log_level(exc.HTTPServiceUnavailable, - expect_log_info=False) - - def test_unmapped_error_logged_exception_level(self): - self._test_error_log_level(exc.HTTPInternalServerError, - expect_log_info=False, use_fault_map=False) - - def test_no_route_args(self): - controller = mock.MagicMock() - - resource = webtest.TestApp(wsgi_resource.Resource(controller)) - - environ = {} - res = resource.get('', extra_environ=environ, expect_errors=True) - self.assertEqual(exc.HTTPInternalServerError.code, res.status_int) - - def test_post_with_body(self): - controller = mock.MagicMock() - controller.test = lambda request, body: {'foo': 'bar'} - - resource = webtest.TestApp(wsgi_resource.Resource(controller)) - - environ = {'wsgiorg.routing_args': (None, {'action': 'test'})} - res = resource.post('', params='{"key": "val"}', - extra_environ=environ) - self.assertEqual(200, res.status_int) diff --git a/apmec/tests/unit/test_attributes.py b/apmec/tests/unit/test_attributes.py deleted file mode 100644 index dc44fde..0000000 --- a/apmec/tests/unit/test_attributes.py +++ /dev/null @@ -1,801 +0,0 @@ -# Copyright 2012 OpenStack Foundation -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, 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 testtools - -from apmec.api.v1 import attributes -from apmec.common import exceptions as n_exc -from apmec.tests import base - - -class TestAttributes(base.BaseTestCase): - - def _construct_dict_and_constraints(self): - """Constructs a test dictionary and a definition of constraints. - - :return: A (dictionary, constraint) tuple - """ - constraints = {'key1': {'type:values': ['val1', 'val2'], - 'required': True}, - 'key2': {'type:string': None, - 'required': False}, - 'key3': {'type:dict': {'k4': {'type:string': None, - 'required': True}}, - 'required': True}} - - dictionary = {'key1': 'val1', - 'key2': 'a string value', - 'key3': {'k4': 'a string value'}} - - return dictionary, constraints - - def test_is_attr_set(self): - data = attributes.ATTR_NOT_SPECIFIED - self.assertFalse(attributes.is_attr_set(data)) - - data = None - self.assertFalse(attributes.is_attr_set(data)) - - data = "I'm set" - self.assertTrue(attributes.is_attr_set(data)) - - def test_validate_values(self): - msg = attributes._validate_values(4, [4, 6]) - self.assertIsNone(msg) - - msg = attributes._validate_values(4, (4, 6)) - self.assertIsNone(msg) - - msg = attributes._validate_values(7, [4, 6]) - self.assertEqual("'7' is not in [4, 6]", msg) - - msg = attributes._validate_values(7, (4, 6)) - self.assertEqual("'7' is not in (4, 6)", msg) - - def test_validate_not_empty_string(self): - msg = attributes._validate_not_empty_string(' ', None) - self.assertEqual(u"' ' Blank strings are not permitted", msg) - - def test_validate_not_empty_string_or_none(self): - msg = attributes._validate_not_empty_string_or_none(' ', None) - self.assertEqual(u"' ' Blank strings are not permitted", msg) - - msg = attributes._validate_not_empty_string_or_none(None, None) - self.assertIsNone(msg) - - def test_validate_string_or_none(self): - msg = attributes._validate_not_empty_string_or_none('test', None) - self.assertIsNone(msg) - - msg = attributes._validate_not_empty_string_or_none(None, None) - self.assertIsNone(msg) - - def test_validate_string(self): - msg = attributes._validate_string(None, None) - self.assertEqual("'None' is not a valid string", msg) - - # 0 == len(data) == max_len - msg = attributes._validate_string("", 0) - self.assertIsNone(msg) - - # 0 == len(data) < max_len - msg = attributes._validate_string("", 9) - self.assertIsNone(msg) - - # 0 < len(data) < max_len - msg = attributes._validate_string("123456789", 10) - self.assertIsNone(msg) - - # 0 < len(data) == max_len - msg = attributes._validate_string("123456789", 9) - self.assertIsNone(msg) - - # 0 < max_len < len(data) - msg = attributes._validate_string("1234567890", 9) - self.assertEqual("'1234567890' exceeds maximum length of 9", msg) - - msg = attributes._validate_string("123456789", None) - self.assertIsNone(msg) - - def test_validate_no_whitespace(self): - data = 'no_white_space' - result = attributes._validate_no_whitespace(data) - self.assertEqual(data, result) - - self.assertRaises(n_exc.InvalidInput, - attributes._validate_no_whitespace, - 'i have whitespace') - - self.assertRaises(n_exc.InvalidInput, - attributes._validate_no_whitespace, - 'i\thave\twhitespace') - - def test_validate_range(self): - msg = attributes._validate_range(1, [1, 9]) - self.assertIsNone(msg) - - msg = attributes._validate_range(5, [1, 9]) - self.assertIsNone(msg) - - msg = attributes._validate_range(9, [1, 9]) - self.assertIsNone(msg) - - msg = attributes._validate_range(1, (1, 9)) - self.assertIsNone(msg) - - msg = attributes._validate_range(5, (1, 9)) - self.assertIsNone(msg) - - msg = attributes._validate_range(9, (1, 9)) - self.assertIsNone(msg) - - msg = attributes._validate_range(0, [1, 9]) - self.assertEqual("'0' is too small - must be at least '1'", msg) - - msg = attributes._validate_range(10, (1, 9)) - self.assertEqual("'10' is too large - must be no larger than '9'", - msg) - - msg = attributes._validate_range("bogus", (1, 9)) - self.assertEqual("'bogus' is not an integer", msg) - - msg = attributes._validate_range(10, (attributes.UNLIMITED, - attributes.UNLIMITED)) - self.assertIsNone(msg) - - msg = attributes._validate_range(10, (1, attributes.UNLIMITED)) - self.assertIsNone(msg) - - msg = attributes._validate_range(1, (attributes.UNLIMITED, 9)) - self.assertIsNone(msg) - - msg = attributes._validate_range(-1, (0, attributes.UNLIMITED)) - self.assertEqual("'-1' is too small - must be at least '0'", msg) - - msg = attributes._validate_range(10, (attributes.UNLIMITED, 9)) - self.assertEqual("'10' is too large - must be no larger than '9'", msg) - - def _test_validate_mac_address(self, validator, allow_none=False): - mac_addr = "ff:16:3e:4f:00:00" - msg = validator(mac_addr) - self.assertIsNone(msg) - - mac_addr = "ffa:16:3e:4f:00:00" - msg = validator(mac_addr) - err_msg = "'%s' is not a valid MAC address" - self.assertEqual(err_msg % mac_addr, msg) - - mac_addr = "123" - msg = validator(mac_addr) - self.assertEqual(err_msg % mac_addr, msg) - - mac_addr = None - msg = validator(mac_addr) - if allow_none: - self.assertIsNone(msg) - else: - self.assertEqual(err_msg % mac_addr, msg) - - def test_validate_mac_address(self): - self._test_validate_mac_address(attributes._validate_mac_address) - - def test_validate_mac_address_or_none(self): - self._test_validate_mac_address( - attributes._validate_mac_address_or_none, allow_none=True) - - def test_validate_ip_address(self): - ip_addr = '1.1.1.1' - msg = attributes._validate_ip_address(ip_addr) - self.assertIsNone(msg) - - ip_addr = '1111.1.1.1' - msg = attributes._validate_ip_address(ip_addr) - self.assertEqual("'%s' is not a valid IP address" % ip_addr, msg) - - ip_addr = '1.1.1.1 has whitespace' - msg = attributes._validate_ip_address(ip_addr) - self.assertEqual("'%s' is not a valid IP address" % ip_addr, msg) - - ip_addr = '111.1.1.1\twhitespace' - msg = attributes._validate_ip_address(ip_addr) - self.assertEqual("'%s' is not a valid IP address" % ip_addr, msg) - - ip_addr = '111.1.1.1\nwhitespace' - msg = attributes._validate_ip_address(ip_addr) - self.assertEqual("'%s' is not a valid IP address" % ip_addr, msg) - - def test_validate_ip_pools(self): - pools = [[{'end': '10.0.0.254'}], - [{'start': '10.0.0.254'}], - [{'start': '1000.0.0.254', - 'end': '1.1.1.1'}], - [{'start': '10.0.0.2', 'end': '10.0.0.254', - 'forza': 'juve'}], - [{'start': '10.0.0.2', 'end': '10.0.0.254'}, - {'end': '10.0.0.254'}], - [None], - None] - for pool in pools: - msg = attributes._validate_ip_pools(pool) - self.assertIsNotNone(msg) - - pools = [[{'end': '10.0.0.254', 'start': '10.0.0.2'}, - {'start': '11.0.0.2', 'end': '11.1.1.1'}], - [{'start': '11.0.0.2', 'end': '11.0.0.100'}]] - for pool in pools: - msg = attributes._validate_ip_pools(pool) - self.assertIsNone(msg) - - def test_validate_fixed_ips(self): - fixed_ips = [ - {'data': [{'subnet_id': '00000000-ffff-ffff-ffff-000000000000', - 'ip_address': '1111.1.1.1'}], - 'error_msg': "'1111.1.1.1' is not a valid IP address"}, - {'data': [{'subnet_id': 'invalid', - 'ip_address': '1.1.1.1'}], - 'error_msg': "'invalid' is not a valid UUID"}, - {'data': None, - 'error_msg': "Invalid data format for fixed IP: 'None'"}, - {'data': "1.1.1.1", - 'error_msg': "Invalid data format for fixed IP: '1.1.1.1'"}, - {'data': ['00000000-ffff-ffff-ffff-000000000000', '1.1.1.1'], - 'error_msg': "Invalid data format for fixed IP: " - "'00000000-ffff-ffff-ffff-000000000000'"}, - {'data': [['00000000-ffff-ffff-ffff-000000000000', '1.1.1.1']], - 'error_msg': "Invalid data format for fixed IP: " - "'['00000000-ffff-ffff-ffff-000000000000', " - "'1.1.1.1']'"}, - {'data': [{'subnet_id': '00000000-0fff-ffff-ffff-000000000000', - 'ip_address': '1.1.1.1'}, - {'subnet_id': '00000000-ffff-ffff-ffff-000000000000', - 'ip_address': '1.1.1.1'}], - 'error_msg': "Duplicate IP address '1.1.1.1'"}] - for fixed in fixed_ips: - msg = attributes._validate_fixed_ips(fixed['data']) - self.assertEqual(fixed['error_msg'], msg) - - fixed_ips = [[{'subnet_id': '00000000-ffff-ffff-ffff-000000000000', - 'ip_address': '1.1.1.1'}], - [{'subnet_id': '00000000-0fff-ffff-ffff-000000000000', - 'ip_address': '1.1.1.1'}, - {'subnet_id': '00000000-ffff-ffff-ffff-000000000000', - 'ip_address': '1.1.1.2'}]] - for fixed in fixed_ips: - msg = attributes._validate_fixed_ips(fixed) - self.assertIsNone(msg) - - def test_validate_nameservers(self): - mes_pools = [['1.1.1.2', '1.1.1.2'], - ['www.hostname.com', 'www.hostname.com'], - ['77.hostname.com'], - ['1000.0.0.1'], - None] - - for mes in mes_pools: - msg = attributes._validate_nameservers(mes, None) - self.assertIsNotNone(msg) - - mes_pools = [['100.0.0.2'], - ['www.hostname.com'], - ['www.great.marathons.to.travel'], - ['valid'], - ['www.internal.hostname.com']] - - for mes in mes_pools: - msg = attributes._validate_nameservers(mes, None) - self.assertIsNone(msg) - - def test_validate_hostroutes(self): - hostroute_pools = [[{'destination': '100.0.0.0/24'}], - [{'nexthop': '10.0.2.20'}], - [{'nexthop': '10.0.2.20', - 'forza': 'juve', - 'destination': '100.0.0.0/8'}], - [{'nexthop': '1110.0.2.20', - 'destination': '100.0.0.0/8'}], - [{'nexthop': '10.0.2.20', - 'destination': '100.0.0.0'}], - [{'nexthop': '10.0.2.20', - 'destination': '100.0.0.0/8'}, - {'nexthop': '10.0.2.20', - 'destination': '100.0.0.0/8'}], - [None], - None] - for host_routes in hostroute_pools: - msg = attributes._validate_hostroutes(host_routes, None) - self.assertIsNotNone(msg) - - hostroute_pools = [[{'destination': '100.0.0.0/24', - 'nexthop': '10.0.2.20'}], - [{'nexthop': '10.0.2.20', - 'destination': '100.0.0.0/8'}, - {'nexthop': '10.0.2.20', - 'destination': '101.0.0.0/8'}]] - for host_routes in hostroute_pools: - msg = attributes._validate_hostroutes(host_routes, None) - self.assertIsNone(msg) - - def test_validate_ip_address_or_none(self): - ip_addr = None - msg = attributes._validate_ip_address_or_none(ip_addr) - self.assertIsNone(msg) - - ip_addr = '1.1.1.1' - msg = attributes._validate_ip_address_or_none(ip_addr) - self.assertIsNone(msg) - - ip_addr = '1111.1.1.1' - msg = attributes._validate_ip_address_or_none(ip_addr) - self.assertEqual("'%s' is not a valid IP address" % ip_addr, - msg) - - def test_hostname_pattern(self): - data = '@openstack' - msg = attributes._validate_regex(data, attributes.HOSTNAME_PATTERN) - self.assertIsNotNone(msg) - - data = 'www.openstack.org' - msg = attributes._validate_regex(data, attributes.HOSTNAME_PATTERN) - self.assertIsNone(msg) - - def test_uuid_pattern(self): - data = 'garbage' - msg = attributes._validate_regex(data, attributes.UUID_PATTERN) - self.assertIsNotNone(msg) - - data = '00000000-ffff-ffff-ffff-000000000000' - msg = attributes._validate_regex(data, attributes.UUID_PATTERN) - self.assertIsNone(msg) - - def test_mac_pattern(self): - # Valid - 3 octets - base_mac = "fa:16:3e:00:00:00" - msg = attributes._validate_regex(base_mac, - attributes.MAC_PATTERN) - self.assertIsNone(msg) - - # Valid - 4 octets - base_mac = "fa:16:3e:4f:00:00" - msg = attributes._validate_regex(base_mac, - attributes.MAC_PATTERN) - self.assertIsNone(msg) - - # Invalid - not unicast - base_mac = "01:16:3e:4f:00:00" - msg = attributes._validate_regex(base_mac, - attributes.MAC_PATTERN) - self.assertIsNotNone(msg) - - # Invalid - invalid format - base_mac = "a:16:3e:4f:00:00" - msg = attributes._validate_regex(base_mac, - attributes.MAC_PATTERN) - self.assertIsNotNone(msg) - - # Invalid - invalid format - base_mac = "ffa:16:3e:4f:00:00" - msg = attributes._validate_regex(base_mac, - attributes.MAC_PATTERN) - self.assertIsNotNone(msg) - - # Invalid - invalid format - base_mac = "01163e4f0000" - msg = attributes._validate_regex(base_mac, - attributes.MAC_PATTERN) - self.assertIsNotNone(msg) - - # Invalid - invalid format - base_mac = "01-16-3e-4f-00-00" - msg = attributes._validate_regex(base_mac, - attributes.MAC_PATTERN) - self.assertIsNotNone(msg) - - # Invalid - invalid format - base_mac = "00:16:3:f:00:00" - msg = attributes._validate_regex(base_mac, - attributes.MAC_PATTERN) - self.assertIsNotNone(msg) - - # Invalid - invalid format - base_mac = "12:3:4:5:67:89ab" - msg = attributes._validate_regex(base_mac, - attributes.MAC_PATTERN) - self.assertIsNotNone(msg) - - def _test_validate_subnet(self, validator, allow_none=False): - # Valid - IPv4 - cidr = "10.0.2.0/24" - msg = validator(cidr, None) - self.assertIsNone(msg) - - # Valid - IPv6 without final octets - cidr = "fe80::/24" - msg = validator(cidr, None) - self.assertIsNone(msg) - - # Valid - IPv6 with final octets - cidr = "fe80::/24" - msg = validator(cidr, None) - self.assertIsNone(msg) - - # Valid - uncompressed ipv6 address - cidr = "fe80:0:0:0:0:0:0:0/128" - msg = validator(cidr, None) - self.assertIsNone(msg) - - # Valid - ipv6 address with multiple consecutive zero - cidr = "2001:0db8:0:0:1::1/128" - msg = validator(cidr, None) - self.assertIsNone(msg) - - # Valid - ipv6 address with multiple consecutive zero - cidr = "2001:0db8::1:0:0:1/128" - msg = validator(cidr, None) - self.assertIsNone(msg) - - # Valid - ipv6 address with multiple consecutive zero - cidr = "2001::0:1:0:0:1100/120" - msg = validator(cidr, None) - self.assertIsNone(msg) - - # Valid - abbreviated ipv4 address - cidr = "10/24" - msg = validator(cidr, None) - self.assertIsNone(msg) - - # Invalid - IPv4 missing mask - cidr = "10.0.2.0" - msg = validator(cidr, None) - error = _("'%(data)s' isn't a recognized IP subnet cidr," - " '%(cidr)s' is recommended") % {"data": cidr, - "cidr": "10.0.2.0/32"} - self.assertEqual(error, msg) - - # Valid - IPv4 with non-zero masked bits is ok - for i in range(1, 255): - cidr = "192.168.1.%s/24" % i - msg = validator(cidr, None) - self.assertIsNone(msg) - - # Invalid - IPv6 without final octets, missing mask - cidr = "fe80::" - msg = validator(cidr, None) - error = _("'%(data)s' isn't a recognized IP subnet cidr," - " '%(cidr)s' is recommended") % {"data": cidr, - "cidr": "fe80::/128"} - self.assertEqual(error, msg) - - # Invalid - IPv6 with final octets, missing mask - cidr = "fe80::0" - msg = validator(cidr, None) - error = _("'%(data)s' isn't a recognized IP subnet cidr," - " '%(cidr)s' is recommended") % {"data": cidr, - "cidr": "fe80::/128"} - self.assertEqual(error, msg) - - # Invalid - Address format error - cidr = 'invalid' - msg = validator(cidr, None) - error = "'%s' is not a valid IP subnet" % cidr - self.assertEqual(error, msg) - - cidr = None - msg = validator(cidr, None) - if allow_none: - self.assertIsNone(msg) - else: - error = "'%s' is not a valid IP subnet" % cidr - self.assertEqual(error, msg) - - def test_validate_subnet(self): - self._test_validate_subnet(attributes._validate_subnet) - - def test_validate_subnet_or_none(self): - self._test_validate_subnet(attributes._validate_subnet_or_none, - allow_none=True) - - def _test_validate_regex(self, validator, allow_none=False): - pattern = '[hc]at' - - data = None - msg = validator(data, pattern) - if allow_none: - self.assertIsNone(msg) - else: - self.assertEqual("'None' is not a valid input", msg) - - data = 'bat' - msg = validator(data, pattern) - self.assertEqual("'%s' is not a valid input" % data, msg) - - data = 'hat' - msg = validator(data, pattern) - self.assertIsNone(msg) - - data = 'cat' - msg = validator(data, pattern) - self.assertIsNone(msg) - - def test_validate_regex(self): - self._test_validate_regex(attributes._validate_regex) - - def test_validate_regex_or_none(self): - self._test_validate_regex(attributes._validate_regex_or_none, - allow_none=True) - - def test_validate_uuid(self): - msg = attributes._validate_uuid('garbage') - self.assertEqual("'garbage' is not a valid UUID", msg) - - msg = attributes._validate_uuid('00000000-ffff-ffff-ffff-000000000000') - self.assertIsNone(msg) - - def test_validate_uuid_list(self): - # check not a list - uuids = [None, - 123, - 'e5069610-744b-42a7-8bd8-ceac1a229cd4', - '12345678123456781234567812345678', - {'uuid': 'e5069610-744b-42a7-8bd8-ceac1a229cd4'}] - for uuid in uuids: - msg = attributes._validate_uuid_list(uuid) - error = "'%s' is not a list" % uuid - self.assertEqual(error, msg) - - # check invalid uuid in a list - invalid_uuid_lists = [[None], - [123], - [123, 'e5069610-744b-42a7-8bd8-ceac1a229cd4'], - ['123', '12345678123456781234567812345678'], - ['t5069610-744b-42a7-8bd8-ceac1a229cd4'], - ['e5069610-744b-42a7-8bd8-ceac1a229cd44'], - ['e50696100-744b-42a7-8bd8-ceac1a229cd4'], - ['e5069610-744bb-42a7-8bd8-ceac1a229cd4']] - for uuid_list in invalid_uuid_lists: - msg = attributes._validate_uuid_list(uuid_list) - error = "'%s' is not a valid UUID" % uuid_list[0] - self.assertEqual(error, msg) - - # check duplicate items in a list - duplicate_uuids = ['e5069610-744b-42a7-8bd8-ceac1a229cd4', - 'f3eeab00-8367-4524-b662-55e64d4cacb5', - 'e5069610-744b-42a7-8bd8-ceac1a229cd4'] - msg = attributes._validate_uuid_list(duplicate_uuids) - error = ("Duplicate items in the list: " - "'%s'" % ', '.join(duplicate_uuids)) - self.assertEqual(error, msg) - - # check valid uuid lists - valid_uuid_lists = [['e5069610-744b-42a7-8bd8-ceac1a229cd4'], - ['f3eeab00-8367-4524-b662-55e64d4cacb5'], - ['e5069610-744b-42a7-8bd8-ceac1a229cd4', - 'f3eeab00-8367-4524-b662-55e64d4cacb5']] - for uuid_list in valid_uuid_lists: - msg = attributes._validate_uuid_list(uuid_list) - self.assertIsNone(msg) - - def test_validate_dict_type(self): - for value in (None, True, '1', []): - self.assertEqual("'%s' is not a dictionary" % value, - attributes._validate_dict(value)) - - def test_validate_dict_without_constraints(self): - msg = attributes._validate_dict({}) - self.assertIsNone(msg) - - # Validate a dictionary without constraints. - msg = attributes._validate_dict({'key': 'value'}) - self.assertIsNone(msg) - - def test_validate_a_valid_dict_with_constraints(self): - dictionary, constraints = self._construct_dict_and_constraints() - - msg = attributes._validate_dict(dictionary, constraints) - self.assertIsNone(msg, 'Validation of a valid dictionary failed.') - - def test_validate_dict_with_invalid_validator(self): - dictionary, constraints = self._construct_dict_and_constraints() - - constraints['key1'] = {'type:unsupported': None, 'required': True} - msg = attributes._validate_dict(dictionary, constraints) - self.assertEqual("Validator 'type:unsupported' does not exist.", - msg) - - def test_validate_dict_not_required_keys(self): - dictionary, constraints = self._construct_dict_and_constraints() - - del dictionary['key2'] - msg = attributes._validate_dict(dictionary, constraints) - self.assertIsNone(msg, 'Field that was not required by the specs was' - 'required by the validator.') - - def test_validate_dict_required_keys(self): - dictionary, constraints = self._construct_dict_and_constraints() - - del dictionary['key1'] - msg = attributes._validate_dict(dictionary, constraints) - self.assertIn('Expected keys:', msg) - - def test_validate_dict_wrong_values(self): - dictionary, constraints = self._construct_dict_and_constraints() - - dictionary['key1'] = 'UNSUPPORTED' - msg = attributes._validate_dict(dictionary, constraints) - self.assertIsNotNone(msg) - - def test_validate_dict_convert_boolean(self): - dictionary, constraints = self._construct_dict_and_constraints() - - constraints['key_bool'] = { - 'type:boolean': None, - 'required': False, - 'convert_to': attributes.convert_to_boolean} - dictionary['key_bool'] = 'true' - msg = attributes._validate_dict(dictionary, constraints) - self.assertIsNone(msg) - # Explicitly comparing with literal 'True' as assertTrue - # succeeds also for 'true' - self.assertTrue(dictionary['key_bool']) - - def test_subdictionary(self): - dictionary, constraints = self._construct_dict_and_constraints() - - del dictionary['key3']['k4'] - dictionary['key3']['k5'] = 'a string value' - msg = attributes._validate_dict(dictionary, constraints) - self.assertIn('Expected keys:', msg) - - def test_validate_dict_or_none(self): - dictionary, constraints = self._construct_dict_and_constraints() - - # Check whether None is a valid value. - msg = attributes._validate_dict_or_none(None, constraints) - self.assertIsNone(msg, 'Validation of a None dictionary failed.') - - # Check validation of a regular dictionary. - msg = attributes._validate_dict_or_none(dictionary, constraints) - self.assertIsNone(msg, 'Validation of a valid dictionary failed.') - - def test_validate_dict_or_empty(self): - dictionary, constraints = self._construct_dict_and_constraints() - - # Check whether an empty dictionary is valid. - msg = attributes._validate_dict_or_empty({}, constraints) - self.assertIsNone(msg, 'Validation of a None dictionary failed.') - - # Check validation of a regular dictionary. - msg = attributes._validate_dict_or_none(dictionary, constraints) - self.assertIsNone(msg, 'Validation of a valid dictionary failed.') - self.assertIsNone(msg, 'Validation of a valid dictionary failed.') - - def test_validate_non_negative(self): - for value in (-1, '-2'): - self.assertEqual("'%s' should be non-negative" % value, - attributes._validate_non_negative(value)) - - for value in (0, 1, '2', True, False): - msg = attributes._validate_non_negative(value) - self.assertIsNone(msg) - - -class TestConvertToBoolean(base.BaseTestCase): - - def test_convert_to_boolean_bool(self): - self.assertTrue(attributes.convert_to_boolean(True)) - self.assertFalse(attributes.convert_to_boolean(False)) - - def test_convert_to_boolean_int(self): - self.assertFalse(attributes.convert_to_boolean(0)) - self.assertTrue(attributes.convert_to_boolean(1)) - self.assertRaises(n_exc.InvalidInput, - attributes.convert_to_boolean, - 7) - - def test_convert_to_boolean_str(self): - self.assertTrue(attributes.convert_to_boolean('True')) - self.assertTrue(attributes.convert_to_boolean('true')) - self.assertFalse(attributes.convert_to_boolean('False')) - self.assertFalse(attributes.convert_to_boolean('false')) - self.assertFalse(attributes.convert_to_boolean('0')) - self.assertTrue(attributes.convert_to_boolean('1')) - self.assertRaises(n_exc.InvalidInput, - attributes.convert_to_boolean, - '7') - - -class TestConvertToInt(base.BaseTestCase): - - def test_convert_to_int_int(self): - self.assertEqual(-1, attributes.convert_to_int(-1)) - self.assertEqual(0, attributes.convert_to_int(0)) - self.assertEqual(1, attributes.convert_to_int(1)) - - def test_convert_to_int_str(self): - self.assertEqual(4, attributes.convert_to_int('4')) - self.assertEqual(6, attributes.convert_to_int('6')) - self.assertRaises(n_exc.InvalidInput, - attributes.convert_to_int, - 'garbage') - - def test_convert_to_int_none(self): - self.assertRaises(n_exc.InvalidInput, - attributes.convert_to_int, - None) - - def test_convert_none_to_empty_list_none(self): - self.assertEqual( - [], attributes.convert_none_to_empty_list(None)) - - def test_convert_none_to_empty_dict(self): - self.assertEqual( - {}, attributes.convert_none_to_empty_dict(None)) - - def test_convert_none_to_empty_list_value(self): - values = ['1', 3, [], [1], {}, {'a': 3}] - for value in values: - self.assertEqual( - value, attributes.convert_none_to_empty_list(value)) - - -class TestConvertKvp(base.BaseTestCase): - - def test_convert_kvp_list_to_dict_succeeds_for_missing_values(self): - result = attributes.convert_kvp_list_to_dict(['True']) - self.assertEqual({}, result) - - def test_convert_kvp_list_to_dict_succeeds_for_multiple_values(self): - self.skip("Not ready yet") - result = attributes.convert_kvp_list_to_dict( - ['a=b', 'a=c', 'a=c', 'b=a']) - self.assertEqual({'a': ['c', 'b'], 'b': ['a']}, result) - - def test_convert_kvp_list_to_dict_succeeds_for_values(self): - result = attributes.convert_kvp_list_to_dict(['a=b', 'c=d']) - self.assertEqual({'a': ['b'], 'c': ['d']}, result) - - def test_convert_kvp_str_to_list_fails_for_missing_key(self): - with testtools.ExpectedException(n_exc.InvalidInput): - attributes.convert_kvp_str_to_list('=a') - - def test_convert_kvp_str_to_list_fails_for_missing_equals(self): - with testtools.ExpectedException(n_exc.InvalidInput): - attributes.convert_kvp_str_to_list('a') - - def test_convert_kvp_str_to_list_succeeds_for_one_equals(self): - result = attributes.convert_kvp_str_to_list('a=') - self.assertEqual(['a', ''], result) - - def test_convert_kvp_str_to_list_succeeds_for_two_equals(self): - result = attributes.convert_kvp_str_to_list('a=a=a') - self.assertEqual(['a', 'a=a'], result) - - -class TestConvertToList(base.BaseTestCase): - - def test_convert_to_empty_list(self): - for item in (None, [], (), {}): - self.assertEqual([], attributes.convert_to_list(item)) - - def test_convert_to_list_string(self): - for item in ('', 'foo'): - self.assertEqual([item], attributes.convert_to_list(item)) - - def test_convert_to_list_iterable(self): - for item in ([None], [1, 2, 3], (1, 2, 3), set([1, 2, 3]), ['foo']): - self.assertEqual(list(item), attributes.convert_to_list(item)) - - def test_convert_to_list_non_iterable(self): - for item in (True, False, 1, 1.2, object()): - self.assertEqual([item], attributes.convert_to_list(item)) diff --git a/apmec/tests/unit/test_auth.py b/apmec/tests/unit/test_auth.py deleted file mode 100644 index cd41ab1..0000000 --- a/apmec/tests/unit/test_auth.py +++ /dev/null @@ -1,100 +0,0 @@ -# Copyright 2012 OpenStack Foundation -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, 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. - -from oslo_middleware import request_id -import webob - -from apmec import auth -from apmec.tests import base - - -class ApmecKeystoneContextTestCase(base.BaseTestCase): - def setUp(self): - super(ApmecKeystoneContextTestCase, self).setUp() - self.skip("Not ready yet") - - @webob.dec.wsgify - def fake_app(req): - self.context = req.environ['apmec.context'] - return webob.Response() - - self.context = None - self.middleware = auth.ApmecKeystoneContext(fake_app) - self.request = webob.Request.blank('/') - self.request.headers['X_AUTH_TOKEN'] = 'testauthtoken' - - def test_no_user_id(self): - self.request.headers['X_PROJECT_ID'] = 'testtenantid' - response = self.request.get_response(self.middleware) - self.assertEqual('401 Unauthorized', response.status) - - def test_with_user_id(self): - self.request.headers['X_PROJECT_ID'] = 'testtenantid' - self.request.headers['X_USER_ID'] = 'testuserid' - response = self.request.get_response(self.middleware) - self.assertEqual('200 OK', response.status) - self.assertEqual('testuserid', self.context.user_id) - self.assertEqual('testuserid', self.context.user) - - def test_with_tenant_id(self): - self.request.headers['X_PROJECT_ID'] = 'testtenantid' - self.request.headers['X_USER_ID'] = 'test_user_id' - response = self.request.get_response(self.middleware) - self.assertEqual('200 OK', response.status) - self.assertEqual('testtenantid', self.context.tenant_id) - self.assertEqual('testtenantid', self.context.tenant) - - def test_roles_no_admin(self): - self.request.headers['X_PROJECT_ID'] = 'testtenantid' - self.request.headers['X_USER_ID'] = 'testuserid' - self.request.headers['X_ROLES'] = 'role1, role2 , role3,role4,role5' - response = self.request.get_response(self.middleware) - self.assertEqual('200 OK', response.status) - self.assertEqual(['role1', 'role2', - 'role3', 'role4', 'role5'], - self.context.roles) - self.assertFalse(self.context.is_admin) - - def test_roles_with_admin(self): - self.request.headers['X_PROJECT_ID'] = 'testtenantid' - self.request.headers['X_USER_ID'] = 'testuserid' - self.request.headers['X_ROLES'] = ('role1, role2 , role3,role4,role5,' - 'AdMiN') - response = self.request.get_response(self.middleware) - self.assertEqual('200 OK', response.status) - self.assertEqual(['role1', 'role2', 'role3', - 'role4', 'role5', 'AdMiN'], - self.context.roles) - self.assertEqual(True, self.context.is_admin) - - def test_with_user_tenant_name(self): - self.request.headers['X_PROJECT_ID'] = 'testtenantid' - self.request.headers['X_USER_ID'] = 'testuserid' - self.request.headers['X_PROJECT_NAME'] = 'testtenantname' - self.request.headers['X_USER_NAME'] = 'testusername' - response = self.request.get_response(self.middleware) - self.assertEqual('200 OK', response.status) - self.assertEqual('testuserid', self.context.user_id) - self.assertEqual('testusername', self.context.user_name) - self.assertEqual('testtenantid', self.context.tenant_id) - self.assertEqual('testtenantname', self.context.tenant_name) - - def test_request_id_extracted_from_env(self): - req_id = 'dummy-request-id' - self.request.headers['X_PROJECT_ID'] = 'testtenantid' - self.request.headers['X_USER_ID'] = 'testuserid' - self.request.environ[request_id.ENV_REQUEST_ID] = req_id - self.request.get_response(self.middleware) - self.assertEqual(req_id, self.context.request_id) diff --git a/apmec/tests/unit/test_common_log.py b/apmec/tests/unit/test_common_log.py deleted file mode 100644 index 5c59c5d..0000000 --- a/apmec/tests/unit/test_common_log.py +++ /dev/null @@ -1,80 +0,0 @@ -# Copyright (c) 2013 OpenStack Foundation. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, 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 mock - -from apmec.common import log as call_log -from apmec.tests import base - - -MODULE_NAME = 'apmec.tests.unit.test_common_log' - - -class TargetKlass(object): - - @call_log.log - def test_method(self, arg1, arg2, *args, **kwargs): - pass - - -class TestCallLog(base.BaseTestCase): - def setUp(self): - super(TestCallLog, self).setUp() - self.skip("Not ready yet") - self.klass = TargetKlass() - self.expected_format = ('%(class_name)s method %(method_name)s ' - 'called with arguments %(args)s %(kwargs)s') - self.expected_data = {'class_name': MODULE_NAME + '.TargetKlass', - 'method_name': 'test_method', - 'args': (), - 'kwargs': {}} - - def test_call_log_all_args(self): - self.expected_data['args'] = (10, 20) - with mock.patch.object(call_log.LOG, 'debug') as log_debug: - self.klass.test_method(10, 20) - log_debug.assert_called_once_with(self.expected_format, - self.expected_data) - - def test_call_log_all_kwargs(self): - self.expected_data['kwargs'] = {'arg1': 10, 'arg2': 20} - with mock.patch.object(call_log.LOG, 'debug') as log_debug: - self.klass.test_method(arg1=10, arg2=20) - log_debug.assert_called_once_with(self.expected_format, - self.expected_data) - - def test_call_log_known_args_unknown_args_kwargs(self): - self.expected_data['args'] = (10, 20, 30) - self.expected_data['kwargs'] = {'arg4': 40} - with mock.patch.object(call_log.LOG, 'debug') as log_debug: - self.klass.test_method(10, 20, 30, arg4=40) - log_debug.assert_called_once_with(self.expected_format, - self.expected_data) - - def test_call_log_known_args_kwargs_unknown_kwargs(self): - self.expected_data['args'] = (10,) - self.expected_data['kwargs'] = {'arg2': 20, 'arg3': 30, 'arg4': 40} - with mock.patch.object(call_log.LOG, 'debug') as log_debug: - self.klass.test_method(10, arg2=20, arg3=30, arg4=40) - log_debug.assert_called_once_with(self.expected_format, - self.expected_data) - - def test_call_log_password_mask_args_kwargs(self): - auth_cred = {'userame': 'demo', 'password': 'changeit'} - self.expected_data['kwargs'] = {'password': '***'} - self.expected_data['args'] = ({'userame': 'demo', 'password': '***'}) - with mock.patch.object(call_log.LOG, 'debug') as log_debug: - self.klass.test_method(auth_cred, password='guessme') - log_debug.assert_called_once_with(self.expected_format, - self.expected_data) diff --git a/apmec/tests/unit/test_common_services_plugin.py b/apmec/tests/unit/test_common_services_plugin.py deleted file mode 100644 index 979d9ec..0000000 --- a/apmec/tests/unit/test_common_services_plugin.py +++ /dev/null @@ -1,160 +0,0 @@ -# Copyright 2016 Brocade Communications System, Inc. -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, 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 mock - -from oslo_utils import timeutils - -from apmec import context -from apmec.db.common_services import common_services_db_plugin -from apmec.extensions import common_services -from apmec.plugins.common_services import common_services_plugin -from apmec.tests.unit.db import base as db_base - - -class TestCommonServicesPlugin(db_base.SqlTestCase): - def setUp(self): - super(TestCommonServicesPlugin, self).setUp() - self.addCleanup(mock.patch.stopall) - self.context = context.get_admin_context() - self.event_db_plugin =\ - common_services_db_plugin.CommonServicesPluginDb() - self.coreutil_plugin = common_services_plugin.CommonServicesPlugin() - - def _get_dummy_event_obj(self): - return { - 'resource_id': '6261579e-d6f3-49ad-8bc3-a9cb974778ff', - 'resource_state': 'ACTIVE', - 'resource_type': 'MEA', - 'event_details': '', - 'event_type': 'scale_up', - 'timestamp': timeutils.parse_strtime('2016-07-20T05:43:52.765172') - } - - def test_create_event(self): - evt_obj = self._get_dummy_event_obj() - result = self.event_db_plugin.create_event(self.context, - evt_obj['resource_id'], - evt_obj['resource_type'], - evt_obj['resource_state'], - evt_obj['event_type'], - evt_obj['timestamp'], - evt_obj['event_details']) - self.assertIsNotNone(result) - self.assertIn('id', result) - self.assertIn('resource_id', result) - self.assertIn('resource_state', result) - self.assertIn('resource_type', result) - self.assertIn('event_type', result) - self.assertIn('event_details', result) - self.assertIn('timestamp', result) - - def test_event_not_found(self): - self.assertRaises(common_services.EventNotFoundException, - self.coreutil_plugin.get_event, self.context, '99') - - def test_InvalidModelInputExceptionNotThrown(self): - evt_obj = self._get_dummy_event_obj() - result = self.event_db_plugin.create_event(self.context, - evt_obj['resource_id'], - evt_obj['resource_type'], - evt_obj['resource_state'], - evt_obj['event_type'], - evt_obj['timestamp'], - evt_obj['event_details']) - try: - self.coreutil_plugin.get_event(self, context, str(result['id'])) - except common_services.InvalidModelException: - self.assertTrue(False) - except Exception: - self.assertTrue(True) - - def test_get_event_by_id(self): - evt_obj = self._get_dummy_event_obj() - evt_created = self.event_db_plugin.create_event( - self.context, evt_obj['resource_id'], - evt_obj['resource_type'], - evt_obj['resource_state'], - evt_obj['event_type'], - evt_obj['timestamp'], - evt_obj['event_details']) - self.assertIsNotNone(evt_created) - evt_get = self.coreutil_plugin.get_event(self.context, - evt_created['id']) - self.assertEqual(evt_created['resource_id'], evt_get['resource_id']) - self.assertEqual(evt_created['resource_state'], - evt_get['resource_state']) - self.assertEqual(evt_created['resource_type'], - evt_get['resource_type']) - self.assertEqual(evt_created['event_type'], evt_get['event_type']) - self.assertEqual(evt_created['event_details'], - evt_get['event_details']) - self.assertEqual(evt_created['timestamp'], evt_get['timestamp']) - - def test_get_events(self): - evt_obj = self._get_dummy_event_obj() - self.event_db_plugin.create_event(self.context, - evt_obj['resource_id'], - evt_obj['resource_type'], - evt_obj['resource_state'], - evt_obj['event_type'], - evt_obj['timestamp'], - evt_obj['event_details']) - result = self.coreutil_plugin.get_events(self.context) - self.assertTrue(len(result)) - - def test_get_events_filtered_invalid_id(self): - evt_obj = self._get_dummy_event_obj() - self.event_db_plugin.create_event(self.context, - evt_obj['resource_id'], - evt_obj['resource_type'], - evt_obj['resource_state'], - evt_obj['event_type'], - evt_obj['timestamp'], - evt_obj['event_details']) - result = self.coreutil_plugin.get_events(self.context, {'id': 'xyz'}) - self.assertFalse(len(result)) - - def test_get_events_filtered_valid_id(self): - evt_obj = self._get_dummy_event_obj() - self.event_db_plugin.create_event(self.context, - evt_obj['resource_id'], - evt_obj['resource_type'], - evt_obj['resource_state'], - evt_obj['event_type'], - evt_obj['timestamp'], - evt_obj['event_details']) - result = self.coreutil_plugin.get_events(self.context, {'id': '1'}) - self.assertTrue(len(result)) - - def test_get_events_valid_fields(self): - evt_obj = self._get_dummy_event_obj() - self.event_db_plugin.create_event(self.context, - evt_obj['resource_id'], - evt_obj['resource_type'], - evt_obj['resource_state'], - evt_obj['event_type'], - evt_obj['timestamp'], - evt_obj['event_details']) - result = self.coreutil_plugin.get_events(self.context, {'id': '1'}, - ['id', 'event_type']) - self.assertTrue(len(result)) - self.assertIn('id', result[0]) - self.assertNotIn('resource_id', result[0]) - self.assertNotIn('resource_state', result[0]) - self.assertNotIn('resource_type', result[0]) - self.assertIn('event_type', result[0]) - self.assertNotIn('event_details', result[0]) - self.assertNotIn('timestamp', result[0]) diff --git a/apmec/tests/unit/test_common_utils.py b/apmec/tests/unit/test_common_utils.py deleted file mode 100644 index 85ac8f5..0000000 --- a/apmec/tests/unit/test_common_utils.py +++ /dev/null @@ -1,38 +0,0 @@ -# Copyright (c) 2012 OpenStack Foundation. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, 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 testtools - -from apmec.common import utils -from apmec.tests import base - - -class TestDict2Tuples(base.BaseTestCase): - def test_dict(self): - input_dict = {'foo': 'bar', '42': 'baz', 'aaa': 'zzz'} - expected = (('42', 'baz'), ('aaa', 'zzz'), ('foo', 'bar')) - output_tuple = utils.dict2tuple(input_dict) - self.assertEqual(expected, output_tuple) - - -class TestChangeMemory(testtools.TestCase): - def test_change_memory_from_mb_to_gb(self): - actual_val = utils.change_memory_unit("1024 mb", "GB") - expected_val = 1 - self.assertEqual(expected_val, actual_val) - - def test_change_memory_from_gb_to_mb(self): - actual_val = utils.change_memory_unit("1 GB", "MB") - expected_val = 1024 - self.assertEqual(expected_val, actual_val) diff --git a/apmec/tests/unit/test_config.py b/apmec/tests/unit/test_config.py deleted file mode 100644 index 1123783..0000000 --- a/apmec/tests/unit/test_config.py +++ /dev/null @@ -1,47 +0,0 @@ -# Copyright (c) 2012 OpenStack Foundation. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# 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 os - -import mock -from oslo_config import cfg - -from apmec.common import config # noqa -from apmec.tests import base - - -class ConfigurationTest(base.BaseTestCase): - - def test_defaults(self): - self.assertEqual('0.0.0.0', cfg.CONF.bind_host) - self.assertEqual(9896, cfg.CONF.bind_port) - self.assertEqual('api-paste.ini', cfg.CONF.api_paste_config) - self.assertEqual('', cfg.CONF.api_extensions_path) - self.assertEqual('policy.json', cfg.CONF.policy_file) - self.assertEqual('keystone', cfg.CONF.auth_strategy) - self.assertTrue(cfg.CONF.allow_bulk) - relative_dir = os.path.join(os.path.dirname(__file__), - '..', '..', '..') - absolute_dir = os.path.abspath(relative_dir) - self.assertEqual(absolute_dir, cfg.CONF.state_path) - self.assertEqual('apmec', cfg.CONF.control_exchange) - - def test_load_paste_app_not_found(self): - self.config(api_paste_config='no_such_file.conf') - with mock.patch.object(cfg.CONF, 'find_file', return_value=None) as ff: - e = self.assertRaises(cfg.ConfigFilesNotFoundError, - config.load_paste_app, 'app') - ff.assert_called_once_with('no_such_file.conf') - self.assertEqual(['no_such_file.conf'], e.config_files) diff --git a/apmec/tests/unit/test_db_migration.py b/apmec/tests/unit/test_db_migration.py deleted file mode 100644 index fa4f065..0000000 --- a/apmec/tests/unit/test_db_migration.py +++ /dev/null @@ -1,157 +0,0 @@ -# Copyright 2012 New Dream Network, LLC (DreamHost) -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, 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. - -# @author Mark McClain (DreamHost) - -import sys - -import mock - -from apmec.db.migration import cli -from apmec.tests import base - - -class TestCli(base.BaseTestCase): - def setUp(self): - super(TestCli, self).setUp() - self.do_alembic_cmd_p = mock.patch.object(cli, 'do_alembic_command') - self.do_alembic_cmd = self.do_alembic_cmd_p.start() - self.mock_alembic_err = mock.patch('alembic.util.err').start() - self.mock_alembic_err.side_effect = SystemExit - - def _main_test_helper(self, argv, func_name, exp_args=(), exp_kwargs={}): - with mock.patch.object(sys, 'argv', argv): - cli.main() - self.do_alembic_cmd.assert_has_calls( - [mock.call(mock.ANY, func_name, *exp_args, **exp_kwargs)] - ) - - def test_stamp(self): - self._main_test_helper( - ['prog', 'stamp', 'foo'], - 'stamp', - ('foo',), - {'sql': False} - ) - - self._main_test_helper( - ['prog', 'stamp', 'foo', '--sql'], - 'stamp', - ('foo',), - {'sql': True} - ) - - def test_current(self): - self._main_test_helper(['prog', 'current'], 'current') - - def test_history(self): - self._main_test_helper(['prog', 'history'], 'history') - - def test_check_migration(self): - with mock.patch.object(cli, 'validate_head_file') as validate: - self._main_test_helper(['prog', 'check_migration'], 'branches') - validate.assert_called_once_with(mock.ANY) - - def test_database_sync_revision(self): - with mock.patch.object(cli, 'update_head_file') as update: - self._main_test_helper( - ['prog', 'revision', '--autogenerate', '-m', 'message'], - 'revision', - (), - {'message': 'message', 'sql': False, 'autogenerate': True} - ) - update.assert_called_once_with(mock.ANY) - - update.reset_mock() - self._main_test_helper( - ['prog', 'revision', '--sql', '-m', 'message'], - 'revision', - (), - {'message': 'message', 'sql': True, 'autogenerate': False} - ) - update.assert_called_once_with(mock.ANY) - - def test_upgrade(self): - self._main_test_helper( - ['prog', 'upgrade', '--sql', 'head'], - 'upgrade', - ('head',), - {'sql': True} - ) - - self._main_test_helper( - ['prog', 'upgrade', '--delta', '3'], - 'upgrade', - ('+3',), - {'sql': False} - ) - - def _test_validate_head_file_helper(self, heads, file_content=None): - with mock.patch('alembic.script.ScriptDirectory.from_config') as fc: - fc.return_value.get_heads.return_value = heads - fc.return_value.get_current_head.return_value = heads[0] - with mock.patch('six.moves.builtins.open') as mock_open: - mock_open.return_value.__enter__ = lambda s: s - mock_open.return_value.__exit__ = mock.Mock() - mock_open.return_value.read.return_value = file_content - - with mock.patch('os.path.isfile') as is_file: - is_file.return_value = file_content is not None - - if file_content in heads: - cli.validate_head_file(mock.sentinel.config) - else: - self.assertRaises( - SystemExit, - cli.validate_head_file, - mock.sentinel.config - ) - self.mock_alembic_err.assert_called_once_with(mock.ANY) - fc.assert_called_once_with(mock.sentinel.config) - - def test_validate_head_file_multiple_heads(self): - self._test_validate_head_file_helper(['a', 'b']) - - def test_validate_head_file_missing_file(self): - self._test_validate_head_file_helper(['a']) - - def test_validate_head_file_wrong_contents(self): - self._test_validate_head_file_helper(['a'], 'b') - - def test_validate_head_success(self): - self._test_validate_head_file_helper(['a'], 'a') - - def test_update_head_file_multiple_heads(self): - with mock.patch('alembic.script.ScriptDirectory.from_config') as fc: - fc.return_value.get_heads.return_value = ['a', 'b'] - self.assertRaises( - SystemExit, - cli.update_head_file, - mock.sentinel.config - ) - self.mock_alembic_err.assert_called_once_with(mock.ANY) - fc.assert_called_once_with(mock.sentinel.config) - - def test_update_head_file_success(self): - with mock.patch('alembic.script.ScriptDirectory.from_config') as fc: - fc.return_value.get_heads.return_value = ['a'] - fc.return_value.get_current_head.return_value = 'a' - with mock.patch('six.moves.builtins.open') as mock_open: - mock_open.return_value.__enter__ = lambda s: s - mock_open.return_value.__exit__ = mock.Mock() - - cli.update_head_file(mock.sentinel.config) - mock_open.return_value.write.assert_called_once_with('a') - fc.assert_called_once_with(mock.sentinel.config) diff --git a/apmec/tests/unit/test_db_purge_delete.py b/apmec/tests/unit/test_db_purge_delete.py deleted file mode 100644 index 729c749..0000000 --- a/apmec/tests/unit/test_db_purge_delete.py +++ /dev/null @@ -1,81 +0,0 @@ -# Copyright 2016 Brocade Communications System, Inc. -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, 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 mock - - -from apmec.common import exceptions -from apmec import context -from apmec.db.migration import purge_tables -from apmec.tests.unit.db import base as db_base - - -class FakeConfig(mock.Mock): - pass - - -class TestDbPurgeDelete(db_base.SqlTestCase): - def setUp(self): - super(TestDbPurgeDelete, self).setUp() - self.addCleanup(mock.patch.stopall) - self.context = context.get_admin_context() - self._mock_config() - mock.patch('sqlalchemy.Table').start() - mock.patch('apmec.db.migration.purge_tables._purge_resource_tables' - ).start() - mock.patch('apmec.db.migration.purge_tables._purge_events_table', - ).start() - mock.patch('apmec.db.migration.purge_tables.' - '_generate_associated_tables_map').start() - mock.patch('apmec.db.migration.purge_tables.get_engine').start() - - def _mock_config(self): - self.config = mock.Mock(wraps=FakeConfig()) - fake_config = mock.Mock() - fake_config.return_value = self.config - self._mock( - 'alembic.config.__init__', fake_config) - - def test_age_not_integer_input(self): - self.assertRaises(exceptions.InvalidInput, purge_tables.purge_deleted, - self.config, 'invalid', 'abc') - - def test_age_negative_integer_input(self): - self.assertRaises(exceptions.InvalidInput, purge_tables.purge_deleted, - self.config, 'invalid', '-90') - - def test_invalid_granularity_input(self): - self.assertRaises(exceptions.InvalidInput, purge_tables.purge_deleted, - self.config, 'mea', '90', 'decade') - - def test_purge_delete_call_mea(self): - purge_tables.purge_deleted(self.config, 'mea', '90', 'days') - purge_tables._purge_resource_tables.assert_called_once_with( - mock.ANY, mock.ANY, mock.ANY, mock.ANY, mock.ANY) - - def test_purge_delete_call_mead(self): - purge_tables.purge_deleted(self.config, 'mead', '90', 'days') - purge_tables._purge_resource_tables.assert_called_once_with( - mock.ANY, mock.ANY, mock.ANY, mock.ANY, mock.ANY) - - def test_purge_delete_call_vim(self): - purge_tables.purge_deleted(self.config, 'vims', '90', 'days') - purge_tables._purge_resource_tables.assert_called_once_with( - mock.ANY, mock.ANY, mock.ANY, mock.ANY, mock.ANY) - - def test_purge_delete_call_events(self): - purge_tables.purge_deleted(self.config, 'events', '90', 'days') - purge_tables._purge_events_table.assert_called_once_with( - mock.ANY, mock.ANY, mock.ANY) diff --git a/apmec/tests/unit/test_extension_extended_attribute.py b/apmec/tests/unit/test_extension_extended_attribute.py deleted file mode 100644 index 4693916..0000000 --- a/apmec/tests/unit/test_extension_extended_attribute.py +++ /dev/null @@ -1,117 +0,0 @@ -# Copyright 2013 VMware, Inc -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, 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. - -""" -Unit tests for extension extended attribute -""" - -import webob.exc as webexc - -import apmec -from apmec.api import extensions -from apmec.api.v1 import attributes -from apmec.common import config -from apmec import manager -from apmec.tests import base -from apmec.tests.unit.extensions import extendedattribute as extattr -from apmec.tests.unit import test_api_v2 -from apmec.tests.unit import testlib_api -from apmec import wsgi - -_uuid = test_api_v2._uuid -_get_path = test_api_v2._get_path -extensions_path = ':'.join(apmec.tests.unit.extensions.__path__) - - -class ExtensionExtendedAttributeTestCase(base.BaseTestCase): - def setUp(self): - super(ExtensionExtendedAttributeTestCase, self).setUp() - self.skip("Not ready yet") - plugin = ( - "apmec.tests.unit.test_extension_extended_attribute." - "ExtensionExtendedAttributeTestPlugin" - ) - - # point config file to: apmec/tests/etc/apmec.conf.test - self.config_parse() - - self.setup_coreplugin(plugin) - - ext_mgr = extensions.ExtensionManager(extensions_path) - ext_mgr.extend_resources("1.0", {}) - extensions.ExtensionManager._instance = ext_mgr - - app = config.load_paste_app('extensions_test_app') - self._api = extensions.ExtensionMiddleware(app, ext_mgr=ext_mgr) - - self._tenant_id = "8c70909f-b081-452d-872b-df48e6c355d1" - # Save the global RESOURCE_ATTRIBUTE_MAP - self.saved_attr_map = {} - for resource, attrs in (attributes.RESOURCE_ATTRIBUTE_MAP).items(): - self.saved_attr_map[resource] = attrs.copy() - # Add the resources to the global attribute map - # This is done here as the setup process won't - # initialize the main API router which extends - # the global attribute map - attributes.RESOURCE_ATTRIBUTE_MAP.update( - extattr.EXTENDED_ATTRIBUTES_2_0) - self.agentscheduler_dbMinxin = manager.ApmecManager.get_plugin() - self.addCleanup(self.restore_attribute_map) - - def restore_attribute_map(self): - # Restore the original RESOURCE_ATTRIBUTE_MAP - attributes.RESOURCE_ATTRIBUTE_MAP = self.saved_attr_map - - def _do_request(self, method, path, data=None, params=None, action=None): - content_type = 'application/json' - body = None - if data is not None: # empty dict is valid - body = wsgi.Serializer().serialize(data, content_type) - - req = testlib_api.create_request( - path, body, content_type, - method, query_string=params) - res = req.get_response(self._api) - if res.status_code >= 400: - raise webexc.HTTPClientError(detail=res.body, code=res.status_code) - if res.status_code != webexc.HTTPNoContent.code: - return res.json - - def _ext_test_resource_create(self, attr=None): - data = { - "ext_test_resource": { - "tenant_id": self._tenant_id, - "name": "test", - extattr.EXTENDED_ATTRIBUTE: attr - } - } - - res = self._do_request('POST', _get_path('ext_test_resources'), data) - return res['ext_test_resource'] - - def test_ext_test_resource_create(self): - ext_test_resource = self._ext_test_resource_create() - attr = _uuid() - ext_test_resource = self._ext_test_resource_create(attr) - self.assertEqual(attr, ext_test_resource[extattr.EXTENDED_ATTRIBUTE]) - - def test_ext_test_resource_get(self): - attr = _uuid() - obj = self._ext_test_resource_create(attr) - obj_id = obj['id'] - res = self._do_request('GET', _get_path( - 'ext_test_resources/{0}'.format(obj_id))) - obj2 = res['ext_test_resource'] - self.assertEqual(attr, obj2[extattr.EXTENDED_ATTRIBUTE]) diff --git a/apmec/tests/unit/test_extensions.py b/apmec/tests/unit/test_extensions.py deleted file mode 100644 index 5b952a8..0000000 --- a/apmec/tests/unit/test_extensions.py +++ /dev/null @@ -1,546 +0,0 @@ -# Copyright (c) 2011 OpenStack Foundation. -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, 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 abc - -from oslo_log import log as logging -from oslo_serialization import jsonutils -import routes -import webob -import webtest - -from apmec.api import extensions -from apmec.common import config -from apmec.plugins.common import constants -from apmec.tests import base -from apmec.tests.unit import extension_stubs as ext_stubs -import apmec.tests.unit.extensions -from apmec.tests.unit import testlib_api -from apmec import wsgi - - -LOG = logging.getLogger(__name__) -extensions_path = ':'.join(apmec.tests.unit.extensions.__path__) - - -class ExtensionsTestApp(wsgi.Router): - - def __init__(self, options={}): - mapper = routes.Mapper() - controller = ext_stubs.StubBaseAppController() - mapper.resource("dummy_resource", "/dummy_resources", - controller=controller) - super(ExtensionsTestApp, self).__init__(mapper) - - -class PluginInterfaceTest(base.BaseTestCase): - def test_issubclass_hook(self): - class A(object): - def f(self): - pass - - class B(extensions.PluginInterface): - @abc.abstractmethod - def f(self): - pass - - self.assertTrue(issubclass(A, B)) - - def test_issubclass_hook_class_without_abstract_methods(self): - class A(object): - def f(self): - pass - - class B(extensions.PluginInterface): - def f(self): - pass - - self.assertFalse(issubclass(A, B)) - - def test_issubclass_hook_not_all_methods_implemented(self): - class A(object): - def f(self): - pass - - class B(extensions.PluginInterface): - @abc.abstractmethod - def f(self): - pass - - @abc.abstractmethod - def g(self): - pass - - self.assertFalse(issubclass(A, B)) - - -class ResourceExtensionTest(base.BaseTestCase): - - class ResourceExtensionController(wsgi.Controller): - - def index(self, request): - return "resource index" - - def show(self, request, id): - return {'data': {'id': id}} - - def notimplemented_function(self, request, id): - return webob.exc.HTTPNotImplemented() - - def custom_member_action(self, request, id): - return {'member_action': 'value'} - - def custom_collection_action(self, request, **kwargs): - return {'collection': 'value'} - - class DummySvcPlugin(wsgi.Controller): - def get_plugin_type(self): - return constants.DUMMY - - def index(self, request, **kwargs): - return "resource index" - - def custom_member_action(self, request, **kwargs): - return {'member_action': 'value'} - - def collection_action(self, request, **kwargs): - return {'collection': 'value'} - - def show(self, request, id): - return {'data': {'id': id}} - - def test_exceptions_notimplemented(self): - controller = self.ResourceExtensionController() - member = {'notimplemented_function': "GET"} - res_ext = extensions.ResourceExtension('tweedles', controller, - member_actions=member) - test_app = _setup_extensions_test_app(SimpleExtensionManager(res_ext)) - - # Ideally we would check for a 501 code here but webtest doesn't take - # anything that is below 200 or above 400 so we can't actually check - # it. It throws webtest.AppError instead. - try: - test_app.get("/tweedles/some_id/notimplemented_function") - # Shouldn't be reached - self.assertTrue(False) - except webtest.AppError as e: - self.assertIn('501', str(e)) - - def test_resource_can_be_added_as_extension(self): - res_ext = extensions.ResourceExtension( - 'tweedles', self.ResourceExtensionController()) - test_app = _setup_extensions_test_app(SimpleExtensionManager(res_ext)) - index_response = test_app.get("/tweedles") - self.assertEqual(200, index_response.status_int) - self.assertEqual(b"resource index", index_response.body) - - show_response = test_app.get("/tweedles/25266") - self.assertEqual({'data': {'id': "25266"}}, show_response.json) - - def test_resource_gets_prefix_of_plugin(self): - class DummySvcPlugin(wsgi.Controller): - def index(self, request): - return "" - - def get_plugin_type(self): - return constants.DUMMY - - res_ext = extensions.ResourceExtension( - 'tweedles', DummySvcPlugin(), path_prefix="/dummy_svc") - test_app = _setup_extensions_test_app(SimpleExtensionManager(res_ext)) - index_response = test_app.get("/dummy_svc/tweedles") - self.assertEqual(200, index_response.status_int) - - def test_resource_extension_with_custom_member_action(self): - controller = self.ResourceExtensionController() - member = {'custom_member_action': "GET"} - res_ext = extensions.ResourceExtension('tweedles', controller, - member_actions=member) - test_app = _setup_extensions_test_app(SimpleExtensionManager(res_ext)) - - response = test_app.get("/tweedles/some_id/custom_member_action") - self.assertEqual(200, response.status_int) - self.assertEqual("value", - jsonutils.loads(response.body)['member_action']) - - def test_resource_ext_with_custom_member_action_gets_plugin_prefix(self): - controller = self.DummySvcPlugin() - member = {'custom_member_action': "GET"} - collections = {'collection_action': "GET"} - res_ext = extensions.ResourceExtension('tweedles', controller, - path_prefix="/dummy_svc", - member_actions=member, - collection_actions=collections) - test_app = _setup_extensions_test_app(SimpleExtensionManager(res_ext)) - - response = test_app.get("/dummy_svc/tweedles/1/custom_member_action") - self.assertEqual(200, response.status_int) - self.assertEqual("value", - jsonutils.loads(response.body)['member_action']) - - response = test_app.get("/dummy_svc/tweedles/collection_action") - self.assertEqual(200, response.status_int) - self.assertEqual("value", - jsonutils.loads(response.body)['collection']) - - def test_plugin_prefix_with_parent_resource(self): - controller = self.DummySvcPlugin() - parent = dict(member_name="tenant", - collection_name="tenants") - member = {'custom_member_action': "GET"} - collections = {'collection_action': "GET"} - res_ext = extensions.ResourceExtension('tweedles', controller, parent, - path_prefix="/dummy_svc", - member_actions=member, - collection_actions=collections) - test_app = _setup_extensions_test_app(SimpleExtensionManager(res_ext)) - - index_response = test_app.get("/dummy_svc/tenants/1/tweedles") - self.assertEqual(200, index_response.status_int) - - response = test_app.get("/dummy_svc/tenants/1/" - "tweedles/1/custom_member_action") - self.assertEqual(200, response.status_int) - self.assertEqual(jsonutils.loads(response.body)['member_action'], - "value") - - response = test_app.get("/dummy_svc/tenants/2/" - "tweedles/collection_action") - self.assertEqual(200, response.status_int) - self.assertEqual("value", - jsonutils.loads(response.body)['collection']) - - def test_resource_extension_for_get_custom_collection_action(self): - controller = self.ResourceExtensionController() - collections = {'custom_collection_action': "GET"} - res_ext = extensions.ResourceExtension('tweedles', controller, - collection_actions=collections) - test_app = _setup_extensions_test_app(SimpleExtensionManager(res_ext)) - - response = test_app.get("/tweedles/custom_collection_action") - self.assertEqual(200, response.status_int) - LOG.debug(jsonutils.loads(response.body)) - self.assertEqual("value", jsonutils.loads(response.body)['collection']) - - def test_resource_extension_for_put_custom_collection_action(self): - controller = self.ResourceExtensionController() - collections = {'custom_collection_action': "PUT"} - res_ext = extensions.ResourceExtension('tweedles', controller, - collection_actions=collections) - test_app = _setup_extensions_test_app(SimpleExtensionManager(res_ext)) - - response = test_app.put("/tweedles/custom_collection_action") - - self.assertEqual(200, response.status_int) - self.assertEqual('value', jsonutils.loads(response.body)['collection']) - - def test_resource_extension_for_post_custom_collection_action(self): - controller = self.ResourceExtensionController() - collections = {'custom_collection_action': "POST"} - res_ext = extensions.ResourceExtension('tweedles', controller, - collection_actions=collections) - test_app = _setup_extensions_test_app(SimpleExtensionManager(res_ext)) - - response = test_app.post("/tweedles/custom_collection_action") - - self.assertEqual(200, response.status_int) - self.assertEqual('value', jsonutils.loads(response.body)['collection']) - - def test_resource_extension_for_delete_custom_collection_action(self): - controller = self.ResourceExtensionController() - collections = {'custom_collection_action': "DELETE"} - res_ext = extensions.ResourceExtension('tweedles', controller, - collection_actions=collections) - test_app = _setup_extensions_test_app(SimpleExtensionManager(res_ext)) - - response = test_app.delete("/tweedles/custom_collection_action") - - self.assertEqual(200, response.status_int) - self.assertEqual('value', jsonutils.loads(response.body)['collection']) - - def test_resource_ext_for_formatted_req_on_custom_collection_action(self): - controller = self.ResourceExtensionController() - collections = {'custom_collection_action': "GET"} - res_ext = extensions.ResourceExtension('tweedles', controller, - collection_actions=collections) - test_app = _setup_extensions_test_app(SimpleExtensionManager(res_ext)) - - response = test_app.get("/tweedles/custom_collection_action.json") - - self.assertEqual(200, response.status_int) - self.assertEqual('value', jsonutils.loads(response.body)['collection']) - - def test_resource_ext_for_nested_resource_custom_collection_action(self): - controller = self.ResourceExtensionController() - collections = {'custom_collection_action': "GET"} - parent = dict(collection_name='beetles', member_name='beetle') - res_ext = extensions.ResourceExtension('tweedles', controller, - collection_actions=collections, - parent=parent) - test_app = _setup_extensions_test_app(SimpleExtensionManager(res_ext)) - - response = test_app.get("/beetles/beetle_id" - "/tweedles/custom_collection_action") - - self.assertEqual(200, response.status_int) - self.assertEqual('value', jsonutils.loads(response.body)['collection']) - - def test_resource_extension_with_custom_member_action_and_attr_map(self): - controller = self.ResourceExtensionController() - member = {'custom_member_action': "GET"} - params = { - 'tweedles': { - 'id': {'allow_post': False, 'allow_put': False, - 'validate': {'type:uuid': None}, - 'is_visible': True}, - 'name': {'allow_post': True, 'allow_put': True, - 'validate': {'type:string': None}, - 'default': '', 'is_visible': True}, - } - } - res_ext = extensions.ResourceExtension('tweedles', controller, - member_actions=member, - attr_map=params) - test_app = _setup_extensions_test_app(SimpleExtensionManager(res_ext)) - - response = test_app.get("/tweedles/some_id/custom_member_action") - self.assertEqual(200, response.status_int) - self.assertEqual('value', - jsonutils.loads(response.body)['member_action']) - - def test_returns_404_for_non_existent_extension(self): - test_app = _setup_extensions_test_app(SimpleExtensionManager(None)) - - response = test_app.get("/non_extistant_extension", status='*') - - self.assertEqual(404, response.status_int) - - -class ActionExtensionTest(base.BaseTestCase): - - def setUp(self): - super(ActionExtensionTest, self).setUp() - self.skip("Not ready yet") - self.extension_app = _setup_extensions_test_app() - - def test_extended_action_for_adding_extra_data(self): - action_name = 'FOXNSOX:add_tweedle' - action_params = dict(name='Beetle') - req_body = jsonutils.dumps({action_name: action_params}) - response = self.extension_app.post('/dummy_resources/1/action', - req_body, - content_type='application/json') - self.assertEqual("Tweedle Beetle Added.", response.body) - - def test_extended_action_for_deleting_extra_data(self): - action_name = 'FOXNSOX:delete_tweedle' - action_params = dict(name='Bailey') - req_body = jsonutils.dumps({action_name: action_params}) - response = self.extension_app.post("/dummy_resources/1/action", - req_body, - content_type='application/json') - self.assertEqual("Tweedle Bailey Deleted.", response.body) - - def test_returns_404_for_non_existent_action(self): - non_existent_action = 'blah_action' - action_params = dict(name="test") - req_body = jsonutils.dumps({non_existent_action: action_params}) - - response = self.extension_app.post("/dummy_resources/1/action", - req_body, - content_type='application/json', - status='*') - - self.assertEqual(404, response.status_int) - - def test_returns_404_for_non_existent_resource(self): - action_name = 'add_tweedle' - action_params = dict(name='Beetle') - req_body = jsonutils.dumps({action_name: action_params}) - - response = self.extension_app.post("/asdf/1/action", req_body, - content_type='application/json', - status='*') - self.assertEqual(404, response.status_int) - - -class RequestExtensionTest(base.BaseTestCase): - - def test_headers_can_be_extended(self): - def extend_headers(req, res): - assert req.headers['X-NEW-REQUEST-HEADER'] == "sox" - res.headers['X-NEW-RESPONSE-HEADER'] = "response_header_data" - return res - - app = self._setup_app_with_request_handler(extend_headers, 'GET') - response = app.get("/dummy_resources/1", - headers={'X-NEW-REQUEST-HEADER': "sox"}) - - self.assertEqual("response_header_data", - response.headers['X-NEW-RESPONSE-HEADER']) - - def test_extend_get_resource_response(self): - def extend_response_data(req, res): - data = jsonutils.loads(res.body) - data['FOXNSOX:extended_key'] = req.GET.get('extended_key') - res.body = jsonutils.dump_as_bytes(data) - return res - - app = self._setup_app_with_request_handler(extend_response_data, 'GET') - response = app.get("/dummy_resources/1?extended_key=extended_data") - - self.assertEqual(200, response.status_int) - response_data = jsonutils.loads(response.body) - self.assertEqual('extended_data', - response_data['FOXNSOX:extended_key']) - self.assertEqual('knox', response_data['fort']) - - def test_get_resources(self): - self.skip("Not ready yet") - app = _setup_extensions_test_app() - - response = app.get("/dummy_resources/1?chewing=newblue") - - response_data = jsonutils.loads(response.body) - self.assertEqual('newblue', response_data['FOXNSOX:googoose']) - self.assertEqual("Pig Bands!", response_data['FOXNSOX:big_bands']) - - def test_edit_previously_uneditable_field(self): - - def _update_handler(req, res): - data = jsonutils.loads(res.body) - data['uneditable'] = req.params['uneditable'] - res.body = jsonutils.dump_as_bytes(data) - return res - - base_app = webtest.TestApp(setup_base_app(self)) - response = base_app.put("/dummy_resources/1", - {'uneditable': "new_value"}) - self.assertEqual("original_value", response.json['uneditable']) - - ext_app = self._setup_app_with_request_handler(_update_handler, - 'PUT') - ext_response = ext_app.put("/dummy_resources/1", - {'uneditable': "new_value"}) - self.assertEqual("new_value", ext_response.json['uneditable']) - - def _setup_app_with_request_handler(self, handler, verb): - req_ext = extensions.RequestExtension(verb, - '/dummy_resources/:(id)', - handler) - manager = SimpleExtensionManager(None, None, req_ext) - return _setup_extensions_test_app(manager) - - -class ExtensionManagerTest(base.BaseTestCase): - - def test_invalid_extensions_are_not_registered(self): - - class InvalidExtension(object): - """Invalid extension. - - This Extension doesn't implement extension methods : - get_name, get_description, get_namespace and get_updated - """ - def get_alias(self): - return "invalid_extension" - - ext_mgr = extensions.ExtensionManager('') - ext_mgr.add_extension(InvalidExtension()) - ext_mgr.add_extension(ext_stubs.StubExtension("valid_extension")) - - self.assertIn('valid_extension', ext_mgr.extensions) - self.assertNotIn('invalid_extension', ext_mgr.extensions) - - -class ExtensionControllerTest(testlib_api.WebTestCase): - - def setUp(self): - super(ExtensionControllerTest, self).setUp() - self.skip("Not ready yet") - self.test_app = _setup_extensions_test_app() - - def test_index_gets_all_registerd_extensions(self): - response = self.test_app.get("/extensions." + self.fmt) - res_body = self.deserialize(response) - foxnsox = res_body["extensions"][0] - - self.assertEqual("FOXNSOX", foxnsox["alias"]) - self.assertEqual("http://www.fox.in.socks/api/ext/pie/v1.0", - foxnsox["namespace"]) - - def test_extension_can_be_accessed_by_alias(self): - response = self.test_app.get("/extensions/FOXNSOX." + self.fmt) - foxnsox_extension = self.deserialize(response) - foxnsox_extension = foxnsox_extension['extension'] - self.assertEqual("FOXNSOX", foxnsox_extension["alias"]) - self.assertEqual("http://www.fox.in.socks/api/ext/pie/v1.0", - foxnsox_extension["namespace"]) - - def test_show_returns_not_found_for_non_existent_extension(self): - response = self.test_app.get("/extensions/non_existent" + self.fmt, - status="*") - - self.assertEqual(404, response.status_int) - - -def app_factory(global_conf, **local_conf): - conf = global_conf.copy() - conf.update(local_conf) - return ExtensionsTestApp(conf) - - -def setup_base_app(test): - base.BaseTestCase.config_parse() - app = config.load_paste_app('extensions_test_app') - return app - - -def setup_extensions_middleware(extension_manager=None): - extension_manager = (extension_manager or - extensions.ExtensionManager(extensions_path)) - base.BaseTestCase.config_parse() - app = config.load_paste_app('extensions_test_app') - return extensions.ExtensionMiddleware(app, ext_mgr=extension_manager) - - -def _setup_extensions_test_app(extension_manager=None): - return webtest.TestApp(setup_extensions_middleware(extension_manager)) - - -class SimpleExtensionManager(object): - - def __init__(self, resource_ext=None, action_ext=None, request_ext=None): - self.resource_ext = resource_ext - self.action_ext = action_ext - self.request_ext = request_ext - - def get_resources(self): - resource_exts = [] - if self.resource_ext: - resource_exts.append(self.resource_ext) - return resource_exts - - def get_actions(self): - action_exts = [] - if self.action_ext: - action_exts.append(self.action_ext) - return action_exts - - def get_request_extensions(self): - request_extensions = [] - if self.request_ext: - request_extensions.append(self.request_ext) - return request_extensions diff --git a/apmec/tests/unit/test_policy.py b/apmec/tests/unit/test_policy.py deleted file mode 100644 index bb0655b..0000000 --- a/apmec/tests/unit/test_policy.py +++ /dev/null @@ -1,557 +0,0 @@ -# Copyright (c) 2012 OpenStack Foundation. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# 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. - -"""Test of Policy Engine For Apmec""" - -import fixtures -import mock -import six - -from oslo_policy import policy as common_policy -from oslo_serialization import jsonutils as json -from oslo_utils import importutils -from six.moves.urllib import request as urlrequest - -import apmec -from apmec.api.v1 import attributes -from apmec.common import exceptions -from apmec import context -from apmec import manager -from apmec import policy -from apmec.tests import base - - -class PolicyFileTestCase(base.BaseTestCase): - def setUp(self): - super(PolicyFileTestCase, self).setUp() - self.skipTest("Not ready yet") - policy.reset() - self.addCleanup(policy.reset) - self.context = context.Context('fake', 'fake', is_admin=False) - self.target = {} - self.tempdir = self.useFixture(fixtures.TempDir()) - - def test_modified_policy_reloads(self): - def fake_find_config_file(_1, _2): - return self.tempdir.join('policy') - - with mock.patch.object(apmec.common.utils, - 'find_config_file', - new=fake_find_config_file): - tmpfilename = fake_find_config_file(None, None) - action = "example:test" - with open(tmpfilename, "w") as policyfile: - policyfile.write("""{"example:test": ""}""") - policy.init() - policy.enforce(self.context, action, self.target) - with open(tmpfilename, "w") as policyfile: - policyfile.write("""{"example:test": "!"}""") - # NOTE(vish): reset stored policy cache so we don't have to - # sleep(1) - policy._POLICY_CACHE = {} - policy.init() - self.assertRaises(exceptions.PolicyNotAuthorized, - policy.enforce, - self.context, - action, - self.target) - - -class PolicyTestCase(base.BaseTestCase): - def setUp(self): - super(PolicyTestCase, self).setUp() - self.skipTest("Not ready yet") - policy.reset() - self.addCleanup(policy.reset) - # NOTE(vish): preload rules to circumvent reloading from file - policy.init() - rules = { - "true": '@', - "example:allowed": '@', - "example:denied": '!', - "example:get_http": "http:http://www.example.com", - "example:my_file": "role:compute_admin or tenant_id:%(tenant_id)s", - "example:early_and_fail": "! and @", - "example:early_or_success": "@ or !", - "example:lowercase_admin": "role:admin or role:sysadmin", - "example:uppercase_admin": "role:ADMIN or role:sysadmin", - } - # NOTE(vish): then overload underlying rules - common_policy.set_rules(common_policy.Rules( - dict((k, common_policy.parse_rule(v)) - for k, v in rules.items()))) - self.context = context.Context('fake', 'fake', roles=['member']) - self.target = {} - - def test_enforce_nonexistent_action_throws(self): - action = "example:noexist" - self.assertRaises(exceptions.PolicyNotAuthorized, policy.enforce, - self.context, action, self.target) - - def test_enforce_bad_action_throws(self): - action = "example:denied" - self.assertRaises(exceptions.PolicyNotAuthorized, policy.enforce, - self.context, action, self.target) - - def test_check_bad_action_noraise(self): - action = "example:denied" - result = policy.check(self.context, action, self.target) - self.assertFalse(result) - - def test_check_non_existent_action(self): - action = "example:idonotexist" - result_1 = policy.check(self.context, action, self.target) - self.assertFalse(result_1) - result_2 = policy.check(self.context, action, self.target, - might_not_exist=True) - self.assertTrue(result_2) - - def test_enforce_good_action(self): - action = "example:allowed" - result = policy.enforce(self.context, action, self.target) - self.assertEqual(True, result) - - def test_enforce_http_true(self): - - def fakeurlopen(url, post_data): - return six.StringIO("True") - - with mock.patch.object(urlrequest, 'urlopen', new=fakeurlopen): - action = "example:get_http" - target = {} - result = policy.enforce(self.context, action, target) - self.assertEqual(True, result) - - def test_enforce_http_false(self): - - def fakeurlopen(url, post_data): - return six.StringIO("False") - - with mock.patch.object(urlrequest, 'urlopen', new=fakeurlopen): - action = "example:get_http" - target = {} - self.assertRaises(exceptions.PolicyNotAuthorized, policy.enforce, - self.context, action, target) - - def test_templatized_enforcement(self): - target_mine = {'tenant_id': 'fake'} - target_not_mine = {'tenant_id': 'another'} - action = "example:my_file" - policy.enforce(self.context, action, target_mine) - self.assertRaises(exceptions.PolicyNotAuthorized, policy.enforce, - self.context, action, target_not_mine) - - def test_early_AND_enforcement(self): - action = "example:early_and_fail" - self.assertRaises(exceptions.PolicyNotAuthorized, policy.enforce, - self.context, action, self.target) - - def test_early_OR_enforcement(self): - action = "example:early_or_success" - policy.enforce(self.context, action, self.target) - - def test_ignore_case_role_check(self): - lowercase_action = "example:lowercase_admin" - uppercase_action = "example:uppercase_admin" - # NOTE(dprince) we mix case in the Admin role here to ensure - # case is ignored - admin_context = context.Context('admin', 'fake', roles=['AdMiN']) - policy.enforce(admin_context, lowercase_action, self.target) - policy.enforce(admin_context, uppercase_action, self.target) - - -class DefaultPolicyTestCase(base.BaseTestCase): - - def setUp(self): - super(DefaultPolicyTestCase, self).setUp() - self.skipTest("Not ready yet") - policy.reset() - policy.init() - self.addCleanup(policy.reset) - - self.rules = { - "default": '', - "example:exist": '!', - } - - self._set_rules('default') - - self.context = context.Context('fake', 'fake') - - def _set_rules(self, default_rule): - rules = common_policy.Rules( - dict((k, common_policy.parse_rule(v)) - for k, v in self.rules.items()), default_rule) - common_policy.set_rules(rules) - - def test_policy_called(self): - self.assertRaises(exceptions.PolicyNotAuthorized, policy.enforce, - self.context, "example:exist", {}) - - def test_not_found_policy_calls_default(self): - policy.enforce(self.context, "example:noexist", {}) - - def test_default_not_found(self): - self._set_rules("default_noexist") - self.assertRaises(exceptions.PolicyNotAuthorized, policy.enforce, - self.context, "example:noexist", {}) - - -FAKE_RESOURCE_NAME = 'something' -FAKE_RESOURCE = {"%ss" % FAKE_RESOURCE_NAME: - {'attr': {'allow_post': True, - 'allow_put': True, - 'is_visible': True, - 'default': None, - 'enforce_policy': True, - 'validate': {'type:dict': - {'sub_attr_1': {'type:string': None}, - 'sub_attr_2': {'type:string': None}}} - }}} - - -class ApmecPolicyTestCase(base.BaseTestCase): - - def setUp(self): - super(ApmecPolicyTestCase, self).setUp() - self.skipTest("Not ready yet") - policy.reset() - policy.init() - self.addCleanup(policy.reset) - self.admin_only_legacy = "role:admin" - self.admin_or_owner_legacy = "role:admin or tenant_id:%(tenant_id)s" - # Add a Fake 'something' resource to RESOURCE_ATTRIBUTE_MAP - attributes.RESOURCE_ATTRIBUTE_MAP.update(FAKE_RESOURCE) - self.rules = dict((k, common_policy.parse_rule(v)) for k, v in { - "context_is_admin": "role:admin", - "admin_or_network_owner": "rule:context_is_admin or " - "tenant_id:%(network:tenant_id)s", - "admin_or_owner": ("rule:context_is_admin or " - "tenant_id:%(tenant_id)s"), - "admin_only": "rule:context_is_admin", - "regular_user": "role:user", - "shared": "field:networks:shared=True", - "external": "field:networks:router:external=True", - "default": '@', - - "create_network": "rule:admin_or_owner", - "create_network:shared": "rule:admin_only", - "update_network": '@', - "update_network:shared": "rule:admin_only", - - "get_network": "rule:admin_or_owner or " - "rule:shared or " - "rule:external", - "create_port:mac": "rule:admin_or_network_owner", - "create_something": "rule:admin_or_owner", - "create_something:attr": "rule:admin_or_owner", - "create_something:attr:sub_attr_1": "rule:admin_or_owner", - "create_something:attr:sub_attr_2": "rule:admin_only", - - "get_firewall_policy": "rule:admin_or_owner or " - "rule:shared", - "get_firewall_rule": "rule:admin_or_owner or " - "rule:shared" - }.items()) - - def fakepolicyinit(): - common_policy.set_rules(common_policy.Rules(self.rules)) - - def remove_fake_resource(): - del attributes.RESOURCE_ATTRIBUTE_MAP["%ss" % FAKE_RESOURCE_NAME] - - self.patcher = mock.patch.object(apmec.policy, - 'init', - new=fakepolicyinit) - self.patcher.start() - self.addCleanup(remove_fake_resource) - self.context = context.Context('fake', 'fake', roles=['user']) - plugin_klass = importutils.import_class( - "apmec.db.db_base_plugin_v2.ApmecDbPluginV2") - self.manager_patcher = mock.patch('apmec.manager.ApmecManager') - fake_manager = self.manager_patcher.start() - fake_manager_instance = fake_manager.return_value - fake_manager_instance.plugin = plugin_klass() - - def _test_action_on_attr(self, context, action, attr, value, - exception=None): - action = "%s_network" % action - target = {'tenant_id': 'the_owner', attr: value} - if exception: - self.assertRaises(exception, policy.enforce, - context, action, target) - else: - result = policy.enforce(context, action, target) - self.assertEqual(True, result) - - def _test_nonadmin_action_on_attr(self, action, attr, value, - exception=None): - user_context = context.Context('', "user", roles=['user']) - self._test_action_on_attr(user_context, action, attr, - value, exception) - - def test_nonadmin_write_on_private_fails(self): - self._test_nonadmin_action_on_attr('create', 'shared', False, - exceptions.PolicyNotAuthorized) - - def test_nonadmin_read_on_private_fails(self): - self._test_nonadmin_action_on_attr('get', 'shared', False, - exceptions.PolicyNotAuthorized) - - def test_nonadmin_write_on_shared_fails(self): - self._test_nonadmin_action_on_attr('create', 'shared', True, - exceptions.PolicyNotAuthorized) - - def test_nonadmin_read_on_shared_succeeds(self): - self._test_nonadmin_action_on_attr('get', 'shared', True) - - def _test_enforce_adminonly_attribute(self, action): - admin_context = context.get_admin_context() - target = {'shared': True} - result = policy.enforce(admin_context, action, target) - self.assertEqual(True, result) - - def test_enforce_adminonly_attribute_create(self): - self._test_enforce_adminonly_attribute('create_network') - - def test_enforce_adminonly_attribute_update(self): - self._test_enforce_adminonly_attribute('update_network') - - def test_enforce_adminonly_attribute_no_context_is_admin_policy(self): - del self.rules[policy.ADMIN_CTX_POLICY] - self.rules['admin_only'] = common_policy.parse_rule( - self.admin_only_legacy) - self.rules['admin_or_owner'] = common_policy.parse_rule( - self.admin_or_owner_legacy) - self._test_enforce_adminonly_attribute('create_network') - - def test_enforce_adminonly_attribute_nonadminctx_returns_403(self): - action = "create_network" - target = {'shared': True, 'tenant_id': 'somebody_else'} - self.assertRaises(exceptions.PolicyNotAuthorized, policy.enforce, - self.context, action, target) - - def test_enforce_adminonly_nonadminctx_no_ctx_is_admin_policy_403(self): - del self.rules[policy.ADMIN_CTX_POLICY] - self.rules['admin_only'] = common_policy.parse_rule( - self.admin_only_legacy) - self.rules['admin_or_owner'] = common_policy.parse_rule( - self.admin_or_owner_legacy) - action = "create_network" - target = {'shared': True, 'tenant_id': 'somebody_else'} - self.assertRaises(exceptions.PolicyNotAuthorized, policy.enforce, - self.context, action, target) - - def _test_build_subattribute_match_rule(self, validate_value): - bk = FAKE_RESOURCE['%ss' % FAKE_RESOURCE_NAME]['attr']['validate'] - FAKE_RESOURCE['%ss' % FAKE_RESOURCE_NAME]['attr']['validate'] = ( - validate_value) - action = "create_something" - target = {'tenant_id': 'fake', 'attr': {'sub_attr_1': 'x'}} - self.assertFalse(policy._build_subattr_match_rule( - 'attr', - FAKE_RESOURCE['%ss' % FAKE_RESOURCE_NAME]['attr'], - action, - target)) - FAKE_RESOURCE['%ss' % FAKE_RESOURCE_NAME]['attr']['validate'] = bk - - def test_build_subattribute_match_rule_empty_dict_validator(self): - self._test_build_subattribute_match_rule({}) - - def test_build_subattribute_match_rule_wrong_validation_info(self): - self._test_build_subattribute_match_rule( - {'type:dict': 'wrong_stuff'}) - - def test_enforce_subattribute(self): - action = "create_something" - target = {'tenant_id': 'fake', 'attr': {'sub_attr_1': 'x'}} - result = policy.enforce(self.context, action, target, None) - self.assertEqual(True, result) - - def test_enforce_admin_only_subattribute(self): - action = "create_something" - target = {'tenant_id': 'fake', 'attr': {'sub_attr_1': 'x', - 'sub_attr_2': 'y'}} - result = policy.enforce(context.get_admin_context(), - action, target, None) - self.assertEqual(True, result) - - def test_enforce_admin_only_subattribute_nonadminctx_returns_403(self): - action = "create_something" - target = {'tenant_id': 'fake', 'attr': {'sub_attr_1': 'x', - 'sub_attr_2': 'y'}} - self.assertRaises(exceptions.PolicyNotAuthorized, policy.enforce, - self.context, action, target, None) - - def test_enforce_regularuser_on_read(self): - action = "get_network" - target = {'shared': True, 'tenant_id': 'somebody_else'} - result = policy.enforce(self.context, action, target) - self.assertTrue(result) - - def test_enforce_firewall_policy_shared(self): - action = "get_firewall_policy" - target = {'shared': True, 'tenant_id': 'somebody_else'} - result = policy.enforce(self.context, action, target) - self.assertTrue(result) - - def test_enforce_firewall_rule_shared(self): - action = "get_firewall_rule" - target = {'shared': True, 'tenant_id': 'somebody_else'} - result = policy.enforce(self.context, action, target) - self.assertTrue(result) - - def test_enforce_tenant_id_check(self): - # Trigger a policy with rule admin_or_owner - action = "create_network" - target = {'tenant_id': 'fake'} - result = policy.enforce(self.context, action, target) - self.assertTrue(result) - - def test_enforce_tenant_id_check_parent_resource(self): - - def fakegetnetwork(*args, **kwargs): - return {'tenant_id': 'fake'} - - action = "create_port:mac" - with mock.patch.object(manager.ApmecManager.get_instance().plugin, - 'get_network', new=fakegetnetwork): - target = {'network_id': 'whatever'} - result = policy.enforce(self.context, action, target) - self.assertTrue(result) - - def test_enforce_plugin_failure(self): - - def fakegetnetwork(*args, **kwargs): - raise NotImplementedError('Blast!') - - # the policy check and plugin method we use in this test are irrelevant - # so long that we verify that, if *f* blows up, the behavior of the - # policy engine to propagate the exception is preserved - action = "create_port:mac" - with mock.patch.object(manager.ApmecManager.get_instance().plugin, - 'get_network', new=fakegetnetwork): - target = {'network_id': 'whatever'} - self.assertRaises(NotImplementedError, - policy.enforce, - self.context, - action, - target) - - def test_enforce_tenant_id_check_parent_resource_bw_compatibility(self): - - def fakegetnetwork(*args, **kwargs): - return {'tenant_id': 'fake'} - - del self.rules['admin_or_network_owner'] - self.rules['admin_or_network_owner'] = common_policy.parse_rule( - "role:admin or tenant_id:%(network_tenant_id)s") - action = "create_port:mac" - with mock.patch.object(manager.ApmecManager.get_instance().plugin, - 'get_network', new=fakegetnetwork): - target = {'network_id': 'whatever'} - result = policy.enforce(self.context, action, target) - self.assertTrue(result) - - def test_tenant_id_check_no_target_field_raises(self): - # Try and add a bad rule - self.assertRaises( - exceptions.PolicyInitError, - common_policy.parse_rule, - 'tenant_id:(wrong_stuff)') - - def _test_enforce_tenant_id_raises(self, bad_rule): - self.rules['admin_or_owner'] = common_policy.parse_rule(bad_rule) - # Trigger a policy with rule admin_or_owner - action = "create_network" - target = {'tenant_id': 'fake'} - policy.init() - self.assertRaises(exceptions.PolicyCheckError, - policy.enforce, - self.context, action, target) - - def test_enforce_tenant_id_check_malformed_target_field_raises(self): - self._test_enforce_tenant_id_raises('tenant_id:%(malformed_field)s') - - def test_enforce_tenant_id_check_invalid_parent_resource_raises(self): - self._test_enforce_tenant_id_raises('tenant_id:%(foobaz_tenant_id)s') - - def test_get_roles_context_is_admin_rule_missing(self): - rules = dict((k, common_policy.parse_rule(v)) for k, v in { - "some_other_rule": "role:admin", - }.items()) - common_policy.set_rules(common_policy.Rules(rules)) - # 'admin' role is expected for bw compatibility - self.assertEqual(['admin'], policy.get_admin_roles()) - - def test_get_roles_with_role_check(self): - rules = dict((k, common_policy.parse_rule(v)) for k, v in { - policy.ADMIN_CTX_POLICY: "role:admin", - }.items()) - common_policy.set_rules(common_policy.Rules(rules)) - self.assertEqual(['admin'], policy.get_admin_roles()) - - def test_get_roles_with_rule_check(self): - rules = dict((k, common_policy.parse_rule(v)) for k, v in { - policy.ADMIN_CTX_POLICY: "rule:some_other_rule", - "some_other_rule": "role:admin", - }.items()) - common_policy.set_rules(common_policy.Rules(rules)) - self.assertEqual(['admin'], policy.get_admin_roles()) - - def test_get_roles_with_or_check(self): - self.rules = dict((k, common_policy.parse_rule(v)) for k, v in { - policy.ADMIN_CTX_POLICY: "rule:rule1 or rule:rule2", - "rule1": "role:admin_1", - "rule2": "role:admin_2" - }.items()) - self.assertEqual(['admin_1', 'admin_2'], - policy.get_admin_roles()) - - def test_get_roles_with_other_rules(self): - self.rules = dict((k, common_policy.parse_rule(v)) for k, v in { - policy.ADMIN_CTX_POLICY: "role:xxx or other:value", - }.items()) - self.assertEqual(['xxx'], policy.get_admin_roles()) - - def _test_set_rules_with_deprecated_policy(self, input_rules, - expected_rules): - policy._set_rules(json.dumps(input_rules)) - # verify deprecated policy has been removed - for pol in input_rules.keys(): - self.assertNotIn(pol, common_policy._rules) - # verify deprecated policy was correctly translated. Iterate - # over items for compatibility with unittest2 in python 2.6 - for rule in expected_rules: - self.assertIn(rule, common_policy._rules) - self.assertEqual(expected_rules[rule], - str(common_policy._rules[rule])) - - def test_set_rules_with_deprecated_view_policy(self): - self._test_set_rules_with_deprecated_policy( - {'extension:router:view': 'rule:admin_or_owner'}, - {'get_network:router:external': 'rule:admin_or_owner'}) - - def test_set_rules_with_deprecated_set_policy(self): - expected_policies = ['create_network:provider:network_type', - 'create_network:provider:physical_network', - 'create_network:provider:segmentation_id', - 'update_network:provider:network_type', - 'update_network:provider:physical_network', - 'update_network:provider:segmentation_id'] - self._test_set_rules_with_deprecated_policy( - {'extension:provider_network:set': 'rule:admin_only'}, - dict((policy, 'rule:admin_only') for policy in - expected_policies)) diff --git a/apmec/tests/unit/test_post_mortem_debug.py b/apmec/tests/unit/test_post_mortem_debug.py deleted file mode 100644 index eaa9156..0000000 --- a/apmec/tests/unit/test_post_mortem_debug.py +++ /dev/null @@ -1,99 +0,0 @@ -# Copyright 2013 Red Hat, Inc. -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, 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 sys - -import mock -from six import moves - -from apmec.tests import base -from apmec.tests import post_mortem_debug - - -class TestTesttoolsExceptionHandler(base.BaseTestCase): - - def test_exception_handler(self): - try: - self.assertTrue(False) - except Exception: - exc_info = sys.exc_info() - with mock.patch('traceback.print_exception') as mock_print_exception: - with mock.patch('pdb.post_mortem') as mock_post_mortem: - with mock.patch.object(post_mortem_debug, - 'get_ignored_traceback', - return_value=mock.Mock()): - post_mortem_debug.exception_handler(exc_info) - - # traceback will become post_mortem_debug.FilteredTraceback - filtered_exc_info = (exc_info[0], exc_info[1], mock.ANY) - mock_print_exception.assert_called_once_with(*filtered_exc_info) - mock_post_mortem.assert_called_once_with(mock.ANY) - - -class TestFilteredTraceback(base.BaseTestCase): - - def test_filter_traceback(self): - tb1 = mock.Mock() - tb2 = mock.Mock() - tb1.tb_next = tb2 - tb2.tb_next = None - ftb1 = post_mortem_debug.FilteredTraceback(tb1, tb2) - for attr in ['lasti', 'lineno', 'frame']: - attr_name = 'tb_%s' % attr - self.assertEqual(getattr(tb1, attr_name, None), - getattr(ftb1, attr_name, None)) - self.assertIsNone(ftb1.tb_next) - - -class TestGetIgnoredTraceback(base.BaseTestCase): - - def _test_get_ignored_traceback(self, ignored_bit_array, expected): - root_tb = mock.Mock() - - tb = root_tb - tracebacks = [tb] - for x in moves.xrange(len(ignored_bit_array) - 1): - tb.tb_next = mock.Mock() - tb = tb.tb_next - tracebacks.append(tb) - tb.tb_next = None - - tb = root_tb - for ignored in ignored_bit_array: - if ignored: - tb.tb_frame.f_globals = ['__unittest'] - else: - tb.tb_frame.f_globals = [] - tb = tb.tb_next - - actual = post_mortem_debug.get_ignored_traceback(root_tb) - if expected is not None: - expected = tracebacks[expected] - self.assertEqual(expected, actual) - - def test_no_ignored_tracebacks(self): - self._test_get_ignored_traceback([0, 0, 0], None) - - def test_single_member_trailing_chain(self): - self._test_get_ignored_traceback([0, 0, 1], 2) - - def test_two_member_trailing_chain(self): - self._test_get_ignored_traceback([0, 1, 1], 1) - - def test_first_traceback_ignored(self): - self._test_get_ignored_traceback([1, 0, 0], None) - - def test_middle_traceback_ignored(self): - self._test_get_ignored_traceback([0, 1, 0], None) diff --git a/apmec/tests/unit/test_tacker_context.py b/apmec/tests/unit/test_tacker_context.py deleted file mode 100644 index ac553ad..0000000 --- a/apmec/tests/unit/test_tacker_context.py +++ /dev/null @@ -1,141 +0,0 @@ -# Copyright 2012 VMware, Inc. -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, 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 mock -from oslo_context import context as oslo_context -from testtools import matchers - -from apmec import context -from apmec.tests import base - - -class TestApmecContext(base.BaseTestCase): - - def setUp(self): - super(TestApmecContext, self).setUp() - self.skip("Not ready yet") - db_api = 'apmec.db.api.get_session' - self._db_api_session_patcher = mock.patch(db_api) - self.db_api_session = self._db_api_session_patcher.start() - - def test_apmec_context_create(self): - ctx = context.Context('user_id', 'tenant_id') - self.assertEqual('user_id', ctx.user_id) - self.assertEqual('tenant_id', ctx.project_id) - self.assertEqual('tenant_id', ctx.tenant_id) - self.assertThat(ctx.request_id, matchers.StartsWith('req-')) - self.assertEqual('user_id', ctx.user) - self.assertEqual('tenant_id', ctx.tenant) - self.assertIsNone(ctx.user_name) - self.assertIsNone(ctx.tenant_name) - - def test_apmec_context_create_logs_unknown_kwarg(self): - with mock.patch.object(context.LOG, 'debug') as mock_log: - context.Context('user_id', 'tenant_id', foo=None) - self.assertEqual(1, mock_log.call_count) - - def test_apmec_context_create_with_name(self): - ctx = context.Context('user_id', 'tenant_id', - tenant_name='tenant_name', user_name='user_name') - # Check name is set - self.assertEqual('user_name', ctx.user_name) - self.assertEqual('tenant_name', ctx.tenant_name) - # Check user/tenant contains its ID even if user/tenant_name is passed - self.assertEqual('user_id', ctx.user) - self.assertEqual('tenant_id', ctx.tenant) - - def test_apmec_context_create_with_request_id(self): - ctx = context.Context('user_id', 'tenant_id', request_id='req_id_xxx') - self.assertEqual('req_id_xxx', ctx.request_id) - - def test_apmec_context_to_dict(self): - ctx = context.Context('user_id', 'tenant_id') - ctx_dict = ctx.to_dict() - self.assertEqual('user_id', ctx_dict['user_id']) - self.assertEqual('tenant_id', ctx_dict['project_id']) - self.assertEqual(ctx.request_id, ctx_dict['request_id']) - self.assertEqual('user_id', ctx_dict['user']) - self.assertEqual('tenant_id', ctx_dict['tenant']) - self.assertIsNone(ctx_dict['user_name']) - self.assertIsNone(ctx_dict['tenant_name']) - self.assertIsNone(ctx_dict['project_name']) - - def test_apmec_context_to_dict_with_name(self): - ctx = context.Context('user_id', 'tenant_id', - tenant_name='tenant_name', user_name='user_name') - ctx_dict = ctx.to_dict() - self.assertEqual('user_name', ctx_dict['user_name']) - self.assertEqual('tenant_name', ctx_dict['tenant_name']) - self.assertEqual('tenant_name', ctx_dict['project_name']) - - def test_apmec_context_admin_to_dict(self): - self.db_api_session.return_value = 'fakesession' - ctx = context.get_admin_context() - ctx_dict = ctx.to_dict() - self.assertIsNone(ctx_dict['user_id']) - self.assertIsNone(ctx_dict['tenant_id']) - self.assertIsNotNone(ctx.session) - self.assertNotIn('session', ctx_dict) - - def test_apmec_context_admin_without_session_to_dict(self): - ctx = context.get_admin_context_without_session() - ctx_dict = ctx.to_dict() - self.assertIsNone(ctx_dict['user_id']) - self.assertIsNone(ctx_dict['tenant_id']) - self.assertFalse(hasattr(ctx, 'session')) - - def test_apmec_context_with_load_roles_true(self): - ctx = context.get_admin_context() - self.assertIn('admin', ctx.roles) - - def test_apmec_context_with_load_roles_false(self): - ctx = context.get_admin_context(load_admin_roles=False) - self.assertFalse(ctx.roles) - - def test_apmec_context_elevated_retains_request_id(self): - ctx = context.Context('user_id', 'tenant_id') - self.assertFalse(ctx.is_admin) - req_id_before = ctx.request_id - - elevated_ctx = ctx.elevated() - self.assertTrue(elevated_ctx.is_admin) - self.assertEqual(req_id_before, elevated_ctx.request_id) - - def test_apmec_context_overwrite(self): - ctx1 = context.Context('user_id', 'tenant_id') - self.assertEqual(oslo_context.get_current().request_id, - ctx1.request_id) - - # If overwrite is not specified, request_id should be updated. - ctx2 = context.Context('user_id', 'tenant_id') - self.assertNotEqual(ctx2.request_id, ctx1.request_id) - self.assertEqual(oslo_context.get_current().request_id, - ctx2.request_id) - - # If overwrite is specified, request_id should be kept. - ctx3 = context.Context('user_id', 'tenant_id', overwrite=False) - self.assertNotEqual(ctx3.request_id, ctx2.request_id) - self.assertEqual(oslo_context.get_current().request_id, - ctx2.request_id) - - def test_apmec_context_get_admin_context_not_update_local_store(self): - ctx = context.Context('user_id', 'tenant_id') - req_id_before = oslo_context.get_current().request_id - self.assertEqual(req_id_before, ctx.request_id) - - ctx_admin = context.get_admin_context() - self.assertEqual(req_id_before, - oslo_context.get_current().request_id) - self.assertNotEqual(req_id_before, ctx_admin.request_id) diff --git a/apmec/tests/unit/test_tosca_templates_under_samples.py b/apmec/tests/unit/test_tosca_templates_under_samples.py deleted file mode 100644 index 90e8073..0000000 --- a/apmec/tests/unit/test_tosca_templates_under_samples.py +++ /dev/null @@ -1,91 +0,0 @@ -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, 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 os - -import testtools -from toscaparser import tosca_template -from toscaparser.utils import yamlparser -from translator.hot import tosca_translator - -from apmec.catalogs.tosca import utils - - -class TestSamples(testtools.TestCase): - """Sample tosca validation. - - Helps to validate the tosca templates provided in the samples folder - to make sure whether its valid YAML, valid TOSCA and - possible to translate into HOT template. - """ - - def _get_list_of_sample(self, tosca_files): - if tosca_files: - base_path = (os.path.dirname(os.path.abspath(__file__)) + - '/../../../samples/tosca-templates/mead/') - if isinstance(tosca_files, list): - list_of_samples = [] - for tosca_file in tosca_files: - sample = base_path + tosca_file - list_of_samples.append(sample) - return list_of_samples - - def _test_samples(self, files): - if files: - for f in self._get_list_of_sample(files): - with open(f, 'r') as _f: - yaml_dict = None - try: - yaml_dict = yamlparser.simple_ordered_parse(_f.read()) - except: # noqa - pass - self.assertIsNotNone( - yaml_dict, - "Yaml parser failed to parse %s" % f) - - utils.updateimports(yaml_dict) - - tosca = None - try: - tosca = tosca_template.ToscaTemplate( - a_file=False, - yaml_dict_tpl=yaml_dict) - except: # noqa - pass - - self.assertIsNotNone( - tosca, - "Tosca parser failed to parse %s" % f) - utils.post_process_template(tosca) - hot = None - try: - hot = tosca_translator.TOSCATranslator(tosca, - {}).translate() - except: # noqa - pass - - self.assertIsNotNone( - hot, - "Heat-translator failed to translate %s" % f) - - def test_scale_sample(self, tosca_file=['tosca-mead-scale.yaml']): - self._test_samples(tosca_file) - - def test_alarm_sample(self, tosca_file=['tosca-mead-alarm-scale.yaml']): - self._test_samples(tosca_file) - - def test_list_samples(self, - files=['tosca-mead-scale.yaml', - 'tosca-mead-alarm-scale.yaml']): - self._test_samples(files) diff --git a/apmec/tests/unit/test_wsgi.py b/apmec/tests/unit/test_wsgi.py deleted file mode 100644 index b19b192..0000000 --- a/apmec/tests/unit/test_wsgi.py +++ /dev/null @@ -1,752 +0,0 @@ -# Copyright 2013 OpenStack Foundation. -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, 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 os -import socket - -import mock -from oslo_config import cfg -import six.moves.urllib.request as urllibrequest -import testtools -import webob -import webob.exc - -from apmec.common import exceptions as exception -from apmec.tests import base -from apmec import wsgi - -CONF = cfg.CONF - -TEST_VAR_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), - '..', 'var')) - - -class TestWSGIServer(base.BaseTestCase): - """WSGI server tests.""" - - def test_start_random_port(self): - server = wsgi.Server("test_random_port") - server.start(None, 0, host="127.0.0.1") - self.assertNotEqual(0, server.port) - server.stop() - server.wait() - - @mock.patch('oslo_service.service.ProcessLauncher') - def test_start_multiple_workers(self, ProcessLauncher): - launcher = ProcessLauncher.return_value - - server = wsgi.Server("test_multiple_processes") - server.start(None, 0, host="127.0.0.1", workers=2) - launcher.running = True - launcher.launch_service.assert_called_once_with(server._server, - workers=2) - - server.stop() - self.assertFalse(launcher.running) - - server.wait() - launcher.wait.assert_called_once_with() - - def test_start_random_port_with_ipv6(self): - server = wsgi.Server("test_random_port") - server.start(None, 0, host="::1") - self.assertEqual("::1", server.host) - self.assertNotEqual(0, server.port) - server.stop() - server.wait() - - def test_ipv6_listen_called_with_scope(self): - self.skipTest("Not ready yet") - server = wsgi.Server("test_app") - - with mock.patch.object(wsgi.eventlet, 'listen') as mock_listen: - with mock.patch.object(socket, 'getaddrinfo') as mock_get_addr: - mock_get_addr.return_value = [ - (socket.AF_INET6, - socket.SOCK_STREAM, - socket.IPPROTO_TCP, - '', - ('fe80::204:acff:fe96:da87%eth0', 1234, 0, 2)) - ] - with mock.patch.object(server, 'pool') as mock_pool: - server.start(None, - 1234, - host="fe80::204:acff:fe96:da87%eth0") - - mock_get_addr.assert_called_once_with( - "fe80::204:acff:fe96:da87%eth0", - 1234, - socket.AF_UNSPEC, - socket.SOCK_STREAM - ) - - mock_listen.assert_called_once_with( - ('fe80::204:acff:fe96:da87%eth0', 1234, 0, 2), - family=socket.AF_INET6, - backlog=cfg.CONF.backlog - ) - - mock_pool.spawn.assert_has_calls([ - mock.call( - server._run, - None, - mock_listen.return_value) - ]) - - def test_app(self): - self.skipTest("Not ready yet") - greetings = 'Hello, World!!!' - - def hello_world(env, start_response): - if env['PATH_INFO'] != '/': - start_response('404 Not Found', - [('Content-Type', 'text/plain')]) - return ['Not Found\r\n'] - start_response('200 OK', [('Content-Type', 'text/plain')]) - return [greetings] - - server = wsgi.Server("test_app") - server.start(hello_world, 0, host="127.0.0.1") - - response = urllibrequest.urlopen('http://127.0.0.1:%d/' % server.port) - self.assertEqual(greetings, response.read()) - - server.stop() - - -class SerializerTest(base.BaseTestCase): - def test_serialize_unknown_content_type(self): - """Verify that exception InvalidContentType is raised.""" - input_dict = {'servers': {'test': 'pass'}} - content_type = 'application/unknown' - serializer = wsgi.Serializer() - - self.assertRaises( - exception.InvalidContentType, serializer.serialize, - input_dict, content_type) - - def test_get_deserialize_handler_unknown_content_type(self): - """Verify that exception InvalidContentType is raised.""" - content_type = 'application/unknown' - serializer = wsgi.Serializer() - - self.assertRaises( - exception.InvalidContentType, - serializer.get_deserialize_handler, content_type) - - def test_serialize_content_type_json(self): - """Test serialize with content type json.""" - input_data = {'servers': ['test=pass']} - content_type = 'application/json' - serializer = wsgi.Serializer() - result = serializer.serialize(input_data, content_type) - - self.assertEqual(b'{"servers": ["test=pass"]}', result) - - def test_deserialize_raise_bad_request(self): - """Test serialize verifies that exception is raises.""" - content_type = 'application/unknown' - data_string = 'test' - serializer = wsgi.Serializer() - - self.assertRaises( - webob.exc.HTTPBadRequest, - serializer.deserialize, data_string, content_type) - - def test_deserialize_json_content_type(self): - """Test Serializer.deserialize with content type json.""" - content_type = 'application/json' - data_string = '{"servers": ["test=pass"]}' - serializer = wsgi.Serializer() - result = serializer.deserialize(data_string, content_type) - - self.assertEqual({'body': {u'servers': [u'test=pass']}}, result) - - -class RequestDeserializerTest(testtools.TestCase): - def setUp(self): - super(RequestDeserializerTest, self).setUp() - - class JSONDeserializer(object): - def deserialize(self, data, action='default'): - return b'pew_json' - - self.body_deserializers = {'application/json': JSONDeserializer()} - self.deserializer = wsgi.RequestDeserializer(self.body_deserializers) - - def test_get_deserializer(self): - """Test RequestDeserializer.get_body_deserializer.""" - expected_json_serializer = self.deserializer.get_body_deserializer( - 'application/json') - - self.assertEqual( - expected_json_serializer, - self.body_deserializers['application/json']) - - def test_get_expected_content_type(self): - """Test RequestDeserializer.get_expected_content_type.""" - request = wsgi.Request.blank('/') - request.headers['Accept'] = 'application/json' - - self.assertEqual( - 'application/json', - self.deserializer.get_expected_content_type(request)) - - def test_get_action_args(self): - """Test RequestDeserializer.get_action_args.""" - env = { - 'wsgiorg.routing_args': [None, { - 'controller': None, - 'format': None, - 'action': 'update', - 'id': 12}]} - expected = {'action': 'update', 'id': 12} - - self.assertEqual( - expected, self.deserializer.get_action_args(env)) - - def test_deserialize(self): - """Test RequestDeserializer.deserialize.""" - with mock.patch.object( - self.deserializer, 'get_action_args') as mock_method: - mock_method.return_value = {'action': 'create'} - request = wsgi.Request.blank('/') - request.headers['Accept'] = 'application/json' - deserialized = self.deserializer.deserialize(request) - expected = ('create', {}, 'application/json') - - self.assertEqual(expected, deserialized) - - def test_get_body_deserializer_unknown_content_type(self): - """Verify that exception InvalidContentType is raised.""" - content_type = 'application/unknown' - deserializer = wsgi.RequestDeserializer() - self.assertRaises( - exception.InvalidContentType, - deserializer.get_body_deserializer, content_type) - - -class ResponseSerializerTest(testtools.TestCase): - def setUp(self): - super(ResponseSerializerTest, self).setUp() - - class JSONSerializer(object): - def serialize(self, data, action='default'): - return b'pew_json' - - class HeadersSerializer(object): - def serialize(self, response, data, action): - response.status_int = 404 - - self.body_serializers = {'application/json': JSONSerializer()} - - self.serializer = wsgi.ResponseSerializer( - self.body_serializers, HeadersSerializer()) - - def test_serialize_unknown_content_type(self): - """Verify that exception InvalidContentType is raised.""" - self.assertRaises( - exception.InvalidContentType, - self.serializer.serialize, - {}, 'application/unknown') - - def test_get_body_serializer(self): - """Verify that exception InvalidContentType is raised.""" - self.assertRaises( - exception.InvalidContentType, - self.serializer.get_body_serializer, 'application/unknown') - - def test_get_serializer(self): - """Test ResponseSerializer.get_body_serializer.""" - content_type = 'application/json' - self.assertEqual( - self.serializer.get_body_serializer(content_type), - self.body_serializers[content_type]) - - def test_serialize_json_response(self): - response = self.serializer.serialize({}, 'application/json') - - self.assertEqual('application/json', response.headers['Content-Type']) - self.assertEqual(b'pew_json', response.body) - self.assertEqual(404, response.status_int) - - def test_serialize_response_None(self): - response = self.serializer.serialize( - None, 'application/json') - - self.assertEqual('application/json', response.headers['Content-Type']) - self.assertEqual(b'', response.body) - self.assertEqual(404, response.status_int) - - -class RequestTest(base.BaseTestCase): - - def test_content_type_missing(self): - request = wsgi.Request.blank('/tests/123', method='POST') - request.body = b"" - - self.assertIsNone(request.get_content_type()) - - def test_content_type_unsupported(self): - request = wsgi.Request.blank('/tests/123', method='POST') - request.headers["Content-Type"] = "text/html" - request.body = b"fake
" - - self.assertIsNone(request.get_content_type()) - - def test_content_type_with_charset(self): - request = wsgi.Request.blank('/tests/123') - request.headers["Content-Type"] = "application/json; charset=UTF-8" - result = request.get_content_type() - - self.assertEqual("application/json", result) - - def test_content_type_with_given_content_types(self): - request = wsgi.Request.blank('/tests/123') - request.headers["Content-Type"] = "application/new-type;" - - self.assertIsNone(request.get_content_type()) - - def test_content_type_from_accept(self): - request = wsgi.Request.blank('/tests/123') - request.headers["Accept"] = "application/json" - result = request.best_match_content_type() - - self.assertEqual("application/json", result) - - request = wsgi.Request.blank('/tests/123') - request.headers["Accept"] = "application/json" - result = request.best_match_content_type() - - self.assertEqual("application/json", result) - - request = wsgi.Request.blank('/tests/123') - request.headers["Accept"] = "application/json" - result = request.best_match_content_type() - - self.assertEqual("application/json", result) - - def test_content_type_from_query_extension(self): - request = wsgi.Request.blank('/tests/123.json') - result = request.best_match_content_type() - - self.assertEqual("application/json", result) - - request = wsgi.Request.blank('/tests/123.invalid') - result = request.best_match_content_type() - - self.assertEqual("application/json", result) - - def test_content_type_accept_and_query_extension(self): - request = wsgi.Request.blank('/tests/123.json') - request.headers["Accept"] = "application/json" - result = request.best_match_content_type() - - self.assertEqual("application/json", result) - - def test_content_type_accept_default(self): - request = wsgi.Request.blank('/tests/123.unsupported') - request.headers["Accept"] = "application/unsupported1" - result = request.best_match_content_type() - - self.assertEqual("application/json", result) - - def test_content_type_accept_with_given_content_types(self): - request = wsgi.Request.blank('/tests/123') - request.headers["Accept"] = "application/new_type" - result = request.best_match_content_type() - - self.assertEqual('application/json', result) - - -class ActionDispatcherTest(base.BaseTestCase): - def test_dispatch(self): - """Test ActionDispatcher.dispatch.""" - serializer = wsgi.ActionDispatcher() - serializer.create = lambda x: x - - self.assertEqual( - 'pants', - serializer.dispatch('pants', action='create')) - - def test_dispatch_action_None(self): - """Test ActionDispatcher.dispatch with none action.""" - serializer = wsgi.ActionDispatcher() - serializer.create = lambda x: x + ' pants' - serializer.default = lambda x: x + ' trousers' - - self.assertEqual( - 'Two trousers', - serializer.dispatch('Two', action=None)) - - def test_dispatch_default(self): - serializer = wsgi.ActionDispatcher() - serializer.create = lambda x: x + ' pants' - serializer.default = lambda x: x + ' trousers' - - self.assertEqual( - 'Two trousers', - serializer.dispatch('Two', action='update')) - - -class ResponseHeadersSerializerTest(base.BaseTestCase): - def test_default(self): - serializer = wsgi.ResponseHeaderSerializer() - response = webob.Response() - serializer.serialize(response, {'v': '123'}, 'fake') - - self.assertEqual(200, response.status_int) - - def test_custom(self): - class Serializer(wsgi.ResponseHeaderSerializer): - def update(self, response, data): - response.status_int = 404 - response.headers['X-Custom-Header'] = data['v'] - serializer = Serializer() - response = webob.Response() - serializer.serialize(response, {'v': '123'}, 'update') - - self.assertEqual(404, response.status_int) - self.assertEqual('123', response.headers['X-Custom-Header']) - - -class DictSerializerTest(base.BaseTestCase): - - def test_dispatch_default(self): - serializer = wsgi.DictSerializer() - self.assertEqual( - '', serializer.serialize({}, 'NonExistentAction')) - - -class JSONDictSerializerTest(base.BaseTestCase): - - def test_json(self): - input_dict = dict(servers=dict(a=(2, 3))) - expected_json = b'{"servers":{"a":[2,3]}}' - serializer = wsgi.JSONDictSerializer() - result = serializer.serialize(input_dict) - result = result.replace(b'\n', b'').replace(b' ', b'') - - self.assertEqual(expected_json, result) - - def test_json_with_utf8(self): - data = b'{"a": "\xe7\xbd\x91\xe7\xbb\x9c"}' - as_dict = {'body': {'a': u'\u7f51\u7edc'}} - deserializer = wsgi.JSONDeserializer() - self.assertEqual(as_dict, - deserializer.deserialize(data)) - - def test_json_with_unicode(self): - data = b'{"a": "\u7f51\u7edc"}' - as_dict = {'body': {'a': u'\u7f51\u7edc'}} - deserializer = wsgi.JSONDeserializer() - self.assertEqual(as_dict, - deserializer.deserialize(data)) - - -class TextDeserializerTest(base.BaseTestCase): - - def test_dispatch_default(self): - deserializer = wsgi.TextDeserializer() - self.assertEqual( - {}, deserializer.deserialize({}, 'update')) - - -class JSONDeserializerTest(base.BaseTestCase): - def test_json(self): - data = """{"a": { - "a1": "1", - "a2": "2", - "bs": ["1", "2", "3", {"c": {"c1": "1"}}], - "d": {"e": "1"}, - "f": "1"}}""" - as_dict = { - 'body': { - 'a': { - 'a1': '1', - 'a2': '2', - 'bs': ['1', '2', '3', {'c': {'c1': '1'}}], - 'd': {'e': '1'}, - 'f': '1'}}} - deserializer = wsgi.JSONDeserializer() - self.assertEqual( - as_dict, deserializer.deserialize(data)) - - def test_default_raise_Malformed_Exception(self): - """Test JsonDeserializer.default. - - Test verifies JsonDeserializer.default raises exception - MalformedRequestBody correctly. - """ - data_string = "" - deserializer = wsgi.JSONDeserializer() - - self.assertRaises( - exception.MalformedRequestBody, deserializer.default, data_string) - - def test_json_with_utf8(self): - data = b'{"a": "\xe7\xbd\x91\xe7\xbb\x9c"}' - as_dict = {'body': {'a': u'\u7f51\u7edc'}} - deserializer = wsgi.JSONDeserializer() - self.assertEqual(as_dict, - deserializer.deserialize(data)) - - def test_json_with_unicode(self): - data = b'{"a": "\u7f51\u7edc"}' - as_dict = {'body': {'a': u'\u7f51\u7edc'}} - deserializer = wsgi.JSONDeserializer() - self.assertEqual(as_dict, - deserializer.deserialize(data)) - - -class RequestHeadersDeserializerTest(base.BaseTestCase): - - def test_default(self): - deserializer = wsgi.RequestHeadersDeserializer() - req = wsgi.Request.blank('/') - - self.assertEqual( - {}, deserializer.deserialize(req, 'nonExistent')) - - def test_custom(self): - class Deserializer(wsgi.RequestHeadersDeserializer): - def update(self, request): - return {'a': request.headers['X-Custom-Header']} - deserializer = Deserializer() - req = wsgi.Request.blank('/') - req.headers['X-Custom-Header'] = 'b' - self.assertEqual( - {'a': 'b'}, deserializer.deserialize(req, 'update')) - - -class ResourceTest(base.BaseTestCase): - def test_dispatch(self): - class Controller(object): - def index(self, request, index=None): - return index - - def my_fault_body_function(): - return 'off' - - resource = wsgi.Resource(Controller(), my_fault_body_function) - actual = resource.dispatch( - resource.controller, 'index', action_args={'index': 'off'}) - expected = 'off' - - self.assertEqual(expected, actual) - - def test_dispatch_unknown_controller_action(self): - class Controller(object): - def index(self, request, pants=None): - return pants - - def my_fault_body_function(): - return b'off' - - resource = wsgi.Resource(Controller(), my_fault_body_function) - self.assertRaises( - AttributeError, resource.dispatch, - resource.controller, 'create', {}) - - def test_malformed_request_body_throws_bad_request(self): - def my_fault_body_function(): - return b'off' - - resource = wsgi.Resource(None, my_fault_body_function) - request = wsgi.Request.blank( - "/", body=b"{mal:formed", method='POST', - headers={'Content-Type': "application/json"}) - - response = resource(request) - self.assertEqual(400, response.status_int) - - def test_wrong_content_type_throws_unsupported_media_type_error(self): - def my_fault_body_function(): - return b'off' - resource = wsgi.Resource(None, my_fault_body_function) - request = wsgi.Request.blank( - "/", body=b"{some:json}", method='POST', - headers={'Content-Type': "xxx"}) - - response = resource(request) - self.assertEqual(400, response.status_int) - - def test_wrong_content_type_server_error(self): - def my_fault_body_function(): - return b'off' - resource = wsgi.Resource(None, my_fault_body_function) - request = wsgi.Request.blank( - "/", method='POST', headers={'Content-Type': "unknow"}) - - response = resource(request) - self.assertEqual(500, response.status_int) - - def test_call_resource_class_bad_request(self): - class Controller(object): - def index(self, request, index=None): - return index - - def my_fault_body_function(): - return b'off' - - class FakeRequest(object): - def __init__(self): - self.url = 'http://where.no' - self.environ = 'environ' - self.body = b'body' - - def method(self): - pass - - def best_match_content_type(self): - return 'best_match_content_type' - - resource = wsgi.Resource(Controller(), my_fault_body_function) - request = FakeRequest() - result = resource(request) - self.assertEqual(400, result.status_int) - - def test_type_error(self): - class Controller(object): - def index(self, request, index=None): - return index - - def my_fault_body_function(): - return b'off' - resource = wsgi.Resource(Controller(), my_fault_body_function) - request = wsgi.Request.blank( - "/", method='POST', headers={'Content-Type': "json"}) - - response = resource.dispatch( - request, action='index', action_args='test') - self.assertEqual(400, response.status_int) - - def test_call_resource_class_internal_error(self): - class Controller(object): - def index(self, request, index=None): - return index - - def my_fault_body_function(): - return b'off' - - class FakeRequest(object): - def __init__(self): - self.url = 'http://where.no' - self.environ = 'environ' - self.body = b'{"Content-Type": "json"}' - - def method(self): - pass - - def best_match_content_type(self): - return 'application/json' - - resource = wsgi.Resource(Controller(), my_fault_body_function) - request = FakeRequest() - result = resource(request) - self.assertEqual(500, result.status_int) - - -class MiddlewareTest(base.BaseTestCase): - def test_process_response(self): - def application(environ, start_response): - response = 'Success' - return response - response = application('test', 'fake') - result = wsgi.Middleware(application).process_response(response) - self.assertEqual('Success', result) - - -class FaultTest(base.BaseTestCase): - def test_call_fault(self): - class MyException(object): - status_int = 415 - explanation = 'test' - - my_exceptions = MyException() - my_fault = wsgi.Fault(exception=my_exceptions) - request = wsgi.Request.blank( - "/", method='POST', headers={'Content-Type': "unknow"}) - response = my_fault(request) - self.assertEqual(415, response.status_int) - - -class TestWSGIServerWithSSL(base.BaseTestCase): - """WSGI server tests.""" - - def setUp(self): - super(TestWSGIServerWithSSL, self).setUp() - self.skip("Not ready yet") - - def test_app_using_ssl(self): - CONF.set_default('use_ssl', True) - CONF.set_default("ssl_cert_file", - os.path.join(TEST_VAR_DIR, 'certificate.crt')) - CONF.set_default("ssl_key_file", - os.path.join(TEST_VAR_DIR, 'privatekey.key')) - - greetings = 'Hello, World!!!' - - @webob.dec.wsgify - def hello_world(req): - return greetings - - server = wsgi.Server("test_app") - server.start(hello_world, 0, host="127.0.0.1") - - response = urllibrequest.urlopen('https://127.0.0.1:%d/' % server.port) - self.assertEqual(greetings, response.read()) - - server.stop() - - def test_app_using_ssl_combined_cert_and_key(self): - CONF.set_default('use_ssl', True) - CONF.set_default("ssl_cert_file", - os.path.join(TEST_VAR_DIR, 'certandkey.pem')) - - greetings = 'Hello, World!!!' - - @webob.dec.wsgify - def hello_world(req): - return greetings - - server = wsgi.Server("test_app") - server.start(hello_world, 0, host="127.0.0.1") - - response = urllibrequest.urlopen('https://127.0.0.1:%d/' % server.port) - self.assertEqual(greetings, response.read()) - - server.stop() - - def test_app_using_ipv6_and_ssl(self): - CONF.set_default('use_ssl', True) - CONF.set_default("ssl_cert_file", - os.path.join(TEST_VAR_DIR, 'certificate.crt')) - CONF.set_default("ssl_key_file", - os.path.join(TEST_VAR_DIR, 'privatekey.key')) - - greetings = 'Hello, World!!!' - - @webob.dec.wsgify - def hello_world(req): - return greetings - - server = wsgi.Server("test_app") - server.start(hello_world, 0, host="::1") - - response = urllibrequest.urlopen('https://[::1]:%d/' % server.port) - self.assertEqual(greetings, response.read()) - - server.stop() diff --git a/apmec/tests/unit/testlib_api.py b/apmec/tests/unit/testlib_api.py deleted file mode 100644 index b6dfe51..0000000 --- a/apmec/tests/unit/testlib_api.py +++ /dev/null @@ -1,82 +0,0 @@ -# Copyright 2012 OpenStack Foundation -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, 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 testtools - -from apmec.tests import base -from apmec import wsgi - - -class ExpectedException(testtools.ExpectedException): - def __enter__(self): - return self - - def __exit__(self, exc_type, exc_value, traceback): - if super(ExpectedException, self).__exit__(exc_type, - exc_value, - traceback): - self.exception = exc_value - return True - return False - - -def create_request(path, body, content_type, method='GET', - query_string=None, context=None): - if query_string: - url = "%s?%s" % (path, query_string) - else: - url = path - req = wsgi.Request.blank(url) - req.method = method - req.headers = {} - req.headers['Accept'] = content_type - req.body = body - if context: - req.environ['apmec.context'] = context - return req - - -class WebTestCase(base.BaseTestCase): - fmt = 'json' - - def setUp(self): - super(WebTestCase, self).setUp() - json_deserializer = wsgi.JSONDeserializer() - self._deserializers = { - 'application/json': json_deserializer, - } - - def deserialize(self, response): - ctype = 'application/%s' % self.fmt - data = self._deserializers[ctype].deserialize(response.body)['body'] - return data - - def serialize(self, data): - ctype = 'application/%s' % self.fmt - result = wsgi.Serializer().serialize(data, ctype) - return result - - -class SubDictMatch(object): - - def __init__(self, sub_dict): - self.sub_dict = sub_dict - - def __eq__(self, super_dict): - return all(item in super_dict.items() - for item in self.sub_dict.items()) - - def __ne__(self, super_dict): - return not self.__eq__(super_dict) diff --git a/devstack/lib/apmec b/devstack/lib/apmec index 1aa4a0e..c6a3f4a 100644 --- a/devstack/lib/apmec +++ b/devstack/lib/apmec @@ -40,6 +40,8 @@ if is_ssl_enabled_service "apmec" || is_service_enabled tls-proxy; then APMEC_PROTOCOL="https" fi +CUSTOM_GIT_BASE=${CUSTOM_GIT_BASE:-https://www.github.com/pineunity} + # Set up default directories GITREPO["apmec-horizon"]=${APMECHORIZON_REPO:-${GIT_BASE}/apmec-horizon.git} GITBRANCH["apmec-horizon"]=${APMECHORIZON_BRANCH:-master} @@ -49,13 +51,13 @@ GITREPO["python-apmecclient"]=${APMECHORIZON_REPO:-${GIT_BASE}/python-apmecclien GITBRANCH["python-apmecclient"]=${APMECHORIZON_BRANCH:-apmec-nfv} GITDIR["python-apmecclient"]=$DEST/python-apmecclient -#GITREPO["mec-tosca-parser"]=${APMECHORIZON_REPO:-${GIT_BASE}/mec-tosca-parser.git} -#GITBRANCH["mec-tosca-parser"]=${APMECHORIZON_BRANCH:-master} -#GITDIR["mec-tosca-parser"]=/$LIB_DEST/toscaparser +GITREPO["mec-tosca-parser"]=${APMECHORIZON_REPO:-${CUSTOM_GIT_BASE}/mec-tosca-parser.git} +GITBRANCH["mec-tosca-parser"]=${APMECHORIZON_BRANCH:-master} +GITDIR["mec-tosca-parser"]=/$LIB_DEST/toscaparser -#GITREPO["mec-heat-translator"]=${APMECHORIZON_REPO:-${GIT_BASE}/mec-heat-translator.git} -#GITBRANCH["mec-heat-translator"]=${APMECHORIZON_BRANCH:-master} -#GITDIR["mec-heat-translator"]=$LIB_DEST/heat_translator +GITREPO["mec-heat-translator"]=${APMECHORIZON_REPO:-${CUSTOM_GIT_BASE}/mec-heat-translator.git} +GITBRANCH["mec-heat-translator"]=${APMECHORIZON_BRANCH:-master} +GITDIR["mec-heat-translator"]=$LIB_DEST/heat_translator APMEC_DIR=$DEST/apmec @@ -332,14 +334,14 @@ function _apmec_setup_keystone { configure_auth_token_middleware $conf_file $APMEC_ADMIN_USERNAME $APMEC_AUTH_CACHE_DIR $section } -#function mec_tosca_parser_install { -# sudo pip install ${EXTRA_CUSTOM_BASE}/mec-tosca-parser.git -#} +function mec_tosca_parser_install { + sudo pip install ${CUSTOM_GIT_BASE}/mec-tosca-parser.git +} -#function mec_heat_translator_install { -# sudo pip install ${EXTRA_CUSTOM_BASE}/mec-heat-translator.git +function mec_heat_translator_install { + sudo pip install ${CUSTOM_GIT_BASE}/mec-heat-translator.git -#} +} function apmec_horizon_install { git_clone_by_name "apmec-horizon" diff --git a/devstack/plugin.sh b/devstack/plugin.sh index a8a188c..48dc474 100644 --- a/devstack/plugin.sh +++ b/devstack/plugin.sh @@ -14,10 +14,10 @@ if is_service_enabled apmec; then # Perform installation of service source echo_summary "Installing Apmec" install_apmec -# echo_summary "Installing tosca parser" -# mec_tosca_parser_install -# echo_summary "Installing heat translator" -# mec_heat_translator_install + echo_summary "Installing tosca parser" + mec_tosca_parser_install + echo_summary "Installing heat translator" + mec_heat_translator_install elif [[ "$1" == "stack" && "$2" == "post-config" ]]; then # Configure after the other layer 1 and 2 services have been configured diff --git a/doc/source/api/apmec._i18n.rst b/doc/source/api/apmec._i18n.rst new file mode 100644 index 0000000..89188e8 --- /dev/null +++ b/doc/source/api/apmec._i18n.rst @@ -0,0 +1,7 @@ +The :mod:`apmec._i18n` Module +============================= + +.. automodule:: apmec._i18n + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.agent.linux.utils.rst b/doc/source/api/apmec.agent.linux.utils.rst new file mode 100644 index 0000000..cc460f2 --- /dev/null +++ b/doc/source/api/apmec.agent.linux.utils.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.agent.linux.utils` Module +========================================= + +.. automodule:: apmec.agent.linux.utils + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.alarm_receiver.rst b/doc/source/api/apmec.alarm_receiver.rst new file mode 100644 index 0000000..2625904 --- /dev/null +++ b/doc/source/api/apmec.alarm_receiver.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.alarm_receiver` Module +====================================== + +.. automodule:: apmec.alarm_receiver + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.api.api_common.rst b/doc/source/api/apmec.api.api_common.rst new file mode 100644 index 0000000..496d04e --- /dev/null +++ b/doc/source/api/apmec.api.api_common.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.api.api_common` Module +====================================== + +.. automodule:: apmec.api.api_common + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.api.extensions.rst b/doc/source/api/apmec.api.extensions.rst new file mode 100644 index 0000000..78a84bf --- /dev/null +++ b/doc/source/api/apmec.api.extensions.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.api.extensions` Module +====================================== + +.. automodule:: apmec.api.extensions + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.api.v1.attributes.rst b/doc/source/api/apmec.api.v1.attributes.rst new file mode 100644 index 0000000..394461a --- /dev/null +++ b/doc/source/api/apmec.api.v1.attributes.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.api.v1.attributes` Module +========================================= + +.. automodule:: apmec.api.v1.attributes + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.api.v1.base.rst b/doc/source/api/apmec.api.v1.base.rst new file mode 100644 index 0000000..7b146d9 --- /dev/null +++ b/doc/source/api/apmec.api.v1.base.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.api.v1.base` Module +=================================== + +.. automodule:: apmec.api.v1.base + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.api.v1.resource.rst b/doc/source/api/apmec.api.v1.resource.rst new file mode 100644 index 0000000..b8d77e9 --- /dev/null +++ b/doc/source/api/apmec.api.v1.resource.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.api.v1.resource` Module +======================================= + +.. automodule:: apmec.api.v1.resource + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.api.v1.resource_helper.rst b/doc/source/api/apmec.api.v1.resource_helper.rst new file mode 100644 index 0000000..b323085 --- /dev/null +++ b/doc/source/api/apmec.api.v1.resource_helper.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.api.v1.resource_helper` Module +============================================== + +.. automodule:: apmec.api.v1.resource_helper + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.api.v1.router.rst b/doc/source/api/apmec.api.v1.router.rst new file mode 100644 index 0000000..5e3bbb6 --- /dev/null +++ b/doc/source/api/apmec.api.v1.router.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.api.v1.router` Module +===================================== + +.. automodule:: apmec.api.v1.router + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.api.versions.rst b/doc/source/api/apmec.api.versions.rst new file mode 100644 index 0000000..43e5f00 --- /dev/null +++ b/doc/source/api/apmec.api.versions.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.api.versions` Module +==================================== + +.. automodule:: apmec.api.versions + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.api.views.versions.rst b/doc/source/api/apmec.api.views.versions.rst new file mode 100644 index 0000000..5d7febd --- /dev/null +++ b/doc/source/api/apmec.api.views.versions.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.api.views.versions` Module +========================================== + +.. automodule:: apmec.api.views.versions + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.auth.rst b/doc/source/api/apmec.auth.rst new file mode 100644 index 0000000..3c07036 --- /dev/null +++ b/doc/source/api/apmec.auth.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.auth` Module +============================ + +.. automodule:: apmec.auth + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.catalogs.tosca.utils.rst b/doc/source/api/apmec.catalogs.tosca.utils.rst new file mode 100644 index 0000000..1023ed5 --- /dev/null +++ b/doc/source/api/apmec.catalogs.tosca.utils.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.catalogs.tosca.utils` Module +============================================ + +.. automodule:: apmec.catalogs.tosca.utils + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.cmd.eventlet.apmec_server.rst b/doc/source/api/apmec.cmd.eventlet.apmec_server.rst new file mode 100644 index 0000000..fb31f7b --- /dev/null +++ b/doc/source/api/apmec.cmd.eventlet.apmec_server.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.cmd.eventlet.apmec_server` Module +================================================= + +.. automodule:: apmec.cmd.eventlet.apmec_server + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.cmd.eventlet.conductor.rst b/doc/source/api/apmec.cmd.eventlet.conductor.rst new file mode 100644 index 0000000..bb7519f --- /dev/null +++ b/doc/source/api/apmec.cmd.eventlet.conductor.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.cmd.eventlet.conductor` Module +============================================== + +.. automodule:: apmec.cmd.eventlet.conductor + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.common.clients.rst b/doc/source/api/apmec.common.clients.rst new file mode 100644 index 0000000..d85712c --- /dev/null +++ b/doc/source/api/apmec.common.clients.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.common.clients` Module +====================================== + +.. automodule:: apmec.common.clients + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.common.cmd_executer.rst b/doc/source/api/apmec.common.cmd_executer.rst new file mode 100644 index 0000000..6f3665c --- /dev/null +++ b/doc/source/api/apmec.common.cmd_executer.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.common.cmd_executer` Module +=========================================== + +.. automodule:: apmec.common.cmd_executer + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.common.config.rst b/doc/source/api/apmec.common.config.rst new file mode 100644 index 0000000..237ad9b --- /dev/null +++ b/doc/source/api/apmec.common.config.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.common.config` Module +===================================== + +.. automodule:: apmec.common.config + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.common.constants.rst b/doc/source/api/apmec.common.constants.rst new file mode 100644 index 0000000..7088e93 --- /dev/null +++ b/doc/source/api/apmec.common.constants.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.common.constants` Module +======================================== + +.. automodule:: apmec.common.constants + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.common.driver_manager.rst b/doc/source/api/apmec.common.driver_manager.rst new file mode 100644 index 0000000..2ca577c --- /dev/null +++ b/doc/source/api/apmec.common.driver_manager.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.common.driver_manager` Module +============================================= + +.. automodule:: apmec.common.driver_manager + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.common.eventlet_utils.rst b/doc/source/api/apmec.common.eventlet_utils.rst new file mode 100644 index 0000000..824ee38 --- /dev/null +++ b/doc/source/api/apmec.common.eventlet_utils.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.common.eventlet_utils` Module +============================================= + +.. automodule:: apmec.common.eventlet_utils + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.common.exceptions.rst b/doc/source/api/apmec.common.exceptions.rst new file mode 100644 index 0000000..8dec1b3 --- /dev/null +++ b/doc/source/api/apmec.common.exceptions.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.common.exceptions` Module +========================================= + +.. automodule:: apmec.common.exceptions + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.common.log.rst b/doc/source/api/apmec.common.log.rst new file mode 100644 index 0000000..dcf8399 --- /dev/null +++ b/doc/source/api/apmec.common.log.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.common.log` Module +================================== + +.. automodule:: apmec.common.log + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.common.rpc.rst b/doc/source/api/apmec.common.rpc.rst new file mode 100644 index 0000000..5d37d53 --- /dev/null +++ b/doc/source/api/apmec.common.rpc.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.common.rpc` Module +================================== + +.. automodule:: apmec.common.rpc + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.common.test_lib.rst b/doc/source/api/apmec.common.test_lib.rst new file mode 100644 index 0000000..9f9f1d6 --- /dev/null +++ b/doc/source/api/apmec.common.test_lib.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.common.test_lib` Module +======================================= + +.. automodule:: apmec.common.test_lib + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.common.topics.rst b/doc/source/api/apmec.common.topics.rst new file mode 100644 index 0000000..12dce75 --- /dev/null +++ b/doc/source/api/apmec.common.topics.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.common.topics` Module +===================================== + +.. automodule:: apmec.common.topics + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.common.utils.rst b/doc/source/api/apmec.common.utils.rst new file mode 100644 index 0000000..480235d --- /dev/null +++ b/doc/source/api/apmec.common.utils.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.common.utils` Module +==================================== + +.. automodule:: apmec.common.utils + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.conductor.conductor_server.rst b/doc/source/api/apmec.conductor.conductor_server.rst new file mode 100644 index 0000000..3309218 --- /dev/null +++ b/doc/source/api/apmec.conductor.conductor_server.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.conductor.conductor_server` Module +================================================== + +.. automodule:: apmec.conductor.conductor_server + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.conductor.conductorrpc.vim_monitor_rpc.rst b/doc/source/api/apmec.conductor.conductorrpc.vim_monitor_rpc.rst new file mode 100644 index 0000000..f30c28c --- /dev/null +++ b/doc/source/api/apmec.conductor.conductorrpc.vim_monitor_rpc.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.conductor.conductorrpc.vim_monitor_rpc` Module +============================================================== + +.. automodule:: apmec.conductor.conductorrpc.vim_monitor_rpc + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.context.rst b/doc/source/api/apmec.context.rst new file mode 100644 index 0000000..fff89a6 --- /dev/null +++ b/doc/source/api/apmec.context.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.context` Module +=============================== + +.. automodule:: apmec.context + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.db.api.rst b/doc/source/api/apmec.db.api.rst new file mode 100644 index 0000000..efe43c4 --- /dev/null +++ b/doc/source/api/apmec.db.api.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.db.api` Module +============================== + +.. automodule:: apmec.db.api + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.db.common_services.common_services_db.rst b/doc/source/api/apmec.db.common_services.common_services_db.rst new file mode 100644 index 0000000..7b54aca --- /dev/null +++ b/doc/source/api/apmec.db.common_services.common_services_db.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.db.common_services.common_services_db` Module +============================================================= + +.. automodule:: apmec.db.common_services.common_services_db + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.db.common_services.common_services_db_plugin.rst b/doc/source/api/apmec.db.common_services.common_services_db_plugin.rst new file mode 100644 index 0000000..fa4ca5a --- /dev/null +++ b/doc/source/api/apmec.db.common_services.common_services_db_plugin.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.db.common_services.common_services_db_plugin` Module +==================================================================== + +.. automodule:: apmec.db.common_services.common_services_db_plugin + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.db.db_base.rst b/doc/source/api/apmec.db.db_base.rst new file mode 100644 index 0000000..eb53a6e --- /dev/null +++ b/doc/source/api/apmec.db.db_base.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.db.db_base` Module +================================== + +.. automodule:: apmec.db.db_base + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.db.mem.mem_db.rst b/doc/source/api/apmec.db.mem.mem_db.rst new file mode 100644 index 0000000..5027efa --- /dev/null +++ b/doc/source/api/apmec.db.mem.mem_db.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.db.mem.mem_db` Module +===================================== + +.. automodule:: apmec.db.mem.mem_db + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.db.meo.meo_db.rst b/doc/source/api/apmec.db.meo.meo_db.rst new file mode 100644 index 0000000..ceb5d13 --- /dev/null +++ b/doc/source/api/apmec.db.meo.meo_db.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.db.meo.meo_db` Module +===================================== + +.. automodule:: apmec.db.meo.meo_db + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.db.meo.meo_db_plugin.rst b/doc/source/api/apmec.db.meo.meo_db_plugin.rst new file mode 100644 index 0000000..0626736 --- /dev/null +++ b/doc/source/api/apmec.db.meo.meo_db_plugin.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.db.meo.meo_db_plugin` Module +============================================ + +.. automodule:: apmec.db.meo.meo_db_plugin + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.db.meo.mes_db.rst b/doc/source/api/apmec.db.meo.mes_db.rst new file mode 100644 index 0000000..c742612 --- /dev/null +++ b/doc/source/api/apmec.db.meo.mes_db.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.db.meo.mes_db` Module +===================================== + +.. automodule:: apmec.db.meo.mes_db + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.db.migration.cli.rst b/doc/source/api/apmec.db.migration.cli.rst new file mode 100644 index 0000000..10b2842 --- /dev/null +++ b/doc/source/api/apmec.db.migration.cli.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.db.migration.cli` Module +======================================== + +.. automodule:: apmec.db.migration.cli + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.db.migration.models.head.rst b/doc/source/api/apmec.db.migration.models.head.rst new file mode 100644 index 0000000..2ba7583 --- /dev/null +++ b/doc/source/api/apmec.db.migration.models.head.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.db.migration.models.head` Module +================================================ + +.. automodule:: apmec.db.migration.models.head + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.db.migration.purge_tables.rst b/doc/source/api/apmec.db.migration.purge_tables.rst new file mode 100644 index 0000000..af78266 --- /dev/null +++ b/doc/source/api/apmec.db.migration.purge_tables.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.db.migration.purge_tables` Module +================================================= + +.. automodule:: apmec.db.migration.purge_tables + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.db.model_base.rst b/doc/source/api/apmec.db.model_base.rst new file mode 100644 index 0000000..4ecaa9a --- /dev/null +++ b/doc/source/api/apmec.db.model_base.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.db.model_base` Module +===================================== + +.. automodule:: apmec.db.model_base + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.db.models_v1.rst b/doc/source/api/apmec.db.models_v1.rst new file mode 100644 index 0000000..8332fc0 --- /dev/null +++ b/doc/source/api/apmec.db.models_v1.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.db.models_v1` Module +==================================== + +.. automodule:: apmec.db.models_v1 + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.db.sqlalchemyutils.rst b/doc/source/api/apmec.db.sqlalchemyutils.rst new file mode 100644 index 0000000..4bcf379 --- /dev/null +++ b/doc/source/api/apmec.db.sqlalchemyutils.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.db.sqlalchemyutils` Module +========================================== + +.. automodule:: apmec.db.sqlalchemyutils + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.db.types.rst b/doc/source/api/apmec.db.types.rst new file mode 100644 index 0000000..1122959 --- /dev/null +++ b/doc/source/api/apmec.db.types.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.db.types` Module +================================ + +.. automodule:: apmec.db.types + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.extensions.common_services.rst b/doc/source/api/apmec.extensions.common_services.rst new file mode 100644 index 0000000..e55342a --- /dev/null +++ b/doc/source/api/apmec.extensions.common_services.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.extensions.common_services` Module +================================================== + +.. automodule:: apmec.extensions.common_services + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.extensions.mem.rst b/doc/source/api/apmec.extensions.mem.rst new file mode 100644 index 0000000..4e2cb21 --- /dev/null +++ b/doc/source/api/apmec.extensions.mem.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.extensions.mem` Module +====================================== + +.. automodule:: apmec.extensions.mem + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.extensions.meo.rst b/doc/source/api/apmec.extensions.meo.rst new file mode 100644 index 0000000..32c216d --- /dev/null +++ b/doc/source/api/apmec.extensions.meo.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.extensions.meo` Module +====================================== + +.. automodule:: apmec.extensions.meo + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.extensions.meo_plugins.edge_service.rst b/doc/source/api/apmec.extensions.meo_plugins.edge_service.rst new file mode 100644 index 0000000..8be924b --- /dev/null +++ b/doc/source/api/apmec.extensions.meo_plugins.edge_service.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.extensions.meo_plugins.edge_service` Module +=========================================================== + +.. automodule:: apmec.extensions.meo_plugins.edge_service + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.hacking.checks.rst b/doc/source/api/apmec.hacking.checks.rst new file mode 100644 index 0000000..7d9969a --- /dev/null +++ b/doc/source/api/apmec.hacking.checks.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.hacking.checks` Module +====================================== + +.. automodule:: apmec.hacking.checks + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.keymgr.barbican_key_manager.rst b/doc/source/api/apmec.keymgr.barbican_key_manager.rst new file mode 100644 index 0000000..238bfdb --- /dev/null +++ b/doc/source/api/apmec.keymgr.barbican_key_manager.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.keymgr.barbican_key_manager` Module +=================================================== + +.. automodule:: apmec.keymgr.barbican_key_manager + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.keymgr.exception.rst b/doc/source/api/apmec.keymgr.exception.rst new file mode 100644 index 0000000..a758c9d --- /dev/null +++ b/doc/source/api/apmec.keymgr.exception.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.keymgr.exception` Module +======================================== + +.. automodule:: apmec.keymgr.exception + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.keymgr.key_manager.rst b/doc/source/api/apmec.keymgr.key_manager.rst new file mode 100644 index 0000000..5ab1941 --- /dev/null +++ b/doc/source/api/apmec.keymgr.key_manager.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.keymgr.key_manager` Module +========================================== + +.. automodule:: apmec.keymgr.key_manager + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.manager.rst b/doc/source/api/apmec.manager.rst new file mode 100644 index 0000000..8470189 --- /dev/null +++ b/doc/source/api/apmec.manager.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.manager` Module +=============================== + +.. automodule:: apmec.manager + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.mem.infra_drivers.abstract_driver.rst b/doc/source/api/apmec.mem.infra_drivers.abstract_driver.rst new file mode 100644 index 0000000..87ea1c2 --- /dev/null +++ b/doc/source/api/apmec.mem.infra_drivers.abstract_driver.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.mem.infra_drivers.abstract_driver` Module +========================================================= + +.. automodule:: apmec.mem.infra_drivers.abstract_driver + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.mem.infra_drivers.noop.rst b/doc/source/api/apmec.mem.infra_drivers.noop.rst new file mode 100644 index 0000000..92288b0 --- /dev/null +++ b/doc/source/api/apmec.mem.infra_drivers.noop.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.mem.infra_drivers.noop` Module +============================================== + +.. automodule:: apmec.mem.infra_drivers.noop + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.mem.infra_drivers.openstack.heat_client.rst b/doc/source/api/apmec.mem.infra_drivers.openstack.heat_client.rst new file mode 100644 index 0000000..b69a4f6 --- /dev/null +++ b/doc/source/api/apmec.mem.infra_drivers.openstack.heat_client.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.mem.infra_drivers.openstack.heat_client` Module +=============================================================== + +.. automodule:: apmec.mem.infra_drivers.openstack.heat_client + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.mem.infra_drivers.openstack.openstack.rst b/doc/source/api/apmec.mem.infra_drivers.openstack.openstack.rst new file mode 100644 index 0000000..62917f9 --- /dev/null +++ b/doc/source/api/apmec.mem.infra_drivers.openstack.openstack.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.mem.infra_drivers.openstack.openstack` Module +============================================================= + +.. automodule:: apmec.mem.infra_drivers.openstack.openstack + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.mem.infra_drivers.openstack.translate_template.rst b/doc/source/api/apmec.mem.infra_drivers.openstack.translate_template.rst new file mode 100644 index 0000000..768e038 --- /dev/null +++ b/doc/source/api/apmec.mem.infra_drivers.openstack.translate_template.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.mem.infra_drivers.openstack.translate_template` Module +====================================================================== + +.. automodule:: apmec.mem.infra_drivers.openstack.translate_template + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.mem.infra_drivers.scale_driver.rst b/doc/source/api/apmec.mem.infra_drivers.scale_driver.rst new file mode 100644 index 0000000..c0bd18b --- /dev/null +++ b/doc/source/api/apmec.mem.infra_drivers.scale_driver.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.mem.infra_drivers.scale_driver` Module +====================================================== + +.. automodule:: apmec.mem.infra_drivers.scale_driver + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.mem.keystone.rst b/doc/source/api/apmec.mem.keystone.rst new file mode 100644 index 0000000..88671f2 --- /dev/null +++ b/doc/source/api/apmec.mem.keystone.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.mem.keystone` Module +==================================== + +.. automodule:: apmec.mem.keystone + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.mem.mgmt_drivers.abstract_driver.rst b/doc/source/api/apmec.mem.mgmt_drivers.abstract_driver.rst new file mode 100644 index 0000000..c59f2c6 --- /dev/null +++ b/doc/source/api/apmec.mem.mgmt_drivers.abstract_driver.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.mem.mgmt_drivers.abstract_driver` Module +======================================================== + +.. automodule:: apmec.mem.mgmt_drivers.abstract_driver + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.mem.mgmt_drivers.constants.rst b/doc/source/api/apmec.mem.mgmt_drivers.constants.rst new file mode 100644 index 0000000..b6aaa4b --- /dev/null +++ b/doc/source/api/apmec.mem.mgmt_drivers.constants.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.mem.mgmt_drivers.constants` Module +================================================== + +.. automodule:: apmec.mem.mgmt_drivers.constants + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.mem.mgmt_drivers.noop.rst b/doc/source/api/apmec.mem.mgmt_drivers.noop.rst new file mode 100644 index 0000000..2f0c8fc --- /dev/null +++ b/doc/source/api/apmec.mem.mgmt_drivers.noop.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.mem.mgmt_drivers.noop` Module +============================================= + +.. automodule:: apmec.mem.mgmt_drivers.noop + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.mem.mgmt_drivers.openwrt.openwrt.rst b/doc/source/api/apmec.mem.mgmt_drivers.openwrt.openwrt.rst new file mode 100644 index 0000000..8689c77 --- /dev/null +++ b/doc/source/api/apmec.mem.mgmt_drivers.openwrt.openwrt.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.mem.mgmt_drivers.openwrt.openwrt` Module +======================================================== + +.. automodule:: apmec.mem.mgmt_drivers.openwrt.openwrt + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.mem.monitor.rst b/doc/source/api/apmec.mem.monitor.rst new file mode 100644 index 0000000..6fe2d61 --- /dev/null +++ b/doc/source/api/apmec.mem.monitor.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.mem.monitor` Module +=================================== + +.. automodule:: apmec.mem.monitor + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.mem.monitor_drivers.abstract_driver.rst b/doc/source/api/apmec.mem.monitor_drivers.abstract_driver.rst new file mode 100644 index 0000000..c7d890a --- /dev/null +++ b/doc/source/api/apmec.mem.monitor_drivers.abstract_driver.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.mem.monitor_drivers.abstract_driver` Module +=========================================================== + +.. automodule:: apmec.mem.monitor_drivers.abstract_driver + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.mem.monitor_drivers.ceilometer.ceilometer.rst b/doc/source/api/apmec.mem.monitor_drivers.ceilometer.ceilometer.rst new file mode 100644 index 0000000..7527bb9 --- /dev/null +++ b/doc/source/api/apmec.mem.monitor_drivers.ceilometer.ceilometer.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.mem.monitor_drivers.ceilometer.ceilometer` Module +================================================================= + +.. automodule:: apmec.mem.monitor_drivers.ceilometer.ceilometer + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.mem.monitor_drivers.http_ping.http_ping.rst b/doc/source/api/apmec.mem.monitor_drivers.http_ping.http_ping.rst new file mode 100644 index 0000000..5c394ce --- /dev/null +++ b/doc/source/api/apmec.mem.monitor_drivers.http_ping.http_ping.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.mem.monitor_drivers.http_ping.http_ping` Module +=============================================================== + +.. automodule:: apmec.mem.monitor_drivers.http_ping.http_ping + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.mem.monitor_drivers.ping.ping.rst b/doc/source/api/apmec.mem.monitor_drivers.ping.ping.rst new file mode 100644 index 0000000..bf2caac --- /dev/null +++ b/doc/source/api/apmec.mem.monitor_drivers.ping.ping.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.mem.monitor_drivers.ping.ping` Module +===================================================== + +.. automodule:: apmec.mem.monitor_drivers.ping.ping + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.mem.monitor_drivers.token.rst b/doc/source/api/apmec.mem.monitor_drivers.token.rst new file mode 100644 index 0000000..8c9ed49 --- /dev/null +++ b/doc/source/api/apmec.mem.monitor_drivers.token.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.mem.monitor_drivers.token` Module +================================================= + +.. automodule:: apmec.mem.monitor_drivers.token + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.mem.plugin.rst b/doc/source/api/apmec.mem.plugin.rst new file mode 100644 index 0000000..eeb0de3 --- /dev/null +++ b/doc/source/api/apmec.mem.plugin.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.mem.plugin` Module +================================== + +.. automodule:: apmec.mem.plugin + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.mem.policy_actions.abstract_action.rst b/doc/source/api/apmec.mem.policy_actions.abstract_action.rst new file mode 100644 index 0000000..b34cc70 --- /dev/null +++ b/doc/source/api/apmec.mem.policy_actions.abstract_action.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.mem.policy_actions.abstract_action` Module +========================================================== + +.. automodule:: apmec.mem.policy_actions.abstract_action + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.mem.policy_actions.autoscaling.autoscaling.rst b/doc/source/api/apmec.mem.policy_actions.autoscaling.autoscaling.rst new file mode 100644 index 0000000..2fe31aa --- /dev/null +++ b/doc/source/api/apmec.mem.policy_actions.autoscaling.autoscaling.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.mem.policy_actions.autoscaling.autoscaling` Module +================================================================== + +.. automodule:: apmec.mem.policy_actions.autoscaling.autoscaling + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.mem.policy_actions.log.log.rst b/doc/source/api/apmec.mem.policy_actions.log.log.rst new file mode 100644 index 0000000..903a0c0 --- /dev/null +++ b/doc/source/api/apmec.mem.policy_actions.log.log.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.mem.policy_actions.log.log` Module +================================================== + +.. automodule:: apmec.mem.policy_actions.log.log + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.mem.policy_actions.respawn.respawn.rst b/doc/source/api/apmec.mem.policy_actions.respawn.respawn.rst new file mode 100644 index 0000000..4445efb --- /dev/null +++ b/doc/source/api/apmec.mem.policy_actions.respawn.respawn.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.mem.policy_actions.respawn.respawn` Module +========================================================== + +.. automodule:: apmec.mem.policy_actions.respawn.respawn + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.mem.vim_client.rst b/doc/source/api/apmec.mem.vim_client.rst new file mode 100644 index 0000000..ef013f8 --- /dev/null +++ b/doc/source/api/apmec.mem.vim_client.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.mem.vim_client` Module +====================================== + +.. automodule:: apmec.mem.vim_client + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.meo.drivers.vim.abstract_vim_driver.rst b/doc/source/api/apmec.meo.drivers.vim.abstract_vim_driver.rst new file mode 100644 index 0000000..1c3e82c --- /dev/null +++ b/doc/source/api/apmec.meo.drivers.vim.abstract_vim_driver.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.meo.drivers.vim.abstract_vim_driver` Module +=========================================================== + +.. automodule:: apmec.meo.drivers.vim.abstract_vim_driver + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.meo.drivers.vim.openstack_driver.rst b/doc/source/api/apmec.meo.drivers.vim.openstack_driver.rst new file mode 100644 index 0000000..0395c52 --- /dev/null +++ b/doc/source/api/apmec.meo.drivers.vim.openstack_driver.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.meo.drivers.vim.openstack_driver` Module +======================================================== + +.. automodule:: apmec.meo.drivers.vim.openstack_driver + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.meo.drivers.workflow.workflow_generator.rst b/doc/source/api/apmec.meo.drivers.workflow.workflow_generator.rst new file mode 100644 index 0000000..da762e0 --- /dev/null +++ b/doc/source/api/apmec.meo.drivers.workflow.workflow_generator.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.meo.drivers.workflow.workflow_generator` Module +=============================================================== + +.. automodule:: apmec.meo.drivers.workflow.workflow_generator + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.meo.meo_plugin.rst b/doc/source/api/apmec.meo.meo_plugin.rst new file mode 100644 index 0000000..863dd03 --- /dev/null +++ b/doc/source/api/apmec.meo.meo_plugin.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.meo.meo_plugin` Module +====================================== + +.. automodule:: apmec.meo.meo_plugin + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.meo.workflows.vim_monitor.vim_monitor_utils.rst b/doc/source/api/apmec.meo.workflows.vim_monitor.vim_monitor_utils.rst new file mode 100644 index 0000000..ed0d82c --- /dev/null +++ b/doc/source/api/apmec.meo.workflows.vim_monitor.vim_monitor_utils.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.meo.workflows.vim_monitor.vim_monitor_utils` Module +=================================================================== + +.. automodule:: apmec.meo.workflows.vim_monitor.vim_monitor_utils + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.meo.workflows.vim_monitor.vim_ping_action.rst b/doc/source/api/apmec.meo.workflows.vim_monitor.vim_ping_action.rst new file mode 100644 index 0000000..858c30c --- /dev/null +++ b/doc/source/api/apmec.meo.workflows.vim_monitor.vim_ping_action.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.meo.workflows.vim_monitor.vim_ping_action` Module +================================================================= + +.. automodule:: apmec.meo.workflows.vim_monitor.vim_ping_action + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.meo.workflows.vim_monitor.workflow_generator.rst b/doc/source/api/apmec.meo.workflows.vim_monitor.workflow_generator.rst new file mode 100644 index 0000000..bdbe81a --- /dev/null +++ b/doc/source/api/apmec.meo.workflows.vim_monitor.workflow_generator.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.meo.workflows.vim_monitor.workflow_generator` Module +==================================================================== + +.. automodule:: apmec.meo.workflows.vim_monitor.workflow_generator + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.mistral.actionrpc.kill_action.rst b/doc/source/api/apmec.mistral.actionrpc.kill_action.rst new file mode 100644 index 0000000..c81adda --- /dev/null +++ b/doc/source/api/apmec.mistral.actionrpc.kill_action.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.mistral.actionrpc.kill_action` Module +===================================================== + +.. automodule:: apmec.mistral.actionrpc.kill_action + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.mistral.mistral_client.rst b/doc/source/api/apmec.mistral.mistral_client.rst new file mode 100644 index 0000000..4c0d8cc --- /dev/null +++ b/doc/source/api/apmec.mistral.mistral_client.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.mistral.mistral_client` Module +============================================== + +.. automodule:: apmec.mistral.mistral_client + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.mistral.workflow_generator.rst b/doc/source/api/apmec.mistral.workflow_generator.rst new file mode 100644 index 0000000..f61c108 --- /dev/null +++ b/doc/source/api/apmec.mistral.workflow_generator.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.mistral.workflow_generator` Module +================================================== + +.. automodule:: apmec.mistral.workflow_generator + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.plugins.common.constants.rst b/doc/source/api/apmec.plugins.common.constants.rst new file mode 100644 index 0000000..7056bf8 --- /dev/null +++ b/doc/source/api/apmec.plugins.common.constants.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.plugins.common.constants` Module +================================================ + +.. automodule:: apmec.plugins.common.constants + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.plugins.common.utils.rst b/doc/source/api/apmec.plugins.common.utils.rst new file mode 100644 index 0000000..62fe8ea --- /dev/null +++ b/doc/source/api/apmec.plugins.common.utils.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.plugins.common.utils` Module +============================================ + +.. automodule:: apmec.plugins.common.utils + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.plugins.common_services.common_services_plugin.rst b/doc/source/api/apmec.plugins.common_services.common_services_plugin.rst new file mode 100644 index 0000000..eaefc10 --- /dev/null +++ b/doc/source/api/apmec.plugins.common_services.common_services_plugin.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.plugins.common_services.common_services_plugin` Module +====================================================================== + +.. automodule:: apmec.plugins.common_services.common_services_plugin + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.policy.rst b/doc/source/api/apmec.policy.rst new file mode 100644 index 0000000..83061f2 --- /dev/null +++ b/doc/source/api/apmec.policy.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.policy` Module +============================== + +.. automodule:: apmec.policy + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.service.rst b/doc/source/api/apmec.service.rst new file mode 100644 index 0000000..f701fc8 --- /dev/null +++ b/doc/source/api/apmec.service.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.service` Module +=============================== + +.. automodule:: apmec.service + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.services.service_base.rst b/doc/source/api/apmec.services.service_base.rst new file mode 100644 index 0000000..97fd351 --- /dev/null +++ b/doc/source/api/apmec.services.service_base.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.services.service_base` Module +============================================= + +.. automodule:: apmec.services.service_base + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.version.rst b/doc/source/api/apmec.version.rst new file mode 100644 index 0000000..088f1fa --- /dev/null +++ b/doc/source/api/apmec.version.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.version` Module +=============================== + +.. automodule:: apmec.version + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/apmec.wsgi.rst b/doc/source/api/apmec.wsgi.rst new file mode 100644 index 0000000..d7852d9 --- /dev/null +++ b/doc/source/api/apmec.wsgi.rst @@ -0,0 +1,7 @@ +The :mod:`apmec.wsgi` Module +============================ + +.. automodule:: apmec.wsgi + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/autoindex.rst b/doc/source/api/autoindex.rst new file mode 100644 index 0000000..abd9a20 --- /dev/null +++ b/doc/source/api/autoindex.rst @@ -0,0 +1,99 @@ +.. toctree:: + :maxdepth: 1 + + apmec._i18n.rst + apmec.agent.linux.utils.rst + apmec.alarm_receiver.rst + apmec.api.api_common.rst + apmec.api.extensions.rst + apmec.api.v1.attributes.rst + apmec.api.v1.base.rst + apmec.api.v1.resource.rst + apmec.api.v1.resource_helper.rst + apmec.api.v1.router.rst + apmec.api.versions.rst + apmec.api.views.versions.rst + apmec.auth.rst + apmec.catalogs.tosca.utils.rst + apmec.cmd.eventlet.apmec_server.rst + apmec.cmd.eventlet.conductor.rst + apmec.common.clients.rst + apmec.common.cmd_executer.rst + apmec.common.config.rst + apmec.common.constants.rst + apmec.common.driver_manager.rst + apmec.common.eventlet_utils.rst + apmec.common.exceptions.rst + apmec.common.log.rst + apmec.common.rpc.rst + apmec.common.test_lib.rst + apmec.common.topics.rst + apmec.common.utils.rst + apmec.conductor.conductor_server.rst + apmec.conductor.conductorrpc.vim_monitor_rpc.rst + apmec.context.rst + apmec.db.api.rst + apmec.db.common_services.common_services_db.rst + apmec.db.common_services.common_services_db_plugin.rst + apmec.db.db_base.rst + apmec.db.mem.mem_db.rst + apmec.db.meo.meo_db.rst + apmec.db.meo.meo_db_plugin.rst + apmec.db.meo.mes_db.rst + apmec.db.migration.cli.rst + apmec.db.migration.models.head.rst + apmec.db.migration.purge_tables.rst + apmec.db.model_base.rst + apmec.db.models_v1.rst + apmec.db.sqlalchemyutils.rst + apmec.db.types.rst + apmec.extensions.common_services.rst + apmec.extensions.mem.rst + apmec.extensions.meo.rst + apmec.extensions.meo_plugins.edge_service.rst + apmec.hacking.checks.rst + apmec.keymgr.barbican_key_manager.rst + apmec.keymgr.exception.rst + apmec.keymgr.key_manager.rst + apmec.manager.rst + apmec.mem.infra_drivers.abstract_driver.rst + apmec.mem.infra_drivers.noop.rst + apmec.mem.infra_drivers.openstack.heat_client.rst + apmec.mem.infra_drivers.openstack.openstack.rst + apmec.mem.infra_drivers.openstack.translate_template.rst + apmec.mem.infra_drivers.scale_driver.rst + apmec.mem.keystone.rst + apmec.mem.mgmt_drivers.abstract_driver.rst + apmec.mem.mgmt_drivers.constants.rst + apmec.mem.mgmt_drivers.noop.rst + apmec.mem.mgmt_drivers.openwrt.openwrt.rst + apmec.mem.monitor.rst + apmec.mem.monitor_drivers.abstract_driver.rst + apmec.mem.monitor_drivers.ceilometer.ceilometer.rst + apmec.mem.monitor_drivers.http_ping.http_ping.rst + apmec.mem.monitor_drivers.ping.ping.rst + apmec.mem.monitor_drivers.token.rst + apmec.mem.plugin.rst + apmec.mem.policy_actions.abstract_action.rst + apmec.mem.policy_actions.autoscaling.autoscaling.rst + apmec.mem.policy_actions.log.log.rst + apmec.mem.policy_actions.respawn.respawn.rst + apmec.mem.vim_client.rst + apmec.meo.drivers.vim.abstract_vim_driver.rst + apmec.meo.drivers.vim.openstack_driver.rst + apmec.meo.drivers.workflow.workflow_generator.rst + apmec.meo.meo_plugin.rst + apmec.meo.workflows.vim_monitor.vim_monitor_utils.rst + apmec.meo.workflows.vim_monitor.vim_ping_action.rst + apmec.meo.workflows.vim_monitor.workflow_generator.rst + apmec.mistral.actionrpc.kill_action.rst + apmec.mistral.mistral_client.rst + apmec.mistral.workflow_generator.rst + apmec.plugins.common.constants.rst + apmec.plugins.common.utils.rst + apmec.plugins.common_services.common_services_plugin.rst + apmec.policy.rst + apmec.service.rst + apmec.services.service_base.rst + apmec.version.rst + apmec.wsgi.rst diff --git a/doc/source/user/mesd_usage_guide.rst b/doc/source/user/mesd_usage_guide.rst deleted file mode 100644 index c8cfe7a..0000000 --- a/doc/source/user/mesd_usage_guide.rst +++ /dev/null @@ -1,256 +0,0 @@ -.. - Licensed under the Apache License, Version 2.0 (the "License"); you may - not use this file except in compliance with the License. You may obtain - a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, 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. - -.. _ref-mesd: - -========================================================== -Orchestrating MEAs using Network Services Descriptor (MESD) -========================================================== - -To enable dynamic composition of network services, MEC introduces Network -Service Descriptors (MESDs) that specify the network service to be created. -This usage guide describes lifecycle of Network service descriptors and -services. - -MESD in Ocata can be used for creating multiple (related) MEAs in one shot -using a single TOSCA template. This is a first (big) step into MESD, few -follow-on enhancements like: -1) Creating VLs / neutron networks using MESD (to support inter-MEA private VL) -2) NFYD support in MESD. - -Creating the MESD -~~~~~~~~~~~~~~~~ - -Once OpenStack along with Apmec has been successfully installed, -deploy a sample MEAD templates using mea1.yaml and mea2.yaml as mentioned in -reference section. - -:: - - apmec mead-create --mead-file mead1.yaml MEAD1 - - apmec mead-create --mead-file mead2.yaml MEAD2 - -The following code represents sample MESD which instantiates the above MEAs - -:: - - tosca_definitions_version: tosca_simple_profile_for_mec_1_0_0 - imports: - - MEAD1 - - MEAD2 - topology_template: - node_templates: - MEA1: - type: tosca.nodes.mec.MEA1 - requirements: - - virtualLink1: VL1 - - virtualLink2: VL2 - MEA2: - type: tosca.nodes.mec.MEA2 - VL1: - type: tosca.nodes.mec.VL - properties: - network_name: net0 - vendor: apmec - VL2: - type: tosca.nodes.mec.VL - properties: - network_name: net_mgmt - vendor: apmec - -In above MESD template VL1 and VL2 are substituting the virtuallinks of MEA1. -To onboard the above MESD: - -:: - - apmec mesd-create --mesd-file - -Creating the MES -~~~~~~~~~~~~~~~~ - -To create a MES, you must have onboarded corresponding MESD and -MEADS(which MES is substituting) - -Apmec provides the following CLI to create MES: - -:: - - apmec mes-create --mesd-id - -Or you can create directly a MES without creating onboarded MESD before by -following CLI command: - -:: - - apmec mes-create --mesd-template - -Reference -~~~~~~~~~ - -MEA1 sample template for mesd named mead1.yaml: - -:: - - tosca_definitions_version: tosca_simple_profile_for_mec_1_0_0 - description: Demo example - node_types: - tosca.nodes.mec.MEA1: - requirements: - - virtualLink1: - type: tosca.nodes.mec.VL - required: true - - virtualLink2: - type: tosca.nodes.mec.VL - required: true - capabilities: - forwarder1: - type: tosca.capabilities.mec.Forwarder - forwarder2: - type: tosca.capabilities.mec.Forwarder - - topology_template: - substitution_mappings: - node_type: tosca.nodes.mec.MEA1 - requirements: - virtualLink1: [CP11, virtualLink] - virtualLink2: [CP14, virtualLink] - capabilities: - forwarder1: [CP11, forwarder] - forwarder2: [CP14, forwarder] - node_templates: - VDU1: - type: tosca.nodes.mec.VDU.Apmec - properties: - image: cirros-0.3.5-x86_64-disk - flavor: m1.tiny - availability_zone: nova - mgmt_driver: noop - config: | - param0: key1 - param1: key2 - CP11: - type: tosca.nodes.mec.CP.Apmec - properties: - management: true - anti_spoofing_protection: false - requirements: - - virtualBinding: - node: VDU1 - - VDU2: - type: tosca.nodes.mec.VDU.Apmec - properties: - image: cirros-0.3.5-x86_64-disk - flavor: m1.medium - availability_zone: nova - mgmt_driver: noop - config: | - param0: key1 - param1: key2 - CP13: - type: tosca.nodes.mec.CP.Apmec - properties: - management: true - anti_spoofing_protection: false - requirements: - - virtualLink: - node: VL1 - - virtualBinding: - node: VDU2 - CP14: - type: tosca.nodes.mec.CP.Apmec - properties: - management: true - anti_spoofing_protection: false - requirements: - - virtualBinding: - node: VDU2 - VL1: - type: tosca.nodes.mec.VL - properties: - network_name: net_mgmt - vendor: Apmec - VL2: - type: tosca.nodes.mec.VL - properties: - network_name: net0 - vendor: Apmec - -MEA2 sample template for mesd named mead2.yaml: - -:: - - tosca_definitions_version: tosca_simple_profile_for_mec_1_0_0 - description: Demo example - - node_types: - tosca.nodes.mec.MEA2: - capabilities: - forwarder1: - type: tosca.capabilities.mec.Forwarder - topology_template: - substitution_mappings: - node_type: tosca.nodes.mec.MEA2 - capabilities: - forwarder1: [CP21, forwarder] - node_templates: - VDU1: - type: tosca.nodes.mec.VDU.Apmec - properties: - image: cirros-0.3.5-x86_64-disk - flavor: m1.tiny - availability_zone: nova - mgmt_driver: noop - config: | - param0: key1 - param1: key2 - CP21: - type: tosca.nodes.mec.CP.Apmec - properties: - management: true - anti_spoofing_protection: false - requirements: - - virtualLink: - node: VL1 - - virtualBinding: - node: VDU1 - VDU2: - type: tosca.nodes.mec.VDU.Apmec - properties: - image: cirros-0.3.5-x86_64-disk - flavor: m1.medium - availability_zone: nova - mgmt_driver: noop - CP22: - type: tosca.nodes.mec.CP.Apmec - properties: - management: true - anti_spoofing_protection: false - requirements: - - virtualLink: - node: VL2 - - virtualBinding: - node: VDU2 - VL1: - type: tosca.nodes.mec.VL - properties: - network_name: net_mgmt - vendor: Apmec - VL2: - type: tosca.nodes.mec.VL - properties: - network_name: net0 - vendor: Apmec - - diff --git a/requirements.txt b/requirements.txt index 6179df4..754f216 100644 --- a/requirements.txt +++ b/requirements.txt @@ -41,5 +41,7 @@ paramiko>=2.0.0 # LGPLv2.1+ pyroute2>=0.4.21;sys_platform!='win32' # Apache-2.0 (+ dual licensed GPL2) python-mistralclient>=3.1.0 # Apache-2.0 python-barbicanclient!=4.5.0,!=4.5.1,>=4.0.0 # Apache-2.0 -tosca-parser>=0.8.1 # Apache-2.0 -heat-translator>=0.4.0 # Apache-2.0 \ No newline at end of file +#tosca-parser>=0.8.1 # Apache-2.0 +#heat-translator>=0.4.0 # Apache-2.0 + + diff --git a/test-requirements.txt b/test-requirements.txt index 289907b..fe75a6f 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -6,6 +6,7 @@ # ascii betical order. coverage!=4.4,>=4.0 # Apache-2.0 doc8>=0.6.0 # Apache-2.0 + fixtures>=3.0.0 # Apache-2.0/BSD hacking!=0.13.0,<0.14,>=0.12.0 # Apache-2.0 mock>=2.0.0 # BSD @@ -22,4 +23,4 @@ WebTest>=2.0.27 # MIT python-barbicanclient!=4.5.0,!=4.5.1,>=4.0.0 # Apache-2.0 # releasenotes -reno>=2.5.0 # Apache-2.0 +reno>=2.5.0 # Apache-2.0 \ No newline at end of file diff --git a/tools/ostestr_compat_shim.sh b/tools/ostestr_compat_shim.sh deleted file mode 100755 index a483ed1..0000000 --- a/tools/ostestr_compat_shim.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -# preserve old behavior of using an arg as a regex when '--' is not present -case $@ in - (*--*) ostestr $@;; - ('') ostestr;; - (*) ostestr --regex "$@" -esac diff --git a/tox.ini b/tox.ini index dae21d6..545df4f 100644 --- a/tox.ini +++ b/tox.ini @@ -13,12 +13,14 @@ deps = -r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt commands = rm -f .testrepository/times.dbm - {toxinidir}/tools/ostestr_compat_shim.sh {posargs} [testenv:functional] setenv = OS_TEST_PATH=./apmec/tests/functional deps = {[testenv]deps} + -e git://github.com/pineunity/python-apmecclient-1.git#egg=python-apmecclient + -e git://github.com/pineunity/mec-tosca-parser.git#egg=tosca-parser + -e git://github.com/pineunity/mec-heat-translator.git#egg=heat-translator [testenv:dsvm-functional] basepython = python2.7 @@ -26,8 +28,9 @@ setenv = {[testenv]setenv} {[testenv:functional]setenv} deps = {[testenv:functional]deps} -commands = - {toxinidir}/tools/ostestr_compat_shim.sh --concurrency 2 {posargs} + -e git://github.com/pineunity/python-apmecclient-1.git#egg=python-apmecclient + -e git://github.com/pineunity/mec-tosca-parser.git#egg=tosca-parser + -e git://github.com/pineunity/mec-heat-translator.git#egg=heat-translator [tox:jenkins] sitepackages = True @@ -100,3 +103,9 @@ local-check-factory = apmec.hacking.checks.factory [testenv:config-gen] commands = oslo-config-generator --config-file=etc/config-generator.conf + +[testenv:lower-constraints] +deps = + -c{toxinidir}/lower-constraints.txt + -r{toxinidir}/test-requirements.txt + -r{toxinidir}/requirements.txt