Add .gitreview file, zuul jobs, and refactoring code

Change-Id: I005b7f84f63af0bde23b224e792b1f39f6ddb065
This commit is contained in:
Tung Doan 2018-05-09 07:39:35 -07:00
parent cd07ba2e87
commit a78db48e89
295 changed files with 950 additions and 15987 deletions

7
.coveragerc Normal file
View File

@ -0,0 +1,7 @@
[run]
branch = True
source = apmec
omit = apmec/tests/*
[report]
ignore_errors = True

34
.gitignore vendored Normal file
View File

@ -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

4
.gitreview Normal file
View File

@ -0,0 +1,4 @@
[gerrit]
host=review.openstack.org
port=29418
project=openstack/apmec.git

4
.testr.conf Normal file
View File

@ -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

View File

@ -11,12 +11,15 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from apmec.mem.monitor_drivers.token import Token
from apmec import wsgi
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging from oslo_log import log as logging
from oslo_serialization import jsonutils from oslo_serialization import jsonutils
from six.moves.urllib import parse 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 # check alarm url with db --> move to plugin

View File

@ -17,14 +17,14 @@ import re
import sys import sys
import yaml 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 log
from apmec.common import utils from apmec.common import utils
from apmec.extensions import mem 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 from collections import OrderedDict
FAILURE = 'tosca.policies.apmec.Failure' FAILURE = 'tosca.policies.apmec.Failure'
@ -66,17 +66,17 @@ FLAVOR_EXTRA_SPECS_LIST = ('cpu_allocation',
'numa_nodes') 'numa_nodes')
delpropmap = {APMECVDU: ('mgmt_driver', 'config', 'service_type', delpropmap = {APMECVDU: ('mgmt_driver', 'config', 'service_type',
'placement_policy', 'monitoring_policy', 'placement_policy', 'monitoring_policy',
'metadata', 'failure_policy'), 'metadata', 'failure_policy'),
APMECCP: ('management',)} APMECCP: ('management',)}
convert_prop = {APMECCP: {'anti_spoofing_protection': convert_prop = {APMECCP: {'anti_spoofing_protection':
'port_security_enabled', 'port_security_enabled',
'type': 'type':
'binding:vnic_type'}} 'binding:vnic_type'}}
convert_prop_values = {APMECCP: {'type': {'sriov': 'direct', convert_prop_values = {APMECCP: {'type': {'sriov': 'direct',
'vnic': 'normal'}}} 'vnic': 'normal'}}}
deletenodes = (MONITORING, FAILURE, PLACEMENT) deletenodes = (MONITORING, FAILURE, PLACEMENT)

View File

@ -16,7 +16,8 @@
# under the License. # under the License.
# If ../apmec/__init__.py exists, add ../ to Python search path, so that # 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 import sys

View File

@ -10,8 +10,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from heatclient import client as heatclient
from apmec.mem import keystone from apmec.mem import keystone
from heatclient import client as heatclient
class OpenstackClients(object): class OpenstackClients(object):

View File

@ -10,6 +10,15 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # 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 datetime import datetime
from oslo_db.exception import DBDuplicateEntry 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.orm import exc as orm_exc
from sqlalchemy import sql 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', VIM_ATTRIBUTES = ('id', 'type', 'tenant_id', 'name', 'description',
'placement_attr', 'shared', 'is_default', 'placement_attr', 'shared', 'is_default',

View File

@ -26,8 +26,8 @@ revision = '12a57080b278'
down_revision = '12a57080b277' down_revision = '12a57080b277'
from alembic import op from alembic import op
from sqlalchemy.dialects import mysql
from apmec.db import migration from apmec.db import migration
from sqlalchemy.dialects import mysql
def upgrade(active_plugins=None, options=None): def upgrade(active_plugins=None, options=None):

View File

@ -26,8 +26,8 @@ revision = 'e8918cda6433'
down_revision = '000632983ada' down_revision = '000632983ada'
from alembic import op from alembic import op
import sqlalchemy as sa
from apmec.db.types import Json from apmec.db.types import Json
import sqlalchemy as sa
def upgrade(active_plugins=None, options=None): def upgrade(active_plugins=None, options=None):

View File

@ -342,7 +342,7 @@ class OpenStack(abstract_driver.DeviceAbstractDriver,
'error': str(e)} 'error': str(e)}
LOG.warning(error_reason) LOG.warning(error_reason)
raise mem.MEAScaleWaitFailed(mea_id=policy['mea']['id'], raise mem.MEAScaleWaitFailed(mea_id=policy['mea']['id'],
reason=error_reason) reason=error_reason)
if stack_retries == 0: if stack_retries == 0:
metadata = heatclient.resource_metadata(stack_id, policy_name) metadata = heatclient.resource_metadata(stack_id, policy_name)
@ -360,7 +360,7 @@ class OpenStack(abstract_driver.DeviceAbstractDriver,
self.STACK_RETRY_WAIT} self.STACK_RETRY_WAIT}
LOG.warning(error_reason) LOG.warning(error_reason)
raise mem.MEAScaleWaitFailed(mea_id=policy['mea']['id'], raise mem.MEAScaleWaitFailed(mea_id=policy['mea']['id'],
reason=error_reason) reason=error_reason)
stack_retries -= 1 stack_retries -= 1
def _fill_scaling_group_name(): def _fill_scaling_group_name():

View File

@ -10,6 +10,11 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # 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_config import cfg
from oslo_log import log as logging from oslo_log import log as logging
from oslo_serialization import jsonutils from oslo_serialization import jsonutils
@ -18,11 +23,6 @@ from toscaparser.utils import yamlparser
from translator.hot import tosca_translator from translator.hot import tosca_translator
import yaml 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__) LOG = logging.getLogger(__name__)
CONF = cfg.CONF CONF = cfg.CONF

View File

@ -12,12 +12,13 @@
# under the License. # under the License.
# #
from apmec.common import utils
from apmec.mem.monitor_drivers import abstract_driver
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging from oslo_log import log as logging
import random import random
import string import string
from apmec.common import utils
from apmec.mem.monitor_drivers import abstract_driver
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -19,11 +19,6 @@ import six
import yaml import yaml
import eventlet 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.api.v1 import attributes
from apmec.common import driver_manager from apmec.common import driver_manager
@ -31,12 +26,18 @@ from apmec.common import exceptions
from apmec.common import utils from apmec.common import utils
from apmec.db.mem import mem_db from apmec.db.mem import mem_db
from apmec.extensions import mem 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.mgmt_drivers import constants as mgmt_constants
from apmec.mem import monitor from apmec.mem import monitor
from apmec.mem import vim_client 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__) LOG = logging.getLogger(__name__)
CONF = cfg.CONF CONF = cfg.CONF
@ -865,4 +866,4 @@ class MEMPlugin(mem_db.MEMPluginDb, MEMMgmtMixin):
# Raise exception when MEA.status != ACTIVE # Raise exception when MEA.status != ACTIVE
else: else:
raise mem.MEAInactive(mea_id=mea_id, raise mem.MEAInactive(mea_id=mea_id,
message=_(' Cannot fetch details')) message=_(' Cannot fetch details'))

View File

@ -12,13 +12,13 @@
# under the License. # 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_log import log as logging
from oslo_utils import timeutils 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__) LOG = logging.getLogger(__name__)

View File

@ -12,13 +12,13 @@
# under the License. # 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_log import log as logging
from oslo_utils import timeutils 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__) LOG = logging.getLogger(__name__)

View File

@ -12,14 +12,14 @@
# under the License. # 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.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.infra_drivers.openstack import heat_client as hc
from apmec.mem.policy_actions import abstract_action from apmec.mem.policy_actions import abstract_action
from apmec.mem import vim_client 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__) LOG = logging.getLogger(__name__)

View File

@ -49,7 +49,7 @@ class VimClient(object):
else: else:
try: try:
vim_info = meo_plugin.get_vim(context, vim_id, vim_info = meo_plugin.get_vim(context, vim_id,
mask_password=False) mask_password=False)
except Exception: except Exception:
raise meo.VimNotFoundException(vim_id=vim_id) raise meo.VimNotFoundException(vim_id=vim_id)
LOG.debug('VIM info found for vim id %s', vim_id) LOG.debug('VIM info found for vim id %s', vim_id)

View File

@ -18,26 +18,25 @@ import os
import six import six
import yaml 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 exceptions
from keystoneauth1 import identity from keystoneauth1 import identity
from keystoneauth1.identity import v2 from keystoneauth1.identity import v2
from keystoneauth1.identity import v3 from keystoneauth1.identity import v3
from keystoneauth1 import session from keystoneauth1 import session
from neutronclient.common import exceptions as nc_exceptions
from neutronclient.v2_0 import client as neutron_client from neutronclient.v2_0 import client as neutron_client
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging 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__) LOG = logging.getLogger(__name__)
CONF = cfg.CONF CONF = cfg.CONF
@ -382,4 +381,4 @@ class NeutronClient(object):
def __init__(self, auth_attr): def __init__(self, auth_attr):
auth = identity.Password(**auth_attr) auth = identity.Password(**auth_attr)
sess = session.Session(auth=auth) sess = session.Session(auth=auth)
self.client = neutron_client.Client(session=sess) self.client = neutron_client.Client(session=sess)

View File

@ -19,16 +19,6 @@ import os
import time import time
import yaml 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._i18n import _
from apmec.common import driver_manager from apmec.common import driver_manager
from apmec.common import log from apmec.common import log
@ -39,12 +29,22 @@ from apmec.extensions import common_services as cs
from apmec.extensions import meo from apmec.extensions import meo
from apmec.keymgr import API as KEYMGR_API from apmec.keymgr import API as KEYMGR_API
from apmec import manager 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.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 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 from toscaparser import tosca_template
LOG = logging.getLogger(__name__) 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) inner_mesd_dict = yaml.safe_load(mesd_yaml)
mesd['meads'] = dict() mesd['meads'] = dict()
LOG.debug('mesd_dict: %s', inner_mesd_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 # Deploy MEC applications
mem_plugin = manager.ApmecManager.get_service_plugins()['MEM'] mem_plugin = manager.ApmecManager.get_service_plugins()['MEM']
mead_imports = inner_mesd_dict['imports']['meads'] 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']: if not mes['mes']['vim_id']:
mes['mes']['vim_id'] = vim_res['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 # Step-1
param_values = mes['mes']['attributes'].get('param_values', {}) param_values = mes['mes']['attributes'].get('param_values', {})
if 'get_input' in str(mesd_dict): if 'get_input' in str(mesd_dict):

View File

@ -12,15 +12,14 @@
import yaml import yaml
from oslo_config import cfg
from oslo_log import log as logging
from apmec.common import rpc 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.actionrpc import kill_action as killaction
from apmec.mistral import mistral_client 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__) LOG = logging.getLogger(__name__)

View File

@ -10,10 +10,9 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # 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.meo.workflows import vim_monitor
from apmec.mistral import workflow_generator
from oslo_log import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

View File

@ -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)

View File

@ -19,6 +19,6 @@ MEA_CIRROS_DEAD_TIMEOUT = 500
ACTIVE_SLEEP_TIME = 3 ACTIVE_SLEEP_TIME = 3
DEAD_SLEEP_TIME = 1 DEAD_SLEEP_TIME = 1
SCALE_WINDOW_SLEEP_TIME = 120 SCALE_WINDOW_SLEEP_TIME = 120
NS_CREATE_TIMEOUT = 400 MES_CREATE_TIMEOUT = 400
NS_DELETE_TIMEOUT = 300 MES_DELETE_TIMEOUT = 300
NOVA_CLIENT_VERSION = 2 NOVA_CLIENT_VERSION = 2

View File

@ -1,2 +0,0 @@
#!/bin/sh
echo "Successfully installed MEAC" > /apmec

View File

@ -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]

View File

@ -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]

View File

@ -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'
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -10,8 +10,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from heatclient import client as heatclient
from apmec.tests.functional import keystone from apmec.tests.functional import keystone
from heatclient import client as heatclient
class OpenstackClients(object): class OpenstackClients(object):

View File

@ -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')

View File

@ -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')

View File

@ -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'])

View File

@ -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])

View File

@ -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')

View File

@ -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')

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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')

View File

@ -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')

View File

@ -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)

View File

@ -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()

View File

@ -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()

View File

@ -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))

View File

@ -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())

View File

@ -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'}}}}}

View File

@ -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'}

View File

@ -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 {}

View File

@ -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

View File

@ -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'])

View File

@ -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 {}

View File

@ -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'

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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'}

View File

@ -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'}

View File

@ -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

View File

@ -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

View File

@ -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: {}

View File

@ -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: {}

View File

@ -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: {}

Some files were not shown because too many files have changed in this diff Show More