Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2892763
DrydockLocalHostBlueprint.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
1 KB
Referenced Files
None
Subscribers
None
DrydockLocalHostBlueprint.php
View Options
<?php
final
class
DrydockLocalHostBlueprint
extends
DrydockBlueprint
{
public
function
isEnabled
(
)
{
return
PhabricatorEnv
::
getEnvConfig
(
'drydock.localhost.enabled'
)
;
}
public
function
canAllocateMoreResources
(
array
$pool
)
{
assert_instances_of
(
$pool
,
'DrydockResource'
)
;
// The localhost can be allocated only once.
foreach
(
$pool
as
$resource
)
{
if
(
$resource
->
getBlueprintClass
(
)
==
$this
->
getBlueprintClass
(
)
)
{
return
false
;
}
}
return
true
;
}
protected
function
executeAllocateResource
(
DrydockLease
$lease
)
{
$path
=
PhabricatorEnv
::
getEnvConfig
(
'drydock.localhost.path'
)
;
if
(
!
Filesystem
::
pathExists
(
$path
)
)
{
throw
new
Exception
(
"Path '{$path}' does not exist!"
)
;
}
Filesystem
::
assertIsDirectory
(
$path
)
;
Filesystem
::
assertWritable
(
$path
)
;
$resource
=
$this
->
newResourceTemplate
(
'localhost'
)
;
$resource
->
setStatus
(
DrydockResourceStatus
::
STATUS_OPEN
)
;
$resource
->
setAttribute
(
'path'
,
$path
)
;
$resource
->
save
(
)
;
return
$resource
;
}
protected
function
executeAcquireLease
(
DrydockResource
$resource
,
DrydockLease
$lease
)
{
$lease_id
=
$lease
->
getID
(
)
;
$cmd
=
$lease
->
getInterface
(
'command'
)
;
$cmd
->
execx
(
'mkdir %s'
,
$lease_id
)
;
$lease
->
setAttribute
(
'path'
,
$resource
->
getAttribute
(
'path'
)
.
'/'
.
$lease_id
)
;
$lease
->
save
(
)
;
return
;
}
public
function
getType
(
)
{
return
'host'
;
}
public
function
getInterface
(
DrydockResource
$resource
,
DrydockLease
$lease
,
$type
)
{
switch
(
$type
)
{
case
'command'
:
return
new
DrydockLocalCommandInterface
(
)
;
}
throw
new
Exception
(
"No interface of type '{$type}'."
)
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, Jan 19, 17:18 (1 w, 5 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1126889
Default Alt Text
DrydockLocalHostBlueprint.php (1 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment