Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F95986437
LeaseHostBuildStepImplementation.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Dec 21, 08:43
Size
2 KB
Mime Type
text/x-php
Expires
Mon, Dec 23, 08:43 (1 d, 21 h)
Engine
blob
Format
Raw Data
Handle
23089070
Attached To
rPH Phabricator
LeaseHostBuildStepImplementation.php
View Options
<?php
final
class
LeaseHostBuildStepImplementation
extends
BuildStepImplementation
{
public
function
getName
()
{
return
pht
(
'Lease Host'
);
}
public
function
getGenericDescription
()
{
return
pht
(
'Obtain a lease on a Drydock host for performing builds.'
);
}
public
function
getDescription
()
{
$settings
=
$this
->
getSettings
();
return
pht
(
'Obtain a lease on a Drydock host whose platform is
\'
%s
\'
.'
,
$settings
[
'platform'
]);
}
public
function
execute
(
HarbormasterBuild
$build
,
HarbormasterBuildTarget
$build_target
)
{
$settings
=
$this
->
getSettings
();
// Create the lease.
$lease
=
new
DrydockLease
();
$lease
->
setResourceType
(
'host'
);
$lease
->
setAttributes
(
array
(
'platform'
=>
$settings
[
'platform'
]));
$lease
->
queueForActivation
();
// Wait until the lease is fulfilled.
// TODO: This will throw an exception if the lease can't be fulfilled;
// we should treat that as build failure not build error.
$lease
->
waitUntilActive
();
// Create the associated artifact.
$artifact
=
$build
->
createArtifact
(
$build_target
,
$settings
[
'name'
],
'host'
);
$artifact
->
setArtifactData
(
array
(
'drydock-lease'
=>
$lease
->
getID
()));
$artifact
->
save
();
}
public
function
validateSettings
()
{
$settings
=
$this
->
getSettings
();
if
(
$settings
[
'name'
]
===
null
||
!
is_string
(
$settings
[
'name'
]))
{
return
false
;
}
if
(
$settings
[
'platform'
]
===
null
||
!
is_string
(
$settings
[
'platform'
]))
{
return
false
;
}
return
true
;
}
public
function
getSettingDefinitions
()
{
return
array
(
'name'
=>
array
(
'name'
=>
'Artifact Name'
,
'description'
=>
'The name of the artifact to reference in future build steps.'
,
'type'
=>
BuildStepImplementation
::
SETTING_TYPE_STRING
),
'platform'
=>
array
(
'name'
=>
'Platform'
,
'description'
=>
'The platform of the host.'
,
'type'
=>
BuildStepImplementation
::
SETTING_TYPE_STRING
));
}
}
Event Timeline
Log In to Comment