Ok posting update, I did get my internal instance to use both amazon and cloudstack by modifying the scalr code I know this is not optimal but it worked for me for the setup I needed.
Basically I was having an issue where both amazon vpc instance and cloudstack instances were being required to have public ip when none where available.
Files modified for EC2
Modules/Platforms/Ec2/Ec2.php
diff -urNp scalr/src/scalr/app/src/Modules/Platforms/Ec2/Ec2.php ec2/Ec2.php
--- scalr/src/scalr/app/src/Modules/Platforms/Ec2/Ec2.php 2014-01-30 12:05:12.000000000 -0800
+++ ec2/Ec2.php 2014-04-02 18:01:23.473999000 -0700
@@ -105,8 +105,7 @@ class Modules_Platforms_Ec2 extends Modu
->get(0)->instancesSet->get(0);
return array(
- 'localIp' => $instance->privateIpAddress,
- 'remoteIp' => $instance->ipAddress
+ 'localIp' => $instance->privateIpAddress
);
}
class.DBServer.php
---
diff -urNp scalr/src/scalr/app/src/class.DBServer.php ec2/class.DBServer.php
--- scalr/src/scalr/app/src/class.DBServer.php 2014-01-30 12:05:12.000000000 -0800
+++ ec2/class.DBServer.php 2014-04-02 18:03:21.650424000 -0700
@@ -1,4 +1,5 @@
<?php
+
use Scalr\Server\Operations;
class DBServer
@@ -1037,10 +1038,10 @@ class DBServer
if (\Scalr::config('scalr.instances_connection_policy') == 'local')
$requestHost = "{$this->localIp}:{$ctrlPort}";
elseif (\Scalr::config('scalr.instances_connection_policy') == 'public')
- $requestHost = "{$this->remoteIp}:{$ctrlPort}";
+ $requestHost = "{$this->localIp}:{$ctrlPort}";
elseif (\Scalr::config('scalr.instances_connection_policy') == 'auto') {
if ($this->remoteIp)
- $requestHost = "{$this->remoteIp}:{$ctrlPort}";
+ $requestHost = "{$this->localIp}:{$ctrlPort}";
else
$requestHost = "{$this->localIp}:{$ctrlPort}";
}
For Cloudstack
Observers/Cloudstack.php
diff -urNp ./scalr/src/scalr/app/src/Modules/Platforms/Cloudstack/Observers/Cloudstack.php cloudstack/ObserversCloudstack.php
--- ./scalr/src/scalr/app/src/Modules/Platforms/Cloudstack/Observers/Cloudstack.php 2014-01-30 12:05:12.000000000 -0800
+++ cloudstack/ObserversCloudstack.php 2014-04-02 18:05:19.000948000 -0700
@@ -1,4 +1,5 @@
<?php
+
class Modules_Platforms_Cloudstack_Observers_Cloudstack extends EventObserver
{
public $ObserverName = 'Cloudstack';
@@ -117,9 +118,8 @@
$event->DBServer->GetCloudLocation(),
$event->DBServer->platform
);
-
- $ipInfo = $cs->listPublicIpAddresses(null, null, null, null, null, $event->DBServer->remoteIp);
- $info = $ipInfo->publicipaddress[0];
+ $ipInfo = $cs->privateIpAddress(null, null, null, null, null, $event->DBServer->localIp);
+ $info = $ipInfo->privateIpAddress[0];
if ($info->isstaticnat) {
if ($info->virtualmachineid == $event->DBServer->GetCloudServerID()) {
$this->Logger->warn(new FarmLogMessage($this->FarmID,
@@ -265,4 +265,4 @@
}
}
}
To change the SSH user the key uses after bootstrap for the user I did
diff -urNp ./scalr/src/scalr/app/src/Scalr/UI/Controller/Servers.php cloudstack/Servers.php
--- ./scalr/src/scalr/app/src/Scalr/UI/Controller/Servers.php 2014-01-30 12:05:12.000000000 -0800
+++ cloudstack/Servers.php 2014-04-02 18:08:02.809705000 -0700
@@ -1,4 +1,5 @@
<?php
+
use Scalr\Acl\Acl;
use Scalr\Server\Alerts;
use Scalr\Service\Aws\Ec2\DataType\InstanceAttributeType;
@@ -327,7 +328,7 @@ class Scalr_UI_Controller_Servers extend
'farmId' => $dbServer->farmId,
'roleName' => $dbRole->name,
'port' => $sshPort,
- 'username' => $dbServer->platform == SERVER_PLATFORMS::GCE ? 'scalr' : 'root',
+ 'username' => $dbServer->platform == SERVER_PLATFORMS::GCE ? 'scalr' : 'alloweduser',
"key" => base64_encode($sshKey->getPrivate())
));
}
I know these changes are not ideal but I needed to get this done and had a deadline. I also briefly looked over the rest of the code and it appears it should work as expected however it seems that the unmodified version somehow when the variable for remoteIp is null does not unset it or disregard it and as a result of it being null & set attempts to use it which of course results in failure.