Problem/Motivation

Proposed resolution

Remaining tasks

Add these Rules/Components into code

Post git pull (rule)

{ "rules_post_git_pull" : {
    "LABEL" : "Post git pull",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "TAGS" : [ "hosting task" ],
    "REQUIRES" : [ "rules", "aegir_rules" ],
    "ON" : { "post_hosting_default_execute" : [] },
    "IF" : [
      { "entity_is_of_type" : { "entity" : [ "task" ], "type" : "node" } },
      { "entity_is_of_bundle" : {
          "entity" : [ "task" ],
          "type" : "node",
          "bundle" : { "value" : { "task" : "task" } }
        }
      },
      { "data_is" : { "data" : [ "task:task-type" ], "value" : "git-pull" } }
    ],
    "DO" : [
      { "component_rules_registry_rebuild" : { "trigger_task" : [ "task" ] } }
    ]
  }
}

Registry rebuild (component)

{ "rules_registry_rebuild" : {
    "LABEL" : "Registry rebuild",
    "PLUGIN" : "rule",
    "OWNER" : "rules",
    "TAGS" : [ "hosting task" ],
    "REQUIRES" : [ "rules" ],
    "USES VARIABLES" : { "trigger_task" : { "label" : "Triggering task", "type" : "node" } },
    "IF" : [
      { "entity_is_of_type" : { "entity" : [ "trigger-task" ], "type" : "node" } },
      { "entity_is_of_bundle" : {
          "entity" : [ "trigger-task" ],
          "type" : "node",
          "bundle" : { "value" : { "task" : "task" } }
        }
      }
    ],
    "DO" : [
      { "entity_create" : {
          "USING" : {
            "type" : "node",
            "param_type" : "task",
            "param_title" : "[trigger-task:title]",
            "param_author" : [ "trigger-task:author" ]
          },
          "PROVIDE" : { "entity_created" : { "new_task" : "New task" } }
        }
      },
      { "data_set" : { "data" : [ "new-task:rid" ], "value" : [ "trigger-task:rid" ] } },
      { "data_set" : { "data" : [ "new-task:task-status" ], "value" : "0" } },
      { "data_set" : { "data" : [ "new-task:task-type" ], "value" : "rebuild_registry" } },
      { "entity_save" : { "data" : [ "new-task" ], "immediate" : "1" } }
    ]
  }
}

User interface changes

API changes

Data model changes

Comments

helmo created an issue. See original summary.

clemens.tolboom’s picture

To create a Rules task action we need to know the arguments. As tasks are provided by modules best location is the module providing the Task.

Lets start with a simple task to get things going. Which events are eligible for creating that task? How do we get to it the Site node to run the task against?

helmo’s picture

clemens.tolboom’s picture

My idea was to create a task based on the current task done. So I need to test for the task type say 'git-pull' to run a new task 'registry rebuild' or 'features-revert-all'.

I learned tasks are nodes but the fields needed

  • task_type
  • task_args

are not entity fields so a condition on entity has field fails.

Should we implement hook_entity_info_alter or define a pseudo field or ..

function aegir_rules_entity_property_info_alter(&$info) {
  $info['node']['bundles']['task']['properties']['task-type'] = array(
    'label' => t("Task type"),
    'description' => t("The type the task node uses."),
    'type' => 'string',
    //'getter callback' => '_aegir_rules_task_node_get_properties',
  );
}

function _aegir_rules_task_node_get_properties() {
  dsm(func_get_args());
} 

The above does not work yet. Guess I'm doing something wrong :(

clemens.tolboom’s picture

To create a new task we need to set several pseudo fields

- task_type
- task_status
- task_arguments

As learned in #2730603-8: Implement hook_entity_property_info exposing these through entity API does not make them writable.

The new action could use for
- task_type hook_hosting_task to get a list of tasks (is that permissions based?)
- task_arguments call the form (ie hosting_task_clone_form) for the task specific fields (is that permissions based?)

I made #2730603: Implement hook_entity_property_info a parent as that needs fixed first.

clemens.tolboom’s picture

As task_arguments is an array stored into hosting_task_arguments as key-value

drush @hostmaster sql-query "select * from hosting_task_arguments"
or even better to get values by type

drush @hostmaster sql-query "select distinct task_type, name, value from hosting_task_arguments a inner join hosting_task t on t.nid = a.nid and t.vid = a.vid;"

I hope we could use the form hooks for the keys

clemens.tolboom’s picture

Issue summary: View changes
clemens.tolboom’s picture

In #2730603: Implement hook_entity_property_info we concluded we can create simple tasks. But how do we process arguments for ie the source site for a site sync or do a forced git pull

helmo’s picture

Version: 7.x-1.x-dev » 7.x-3.x-dev