Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fw service update api support #446

Open
wants to merge 1 commit into
base: mitaka_nfp_17_june_2016
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions gbpservice/nfp/config_orchestrator/handlers/config/firewall.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,17 @@ def create_firewall(self, context, firewall, host):
context, body, "CREATE")
nfp_logging.clear_logging_context()

@log_helpers.log_method_call
def update_firewall(self, context, firewall, host):
# Fetch nf_id from description of the resource
nf_id = self._fetch_nf_from_resource_desc(firewall["description"])
nfp_logging.store_logging_context(meta_id=nf_id)
nf = common.get_network_function_details(context, nf_id)
body = self._data_wrapper(context, firewall, host, nf, 'UPDATE')
transport.send_request_to_configurator(self._conf,
context, body, "UPDATE")
nfp_logging.clear_logging_context()

@log_helpers.log_method_call
def delete_firewall(self, context, firewall, host):
# Fetch nf_id from description of the resource
Expand Down
8 changes: 5 additions & 3 deletions gbpservice/nfp/orchestrator/config_drivers/heat_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -1182,8 +1182,9 @@ def delete_config(self, stack_id, tenant_id):
def is_update_config_supported(self, service_type):
return (
False
if (service_type == pconst.VPN or
service_type == pconst.FIREWALL)
if (service_type == pconst.VPN)
# or
# service_type == pconst.FIREWALL)
else True
)

Expand Down Expand Up @@ -1217,7 +1218,8 @@ def _update(self, auth_token, resource_owner_tenant_id, service_profile,
return None

if stack_id:
if service_type == pconst.VPN or service_type == pconst.FIREWALL:
if service_type == pconst.VPN:
# or service_type == pconst.FIREWALL:
stack_name = ("stack_" + service_chain_instance['name'] +
service_chain_node['name'] +
service_chain_instance['id'][:8] +
Expand Down
7 changes: 4 additions & 3 deletions gbpservice/nfp/orchestrator/modules/service_orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ def _log_event_created(self, event_id, event_data):
def _create_event(self, event_id, event_data=None,
key=None, binding_key=None, serialize=False,
is_poll_event=False, original_event=None,
is_internal_event=False):
is_internal_event=False, max_times=20):
if not is_internal_event:
if is_poll_event:
ev = self._controller.new_event(
Expand All @@ -473,7 +473,7 @@ def _create_event(self, event_id, event_data=None,
binding_key=original_event.binding_key,
key=original_event.desc.uid)
LOG.debug("poll event started for %s" % (ev.id))
self._controller.poll_event(ev, max_times=20)
self._controller.poll_event(ev, max_times=max_times)
else:
if original_event:
ev = self._controller.new_event(
Expand Down Expand Up @@ -978,7 +978,8 @@ def handle_continue_update_user_config(self, event):
{'heat_stack_id': config_id})
self._create_event('UPDATE_USER_CONFIG_STILL_IN_PROGRESS',
event_data=request_data,
is_poll_event=True, original_event=event)
is_poll_event=True, original_event=event,
max_times=30)

def handle_device_create_failed(self, event):
request_data = event.data
Expand Down
31 changes: 30 additions & 1 deletion gbpservice/nfp/service_plugins/firewall/nfp_fwaas_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,29 @@
from neutron.plugins.common import constants as n_const
from oslo_config import cfg

from functools import wraps
from gbpservice.nfp.config_orchestrator.common import topics
import neutron_fwaas.extensions
from neutron_fwaas.services.firewall import fwaas_plugin as ref_fw_plugin

import neutron_fwaas.extensions
import time


def poll_on_firewall_status(func):
@wraps(func)
def wrapper(self, *args, **kwargs):
retry = 12
while retry > 0:
retry = retry - 1
context = args[0]
firewall_id = args[1]
fwall = self.get_firewall(context, firewall_id)
if fwall['status'] == 'ACTIVE':
break
time.sleep(5)
return func(self, *args, **kwargs)
return wrapper


class NFPFirewallPlugin(ref_fw_plugin.FirewallPlugin):
def __init__(self):
Expand Down Expand Up @@ -58,3 +77,13 @@ def _get_routers_for_create_firewall(self, tenant_id, context, firewall):
# self.validate_firewall_routers_not_in_use(context,
# router_ids)
return router_ids

@poll_on_firewall_status
def _ensure_update_firewall(self, context, firewall_id):
fwall = self.get_firewall(context, firewall_id)
if fwall['status'] in [n_const.PENDING_CREATE,
n_const.PENDING_UPDATE,
n_const.PENDING_DELETE]:
raise self.fw_ext.FirewallInPendingState(
firewall_id=firewall_id,
pending_state=fwall['status'])