The requirement of having to create a "platform" before you can create a site has been a challenge for user experience and for the API for a very long time.

DevShop jumps through hoops (hooks) just to clone a codebase and install drupal. It hooks into platform_verify and then creates the site node. When all I want to do is create a site and platform in one shot.

You can't spin up a new site in a single request unless you already have the codebase created in a separate request.

You can't even just "save a site node" and make that work. Any API should be able to handle this, especially given how simple platforms are.

So, my proposal is to start simple:

  1. Patch the node API so that saving a site node without an existing platform ID is possible.
  2. If the site node has the needed properties that a platform needs (publish path, makefile/git url) then hosting_site_insert() creates the platform node automatically, along with it's verify task.
  3. Don't do much else than that, so as to get accepted in the 3.x branch.

If I can get this to work. DevShop will adopt this patch now in it's next release and use it instead of the hook jumping.

Members fund testing for the Drupal project. Drupal Association Learn more

Comments

Jon Pugh created an issue. See original summary.

Jon Pugh’s picture

Title: Allow creation of site and new platform in one request. » API Only: Allow creation of site and new platform in one request.
helmo’s picture

I can see where that would simplify things for devshop... and it could pave the way for site repo's that describe their desired platform in a makefile/composerfile or whatelse...

  • Jon Pugh committed f185514 on 2824731-site-create-platform
    Issue #2824731: On site insert, if platform_node data is passed, create...
colan’s picture

This would be quite useful for Aegir Services, especially #2634074: Allow remote platform creation.

helmo’s picture

  • Jon Pugh committed 36cd882 on 2824731-site-create-platform
    Issue #2824731: Ensure platform is run through node_submit() and then...
Jon Pugh’s picture

Updated patch. I'm using this in devshop now.

Jon Pugh’s picture

Issue tags: +devshop patches

  • Jon Pugh committed 36cd882 on 2754069-2824731-install-platform
    Issue #2824731: Ensure platform is run through node_submit() and then...
  • Jon Pugh committed f185514 on 2754069-2824731-install-platform
    Issue #2824731: On site insert, if platform_node data is passed, create...

  • Jon Pugh committed 2076370 on 2754069-2824731-install-platform
    Issue #2824731: If site node 'profile' is empty and 'profile_name' is...

  • Jon Pugh committed 3fc6dbe on 2754069-2824731-install-platform
    Issue #2824731: Add site node to log message.
    
  • Jon Pugh committed 554714d on 2754069-2824731-install-platform
    Issue #2824731: Fix the query to lookup the profile_name, and output a...
Jon Pugh’s picture

Just pushed code that allows install profile to be specified by "profile_name". This has to happen post-platform-verify because the packages don't exist until then.

If $site_node->profile is empty, but $site_node->profile_name is, then lookup the profile package ID and save it to the site node.

Jon Pugh’s picture

FileSize
6.06 KB
Jon Pugh’s picture

helmo’s picture

Status: Needs review » Needs work
+++ b/alias/hosting_alias.module
@@ -493,7 +493,7 @@ function hosting_alias_settings($form, &$form_state) {
-  if (!empty($form_state['values']['hosting_alias_subdomain']) && !valid_url($form_state['values']['hosting_alias_subdomain'])) {
+  if (!valid_url($form_state['values']['hosting_alias_subdomain'])) {

I don't see this in the feature branch ... and don't think it's intended ;)

Where can we document this API addition? small example in hosting.api.php?

  • Jon Pugh committed 3d8cb0e on 2824731-site-create-platform
    Issue #2824731: When creating a site with a platform path that already...

  • Jon Pugh committed e65c540 on 2824731-site-create-platform
    Issue #2824731: Use direct db_update to save profile package.
    

  • Jon Pugh committed 1048817 on 2824731-site-create-platform
    Issue #2824731: Use correct status column.
    

  • Jon Pugh committed 6c21da1 on 2824731-site-create-platform
    Issue #2824731: Typo in variable name.
    

  • Jon Pugh committed ea38ed3 on 2824731-site-create-platform
    Issue #2824731: Set $task->ref->profile in case other hooks need it.
    

  • Jon Pugh committed eccc760 on 2824731-site-create-platform
    Issue #2824731: Add example function for creating site and platform in...
Jon Pugh’s picture

Status: Needs work » Needs review
FileSize
6.58 KB

Fixed a few bugs and added an example function, that I tested, it works!

Branch pushed and patch attached.

  • Jon Pugh committed 1048817 on 7.x-3.x
    Issue #2824731: Use correct status column.
    
  • Jon Pugh committed 36cd882 on 7.x-3.x
    Issue #2824731: Ensure platform is run through node_submit() and then...
  • Jon Pugh committed 3d8cb0e on 7.x-3.x
    Issue #2824731: When creating a site with a platform path that already...
  • Jon Pugh committed 6c21da1 on 7.x-3.x
    Issue #2824731: Typo in variable name.
    
  • Jon Pugh committed e65c540 on 7.x-3.x
    Issue #2824731: Use direct db_update to save profile package.
    
  • Jon Pugh committed ea38ed3 on 7.x-3.x
    Issue #2824731: Set $task->ref->profile in case other hooks need it.
    
  • Jon Pugh committed eccc760 on 7.x-3.x
    Issue #2824731: Add example function for creating site and platform in...
  • Jon Pugh committed f185514 on 7.x-3.x
    Issue #2824731: On site insert, if platform_node data is passed, create...
helmo’s picture

Status: Needs review » Fixed

Thanks, merged.

Jon Pugh’s picture

Awesome, thanks helmo!

This is a good step but I think we have more to do to get a better API. A few thoughts:

  1. Define the exact actual data model of sites and platforms, determining what exactly is required.
  2. Create an API level functions for CRUD on sites, just wrappers for Node API.
  3. Change site profile field to a string, to store the machine name of the install profile. [#]
  4. Add a site machine name field, so that things like platform path and domain name can be automatically generated.
  5. Use this model and API to improve Hosting Services and our own UI.
helmo’s picture

Status: Fixed » Needs review
FileSize
1.1 KB

We have a build failure :( looks like an issue with one of the hosting commits from here ... I suspect ff9e5e68c6b89e5bba6603e569fce62bb1f00eb1

Regression ... and release blocker.

  • helmo committed 3110bf8 on 7.x-3.x
    Issue #2824731 by Jon Pugh, helmo: Fix regression in API only code
    
helmo’s picture

helmo’s picture

Status: Needs review » Needs work

There's little to review as most of the work here seems to be committed already.

Setting back to needs work to look at #26