Page MenuHomePhabricator

D7695.id17378.diff
No OneTemporary

D7695.id17378.diff

Index: src/applications/drydock/blueprint/DrydockPreallocatedHostBlueprintImplementation.php
===================================================================
--- src/applications/drydock/blueprint/DrydockPreallocatedHostBlueprintImplementation.php
+++ src/applications/drydock/blueprint/DrydockPreallocatedHostBlueprintImplementation.php
@@ -37,6 +37,29 @@
DrydockResource $resource,
DrydockLease $lease) {
+ // Because preallocated resources are manually created, we should verify
+ // we have all the information we need.
+ $v_platform = $resource->getAttribute('platform');
+ $v_host = $resource->getAttribute('host');
+ $v_port = $resource->getAttribute('port');
+ $v_user = $resource->getAttribute('user');
+ $v_path = $resource->getAttribute('path');
+ if (empty($v_platform)) {
+ throw new Exception("Missing 'platform' attribute on resource.");
+ }
+ if (empty($v_host)) {
+ throw new Exception("Missing 'host' attribute on resource.");
+ }
+ if (empty($v_port)) {
+ throw new Exception("Missing 'port' attribute on resource.");
+ }
+ if (empty($v_user)) {
+ throw new Exception("Missing 'user' attribute on resource.");
+ }
+ if (empty($v_path)) {
+ throw new Exception("Missing 'path' attribute on resource.");
+ }
+
// Similar to DrydockLocalHostBlueprint, we create a folder
// on the remote host that the lease can use.
@@ -46,18 +69,18 @@
// the platform we're currently running on, not the platform we are
// remoting to.
$separator = '/';
- if ($lease->getAttribute('platform') === 'windows') {
+ if ($v_platform === 'windows') {
$separator = '\\';
}
// Clean up the directory path a little.
- $base_path = rtrim($resource->getAttribute('path'), '/');
+ $base_path = rtrim($v_path, '/');
$base_path = rtrim($base_path, '\\');
$full_path = $base_path.$separator.$lease_id;
$cmd = $lease->getInterface('command');
- if ($lease->getAttribute('platform') !== 'windows') {
+ if ($v_platform !== 'windows') {
$cmd->execx('mkdir %s', $full_path);
} else {
// Windows is terrible. The mkdir command doesn't even support putting

File Metadata

Mime Type
text/plain
Expires
Mon, Mar 31, 8:37 PM (1 w, 2 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7725344
Default Alt Text
D7695.id17378.diff (2 KB)

Event Timeline