text: from cloudify.decorators import workflow
  from cloudify.workflows import ctx
  from cloudify.workflows import tasks as workflow_tasks
  from utils import set_state_task
  from utils import operation_task
  from utils import link_tasks
  from utils import CustomContext
  from utils import generate_native_node_workflows
  from utils import _get_all_nodes
  from utils import _get_all_nodes_instances
  from utils import _get_all_modified_node_instances
  from utils import is_host_node
  from utils import is_kubernetes_node
  from utils import relationship_operation_task
  from workflow import WfStartEvent
  from workflow import build_pre_event
  
  
  # Subworkflow for host
  def install_host_server(ctx, graph, custom_context):
      custom_context.add_customized_wf_node('Apache')
      custom_context.add_customized_wf_node('Apache')
      custom_context.add_customized_wf_node('Apache')
      custom_context.add_customized_wf_node('Wordpress')
      custom_context.add_customized_wf_node('Apache')
      custom_context.add_customized_wf_node('Wordpress')
      custom_context.add_customized_wf_node('Apache')
      custom_context.add_customized_wf_node('Wordpress')
      custom_context.add_customized_wf_node('Wordpress')
      custom_context.add_customized_wf_node('Apache')
      custom_context.add_customized_wf_node('PHP')
      custom_context.add_customized_wf_node('PHP')
      custom_context.add_customized_wf_node('Apache')
      custom_context.add_customized_wf_node('Wordpress')
      custom_context.add_customized_wf_node('Wordpress')
      custom_context.add_customized_wf_node('Wordpress')
      custom_context.add_customized_wf_node('PHP')
      custom_context.add_customized_wf_node('PHP')
      custom_context.add_customized_wf_node('PHP')
      custom_context.add_customized_wf_node('PHP')
      custom_context.add_customized_wf_node('PHP')
      set_state_task(ctx, graph, 'Apache', 'created', 'Apache_created', custom_context)
      relationship_operation_task(ctx, graph, 'PHP', 'Server', 'cloudify.interfaces.relationship_lifecycle.preconfigure', 'SOURCE', 'PHP_host_pre_configure_source', custom_context)
      set_state_task(ctx, graph, 'Apache', 'started', 'Apache_started', custom_context)
      set_state_task(ctx, graph, 'Apache', 'configured', 'Apache_configured', custom_context)
      relationship_operation_task(ctx, graph, 'Wordpress', 'Mysql', 'cloudify.interfaces.relationship_lifecycle.postconfigure', 'TARGET', 'Wordpress_database_post_configure_target', custom_context)
      relationship_operation_task(ctx, graph, 'PHP', 'Server', 'cloudify.interfaces.relationship_lifecycle.establish', 'SOURCE', 'PHP_host_add_target', custom_context)
      operation_task(ctx, graph, 'Wordpress', 'cloudify.interfaces.lifecycle.start', 'Wordpress_start', custom_context)
      relationship_operation_task(ctx, graph, 'Wordpress', 'Mysql', 'cloudify.interfaces.relationship_lifecycle.postconfigure', 'SOURCE', 'Wordpress_database_post_configure_source', custom_context)
      operation_task(ctx, graph, 'PHP', 'cloudify.interfaces.lifecycle.configure', 'PHP_configure', custom_context)
      relationship_operation_task(ctx, graph, 'Wordpress', 'Apache', 'cloudify.interfaces.relationship_lifecycle.establish', 'SOURCE', 'Wordpress_host_add_target', custom_context)
      operation_task(ctx, graph, 'Wordpress', 'cloudify.interfaces.lifecycle.configure', 'Wordpress_configure', custom_context)
      relationship_operation_task(ctx, graph, 'Wordpress', 'Apache', 'cloudify.interfaces.relationship_lifecycle.preconfigure', 'SOURCE', 'Wordpress_host_pre_configure_source', custom_context)
      set_state_task(ctx, graph, 'Wordpress', 'created', 'Wordpress_created', custom_context)
      relationship_operation_task(ctx, graph, 'Apache', 'Server', 'cloudify.interfaces.relationship_lifecycle.postconfigure', 'SOURCE', 'Apache_host_post_configure_source', custom_context)
      set_state_task(ctx, graph, 'Apache', 'initial', 'Apache_initial', custom_context)
      relationship_operation_task(ctx, graph, 'Wordpress', 'PHP', 'cloudify.interfaces.relationship_lifecycle.establish', 'SOURCE', 'Wordpress_php_add_target', custom_context)
      set_state_task(ctx, graph, 'Wordpress', 'starting', 'Wordpress_starting', custom_context)
      set_state_task(ctx, graph, 'Apache', 'configuring', 'Apache_configuring', custom_context)
      set_state_task(ctx, graph, 'Wordpress', 'creating', 'Wordpress_creating', custom_context)
      relationship_operation_task(ctx, graph, 'Wordpress', 'Mysql', 'cloudify.interfaces.relationship_lifecycle.establish', 'TARGET', 'Wordpress_database_add_source', custom_context)
      operation_task(ctx, graph, 'Apache', 'cloudify.interfaces.lifecycle.configure', 'Apache_configure', custom_context)
      operation_task(ctx, graph, 'PHP', 'cloudify.interfaces.lifecycle.create', 'PHP_create', custom_context)
      relationship_operation_task(ctx, graph, 'Wordpress', 'Apache', 'cloudify.interfaces.relationship_lifecycle.postconfigure', 'TARGET', 'Wordpress_host_post_configure_target', custom_context)
      set_state_task(ctx, graph, 'Wordpress', 'started', 'Wordpress_started', custom_context)
      set_state_task(ctx, graph, 'Apache', 'starting', 'Apache_starting', custom_context)
      set_state_task(ctx, graph, 'PHP', 'configuring', 'PHP_configuring', custom_context)
      set_state_task(ctx, graph, 'PHP', 'configured', 'PHP_configured', custom_context)
      relationship_operation_task(ctx, graph, 'Apache', 'Server', 'cloudify.interfaces.relationship_lifecycle.preconfigure', 'SOURCE', 'Apache_host_pre_configure_source', custom_context)
      relationship_operation_task(ctx, graph, 'Wordpress', 'Mysql', 'cloudify.interfaces.relationship_lifecycle.establish', 'SOURCE', 'Wordpress_database_add_target', custom_context)
      relationship_operation_task(ctx, graph, 'Wordpress', 'Apache', 'cloudify.interfaces.relationship_lifecycle.establish', 'TARGET', 'Wordpress_host_add_source', custom_context)
      relationship_operation_task(ctx, graph, 'PHP', 'Server', 'cloudify.interfaces.relationship_lifecycle.postconfigure', 'SOURCE', 'PHP_host_post_configure_source', custom_context)
      set_state_task(ctx, graph, 'Apache', 'creating', 'Apache_creating', custom_context)
      set_state_task(ctx, graph, 'Wordpress', 'initial', 'Wordpress_initial', custom_context)
      set_state_task(ctx, graph, 'Wordpress', 'configuring', 'Wordpress_configuring', custom_context)
      operation_task(ctx, graph, 'Apache', 'cloudify.interfaces.lifecycle.start', 'Apache_start', custom_context)
      set_state_task(ctx, graph, 'Wordpress', 'configured', 'Wordpress_configured', custom_context)
      relationship_operation_task(ctx, graph, 'Wordpress', 'PHP', 'cloudify.interfaces.relationship_lifecycle.preconfigure', 'SOURCE', 'Wordpress_php_pre_configure_source', custom_context)
      operation_task(ctx, graph, 'Wordpress', 'cloudify.interfaces.lifecycle.create', 'Wordpress_create', custom_context)
      relationship_operation_task(ctx, graph, 'Wordpress', 'PHP', 'cloudify.interfaces.relationship_lifecycle.preconfigure', 'TARGET', 'Wordpress_php_pre_configure_target', custom_context)
      relationship_operation_task(ctx, graph, 'Wordpress', 'Mysql', 'cloudify.interfaces.relationship_lifecycle.preconfigure', 'TARGET', 'Wordpress_database_pre_configure_target', custom_context)
      relationship_operation_task(ctx, graph, 'Wordpress', 'PHP', 'cloudify.interfaces.relationship_lifecycle.postconfigure', 'SOURCE', 'Wordpress_php_post_configure_source', custom_context)
      relationship_operation_task(ctx, graph, 'Wordpress', 'Apache', 'cloudify.interfaces.relationship_lifecycle.postconfigure', 'SOURCE', 'Wordpress_host_post_configure_source', custom_context)
      set_state_task(ctx, graph, 'PHP', 'created', 'PHP_created', custom_context)
      set_state_task(ctx, graph, 'PHP', 'started', 'PHP_started', custom_context)
      operation_task(ctx, graph, 'Apache', 'cloudify.interfaces.lifecycle.create', 'Apache_create', custom_context)
      operation_task(ctx, graph, 'PHP', 'cloudify.interfaces.lifecycle.start', 'PHP_start', custom_context)
      set_state_task(ctx, graph, 'PHP', 'starting', 'PHP_starting', custom_context)
      relationship_operation_task(ctx, graph, 'Apache', 'Server', 'cloudify.interfaces.relationship_lifecycle.establish', 'SOURCE', 'Apache_host_add_target', custom_context)
      set_state_task(ctx, graph, 'PHP', 'initial', 'PHP_initial', custom_context)
      set_state_task(ctx, graph, 'PHP', 'creating', 'PHP_creating', custom_context)
      custom_context.register_native_delegate_wf_step('Server', 'Server_install')
      relationship_operation_task(ctx, graph, 'Wordpress', 'Apache', 'cloudify.interfaces.relationship_lifecycle.preconfigure', 'TARGET', 'Wordpress_host_pre_configure_target', custom_context)
      relationship_operation_task(ctx, graph, 'Wordpress', 'PHP', 'cloudify.interfaces.relationship_lifecycle.establish', 'TARGET', 'Wordpress_php_add_source', custom_context)
      relationship_operation_task(ctx, graph, 'Wordpress', 'PHP', 'cloudify.interfaces.relationship_lifecycle.postconfigure', 'TARGET', 'Wordpress_php_post_configure_target', custom_context)
      relationship_operation_task(ctx, graph, 'Wordpress', 'Mysql', 'cloudify.interfaces.relationship_lifecycle.preconfigure', 'SOURCE', 'Wordpress_database_pre_configure_source', custom_context)
      operation_task(ctx, graph, 'PHP', 'org.alien4cloud.interfaces.cfy.lifecycle.NodeInit', '_a4c_init_PHP', custom_context)
      operation_task(ctx, graph, 'Wordpress', 'org.alien4cloud.interfaces.cfy.lifecycle.NodeInit', '_a4c_init_Wordpress', custom_context)
      operation_task(ctx, graph, 'Apache', 'org.alien4cloud.interfaces.cfy.lifecycle.NodeInit', '_a4c_init_Apache', custom_context)
      generate_native_node_workflows(ctx, graph, custom_context, 'install')
      link_tasks(graph, 'Apache_configuring', 'Apache_created', custom_context)
      link_tasks(graph, 'PHP_configure', 'PHP_host_pre_configure_source', custom_context)
      link_tasks(graph, 'Wordpress_initial', 'Apache_started', custom_context)
      link_tasks(graph, 'Apache_host_add_target', 'Apache_started', custom_context)
      link_tasks(graph, 'Apache_starting', 'Apache_configured', custom_context)
      link_tasks(graph, 'Wordpress_started', 'Wordpress_start', custom_context)
      link_tasks(graph, 'Wordpress_configured', 'Wordpress_database_post_configure_source', custom_context)
      link_tasks(graph, 'PHP_host_post_configure_source', 'PHP_configure', custom_context)
      link_tasks(graph, 'Wordpress_php_post_configure_target', 'PHP_configure', custom_context)
      link_tasks(graph, 'PHP_configured', 'PHP_configure', custom_context)
      link_tasks(graph, 'Wordpress_host_post_configure_source', 'Wordpress_configure', custom_context)
      link_tasks(graph, 'Wordpress_php_post_configure_source', 'Wordpress_configure', custom_context)
      link_tasks(graph, 'Wordpress_configured', 'Wordpress_configure', custom_context)
      link_tasks(graph, 'Wordpress_database_post_configure_source', 'Wordpress_configure', custom_context)
      link_tasks(graph, 'Wordpress_configure', 'Wordpress_host_pre_configure_source', custom_context)
      link_tasks(graph, 'Wordpress_configuring', 'Wordpress_created', custom_context)
      link_tasks(graph, 'Apache_configured', 'Apache_host_post_configure_source', custom_context)
      link_tasks(graph, 'Apache_creating', 'Apache_initial', custom_context)
      link_tasks(graph, 'Wordpress_start', 'Wordpress_starting', custom_context)
      link_tasks(graph, 'Wordpress_host_pre_configure_target', 'Apache_configuring', custom_context)
      link_tasks(graph, 'Apache_configure', 'Apache_configuring', custom_context)
      link_tasks(graph, 'Apache_host_pre_configure_source', 'Apache_configuring', custom_context)
      link_tasks(graph, '_a4c_init_Wordpress', 'Wordpress_creating', custom_context)
      link_tasks(graph, 'Apache_host_post_configure_source', 'Apache_configure', custom_context)
      link_tasks(graph, 'Apache_configured', 'Apache_configure', custom_context)
      link_tasks(graph, 'Wordpress_host_post_configure_target', 'Apache_configure', custom_context)
      link_tasks(graph, 'PHP_created', 'PHP_create', custom_context)
      link_tasks(graph, 'Apache_configured', 'Wordpress_host_post_configure_target', custom_context)
      link_tasks(graph, 'Wordpress_host_add_target', 'Wordpress_started', custom_context)
      link_tasks(graph, 'Wordpress_database_add_source', 'Wordpress_started', custom_context)
      link_tasks(graph, 'Wordpress_php_add_source', 'Wordpress_started', custom_context)
      link_tasks(graph, 'Wordpress_database_add_target', 'Wordpress_started', custom_context)
      link_tasks(graph, 'Wordpress_php_add_target', 'Wordpress_started', custom_context)
      link_tasks(graph, 'Wordpress_host_add_source', 'Wordpress_started', custom_context)
      link_tasks(graph, 'Apache_start', 'Apache_starting', custom_context)
      link_tasks(graph, 'PHP_host_pre_configure_source', 'PHP_configuring', custom_context)
      link_tasks(graph, 'PHP_configure', 'PHP_configuring', custom_context)
      link_tasks(graph, 'Wordpress_php_pre_configure_target', 'PHP_configuring', custom_context)
      link_tasks(graph, 'PHP_starting', 'PHP_configured', custom_context)
      link_tasks(graph, 'Apache_configure', 'Apache_host_pre_configure_source', custom_context)
      link_tasks(graph, 'PHP_configured', 'PHP_host_post_configure_source', custom_context)
      link_tasks(graph, '_a4c_init_Apache', 'Apache_creating', custom_context)
      link_tasks(graph, 'Wordpress_creating', 'Wordpress_initial', custom_context)
      link_tasks(graph, 'Wordpress_php_pre_configure_source', 'Wordpress_configuring', custom_context)
      link_tasks(graph, 'Wordpress_configure', 'Wordpress_configuring', custom_context)
      link_tasks(graph, 'Wordpress_host_pre_configure_source', 'Wordpress_configuring', custom_context)
      link_tasks(graph, 'Wordpress_database_pre_configure_source', 'Wordpress_configuring', custom_context)
      link_tasks(graph, 'Apache_started', 'Apache_start', custom_context)
      link_tasks(graph, 'Wordpress_starting', 'Wordpress_configured', custom_context)
      link_tasks(graph, 'Wordpress_configure', 'Wordpress_php_pre_configure_source', custom_context)
      link_tasks(graph, 'Wordpress_created', 'Wordpress_create', custom_context)
      link_tasks(graph, 'PHP_configure', 'Wordpress_php_pre_configure_target', custom_context)
      link_tasks(graph, 'Wordpress_configured', 'Wordpress_php_post_configure_source', custom_context)
      link_tasks(graph, 'Wordpress_configured', 'Wordpress_host_post_configure_source', custom_context)
      link_tasks(graph, 'PHP_configuring', 'PHP_created', custom_context)
      link_tasks(graph, 'PHP_host_add_target', 'PHP_started', custom_context)
      link_tasks(graph, 'Wordpress_initial', 'PHP_started', custom_context)
      link_tasks(graph, 'Apache_created', 'Apache_create', custom_context)
      link_tasks(graph, 'PHP_started', 'PHP_start', custom_context)
      link_tasks(graph, 'PHP_start', 'PHP_starting', custom_context)
      link_tasks(graph, 'PHP_creating', 'PHP_initial', custom_context)
      link_tasks(graph, '_a4c_init_PHP', 'PHP_creating', custom_context)
      link_tasks(graph, 'Apache_initial', 'Server_install', custom_context)
      link_tasks(graph, 'PHP_initial', 'Server_install', custom_context)
      link_tasks(graph, 'Apache_configure', 'Wordpress_host_pre_configure_target', custom_context)
      link_tasks(graph, 'PHP_configured', 'Wordpress_php_post_configure_target', custom_context)
      link_tasks(graph, 'Wordpress_configure', 'Wordpress_database_pre_configure_source', custom_context)
      link_tasks(graph, 'PHP_create', '_a4c_init_PHP', custom_context)
      link_tasks(graph, 'Wordpress_create', '_a4c_init_Wordpress', custom_context)
      link_tasks(graph, 'Apache_create', '_a4c_init_Apache', custom_context)
  
  
  # Subworkflow for host
  def install_host_database(ctx, graph, custom_context):
      custom_context.add_customized_wf_node('Mysql')
      custom_context.add_customized_wf_node('Mysql')
      custom_context.add_customized_wf_node('Mysql')
      custom_context.add_customized_wf_node('Mysql')
      custom_context.add_customized_wf_node('Mysql')
      custom_context.add_customized_wf_node('Mysql')
      custom_context.add_customized_wf_node('Mysql')
      relationship_operation_task(ctx, graph, 'Wordpress', 'Mysql', 'cloudify.interfaces.relationship_lifecycle.postconfigure', 'TARGET', 'Wordpress_database_post_configure_target', custom_context)
      operation_task(ctx, graph, 'Mysql', 'cloudify.interfaces.lifecycle.configure', 'Mysql_configure', custom_context)
      relationship_operation_task(ctx, graph, 'Wordpress', 'Mysql', 'cloudify.interfaces.relationship_lifecycle.postconfigure', 'SOURCE', 'Wordpress_database_post_configure_source', custom_context)
      operation_task(ctx, graph, 'Mysql', 'cloudify.interfaces.lifecycle.start', 'Mysql_start', custom_context)
      set_state_task(ctx, graph, 'Mysql', 'initial', 'Mysql_initial', custom_context)
      set_state_task(ctx, graph, 'Mysql', 'creating', 'Mysql_creating', custom_context)
      set_state_task(ctx, graph, 'Mysql', 'configuring', 'Mysql_configuring', custom_context)
      relationship_operation_task(ctx, graph, 'Mysql', 'DataBase', 'cloudify.interfaces.relationship_lifecycle.establish', 'SOURCE', 'Mysql_host_add_target', custom_context)
      set_state_task(ctx, graph, 'Mysql', 'starting', 'Mysql_starting', custom_context)
      custom_context.register_native_delegate_wf_step('DataBase', 'DataBase_install')
      relationship_operation_task(ctx, graph, 'Wordpress', 'Mysql', 'cloudify.interfaces.relationship_lifecycle.establish', 'TARGET', 'Wordpress_database_add_source', custom_context)
      set_state_task(ctx, graph, 'Mysql', 'started', 'Mysql_started', custom_context)
      relationship_operation_task(ctx, graph, 'Wordpress', 'Mysql', 'cloudify.interfaces.relationship_lifecycle.establish', 'SOURCE', 'Wordpress_database_add_target', custom_context)
      relationship_operation_task(ctx, graph, 'Mysql', 'DataBase', 'cloudify.interfaces.relationship_lifecycle.preconfigure', 'SOURCE', 'Mysql_host_pre_configure_source', custom_context)
      operation_task(ctx, graph, 'Mysql', 'cloudify.interfaces.lifecycle.create', 'Mysql_create', custom_context)
      relationship_operation_task(ctx, graph, 'Wordpress', 'Mysql', 'cloudify.interfaces.relationship_lifecycle.preconfigure', 'TARGET', 'Wordpress_database_pre_configure_target', custom_context)
      set_state_task(ctx, graph, 'Mysql', 'configured', 'Mysql_configured', custom_context)
      relationship_operation_task(ctx, graph, 'Mysql', 'DataBase', 'cloudify.interfaces.relationship_lifecycle.postconfigure', 'SOURCE', 'Mysql_host_post_configure_source', custom_context)
      set_state_task(ctx, graph, 'Mysql', 'created', 'Mysql_created', custom_context)
      relationship_operation_task(ctx, graph, 'Wordpress', 'Mysql', 'cloudify.interfaces.relationship_lifecycle.preconfigure', 'SOURCE', 'Wordpress_database_pre_configure_source', custom_context)
      operation_task(ctx, graph, 'Mysql', 'org.alien4cloud.interfaces.cfy.lifecycle.NodeInit', '_a4c_init_Mysql', custom_context)
      generate_native_node_workflows(ctx, graph, custom_context, 'install')
      link_tasks(graph, 'Mysql_configured', 'Wordpress_database_post_configure_target', custom_context)
      link_tasks(graph, 'Mysql_configured', 'Mysql_configure', custom_context)
      link_tasks(graph, 'Mysql_host_post_configure_source', 'Mysql_configure', custom_context)
      link_tasks(graph, 'Wordpress_database_post_configure_target', 'Mysql_configure', custom_context)
      link_tasks(graph, 'Mysql_started', 'Mysql_start', custom_context)
      link_tasks(graph, 'Mysql_creating', 'Mysql_initial', custom_context)
      link_tasks(graph, '_a4c_init_Mysql', 'Mysql_creating', custom_context)
      link_tasks(graph, 'Wordpress_database_pre_configure_target', 'Mysql_configuring', custom_context)
      link_tasks(graph, 'Mysql_configure', 'Mysql_configuring', custom_context)
      link_tasks(graph, 'Mysql_host_pre_configure_source', 'Mysql_configuring', custom_context)
      link_tasks(graph, 'Mysql_start', 'Mysql_starting', custom_context)
      link_tasks(graph, 'Mysql_initial', 'DataBase_install', custom_context)
      link_tasks(graph, 'Mysql_host_add_target', 'Mysql_started', custom_context)
      link_tasks(graph, 'Mysql_configure', 'Mysql_host_pre_configure_source', custom_context)
      link_tasks(graph, 'Mysql_created', 'Mysql_create', custom_context)
      link_tasks(graph, 'Mysql_configure', 'Wordpress_database_pre_configure_target', custom_context)
      link_tasks(graph, 'Mysql_starting', 'Mysql_configured', custom_context)
      link_tasks(graph, 'Mysql_configured', 'Mysql_host_post_configure_source', custom_context)
      link_tasks(graph, 'Mysql_configuring', 'Mysql_created', custom_context)
      link_tasks(graph, 'Mysql_create', '_a4c_init_Mysql', custom_context)
  
  
  # Subworkflow for host
  def install_host_netpub(ctx, graph, custom_context):
      custom_context.register_native_delegate_wf_step('NetPub', 'NetPub_install')
      generate_native_node_workflows(ctx, graph, custom_context, 'install')
  
  
  # Subworkflow for host
  def uninstall_host_server(ctx, graph, custom_context):
      custom_context.add_customized_wf_node('Wordpress')
      custom_context.add_customized_wf_node('Apache')
      custom_context.add_customized_wf_node('Apache')
      custom_context.add_customized_wf_node('PHP')
      custom_context.add_customized_wf_node('PHP')
      custom_context.add_customized_wf_node('Wordpress')
      custom_context.add_customized_wf_node('Wordpress')
      custom_context.add_customized_wf_node('Apache')
      custom_context.add_customized_wf_node('Wordpress')
      custom_context.add_customized_wf_node('PHP')
      custom_context.add_customized_wf_node('PHP')
      custom_context.add_customized_wf_node('Apache')
      relationship_operation_task(ctx, graph, 'Wordpress', 'PHP', 'cloudify.interfaces.relationship_lifecycle.unlink', 'TARGET', 'Wordpress_php_remove_source', custom_context)
      set_state_task(ctx, graph, 'Wordpress', 'deleted', 'Wordpress_deleted', custom_context)
      set_state_task(ctx, graph, 'Apache', 'stopped', 'Apache_stopped', custom_context)
      set_state_task(ctx, graph, 'Apache', 'stopping', 'Apache_stopping', custom_context)
      operation_task(ctx, graph, 'Wordpress', 'cloudify.interfaces.lifecycle.stop', 'Wordpress_stop', custom_context)
      relationship_operation_task(ctx, graph, 'Apache', 'Server', 'cloudify.interfaces.relationship_lifecycle.unlink', 'SOURCE', 'Apache_host_remove_target', custom_context)
      relationship_operation_task(ctx, graph, 'Wordpress', 'PHP', 'cloudify.interfaces.relationship_lifecycle.unlink', 'SOURCE', 'Wordpress_php_remove_target', custom_context)
      set_state_task(ctx, graph, 'PHP', 'stopping', 'PHP_stopping', custom_context)
      set_state_task(ctx, graph, 'PHP', 'deleted', 'PHP_deleted', custom_context)
      set_state_task(ctx, graph, 'Wordpress', 'stopped', 'Wordpress_stopped', custom_context)
      operation_task(ctx, graph, 'PHP', 'cloudify.interfaces.lifecycle.delete', 'PHP_delete', custom_context)
      relationship_operation_task(ctx, graph, 'Wordpress', 'Apache', 'cloudify.interfaces.relationship_lifecycle.unlink', 'SOURCE', 'Wordpress_host_remove_target', custom_context)
      operation_task(ctx, graph, 'Apache', 'cloudify.interfaces.lifecycle.delete', 'Apache_delete', custom_context)
      set_state_task(ctx, graph, 'Wordpress', 'deleting', 'Wordpress_deleting', custom_context)
      relationship_operation_task(ctx, graph, 'Wordpress', 'Mysql', 'cloudify.interfaces.relationship_lifecycle.unlink', 'TARGET', 'Wordpress_database_remove_source', custom_context)
      operation_task(ctx, graph, 'PHP', 'cloudify.interfaces.lifecycle.stop', 'PHP_stop', custom_context)
      set_state_task(ctx, graph, 'Apache', 'deleting', 'Apache_deleting', custom_context)
      relationship_operation_task(ctx, graph, 'Wordpress', 'Mysql', 'cloudify.interfaces.relationship_lifecycle.unlink', 'SOURCE', 'Wordpress_database_remove_target', custom_context)
      relationship_operation_task(ctx, graph, 'PHP', 'Server', 'cloudify.interfaces.relationship_lifecycle.unlink', 'SOURCE', 'PHP_host_remove_target', custom_context)
      set_state_task(ctx, graph, 'Wordpress', 'stopping', 'Wordpress_stopping', custom_context)
      set_state_task(ctx, graph, 'PHP', 'deleting', 'PHP_deleting', custom_context)
      set_state_task(ctx, graph, 'PHP', 'stopped', 'PHP_stopped', custom_context)
      custom_context.register_native_delegate_wf_step('Server', 'Server_uninstall')
      relationship_operation_task(ctx, graph, 'Wordpress', 'Apache', 'cloudify.interfaces.relationship_lifecycle.unlink', 'TARGET', 'Wordpress_host_remove_source', custom_context)
      operation_task(ctx, graph, 'Apache', 'cloudify.interfaces.lifecycle.stop', 'Apache_stop', custom_context)
      set_state_task(ctx, graph, 'Apache', 'deleted', 'Apache_deleted', custom_context)
      operation_task(ctx, graph, 'Wordpress', 'cloudify.interfaces.lifecycle.delete', 'Wordpress_delete', custom_context)
      generate_native_node_workflows(ctx, graph, custom_context, 'uninstall')
      link_tasks(graph, 'Wordpress_stopping', 'Wordpress_php_remove_source', custom_context)
      link_tasks(graph, 'Apache_stopping', 'Wordpress_deleted', custom_context)
      link_tasks(graph, 'PHP_stopping', 'Wordpress_deleted', custom_context)
      link_tasks(graph, 'Apache_deleting', 'Apache_stopped', custom_context)
      link_tasks(graph, 'Apache_stop', 'Apache_stopping', custom_context)
      link_tasks(graph, 'Wordpress_stopped', 'Wordpress_stop', custom_context)
      link_tasks(graph, 'Apache_stopping', 'Apache_host_remove_target', custom_context)
      link_tasks(graph, 'Wordpress_stopping', 'Wordpress_php_remove_target', custom_context)
      link_tasks(graph, 'PHP_stop', 'PHP_stopping', custom_context)
      link_tasks(graph, 'Server_uninstall', 'PHP_deleted', custom_context)
      link_tasks(graph, 'Wordpress_deleting', 'Wordpress_stopped', custom_context)
      link_tasks(graph, 'PHP_deleted', 'PHP_delete', custom_context)
      link_tasks(graph, 'Wordpress_stopping', 'Wordpress_host_remove_target', custom_context)
      link_tasks(graph, 'Apache_deleted', 'Apache_delete', custom_context)
      link_tasks(graph, 'Wordpress_delete', 'Wordpress_deleting', custom_context)
      link_tasks(graph, 'Wordpress_stopping', 'Wordpress_database_remove_source', custom_context)
      link_tasks(graph, 'PHP_stopped', 'PHP_stop', custom_context)
      link_tasks(graph, 'Apache_delete', 'Apache_deleting', custom_context)
      link_tasks(graph, 'Wordpress_stopping', 'Wordpress_database_remove_target', custom_context)
      link_tasks(graph, 'PHP_stopping', 'PHP_host_remove_target', custom_context)
      link_tasks(graph, 'Wordpress_stop', 'Wordpress_stopping', custom_context)
      link_tasks(graph, 'PHP_delete', 'PHP_deleting', custom_context)
      link_tasks(graph, 'PHP_deleting', 'PHP_stopped', custom_context)
      link_tasks(graph, 'Wordpress_stopping', 'Wordpress_host_remove_source', custom_context)
      link_tasks(graph, 'Apache_stopped', 'Apache_stop', custom_context)
      link_tasks(graph, 'Server_uninstall', 'Apache_deleted', custom_context)
      link_tasks(graph, 'Wordpress_deleted', 'Wordpress_delete', custom_context)
  
  
  # Subworkflow for host
  def uninstall_host_database(ctx, graph, custom_context):
      custom_context.add_customized_wf_node('Mysql')
      custom_context.add_customized_wf_node('Mysql')
      custom_context.add_customized_wf_node('Mysql')
      custom_context.add_customized_wf_node('Mysql')
      operation_task(ctx, graph, 'Mysql', 'cloudify.interfaces.lifecycle.delete', 'Mysql_delete', custom_context)
      set_state_task(ctx, graph, 'Mysql', 'stopping', 'Mysql_stopping', custom_context)
      relationship_operation_task(ctx, graph, 'Mysql', 'DataBase', 'cloudify.interfaces.relationship_lifecycle.unlink', 'SOURCE', 'Mysql_host_remove_target', custom_context)
      relationship_operation_task(ctx, graph, 'Wordpress', 'Mysql', 'cloudify.interfaces.relationship_lifecycle.unlink', 'TARGET', 'Wordpress_database_remove_source', custom_context)
      relationship_operation_task(ctx, graph, 'Wordpress', 'Mysql', 'cloudify.interfaces.relationship_lifecycle.unlink', 'SOURCE', 'Wordpress_database_remove_target', custom_context)
      set_state_task(ctx, graph, 'Mysql', 'deleting', 'Mysql_deleting', custom_context)
      operation_task(ctx, graph, 'Mysql', 'cloudify.interfaces.lifecycle.stop', 'Mysql_stop', custom_context)
      custom_context.register_native_delegate_wf_step('DataBase', 'DataBase_uninstall')
      set_state_task(ctx, graph, 'Mysql', 'stopped', 'Mysql_stopped', custom_context)
      set_state_task(ctx, graph, 'Mysql', 'deleted', 'Mysql_deleted', custom_context)
      generate_native_node_workflows(ctx, graph, custom_context, 'uninstall')
      link_tasks(graph, 'Mysql_deleted', 'Mysql_delete', custom_context)
      link_tasks(graph, 'Mysql_stop', 'Mysql_stopping', custom_context)
      link_tasks(graph, 'Mysql_stopping', 'Mysql_host_remove_target', custom_context)
      link_tasks(graph, 'Mysql_delete', 'Mysql_deleting', custom_context)
      link_tasks(graph, 'Mysql_stopped', 'Mysql_stop', custom_context)
      link_tasks(graph, 'Mysql_deleting', 'Mysql_stopped', custom_context)
      link_tasks(graph, 'DataBase_uninstall', 'Mysql_deleted', custom_context)
  
  
  # Subworkflow for host
  def uninstall_host_netpub(ctx, graph, custom_context):
      custom_context.register_native_delegate_wf_step('NetPub', 'NetPub_uninstall')
      generate_native_node_workflows(ctx, graph, custom_context, 'uninstall')
  
  
  def install_host(ctx, graph, custom_context, compute):
      options = {}
      options['Server'] = install_host_server
      options['DataBase'] = install_host_database
      options['NetPub'] = install_host_netpub
      options[compute](ctx, graph, custom_context)
  
  
  def uninstall_host(ctx, graph, custom_context, compute):
      options = {}
      options['Server'] = uninstall_host_server
      options['DataBase'] = uninstall_host_database
      options['NetPub'] = uninstall_host_netpub
      options[compute](ctx, graph, custom_context)
  
  
  @workflow
  def a4c_install(**kwargs):
      graph = ctx.graph_mode()
      nodes = _get_all_nodes(ctx)
      instances = _get_all_nodes_instances(ctx)
      custom_context = CustomContext(ctx, instances, nodes)
      ctx.internal.send_workflow_event(event_type='a4c_workflow_started', message=build_pre_event(WfStartEvent('install')))
      _a4c_install(ctx, graph, custom_context)
      return graph.execute()
  
  
  @workflow
  def a4c_uninstall(**kwargs):
      graph = ctx.graph_mode()
      nodes = _get_all_nodes(ctx)
      instances = _get_all_nodes_instances(ctx)
      custom_context = CustomContext(ctx, instances, nodes)
      ctx.internal.send_workflow_event(event_type='a4c_workflow_started', message=build_pre_event(WfStartEvent('uninstall')))
      _a4c_uninstall(ctx, graph, custom_context)
      return graph.execute()
  
  
  @workflow
  def a4c_start(**kwargs):
      graph = ctx.graph_mode()
      nodes = _get_all_nodes(ctx)
      instances = _get_all_nodes_instances(ctx)
      custom_context = CustomContext(ctx, instances, nodes)
      ctx.internal.send_workflow_event(event_type='a4c_workflow_started', message=build_pre_event(WfStartEvent('start')))
      _a4c_start(ctx, graph, custom_context)
      return graph.execute()
  
  
  @workflow
  def a4c_stop(**kwargs):
      graph = ctx.graph_mode()
      nodes = _get_all_nodes(ctx)
      instances = _get_all_nodes_instances(ctx)
      custom_context = CustomContext(ctx, instances, nodes)
      ctx.internal.send_workflow_event(event_type='a4c_workflow_started', message=build_pre_event(WfStartEvent('stop')))
      _a4c_stop(ctx, graph, custom_context)
      return graph.execute()
  
  
  def _a4c_install(ctx, graph, custom_context):
      #  following code can be pasted in src/test/python/workflows/tasks.py for simulation
      custom_context.add_customized_wf_node('Apache')
      custom_context.add_customized_wf_node('Apache')
      custom_context.add_customized_wf_node('Apache')
      custom_context.add_customized_wf_node('Mysql')
      custom_context.add_customized_wf_node('Mysql')
      custom_context.add_customized_wf_node('Mysql')
      custom_context.add_customized_wf_node('Wordpress')
      custom_context.add_customized_wf_node('Apache')
      custom_context.add_customized_wf_node('Mysql')
      custom_context.add_customized_wf_node('Wordpress')
      custom_context.add_customized_wf_node('Apache')
      custom_context.add_customized_wf_node('Wordpress')
      custom_context.add_customized_wf_node('Mysql')
      custom_context.add_customized_wf_node('Wordpress')
      custom_context.add_customized_wf_node('Apache')
      custom_context.add_customized_wf_node('PHP')
      custom_context.add_customized_wf_node('PHP')
      custom_context.add_customized_wf_node('Apache')
      custom_context.add_customized_wf_node('Wordpress')
      custom_context.add_customized_wf_node('Wordpress')
      custom_context.add_customized_wf_node('Wordpress')
      custom_context.add_customized_wf_node('Mysql')
      custom_context.add_customized_wf_node('PHP')
      custom_context.add_customized_wf_node('PHP')
      custom_context.add_customized_wf_node('PHP')
      custom_context.add_customized_wf_node('PHP')
      custom_context.add_customized_wf_node('PHP')
      custom_context.add_customized_wf_node('Mysql')
      set_state_task(ctx, graph, 'Apache', 'created', 'Apache_created', custom_context)
      relationship_operation_task(ctx, graph, 'PHP', 'Server', 'cloudify.interfaces.relationship_lifecycle.preconfigure', 'SOURCE', 'PHP_host_pre_configure_source', custom_context)
      set_state_task(ctx, graph, 'Apache', 'started', 'Apache_started', custom_context)
      set_state_task(ctx, graph, 'Apache', 'configured', 'Apache_configured', custom_context)
      relationship_operation_task(ctx, graph, 'Wordpress', 'Mysql', 'cloudify.interfaces.relationship_lifecycle.postconfigure', 'TARGET', 'Wordpress_database_post_configure_target', custom_context)
      relationship_operation_task(ctx, graph, 'PHP', 'Server', 'cloudify.interfaces.relationship_lifecycle.establish', 'SOURCE', 'PHP_host_add_target', custom_context)
      operation_task(ctx, graph, 'Wordpress', 'cloudify.interfaces.lifecycle.start', 'Wordpress_start', custom_context)
      operation_task(ctx, graph, 'Mysql', 'cloudify.interfaces.lifecycle.configure', 'Mysql_configure', custom_context)
      relationship_operation_task(ctx, graph, 'Wordpress', 'Mysql', 'cloudify.interfaces.relationship_lifecycle.postconfigure', 'SOURCE', 'Wordpress_database_post_configure_source', custom_context)
      operation_task(ctx, graph, 'Mysql', 'cloudify.interfaces.lifecycle.start', 'Mysql_start', custom_context)
      set_state_task(ctx, graph, 'Mysql', 'initial', 'Mysql_initial', custom_context)
      set_state_task(ctx, graph, 'Mysql', 'creating', 'Mysql_creating', custom_context)
      operation_task(ctx, graph, 'PHP', 'cloudify.interfaces.lifecycle.configure', 'PHP_configure', custom_context)
      relationship_operation_task(ctx, graph, 'Wordpress', 'Apache', 'cloudify.interfaces.relationship_lifecycle.establish', 'SOURCE', 'Wordpress_host_add_target', custom_context)
      operation_task(ctx, graph, 'Wordpress', 'cloudify.interfaces.lifecycle.configure', 'Wordpress_configure', custom_context)
      relationship_operation_task(ctx, graph, 'Wordpress', 'Apache', 'cloudify.interfaces.relationship_lifecycle.preconfigure', 'SOURCE', 'Wordpress_host_pre_configure_source', custom_context)
      set_state_task(ctx, graph, 'Mysql', 'configuring', 'Mysql_configuring', custom_context)
      set_state_task(ctx, graph, 'Wordpress', 'created', 'Wordpress_created', custom_context)
      relationship_operation_task(ctx, graph, 'Apache', 'Server', 'cloudify.interfaces.relationship_lifecycle.postconfigure', 'SOURCE', 'Apache_host_post_configure_source', custom_context)
      set_state_task(ctx, graph, 'Apache', 'initial', 'Apache_initial', custom_context)
      relationship_operation_task(ctx, graph, 'Mysql', 'DataBase', 'cloudify.interfaces.relationship_lifecycle.establish', 'SOURCE', 'Mysql_host_add_target', custom_context)
      set_state_task(ctx, graph, 'Mysql', 'starting', 'Mysql_starting', custom_context)
      relationship_operation_task(ctx, graph, 'Wordpress', 'PHP', 'cloudify.interfaces.relationship_lifecycle.establish', 'SOURCE', 'Wordpress_php_add_target', custom_context)
      set_state_task(ctx, graph, 'Wordpress', 'starting', 'Wordpress_starting', custom_context)
      custom_context.register_native_delegate_wf_step('NetPub', 'NetPub_install')
      set_state_task(ctx, graph, 'Apache', 'configuring', 'Apache_configuring', custom_context)
      custom_context.register_native_delegate_wf_step('DataBase', 'DataBase_install')
      set_state_task(ctx, graph, 'Wordpress', 'creating', 'Wordpress_creating', custom_context)
      relationship_operation_task(ctx, graph, 'Wordpress', 'Mysql', 'cloudify.interfaces.relationship_lifecycle.establish', 'TARGET', 'Wordpress_database_add_source', custom_context)
      operation_task(ctx, graph, 'Apache', 'cloudify.interfaces.lifecycle.configure', 'Apache_configure', custom_context)
      operation_task(ctx, graph, 'PHP', 'cloudify.interfaces.lifecycle.create', 'PHP_create', custom_context)
      set_state_task(ctx, graph, 'Mysql', 'started', 'Mysql_started', custom_context)
      relationship_operation_task(ctx, graph, 'Wordpress', 'Apache', 'cloudify.interfaces.relationship_lifecycle.postconfigure', 'TARGET', 'Wordpress_host_post_configure_target', custom_context)
      set_state_task(ctx, graph, 'Wordpress', 'started', 'Wordpress_started', custom_context)
      set_state_task(ctx, graph, 'Apache', 'starting', 'Apache_starting', custom_context)
      set_state_task(ctx, graph, 'PHP', 'configuring', 'PHP_configuring', custom_context)
      set_state_task(ctx, graph, 'PHP', 'configured', 'PHP_configured', custom_context)
      relationship_operation_task(ctx, graph, 'Apache', 'Server', 'cloudify.interfaces.relationship_lifecycle.preconfigure', 'SOURCE', 'Apache_host_pre_configure_source', custom_context)
      relationship_operation_task(ctx, graph, 'Wordpress', 'Mysql', 'cloudify.interfaces.relationship_lifecycle.establish', 'SOURCE', 'Wordpress_database_add_target', custom_context)
      relationship_operation_task(ctx, graph, 'Wordpress', 'Apache', 'cloudify.interfaces.relationship_lifecycle.establish', 'TARGET', 'Wordpress_host_add_source', custom_context)
      relationship_operation_task(ctx, graph, 'PHP', 'Server', 'cloudify.interfaces.relationship_lifecycle.postconfigure', 'SOURCE', 'PHP_host_post_configure_source', custom_context)
      set_state_task(ctx, graph, 'Apache', 'creating', 'Apache_creating', custom_context)
      set_state_task(ctx, graph, 'Wordpress', 'initial', 'Wordpress_initial', custom_context)
      set_state_task(ctx, graph, 'Wordpress', 'configuring', 'Wordpress_configuring', custom_context)
      operation_task(ctx, graph, 'Apache', 'cloudify.interfaces.lifecycle.start', 'Apache_start', custom_context)
      set_state_task(ctx, graph, 'Wordpress', 'configured', 'Wordpress_configured', custom_context)
      relationship_operation_task(ctx, graph, 'Wordpress', 'PHP', 'cloudify.interfaces.relationship_lifecycle.preconfigure', 'SOURCE', 'Wordpress_php_pre_configure_source', custom_context)
      operation_task(ctx, graph, 'Wordpress', 'cloudify.interfaces.lifecycle.create', 'Wordpress_create', custom_context)
      relationship_operation_task(ctx, graph, 'Mysql', 'DataBase', 'cloudify.interfaces.relationship_lifecycle.preconfigure', 'SOURCE', 'Mysql_host_pre_configure_source', custom_context)
      operation_task(ctx, graph, 'Mysql', 'cloudify.interfaces.lifecycle.create', 'Mysql_create', custom_context)
      relationship_operation_task(ctx, graph, 'Wordpress', 'PHP', 'cloudify.interfaces.relationship_lifecycle.preconfigure', 'TARGET', 'Wordpress_php_pre_configure_target', custom_context)
      relationship_operation_task(ctx, graph, 'Wordpress', 'Mysql', 'cloudify.interfaces.relationship_lifecycle.preconfigure', 'TARGET', 'Wordpress_database_pre_configure_target', custom_context)
      relationship_operation_task(ctx, graph, 'Wordpress', 'PHP', 'cloudify.interfaces.relationship_lifecycle.postconfigure', 'SOURCE', 'Wordpress_php_post_configure_source', custom_context)
      set_state_task(ctx, graph, 'Mysql', 'configured', 'Mysql_configured', custom_context)
      relationship_operation_task(ctx, graph, 'Wordpress', 'Apache', 'cloudify.interfaces.relationship_lifecycle.postconfigure', 'SOURCE', 'Wordpress_host_post_configure_source', custom_context)
      set_state_task(ctx, graph, 'PHP', 'created', 'PHP_created', custom_context)
      relationship_operation_task(ctx, graph, 'Mysql', 'DataBase', 'cloudify.interfaces.relationship_lifecycle.postconfigure', 'SOURCE', 'Mysql_host_post_configure_source', custom_context)
      set_state_task(ctx, graph, 'PHP', 'started', 'PHP_started', custom_context)
      operation_task(ctx, graph, 'Apache', 'cloudify.interfaces.lifecycle.create', 'Apache_create', custom_context)
      operation_task(ctx, graph, 'PHP', 'cloudify.interfaces.lifecycle.start', 'PHP_start', custom_context)
      set_state_task(ctx, graph, 'PHP', 'starting', 'PHP_starting', custom_context)
      relationship_operation_task(ctx, graph, 'Apache', 'Server', 'cloudify.interfaces.relationship_lifecycle.establish', 'SOURCE', 'Apache_host_add_target', custom_context)
      set_state_task(ctx, graph, 'PHP', 'initial', 'PHP_initial', custom_context)
      set_state_task(ctx, graph, 'PHP', 'creating', 'PHP_creating', custom_context)
      set_state_task(ctx, graph, 'Mysql', 'created', 'Mysql_created', custom_context)
      custom_context.register_native_delegate_wf_step('Server', 'Server_install')
      relationship_operation_task(ctx, graph, 'Wordpress', 'Apache', 'cloudify.interfaces.relationship_lifecycle.preconfigure', 'TARGET', 'Wordpress_host_pre_configure_target', custom_context)
      relationship_operation_task(ctx, graph, 'Wordpress', 'PHP', 'cloudify.interfaces.relationship_lifecycle.establish', 'TARGET', 'Wordpress_php_add_source', custom_context)
      relationship_operation_task(ctx, graph, 'Wordpress', 'PHP', 'cloudify.interfaces.relationship_lifecycle.postconfigure', 'TARGET', 'Wordpress_php_post_configure_target', custom_context)
      relationship_operation_task(ctx, graph, 'Wordpress', 'Mysql', 'cloudify.interfaces.relationship_lifecycle.preconfigure', 'SOURCE', 'Wordpress_database_pre_configure_source', custom_context)
      operation_task(ctx, graph, 'PHP', 'org.alien4cloud.interfaces.cfy.lifecycle.NodeInit', '_a4c_init_PHP', custom_context)
      operation_task(ctx, graph, 'Mysql', 'org.alien4cloud.interfaces.cfy.lifecycle.NodeInit', '_a4c_init_Mysql', custom_context)
      operation_task(ctx, graph, 'Wordpress', 'org.alien4cloud.interfaces.cfy.lifecycle.NodeInit', '_a4c_init_Wordpress', custom_context)
      operation_task(ctx, graph, 'Apache', 'org.alien4cloud.interfaces.cfy.lifecycle.NodeInit', '_a4c_init_Apache', custom_context)
      generate_native_node_workflows(ctx, graph, custom_context, 'install')
      link_tasks(graph, 'Apache_created', 'Apache_create', custom_context)
      link_tasks(graph, 'PHP_host_pre_configure_source', 'PHP_configuring', custom_context)
      link_tasks(graph, 'Apache_started', 'Apache_start', custom_context)
      link_tasks(graph, 'Apache_configured', 'Apache_configure', custom_context)
      link_tasks(graph, 'Apache_configured', 'Apache_host_post_configure_source', custom_context)
      link_tasks(graph, 'Apache_configured', 'Wordpress_host_post_configure_target', custom_context)
      link_tasks(graph, 'Wordpress_database_post_configure_target', 'Mysql_configure', custom_context)
      link_tasks(graph, 'PHP_host_add_target', 'PHP_started', custom_context)
      link_tasks(graph, 'Wordpress_start', 'Wordpress_starting', custom_context)
      link_tasks(graph, 'Mysql_configure', 'Mysql_configuring', custom_context)
      link_tasks(graph, 'Mysql_configure', 'Wordpress_database_pre_configure_target', custom_context)
      link_tasks(graph, 'Mysql_configure', 'Mysql_host_pre_configure_source', custom_context)
      link_tasks(graph, 'Wordpress_database_post_configure_source', 'Wordpress_configure', custom_context)
      link_tasks(graph, 'Mysql_start', 'Mysql_starting', custom_context)
      link_tasks(graph, 'Mysql_initial', 'DataBase_install', custom_context)
      link_tasks(graph, 'Mysql_creating', 'Mysql_initial', custom_context)
      link_tasks(graph, 'PHP_configure', 'PHP_host_pre_configure_source', custom_context)
      link_tasks(graph, 'PHP_configure', 'Wordpress_php_pre_configure_target', custom_context)
      link_tasks(graph, 'PHP_configure', 'PHP_configuring', custom_context)
      link_tasks(graph, 'Wordpress_host_add_target', 'Wordpress_started', custom_context)
      link_tasks(graph, 'Wordpress_configure', 'Wordpress_php_pre_configure_source', custom_context)
      link_tasks(graph, 'Wordpress_configure', 'Wordpress_host_pre_configure_source', custom_context)
      link_tasks(graph, 'Wordpress_configure', 'Wordpress_configuring', custom_context)
      link_tasks(graph, 'Wordpress_configure', 'Wordpress_database_pre_configure_source', custom_context)
      link_tasks(graph, 'Wordpress_host_pre_configure_source', 'Wordpress_configuring', custom_context)
      link_tasks(graph, 'Mysql_configuring', 'Mysql_created', custom_context)
      link_tasks(graph, 'Wordpress_created', 'Wordpress_create', custom_context)
      link_tasks(graph, 'Apache_host_post_configure_source', 'Apache_configure', custom_context)
      link_tasks(graph, 'Apache_initial', 'Server_install', custom_context)
      link_tasks(graph, 'Mysql_host_add_target', 'Mysql_started', custom_context)
      link_tasks(graph, 'Mysql_starting', 'Mysql_configured', custom_context)
      link_tasks(graph, 'Wordpress_php_add_target', 'Wordpress_started', custom_context)
      link_tasks(graph, 'Wordpress_starting', 'Wordpress_configured', custom_context)
      link_tasks(graph, 'Apache_configuring', 'Apache_created', custom_context)
      link_tasks(graph, 'Wordpress_creating', 'Wordpress_initial', custom_context)
      link_tasks(graph, 'Wordpress_database_add_source', 'Wordpress_started', custom_context)
      link_tasks(graph, 'Apache_configure', 'Apache_configuring', custom_context)
      link_tasks(graph, 'Apache_configure', 'Wordpress_host_pre_configure_target', custom_context)
      link_tasks(graph, 'Apache_configure', 'Apache_host_pre_configure_source', custom_context)
      link_tasks(graph, 'PHP_create', '_a4c_init_PHP', custom_context)
      link_tasks(graph, 'Mysql_started', 'Mysql_start', custom_context)
      link_tasks(graph, 'Wordpress_host_post_configure_target', 'Apache_configure', custom_context)
      link_tasks(graph, 'Wordpress_started', 'Wordpress_start', custom_context)
      link_tasks(graph, 'Apache_starting', 'Apache_configured', custom_context)
      link_tasks(graph, 'PHP_configuring', 'PHP_created', custom_context)
      link_tasks(graph, 'PHP_configured', 'PHP_configure', custom_context)
      link_tasks(graph, 'PHP_configured', 'PHP_host_post_configure_source', custom_context)
      link_tasks(graph, 'PHP_configured', 'Wordpress_php_post_configure_target', custom_context)
      link_tasks(graph, 'Apache_host_pre_configure_source', 'Apache_configuring', custom_context)
      link_tasks(graph, 'Wordpress_database_add_target', 'Wordpress_started', custom_context)
      link_tasks(graph, 'Wordpress_host_add_source', 'Wordpress_started', custom_context)
      link_tasks(graph, 'PHP_host_post_configure_source', 'PHP_configure', custom_context)
      link_tasks(graph, 'Apache_creating', 'Apache_initial', custom_context)
      link_tasks(graph, 'Wordpress_initial', 'Apache_started', custom_context)
      link_tasks(graph, 'Wordpress_initial', 'Mysql_started', custom_context)
      link_tasks(graph, 'Wordpress_initial', 'PHP_started', custom_context)
      link_tasks(graph, 'Wordpress_configuring', 'Wordpress_created', custom_context)
      link_tasks(graph, 'Apache_start', 'Apache_starting', custom_context)
      link_tasks(graph, 'Wordpress_configured', 'Wordpress_host_post_configure_source', custom_context)
      link_tasks(graph, 'Wordpress_configured', 'Wordpress_configure', custom_context)
      link_tasks(graph, 'Wordpress_configured', 'Wordpress_php_post_configure_source', custom_context)
      link_tasks(graph, 'Wordpress_configured', 'Wordpress_database_post_configure_source', custom_context)
      link_tasks(graph, 'Wordpress_php_pre_configure_source', 'Wordpress_configuring', custom_context)
      link_tasks(graph, 'Wordpress_create', '_a4c_init_Wordpress', custom_context)
      link_tasks(graph, 'Mysql_host_pre_configure_source', 'Mysql_configuring', custom_context)
      link_tasks(graph, 'Mysql_create', '_a4c_init_Mysql', custom_context)
      link_tasks(graph, 'Wordpress_php_pre_configure_target', 'PHP_configuring', custom_context)
      link_tasks(graph, 'Wordpress_database_pre_configure_target', 'Mysql_configuring', custom_context)
      link_tasks(graph, 'Wordpress_php_post_configure_source', 'Wordpress_configure', custom_context)
      link_tasks(graph, 'Mysql_configured', 'Mysql_host_post_configure_source', custom_context)
      link_tasks(graph, 'Mysql_configured', 'Wordpress_database_post_configure_target', custom_context)
      link_tasks(graph, 'Mysql_configured', 'Mysql_configure', custom_context)
      link_tasks(graph, 'Wordpress_host_post_configure_source', 'Wordpress_configure', custom_context)
      link_tasks(graph, 'PHP_created', 'PHP_create', custom_context)
      link_tasks(graph, 'Mysql_host_post_configure_source', 'Mysql_configure', custom_context)
      link_tasks(graph, 'PHP_started', 'PHP_start', custom_context)
      link_tasks(graph, 'Apache_create', '_a4c_init_Apache', custom_context)
      link_tasks(graph, 'PHP_start', 'PHP_starting', custom_context)
      link_tasks(graph, 'PHP_starting', 'PHP_configured', custom_context)
      link_tasks(graph, 'Apache_host_add_target', 'Apache_started', custom_context)
      link_tasks(graph, 'PHP_initial', 'Server_install', custom_context)
      link_tasks(graph, 'PHP_creating', 'PHP_initial', custom_context)
      link_tasks(graph, 'Mysql_created', 'Mysql_create', custom_context)
      link_tasks(graph, 'Wordpress_host_pre_configure_target', 'Apache_configuring', custom_context)
      link_tasks(graph, 'Wordpress_php_add_source', 'Wordpress_started', custom_context)
      link_tasks(graph, 'Wordpress_php_post_configure_target', 'PHP_configure', custom_context)
      link_tasks(graph, 'Wordpress_database_pre_configure_source', 'Wordpress_configuring', custom_context)
      link_tasks(graph, '_a4c_init_PHP', 'PHP_creating', custom_context)
      link_tasks(graph, '_a4c_init_Mysql', 'Mysql_creating', custom_context)
      link_tasks(graph, '_a4c_init_Wordpress', 'Wordpress_creating', custom_context)
      link_tasks(graph, '_a4c_init_Apache', 'Apache_creating', custom_context)
  def _a4c_uninstall(ctx, graph, custom_context):
      #  following code can be pasted in src/test/python/workflows/tasks.py for simulation
      custom_context.add_customized_wf_node('Wordpress')
      custom_context.add_customized_wf_node('Apache')
      custom_context.add_customized_wf_node('Apache')
      custom_context.add_customized_wf_node('PHP')
      custom_context.add_customized_wf_node('PHP')
      custom_context.add_customized_wf_node('Wordpress')
      custom_context.add_customized_wf_node('Mysql')
      custom_context.add_customized_wf_node('Wordpress')
      custom_context.add_customized_wf_node('Apache')
      custom_context.add_customized_wf_node('Wordpress')
      custom_context.add_customized_wf_node('PHP')
      custom_context.add_customized_wf_node('Mysql')
      custom_context.add_customized_wf_node('PHP')
      custom_context.add_customized_wf_node('Mysql')
      custom_context.add_customized_wf_node('Apache')
      custom_context.add_customized_wf_node('Mysql')
      relationship_operation_task(ctx, graph, 'Wordpress', 'PHP', 'cloudify.interfaces.relationship_lifecycle.unlink', 'TARGET', 'Wordpress_php_remove_source', custom_context)
      set_state_task(ctx, graph, 'Wordpress', 'deleted', 'Wordpress_deleted', custom_context)
      set_state_task(ctx, graph, 'Apache', 'stopped', 'Apache_stopped', custom_context)
      set_state_task(ctx, graph, 'Apache', 'stopping', 'Apache_stopping', custom_context)
      operation_task(ctx, graph, 'Wordpress', 'cloudify.interfaces.lifecycle.stop', 'Wordpress_stop', custom_context)
      operation_task(ctx, graph, 'Mysql', 'cloudify.interfaces.lifecycle.delete', 'Mysql_delete', custom_context)
      relationship_operation_task(ctx, graph, 'Apache', 'Server', 'cloudify.interfaces.relationship_lifecycle.unlink', 'SOURCE', 'Apache_host_remove_target', custom_context)
      relationship_operation_task(ctx, graph, 'Wordpress', 'PHP', 'cloudify.interfaces.relationship_lifecycle.unlink', 'SOURCE', 'Wordpress_php_remove_target', custom_context)
      set_state_task(ctx, graph, 'PHP', 'stopping', 'PHP_stopping', custom_context)
      custom_context.register_native_delegate_wf_step('NetPub', 'NetPub_uninstall')
      set_state_task(ctx, graph, 'PHP', 'deleted', 'PHP_deleted', custom_context)
      set_state_task(ctx, graph, 'Wordpress', 'stopped', 'Wordpress_stopped', custom_context)
      operation_task(ctx, graph, 'PHP', 'cloudify.interfaces.lifecycle.delete', 'PHP_delete', custom_context)
      set_state_task(ctx, graph, 'Mysql', 'stopping', 'Mysql_stopping', custom_context)
      relationship_operation_task(ctx, graph, 'Mysql', 'DataBase', 'cloudify.interfaces.relationship_lifecycle.unlink', 'SOURCE', 'Mysql_host_remove_target', custom_context)
      relationship_operation_task(ctx, graph, 'Wordpress', 'Apache', 'cloudify.interfaces.relationship_lifecycle.unlink', 'SOURCE', 'Wordpress_host_remove_target', custom_context)
      operation_task(ctx, graph, 'Apache', 'cloudify.interfaces.lifecycle.delete', 'Apache_delete', custom_context)
      set_state_task(ctx, graph, 'Wordpress', 'deleting', 'Wordpress_deleting', custom_context)
      relationship_operation_task(ctx, graph, 'Wordpress', 'Mysql', 'cloudify.interfaces.relationship_lifecycle.unlink', 'TARGET', 'Wordpress_database_remove_source', custom_context)
      operation_task(ctx, graph, 'PHP', 'cloudify.interfaces.lifecycle.stop', 'PHP_stop', custom_context)
      set_state_task(ctx, graph, 'Apache', 'deleting', 'Apache_deleting', custom_context)
      relationship_operation_task(ctx, graph, 'Wordpress', 'Mysql', 'cloudify.interfaces.relationship_lifecycle.unlink', 'SOURCE', 'Wordpress_database_remove_target', custom_context)
      relationship_operation_task(ctx, graph, 'PHP', 'Server', 'cloudify.interfaces.relationship_lifecycle.unlink', 'SOURCE', 'PHP_host_remove_target', custom_context)
      set_state_task(ctx, graph, 'Wordpress', 'stopping', 'Wordpress_stopping', custom_context)
      set_state_task(ctx, graph, 'PHP', 'deleting', 'PHP_deleting', custom_context)
      set_state_task(ctx, graph, 'Mysql', 'deleting', 'Mysql_deleting', custom_context)
      set_state_task(ctx, graph, 'PHP', 'stopped', 'PHP_stopped', custom_context)
      operation_task(ctx, graph, 'Mysql', 'cloudify.interfaces.lifecycle.stop', 'Mysql_stop', custom_context)
      custom_context.register_native_delegate_wf_step('Server', 'Server_uninstall')
      relationship_operation_task(ctx, graph, 'Wordpress', 'Apache', 'cloudify.interfaces.relationship_lifecycle.unlink', 'TARGET', 'Wordpress_host_remove_source', custom_context)
      operation_task(ctx, graph, 'Apache', 'cloudify.interfaces.lifecycle.stop', 'Apache_stop', custom_context)
      custom_context.register_native_delegate_wf_step('DataBase', 'DataBase_uninstall')
      set_state_task(ctx, graph, 'Mysql', 'stopped', 'Mysql_stopped', custom_context)
      set_state_task(ctx, graph, 'Apache', 'deleted', 'Apache_deleted', custom_context)
      set_state_task(ctx, graph, 'Mysql', 'deleted', 'Mysql_deleted', custom_context)
      operation_task(ctx, graph, 'Wordpress', 'cloudify.interfaces.lifecycle.delete', 'Wordpress_delete', custom_context)
      generate_native_node_workflows(ctx, graph, custom_context, 'uninstall')
      link_tasks(graph, 'Wordpress_deleted', 'Wordpress_delete', custom_context)
      link_tasks(graph, 'Apache_stopped', 'Apache_stop', custom_context)
      link_tasks(graph, 'Apache_stopping', 'Wordpress_deleted', custom_context)
      link_tasks(graph, 'Apache_stopping', 'Apache_host_remove_target', custom_context)
      link_tasks(graph, 'Wordpress_stop', 'Wordpress_stopping', custom_context)
      link_tasks(graph, 'Mysql_delete', 'Mysql_deleting', custom_context)
      link_tasks(graph, 'PHP_stopping', 'PHP_host_remove_target', custom_context)
      link_tasks(graph, 'PHP_stopping', 'Wordpress_deleted', custom_context)
      link_tasks(graph, 'PHP_deleted', 'PHP_delete', custom_context)
      link_tasks(graph, 'Wordpress_stopped', 'Wordpress_stop', custom_context)
      link_tasks(graph, 'PHP_delete', 'PHP_deleting', custom_context)
      link_tasks(graph, 'Mysql_stopping', 'Wordpress_deleted', custom_context)
      link_tasks(graph, 'Mysql_stopping', 'Mysql_host_remove_target', custom_context)
      link_tasks(graph, 'Apache_delete', 'Apache_deleting', custom_context)
      link_tasks(graph, 'Wordpress_deleting', 'Wordpress_stopped', custom_context)
      link_tasks(graph, 'PHP_stop', 'PHP_stopping', custom_context)
      link_tasks(graph, 'Apache_deleting', 'Apache_stopped', custom_context)
      link_tasks(graph, 'Wordpress_stopping', 'Wordpress_host_remove_source', custom_context)
      link_tasks(graph, 'Wordpress_stopping', 'Wordpress_database_remove_target', custom_context)
      link_tasks(graph, 'Wordpress_stopping', 'Wordpress_php_remove_source', custom_context)
      link_tasks(graph, 'Wordpress_stopping', 'Wordpress_host_remove_target', custom_context)
      link_tasks(graph, 'Wordpress_stopping', 'Wordpress_database_remove_source', custom_context)
      link_tasks(graph, 'Wordpress_stopping', 'Wordpress_php_remove_target', custom_context)
      link_tasks(graph, 'PHP_deleting', 'PHP_stopped', custom_context)
      link_tasks(graph, 'Mysql_deleting', 'Mysql_stopped', custom_context)
      link_tasks(graph, 'PHP_stopped', 'PHP_stop', custom_context)
      link_tasks(graph, 'Mysql_stop', 'Mysql_stopping', custom_context)
      link_tasks(graph, 'Server_uninstall', 'Apache_deleted', custom_context)
      link_tasks(graph, 'Server_uninstall', 'PHP_deleted', custom_context)
      link_tasks(graph, 'Apache_stop', 'Apache_stopping', custom_context)
      link_tasks(graph, 'DataBase_uninstall', 'Mysql_deleted', custom_context)
      link_tasks(graph, 'Mysql_stopped', 'Mysql_stop', custom_context)
      link_tasks(graph, 'Apache_deleted', 'Apache_delete', custom_context)
      link_tasks(graph, 'Mysql_deleted', 'Mysql_delete', custom_context)
      link_tasks(graph, 'Wordpress_delete', 'Wordpress_deleting', custom_context)
  def _a4c_start(ctx, graph, custom_context):
      #  following code can be pasted in src/test/python/workflows/tasks.py for simulation
      custom_context.add_customized_wf_node('Apache')
      custom_context.add_customized_wf_node('Mysql')
      custom_context.add_customized_wf_node('PHP')
      custom_context.add_customized_wf_node('Wordpress')
      custom_context.add_customized_wf_node('Apache')
      custom_context.add_customized_wf_node('PHP')
      custom_context.add_customized_wf_node('Mysql')
      custom_context.add_customized_wf_node('Wordpress')
      set_state_task(ctx, graph, 'Apache', 'started', 'Apache_started', custom_context)
      relationship_operation_task(ctx, graph, 'Wordpress', 'Mysql', 'cloudify.interfaces.relationship_lifecycle.establish', 'TARGET', 'Wordpress_database_add_source', custom_context)
      set_state_task(ctx, graph, 'Mysql', 'started', 'Mysql_started', custom_context)
      set_state_task(ctx, graph, 'PHP', 'started', 'PHP_started', custom_context)
      custom_context.register_native_delegate_wf_step('DataBase', 'DataBase_start')
      relationship_operation_task(ctx, graph, 'PHP', 'Server', 'cloudify.interfaces.relationship_lifecycle.establish', 'SOURCE', 'PHP_host_add_target', custom_context)
      set_state_task(ctx, graph, 'Wordpress', 'started', 'Wordpress_started', custom_context)
      operation_task(ctx, graph, 'Wordpress', 'cloudify.interfaces.lifecycle.start', 'Wordpress_start', custom_context)
      set_state_task(ctx, graph, 'Apache', 'starting', 'Apache_starting', custom_context)
      operation_task(ctx, graph, 'PHP', 'cloudify.interfaces.lifecycle.start', 'PHP_start', custom_context)
      set_state_task(ctx, graph, 'PHP', 'starting', 'PHP_starting', custom_context)
      relationship_operation_task(ctx, graph, 'Apache', 'Server', 'cloudify.interfaces.relationship_lifecycle.establish', 'SOURCE', 'Apache_host_add_target', custom_context)
      relationship_operation_task(ctx, graph, 'Wordpress', 'Mysql', 'cloudify.interfaces.relationship_lifecycle.establish', 'SOURCE', 'Wordpress_database_add_target', custom_context)
      operation_task(ctx, graph, 'Mysql', 'cloudify.interfaces.lifecycle.start', 'Mysql_start', custom_context)
      relationship_operation_task(ctx, graph, 'Wordpress', 'Apache', 'cloudify.interfaces.relationship_lifecycle.establish', 'TARGET', 'Wordpress_host_add_source', custom_context)
      custom_context.register_native_delegate_wf_step('Server', 'Server_start')
      relationship_operation_task(ctx, graph, 'Wordpress', 'Apache', 'cloudify.interfaces.relationship_lifecycle.establish', 'SOURCE', 'Wordpress_host_add_target', custom_context)
      relationship_operation_task(ctx, graph, 'Wordpress', 'PHP', 'cloudify.interfaces.relationship_lifecycle.establish', 'TARGET', 'Wordpress_php_add_source', custom_context)
      relationship_operation_task(ctx, graph, 'Mysql', 'DataBase', 'cloudify.interfaces.relationship_lifecycle.establish', 'SOURCE', 'Mysql_host_add_target', custom_context)
      custom_context.register_native_delegate_wf_step('NetPub', 'NetPub_start')
      operation_task(ctx, graph, 'Apache', 'cloudify.interfaces.lifecycle.start', 'Apache_start', custom_context)
      set_state_task(ctx, graph, 'Mysql', 'starting', 'Mysql_starting', custom_context)
      relationship_operation_task(ctx, graph, 'Wordpress', 'PHP', 'cloudify.interfaces.relationship_lifecycle.establish', 'SOURCE', 'Wordpress_php_add_target', custom_context)
      set_state_task(ctx, graph, 'Wordpress', 'starting', 'Wordpress_starting', custom_context)
      generate_native_node_workflows(ctx, graph, custom_context, 'start')
      link_tasks(graph, 'Apache_started', 'Apache_start', custom_context)
      link_tasks(graph, 'Wordpress_database_add_source', 'Wordpress_started', custom_context)
      link_tasks(graph, 'Mysql_started', 'Mysql_start', custom_context)
      link_tasks(graph, 'PHP_started', 'PHP_start', custom_context)
      link_tasks(graph, 'PHP_host_add_target', 'PHP_started', custom_context)
      link_tasks(graph, 'Wordpress_started', 'Wordpress_start', custom_context)
      link_tasks(graph, 'Wordpress_start', 'Wordpress_starting', custom_context)
      link_tasks(graph, 'Apache_starting', 'Server_start', custom_context)
      link_tasks(graph, 'PHP_start', 'PHP_starting', custom_context)
      link_tasks(graph, 'PHP_starting', 'Server_start', custom_context)
      link_tasks(graph, 'Apache_host_add_target', 'Apache_started', custom_context)
      link_tasks(graph, 'Wordpress_database_add_target', 'Wordpress_started', custom_context)
      link_tasks(graph, 'Mysql_start', 'Mysql_starting', custom_context)
      link_tasks(graph, 'Wordpress_host_add_source', 'Wordpress_started', custom_context)
      link_tasks(graph, 'Wordpress_host_add_target', 'Wordpress_started', custom_context)
      link_tasks(graph, 'Wordpress_php_add_source', 'Wordpress_started', custom_context)
      link_tasks(graph, 'Mysql_host_add_target', 'Mysql_started', custom_context)
      link_tasks(graph, 'Apache_start', 'Apache_starting', custom_context)
      link_tasks(graph, 'Mysql_starting', 'DataBase_start', custom_context)
      link_tasks(graph, 'Wordpress_php_add_target', 'Wordpress_started', custom_context)
      link_tasks(graph, 'Wordpress_starting', 'Apache_started', custom_context)
      link_tasks(graph, 'Wordpress_starting', 'Mysql_started', custom_context)
      link_tasks(graph, 'Wordpress_starting', 'PHP_started', custom_context)
  def _a4c_stop(ctx, graph, custom_context):
      #  following code can be pasted in src/test/python/workflows/tasks.py for simulation
      custom_context.add_customized_wf_node('Apache')
      custom_context.add_customized_wf_node('Wordpress')
      custom_context.add_customized_wf_node('Apache')
      custom_context.add_customized_wf_node('PHP')
      custom_context.add_customized_wf_node('PHP')
      custom_context.add_customized_wf_node('Wordpress')
      custom_context.add_customized_wf_node('Mysql')
      custom_context.add_customized_wf_node('Mysql')
      relationship_operation_task(ctx, graph, 'Wordpress', 'Mysql', 'cloudify.interfaces.relationship_lifecycle.unlink', 'SOURCE', 'Wordpress_database_remove_target', custom_context)
      relationship_operation_task(ctx, graph, 'Wordpress', 'PHP', 'cloudify.interfaces.relationship_lifecycle.unlink', 'TARGET', 'Wordpress_php_remove_source', custom_context)
      relationship_operation_task(ctx, graph, 'PHP', 'Server', 'cloudify.interfaces.relationship_lifecycle.unlink', 'SOURCE', 'PHP_host_remove_target', custom_context)
      set_state_task(ctx, graph, 'Apache', 'stopped', 'Apache_stopped', custom_context)
      set_state_task(ctx, graph, 'Wordpress', 'stopping', 'Wordpress_stopping', custom_context)
      set_state_task(ctx, graph, 'Apache', 'stopping', 'Apache_stopping', custom_context)
      operation_task(ctx, graph, 'Wordpress', 'cloudify.interfaces.lifecycle.stop', 'Wordpress_stop', custom_context)
      set_state_task(ctx, graph, 'PHP', 'stopped', 'PHP_stopped', custom_context)
      relationship_operation_task(ctx, graph, 'Apache', 'Server', 'cloudify.interfaces.relationship_lifecycle.unlink', 'SOURCE', 'Apache_host_remove_target', custom_context)
      relationship_operation_task(ctx, graph, 'Wordpress', 'PHP', 'cloudify.interfaces.relationship_lifecycle.unlink', 'SOURCE', 'Wordpress_php_remove_target', custom_context)
      set_state_task(ctx, graph, 'PHP', 'stopping', 'PHP_stopping', custom_context)
      custom_context.register_native_delegate_wf_step('NetPub', 'NetPub_stop')
      custom_context.register_native_delegate_wf_step('Server', 'Server_stop')
      operation_task(ctx, graph, 'Mysql', 'cloudify.interfaces.lifecycle.stop', 'Mysql_stop', custom_context)
      relationship_operation_task(ctx, graph, 'Wordpress', 'Apache', 'cloudify.interfaces.relationship_lifecycle.unlink', 'TARGET', 'Wordpress_host_remove_source', custom_context)
      set_state_task(ctx, graph, 'Wordpress', 'stopped', 'Wordpress_stopped', custom_context)
      operation_task(ctx, graph, 'Apache', 'cloudify.interfaces.lifecycle.stop', 'Apache_stop', custom_context)
      set_state_task(ctx, graph, 'Mysql', 'stopped', 'Mysql_stopped', custom_context)
      set_state_task(ctx, graph, 'Mysql', 'stopping', 'Mysql_stopping', custom_context)
      relationship_operation_task(ctx, graph, 'Mysql', 'DataBase', 'cloudify.interfaces.relationship_lifecycle.unlink', 'SOURCE', 'Mysql_host_remove_target', custom_context)
      relationship_operation_task(ctx, graph, 'Wordpress', 'Apache', 'cloudify.interfaces.relationship_lifecycle.unlink', 'SOURCE', 'Wordpress_host_remove_target', custom_context)
      custom_context.register_native_delegate_wf_step('DataBase', 'DataBase_stop')
      relationship_operation_task(ctx, graph, 'Wordpress', 'Mysql', 'cloudify.interfaces.relationship_lifecycle.unlink', 'TARGET', 'Wordpress_database_remove_source', custom_context)
      operation_task(ctx, graph, 'PHP', 'cloudify.interfaces.lifecycle.stop', 'PHP_stop', custom_context)
      generate_native_node_workflows(ctx, graph, custom_context, 'stop')
      link_tasks(graph, 'Apache_stopped', 'Apache_stop', custom_context)
      link_tasks(graph, 'Wordpress_stopping', 'Wordpress_host_remove_source', custom_context)
      link_tasks(graph, 'Wordpress_stopping', 'Wordpress_database_remove_target', custom_context)
      link_tasks(graph, 'Wordpress_stopping', 'Wordpress_php_remove_source', custom_context)
      link_tasks(graph, 'Wordpress_stopping', 'Wordpress_host_remove_target', custom_context)
      link_tasks(graph, 'Wordpress_stopping', 'Wordpress_database_remove_source', custom_context)
      link_tasks(graph, 'Wordpress_stopping', 'Wordpress_php_remove_target', custom_context)
      link_tasks(graph, 'Apache_stopping', 'Wordpress_stopped', custom_context)
      link_tasks(graph, 'Apache_stopping', 'Apache_host_remove_target', custom_context)
      link_tasks(graph, 'Wordpress_stop', 'Wordpress_stopping', custom_context)
      link_tasks(graph, 'PHP_stopped', 'PHP_stop', custom_context)
      link_tasks(graph, 'PHP_stopping', 'Wordpress_stopped', custom_context)
      link_tasks(graph, 'PHP_stopping', 'PHP_host_remove_target', custom_context)
      link_tasks(graph, 'Server_stop', 'Apache_stopped', custom_context)
      link_tasks(graph, 'Server_stop', 'PHP_stopped', custom_context)
      link_tasks(graph, 'Mysql_stop', 'Mysql_stopping', custom_context)
      link_tasks(graph, 'Wordpress_stopped', 'Wordpress_stop', custom_context)
      link_tasks(graph, 'Apache_stop', 'Apache_stopping', custom_context)
      link_tasks(graph, 'Mysql_stopped', 'Mysql_stop', custom_context)
      link_tasks(graph, 'Mysql_stopping', 'Wordpress_stopped', custom_context)
      link_tasks(graph, 'Mysql_stopping', 'Mysql_host_remove_target', custom_context)
      link_tasks(graph, 'DataBase_stop', 'Mysql_stopped', custom_context)
      link_tasks(graph, 'PHP_stop', 'PHP_stopping', custom_context)
  
  def _get_scaling_group_name_from_node_id(ctx, node_id):
      scaling_groups=ctx.deployment.scaling_groups
      for group_name, scaling_group in ctx.deployment.scaling_groups.iteritems():
          for member in scaling_group['members']:
              if member == node_id:
                  ctx.logger.info("Node {} found in scaling group {}".format(node_id, group_name))
                  return group_name
      return None
  
  
  @workflow
  def a4c_scale(ctx, node_id, delta, scale_compute, **kwargs):
      delta = int(delta)
      scalable_entity_name = _get_scaling_group_name_from_node_id(ctx, node_id)
      scaling_group = ctx.deployment.scaling_groups.get(scalable_entity_name)
      if scalable_entity_name:
          curr_num_instances = scaling_group['properties']['current_instances']
          planned_num_instances = curr_num_instances + delta
          scale_id = scalable_entity_name
      else:
        scaled_node = ctx.get_node(node_id)
        if not scaled_node:
            raise ValueError("Node {0} doesn't exist".format(scalable_entity_name))
        if not is_host_node(scaled_node) and not is_kubernetes_node(scaled_node):
            raise ValueError("Node {0} is not a host. This workflow can only scale hosts".format(scalable_entity_name))
        if delta == 0:
            ctx.logger.info('delta parameter is 0, so no scaling will take place.')
            return
        curr_num_instances = scaled_node.number_of_instances
        planned_num_instances = curr_num_instances + delta
        scale_id = scaled_node.id
        scalable_entity_name = scale_id
  
      if planned_num_instances < 1:
          raise ValueError('Provided delta: {0} is illegal. current number of'
                           'instances of node/group {1} is {2}'
                           .format(delta, scalable_entity_name, curr_num_instances))
  
      modification = ctx.deployment.start_modification({
          scale_id: {
              'instances': planned_num_instances
          }
      })
      ctx.logger.info('Deployment modification started. [modification_id={0} : {1}]'.format(modification.id, dir(modification)))
      
      try:
          if delta > 0:
              ctx.logger.info('Scaling host/group {0} adding {1} instances'.format(scalable_entity_name, delta))
              added_and_related = _get_all_nodes(modification.added)
              added = _get_all_modified_node_instances(added_and_related, 'added')
              graph = ctx.graph_mode()
              ctx.internal.send_workflow_event(event_type='a4c_workflow_started',
                                               message=build_pre_event(WfStartEvent('scale', 'install')))
              custom_context = CustomContext(ctx, added, added_and_related)
              install_host(ctx, graph, custom_context, node_id)
              try:
                  graph.execute()
              except:
                  ctx.logger.error('Scale failed. Uninstalling node/group {0}'.format(scalable_entity_name))
                  graph = ctx.internal.task_graph
                  for task in graph.tasks_iter():
                      graph.remove_task(task)
                  try:
                      custom_context = CustomContext(ctx, added, added_and_related)
                      uninstall_host(ctx, graph, custom_context, scalable_entity_name)
                      graph.execute()
                  except:
                      ctx.logger.error('Node {0} uninstallation following scale failure has failed'.format(scalable_entity_name))
                  raise
          else:
              ctx.logger.info('Unscaling host/group {0} removing {1} instances'.format(scalable_entity_name, delta))
              removed_and_related = _get_all_nodes(modification.removed)
              removed = _get_all_modified_node_instances(removed_and_related, 'removed')
              graph = ctx.graph_mode()
              ctx.internal.send_workflow_event(event_type='a4c_workflow_started',
                                               message=build_pre_event(WfStartEvent('scale', 'uninstall')))
              custom_context = CustomContext(ctx, removed, removed_and_related)
              uninstall_host(ctx, graph, custom_context, node_id)
              try:
                  graph.execute()
              except:
                  ctx.logger.error('Unscale failed.')
                  raise
      except:
          ctx.logger.warn('Rolling back deployment modification. [modification_id={0}]'.format(modification.id))
          try:
              modification.rollback()
          except:
              ctx.logger.warn('Deployment modification rollback failed. The '
                              'deployment model is most likely in some corrupted'
                              ' state.'
                              '[modification_id={0}]'.format(modification.id))
              raise
          raise
      else:
          try:
              modification.finish()
          except:
              ctx.logger.warn('Deployment modification finish failed. The '
                              'deployment model is most likely in some corrupted'
                              ' state.'
                              '[modification_id={0}]'.format(modification.id))
              raise
  
  
  @workflow
  def a4c_heal(
          ctx,
          node_instance_id,
          diagnose_value='Not provided',
          **kwargs):
      """Reinstalls the whole subgraph of the system topology
  
      The subgraph consists of all the nodes that are hosted in the
      failing node's compute and the compute itself.
      Additionally it unlinks and establishes appropriate relationships
  
      :param ctx: cloudify context
      :param node_id: failing node's id
      :param diagnose_value: diagnosed reason of failure
      """
  
      ctx.logger.info("Starting 'heal' workflow on {0}, Diagnosis: {1}"
                      .format(node_instance_id, diagnose_value))
      failing_node = ctx.get_node_instance(node_instance_id)
      host_instance_id = failing_node._node_instance.host_id
      failing_node_host = ctx.get_node_instance(host_instance_id)
      node_id = failing_node_host.node_id
      subgraph_node_instances = failing_node_host.get_contained_subgraph()
      added_and_related = _get_all_nodes(ctx)
      try:
        graph = ctx.graph_mode()
        ctx.internal.send_workflow_event(event_type='a4c_workflow_started',
                                                 message=build_pre_event(WfStartEvent('heal', 'uninstall')))
        custom_context = CustomContext(ctx, subgraph_node_instances, added_and_related)
        uninstall_host(ctx, graph, custom_context, node_id)
        graph.execute()
      except:
        ctx.logger.error('Uninstall while healing failed.')
      graph = ctx.internal.task_graph
      for task in graph.tasks_iter():
        graph.remove_task(task)
      ctx.internal.send_workflow_event(event_type='a4c_workflow_started',
                                               message=build_pre_event(WfStartEvent('heal', 'install')))
      custom_context = CustomContext(ctx, subgraph_node_instances, added_and_related)
      install_host(ctx, graph, custom_context, node_id)
      graph.execute()
  
  #following code can be pasted in src/test/python/workflows/context.py for simulation
  #def _build_nodes(ctx):
      #types = []
      #types.append('alien.cloudify.aws.nodes.Compute')
      #types.append('tosca.nodes.Compute')
      #types.append('tosca.nodes.Root')
      #node_Server = _build_node(ctx, 'Server', types, 1)
      #types = []
      #types.append('org.alien4cloud.nodes.Wordpress')
      #types.append('tosca.nodes.WebApplication')
      #types.append('tosca.nodes.Root')
      #node_Wordpress = _build_node(ctx, 'Wordpress', types, 1)
      #types = []
      #types.append('org.alien4cloud.nodes.Mysql')
      #types.append('org.alien4cloud.nodes.AbstractMysql')
      #types.append('tosca.nodes.Database')
      #types.append('tosca.nodes.Root')
      #node_Mysql = _build_node(ctx, 'Mysql', types, 1)
      #types = []
      #types.append('org.alien4cloud.nodes.PHP')
      #types.append('tosca.nodes.SoftwareComponent')
      #types.append('tosca.nodes.Root')
      #node_PHP = _build_node(ctx, 'PHP', types, 1)
      #types = []
      #types.append('org.alien4cloud.nodes.Apache')
      #types.append('tosca.nodes.WebServer')
      #types.append('tosca.nodes.SoftwareComponent')
      #types.append('tosca.nodes.Root')
      #node_Apache = _build_node(ctx, 'Apache', types, 1)
      #types = []
      #types.append('alien.nodes.aws.PublicNetwork')
      #types.append('alien.nodes.PublicNetwork')
      #types.append('tosca.nodes.Network')
      #types.append('tosca.nodes.Root')
      #node_NetPub = _build_node(ctx, 'NetPub', types, 1)
      #types = []
      #types.append('alien.cloudify.aws.nodes.Compute')
      #types.append('tosca.nodes.Compute')
      #types.append('tosca.nodes.Root')
      #node_DataBase = _build_node(ctx, 'DataBase', types, 1)
      #_add_relationship(node_Server, node_NetPub)
      #_add_relationship(node_Wordpress, node_Apache)
      #_add_relationship(node_Wordpress, node_Mysql)
      #_add_relationship(node_Wordpress, node_PHP)
      #_add_relationship(node_Mysql, node_DataBase)
      #_add_relationship(node_PHP, node_Server)
      #_add_relationship(node_Apache, node_Server)
  