Move preinstalled workflows to mistral-extra
* These workflows are openstack workflows and should be in mistral-extra * Rename the function name to register_preinstalled_workflows * Rename then function name to register_preinstalled_actions Change-Id: I80fc1dfe4ec5e81b1b5163c9771eea5a49432f88 Depends-On: https://review.opendev.org/#/c/709970/ Depends-On: https://review.opendev.org/#/c/710024/
This commit is contained in:
parent
5aa1c70452
commit
b705666f9f
|
@ -1,88 +0,0 @@
|
|||
---
|
||||
version: '2.0'
|
||||
|
||||
std.create_instance:
|
||||
type: direct
|
||||
|
||||
description: |
|
||||
Creates VM and waits till VM OS is up and running.
|
||||
|
||||
input:
|
||||
- name
|
||||
- image_id
|
||||
- flavor_id
|
||||
- ssh_username: null
|
||||
- ssh_password: null
|
||||
|
||||
# Name of previously created keypair to inject into the instance.
|
||||
# Either ssh credentials or keypair must be provided.
|
||||
- key_name: null
|
||||
|
||||
# Security_groups: A list of security group names
|
||||
- security_groups: null
|
||||
|
||||
# An ordered list of nics to be added to this server, with information about connected networks, fixed IPs, port etc.
|
||||
# Example: nics: [{"net-id": "27aa8c1c-d6b8-4474-b7f7-6cdcf63ac856"}]
|
||||
- nics: null
|
||||
|
||||
task-defaults:
|
||||
on-error:
|
||||
- delete_vm
|
||||
|
||||
output:
|
||||
ip: <% $.vm_ip %>
|
||||
id: <% $.vm_id %>
|
||||
name: <% $.name %>
|
||||
status: <% $.status %>
|
||||
|
||||
tasks:
|
||||
create_vm:
|
||||
description: Initial request to create a VM.
|
||||
action: nova.servers_create name=<% $.name %> image=<% $.image_id %> flavor=<% $.flavor_id %>
|
||||
input:
|
||||
key_name: <% $.key_name %>
|
||||
security_groups: <% $.security_groups %>
|
||||
nics: <% $.nics %>
|
||||
publish:
|
||||
vm_id: <% task(create_vm).result.id %>
|
||||
on-success:
|
||||
- search_for_ip
|
||||
|
||||
search_for_ip:
|
||||
description: Gets first free ip from Nova floating IPs.
|
||||
action: nova.floating_ips_findall instance_id=null
|
||||
publish:
|
||||
vm_ip: <% task(search_for_ip).result[0].ip %>
|
||||
on-success:
|
||||
- wait_vm_active
|
||||
|
||||
wait_vm_active:
|
||||
description: Waits till VM is ACTIVE.
|
||||
action: nova.servers_find id=<% $.vm_id %> status="ACTIVE"
|
||||
retry:
|
||||
count: 10
|
||||
delay: 10
|
||||
publish:
|
||||
status: <% task(wait_vm_active).result.status %>
|
||||
on-success:
|
||||
- associate_ip
|
||||
|
||||
associate_ip:
|
||||
description: Associate server with one of floating IPs.
|
||||
action: nova.servers_add_floating_ip server=<% $.vm_id %> address=<% $.vm_ip %>
|
||||
wait-after: 5
|
||||
on-success:
|
||||
- wait_ssh
|
||||
|
||||
wait_ssh:
|
||||
description: Wait till operating system on the VM is up (SSH command).
|
||||
action: std.wait_ssh username=<% $.ssh_username %> password=<% $.ssh_password %> host=<% $.vm_ip %>
|
||||
retry:
|
||||
count: 10
|
||||
delay: 10
|
||||
|
||||
delete_vm:
|
||||
description: Destroy VM.
|
||||
workflow: std.delete_instance instance_id=<% $.vm_id %>
|
||||
on-complete:
|
||||
- fail
|
|
@ -1,25 +0,0 @@
|
|||
---
|
||||
version: "2.0"
|
||||
|
||||
std.delete_instance:
|
||||
type: direct
|
||||
|
||||
input:
|
||||
- instance_id
|
||||
|
||||
description: Deletes VM.
|
||||
|
||||
tasks:
|
||||
delete_vm:
|
||||
description: Destroy VM.
|
||||
action: nova.servers_delete server=<% $.instance_id %>
|
||||
wait-after: 10
|
||||
on-success:
|
||||
- find_given_vm
|
||||
|
||||
find_given_vm:
|
||||
description: Checks that VM is already deleted.
|
||||
action: nova.servers_find id=<% $.instance_id %>
|
||||
on-error:
|
||||
- succeed
|
||||
|
|
@ -30,12 +30,9 @@ from mistral_lib.utils import inspect_utils as i_utils
|
|||
LOG = logging.getLogger(__name__)
|
||||
|
||||
ACTIONS_PATH = 'resources/actions'
|
||||
_ACTION_CTX_PARAM = 'action_context'
|
||||
|
||||
|
||||
# TODO(rakhmerov): It's confusing because we have std.xxx actions and actions
|
||||
# TODO(rakhmerov): under '../resources/actions' that we also call standard.
|
||||
def register_standard_actions():
|
||||
def register_preinstalled_actions():
|
||||
action_paths = utils.get_file_list(ACTIONS_PATH)
|
||||
|
||||
for action_path in action_paths:
|
||||
|
@ -79,7 +76,7 @@ def sync_db():
|
|||
with db_api.transaction():
|
||||
_clear_system_action_db()
|
||||
register_action_classes()
|
||||
register_standard_actions()
|
||||
register_preinstalled_actions()
|
||||
|
||||
|
||||
def _register_dynamic_action_classes(namespace=''):
|
||||
|
|
|
@ -21,27 +21,37 @@ from mistral.utils import safe_yaml
|
|||
from mistral.workflow import states
|
||||
from mistral_lib import utils
|
||||
from oslo_log import log as logging
|
||||
from stevedore import extension
|
||||
|
||||
|
||||
STD_WF_PATH = 'resources/workflows'
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def register_standard_workflows(run_in_tx=True):
|
||||
LOG.debug("Registering standard workflows...")
|
||||
def register_preinstalled_workflows(run_in_tx=True):
|
||||
|
||||
workflow_paths = utils.get_file_list(STD_WF_PATH)
|
||||
extensions = extension.ExtensionManager(
|
||||
namespace='mistral.preinstalled_workflows',
|
||||
invoke_on_load=True
|
||||
)
|
||||
|
||||
for wf_path in workflow_paths:
|
||||
workflow_definition = open(wf_path).read()
|
||||
for ext in extensions:
|
||||
for wf_path in ext.obj:
|
||||
register_workflow(run_in_tx, wf_path)
|
||||
|
||||
create_workflows(
|
||||
workflow_definition,
|
||||
scope='public',
|
||||
is_system=True,
|
||||
run_in_tx=run_in_tx,
|
||||
namespace=''
|
||||
)
|
||||
|
||||
def register_workflow(run_in_tx, wf_path):
|
||||
LOG.debug("Registering preinstalled workflow %s", wf_path)
|
||||
|
||||
workflow_definition = open(wf_path).read()
|
||||
|
||||
create_workflows(
|
||||
workflow_definition,
|
||||
scope='public',
|
||||
is_system=True,
|
||||
run_in_tx=run_in_tx,
|
||||
namespace=''
|
||||
)
|
||||
|
||||
|
||||
def _clear_system_workflow_db():
|
||||
|
@ -54,7 +64,7 @@ def sync_db():
|
|||
with db_api.transaction():
|
||||
_clear_system_workflow_db()
|
||||
|
||||
register_standard_workflows(run_in_tx=False)
|
||||
register_preinstalled_workflows(run_in_tx=False)
|
||||
|
||||
|
||||
def create_workflows(definition, scope='private', is_system=False,
|
||||
|
|
Loading…
Reference in New Issue