I find myself using the '@hostmaster' alias a lot. But those 10 characters become a hassle after a while. I've begin to copy the hostmaster alias file to create an '@d' alias, which is pretty trivial, but allows for saving 9 key presses on each and every call to an Aegir operation from the command-line. I think it's be nice to provide such a shortcut alias by default. I used '@d' in honor of our d() function, but any such short alias would do.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ergonlogic’s picture

Actually, come to think of it, it'd be nice to provide front-end fields to allow user-specified aliases to be generated for all Aegir entities.

anarcat’s picture

@hm seems more appropriate... can we put an alias of an alias in an alias? or do we need to make a separate file?

ergonlogic’s picture

can we put an alias of an alias in an alias?

Yes... yes, we can. By moving to GROUPNAME.aliases.drushrc.php:

$ cat ../hostmaster.aliases.drushrc.php

$aliases['hostmaster'] = array (
  'context_type' => 'site',
  'platform' => '@platform_hostmaster',
  'server' => '@server_master',
  'db_server' => '@server_localhost',
  'uri' => 'aegir2.aegir2.local',
  'root' => '/var/aegir/hostmaster-6.x-2.x',
  'site_path' => '/var/aegir/hostmaster-6.x-2.x/sites/aegir2.aegir2.local',
  'site_enabled' => true,
  'language' => 'en',
  'client_name' => 'admin',
  'aliases' => 
  array (
  ),
  'redirection' => false,
  'cron_key' => '',
  'profile' => 'hostmaster',
);
$aliases['hm'] = array(
  'parent' => '@hostmaster',
);

We could generalize this, and add a '--drush-aliases' option to provision-save. We could then alter the template to iterate through such a list, adding arbitrary aliases. Down the road we could add a front-end field to allow #1057698: Configurable node title for hosting import (though the discussion in that issue appears to be about something else entirely.)

ergonlogic’s picture

Status: Active » Needs review
FileSize
1019 bytes
3.25 KB

So, the first patch adds the ability to specify '--drush_aliases=foo,bar' during provision-save for sites, and has site aliases generated as alias groups. The second (pretty trivial) patch adds the 'hm' alias for hostmaster sites.

anarcat’s picture

Why do we need a new template for this? Couldn't we just add this to the Provision_Config_Drushrc_Alias template?

ergonlogic’s picture

Status: Needs review » Needs work

I suppose we could use the same template for both.

ergonlogic’s picture

Status: Needs work » Needs review
FileSize
3.25 KB

Now using the same template.

anarcat’s picture

that's not what I mean...

+++ b/Provision/Context/site.phpundefined
@@ -36,8 +37,18 @@ class Provision_Context_site extends Provision_Context {
+
+  /**
+   * Write out this named context to an alias group file.
+   */
+  function write_alias() {
+    $config = new Provision_Config_Drushrc_Alias_Group($this->name, $this->properties);
+    $config->write();
+  }

why do we need this at all? Why do we need a new context? Wouldn't the alias's aliases be written along with the others?

ergonlogic’s picture

Version: 6.x-2.x-dev » 7.x-3.x-dev
Status: Needs review » Needs work

We need the new context in order to write to a new file name.

In IRC discussions, anarcat suggested moving to *.aliases.drushrc.php for platforms and servers too. We'll also need to clean up the old aliases. So bumping to 3.x

anarcat’s picture

the reason we need to go to GROUPNAME.aliases is that drush is a little weird: it will *not* look into hostmaster.alias.drushrc.php for a @hm alias, but it will look into hostmaster.aliases.drushrc.php.

Go figure... I would guess this is a performance improvement - so that must also be considered: do we want to sacrifice that performance for convenience?

ergonlogic’s picture

So, yeah... it looks like all *.aliases.drushrc.php files are included in every drush command, whereas only the named alias file is loaded.

We don't actually need the group alias functionality, per se. It is designed to run commands against lists of aliases. Perhaps we'd be better off generating additional *.alias.drushrc.php instead. Unfortunately, 'parent' won't work for that, so we'd need to replicate the whole alias in each file. Still, it should be pretty easy, as write_alias() could just iterate over the extra alias names using the same $properties.

anarcat’s picture

maybe we could do a require_once() in the alias?

ergonlogic’s picture

I don't think I understand the suggestion. It's Drush that'll parse any and all *.aliases.drushrc.php files it can find...

anarcat’s picture

yes, but in hm.alias.drushrc we could just do:

require_once('hostmaster.alias.drushrc.php');

instead of copying the entire content of the alias.

ergonlogic’s picture

oh, I see. That should work.

ergonlogic’s picture

Status: Needs work » Needs review
FileSize
2 KB

Actually, come to think of it, I'm not sure why we would do #14, instead of just writing out the alias anew with the alternate name. The attached patch does so, and as a result makes only very minimal changes. I guess we'd need to clean up these extra aliases too.

The provision-shorter_hm_alias-2031397-4.patch patch from #4 is still required for this to work with the hostmaster alias.

FWIW, I'd still like to squeeze this into 2.x, since I feel that its a significant CLI usability win, and an 'experimental' front-end feature should be pretty easy to write.

ergonlogic’s picture

Here's a single patch that combines the one in #16 and the one from #4 that adds the '@hm' alias, along with cleanup of these new aliases.

anarcat’s picture

Status: Needs review » Needs work

the idea of using a require() is that we avoid copying critical credentials in multiple places. the less we write passwords on disk the happier i am.

ergonlogic’s picture

Status: Needs work » Needs review

There aren't any credentials in hostmaster.alias.drushrc.php...

anarcat’s picture

fair enough. :P

ergonlogic’s picture

Boy, it'd be nice to get this into 2.x... Just sayin'...

ergonlogic’s picture

Issue summary: View changes
Status: Needs review » Needs work

Well, 7.x-3.x is open for dev, so I'm going to look at merging this.

ergonlogic’s picture

Title: Provide shorter alias for hostmaster site » Confugurable context/alias names

#1057698: Configurable node title for hosting import used to have this title, but I think it's more appropriate here. The general use-case and proposed solution would allow for any context to have additional aliases generated. Once the Provision component is in, I'll move this over to the Hosting queue for the addition of front-end and IPC components.

ergonlogic’s picture

Title: Confugurable context/alias names » Configurable context/alias names

grr, title typo.

ergonlogic’s picture

Project: Provision » Hosting
Component: Drush integration » Code
Status: Needs work » Active

Merged the patch form #17 into Provision in dfc48d6. Yay, @hm!

If anyone wants to implement the front-end components to take advantage of this, be my guest.