Andrew Bogott has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/64302


Change subject: Added getDisplayName and getFullyQualifiedDisplayName
......................................................................

Added getDisplayName and getFullyQualifiedDisplayName

This is what newer instances use to identify themselves rather
than the old-school i-xxxx names returned by getHostName().

Change-Id: Ie8afcc61226335c56c0d249650533d619a9b52e2
---
M nova/OpenStackNovaHost.php
1 file changed, 36 insertions(+), 2 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/OpenStackManager 
refs/changes/02/64302/1

diff --git a/nova/OpenStackNovaHost.php b/nova/OpenStackNovaHost.php
index f75334a..5af62c8 100644
--- a/nova/OpenStackNovaHost.php
+++ b/nova/OpenStackNovaHost.php
@@ -60,12 +60,36 @@
        }
 
        /**
-        * Return the host's short name
+        *
+        * Return i-<id> style hostname
         *
         * @return
         */
        function getHostName() {
                return $this->hostInfo[0]['dc'][0];
+       }
+
+       /**
+        * Return human-readable hostname
+        *
+        * @return
+        */
+       function getDisplayName() {
+               global $wgAuth;
+
+               if ( isset( $this->hostInfo[0]['puppetvar'] ) ) {
+                       $puppetVals = $this->hostInfo[0]['puppetvar'];
+                       array_shift( $puppetVals );
+                       foreach ( $puppetVals as $val ) {
+                               $pieces = explode( '=', $val );
+                               if ( $pieces[0] == 'instancename' ) {
+                                       return $pieces[1];
+                               }
+                       }
+               }
+
+               $wgAuth->printDebug( "Error: Unable to determine instancename 
of " . $this->searchvalue, NONSENSITIVE );
+               return "";
        }
 
        /**
@@ -78,7 +102,17 @@
        }
 
        /**
-        * Return the host's fully qualified domain name
+        * Return the host's fully qualified display name
+        *
+        * @return string
+        */
+       function getFullyQualifiedDisplayName() {
+               return $this->getDisplayName() . '.' . 
$this->domain->getFullyQualifiedDomainName();
+       }
+
+       /**
+        *
+        * Return i-xxxxx.<domain>
         *
         * @return string
         */

-- 
To view, visit https://gerrit.wikimedia.org/r/64302
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie8afcc61226335c56c0d249650533d619a9b52e2
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/OpenStackManager
Gerrit-Branch: master
Gerrit-Owner: Andrew Bogott <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to