Server related APIs.
This class provides the following APIs:
This trait can be implemented by any class that has
Type Params | Return Type | Name and description |
---|---|---|
|
def |
addTags(def tags, def... args) Assigns existing tags to an existing server. |
|
def |
attach(Resource storageDevice, def... args) Attaches a storage as a device to a server. |
|
def |
cancel(def... args) Cancels a running server operation. |
|
def |
createFirewallRule(Resource firewallRule, def... args) Create a firewall rule for a server. |
|
def |
delete(def... args) Deletes an existing server. |
|
def |
deleteFirewallRule(def position, def... args) Removes a firewall rule from a server. |
|
def |
deleteTags(def tags, def... args) Removes existing tags from an existing server. |
|
def |
detach(Resource storageDevice, def... args) Detaches a storage device from a server. |
|
def |
eject(def... args) Ejects the storage from the CD-ROM device of a server. |
|
def |
firewallRules(def... args) Fetch firewall rules for a server. |
|
AbstractSession<?> |
getHTTP() |
|
String |
getUuid() |
|
def |
insert(Resource storageDevice, def... args) Loads a storage as a CD-ROM in the CD-ROM device of a server. |
|
def |
load(def... args) Fetch detailed information about a specific Server. |
|
def |
loadFirewallRule(def position, def... args) Fetch detailed information about a specific firewall rule. |
|
def |
restart(def... args) Restarts a started server. |
|
def |
start(def... args) Starts a stopped server. |
|
def |
stop(def... args) Stops a started server. |
|
def |
update(Resource resource, def... args) Modifies the configuration of an existing server. |
Assigns existing tags to an existing server.
A 200 OK
response will include an instance of Server
in the server
property.
serverApi.addTags(['DEV','private','RHEL']) { resp, err ->
assert resp?.server instanceof Server
}
tags
- List of tags to assignargs
- Request callbacks for the POST /server/${server.uuid}/tag/${tags.join(',')}
call.Attaches a storage as a device to a server.
SCSI and virtio devices can be attached to a running server, but for IDE devices the server must be stopped.
When attaching a CD-ROM device (with or without a storage), the server must be stopped. Storage can then be inserted and ejected while the server is running.
A 200 OK
response will include an instance of Server
in the server
property.
import static fi.linuxbox.upcloud.resource.Builder.storageDevice
def dataDisk = storageDevice {
type = 'disk'
address = 'scsi:0:0'
storage = '00798b85-efdc-41ca-8021-f6ef457b8531'
}
serverApi.attach dataDisk, { resp, err ->
assert resp?.server instanceof Server
}
storageDevice
- Storage device to attachargs
- Request callbacks for the POST /server/${server.uuid}/storage/attach
call.Cancels a running server operation.
The server must be in maintenance
state.
A 204 No Content
response signifies success.
args
- Request callbacks for the POST /server/${server.uuid}/cancel
call.Create a firewall rule for a server.
If a position property is not set in the given firewall rule, then the rule is appended to the list of firewall rules. If the position property is set, then the rule is inserted at that position in the rule list, and the position properties of any following rules are increased by one.
A 201 Created
response will include an instance of FirewallRule
in the firewallRule
property.
import static fi.linuxbox.upcloud.resource.Builder.firewallRule
def acceptHttp = firewallRule {
action = 'accept'
comment = 'Allow HTTP from anywhere'
destinationPortEnd = '80'
destinationPortStart = '80'
direction = 'in'
family = 'IPv4'
protocol = 'tcp'
}
serverApi.createFirewallRule acceptHttp, { resp, err ->
assert resp?.firewallRule instanceof FirewallRule
}
firewallRule
- Description of the firewall ruleargs
- Request callbacks for the POST /server/${server.uuid}/firewall_rule
call.Deletes an existing server.
A 204 No Content
response will signify that the server is deleted.
The Server.state of the server must be stopped
.
The storage devices of the server are automatically detached, and IP addresses are released.
args
- Request callbacks for the DELETE /server/${server.uuid}
call.Removes a firewall rule from a server.
The position properties of any following rules are decreased by one.
A 204 No Content
response signifies success.
position
- The position number of the rule in the firewall rules listargs
- Request callbacks for the DELETE /server/${server.uuid}/firewall_rule/$position
call.Removes existing tags from an existing server.
A 200 OK
response will include an instance of Server
in the server
property.
serverApi.deleteTags(['DEV','private','RHEL']) { resp, err ->
assert resp?.server instanceof Server
}
tags
- List of tags to removeargs
- Request callbacks for the POST /server/${server.uuid}/untag/${tags.join(',')}
call.Detaches a storage device from a server.
For IDE devices, the server must be stopped.
A 200 OK
response will include an instance of Server
in the server
property.
import static fi.linuxbox.upcloud.resource.Builder.storageDevice
def dataDisk = storageDevice {
address = 'scsi:0:0'
}
serverApi.detach dataDisk, { resp, err ->
assert resp?.server instanceof Server
}
storageDevice
- Storage device to detachargs
- Request callbacks for the POST /server/${server.uuid}/storage/detach
call.Ejects the storage from the CD-ROM device of a server.
A 200 OK
response will include an instance of Server
in the server
property.
args
- Request callbacks for the POST /server/${server.uuid}/cdrom/eject
call.Fetch firewall rules for a server.
A 200 OK
response will include a list of FirewallRule
instances in the firewallRules
property.
serverApi.firewallRules { resp, err ->
assert resp?.firewallRules instanceof List
assert resp.firewallRules.every { it instanceof FirewallRule }
}
args
- Request callbacks for the GET /server/${server.uuid}/firewall_rule
call.Loads a storage as a CD-ROM in the CD-ROM device of a server.
This requires that the CD-ROM device is already attached to the server.
Storages of type normal
, cdrom
, and backup
can be inserted as CD-ROMs.
A 200 OK
response will include an instance of Server
in the server
property.
import static fi.linuxbox.upcloud.resource.Builder.storageDevice
def knoppixInstallCD = storageDevice {
storage = '01000000-0000-4000-8000-000060010101'
}
serverApi.insert knoppixInstallCD, { resp, err ->
assert resp?.server instanceof Server
}
storageDevice
- Storage device to insert as CD-ROMargs
- Request callbacks for the POST /server/${server.uuid}/cdrom/load
call.Fetch detailed information about a specific Server.
A 200 OK
response will include an instance of Server
in the server
property.
serverApi.load { resp, err ->
assert resp?.server instanceof Server
}
While this operation returns details of a single server, a less details list of all servers can be requested with the UpCloud.servers API.
args
- Request callbacks for the GET /server/${server.uuid}
call.Fetch detailed information about a specific firewall rule.
A 200 OK
response will include an instance of FirewallRule
in the firewallRule
property.
serverApi.loadFirewallRule 1, { resp, err ->
assert resp?.firewallRule instanceof FirewallRule
}
position
- The position number of the rule in the firewall rules listargs
- Request callbacks for the GET /server/${server.uuid}/firewall_rule/$position
call.Restarts a started server.
By default, a soft stop is performed. In soft stop, an ACPI signal is sent to the server. Keyword
arguments timeout
and timeout_action
can be used to configure what happens after the soft
stop attempt. If the server stops before the timeout, it is started. If the server has not stopped by
itself after timeout
seconds, timeout_action: "ignore"
can be used to cancel the restart
operation, and timeout_action: "destroy"
can be used to hard stop the server before starting it.
Alternatively, keyword argument stop_type: "hard"
can be used to basically kill the server and then
start it.
A 200 OK
response will include an instance of Server
in the server
property.
serverApi.restart timeout: "60", timeout_action: "destroy" { resp, err ->
assert resp?.server instanceof Server
}
args.stop_type
- Either soft
(default) or hard
.args.timeout
- Number of seconds to wait for the server to shutdown after ACPI signal, before performing timeout_action
.args.timeout_action
- Either destroy
(hard stop and start) or ignore
(do not restart).args
- Stop type arguments and request callbacks for the POST /server/${server.uuid}/restart
call.Starts a stopped server.
A 200 OK
response will include an instance of Server
in the server
property.
serverApi.start { resp, err ->
assert resp?.server instanceof Server
}
args
- Request callbacks for the POST /server/${server.uuid}/start
call.Stops a started server.
By default, a soft stop is performed. In soft stop, an ACPI signal is sent to the server.
Optionally, a timeout
keyword argument can be added to specify the time in seconds after which
the server is hard stopped if it hasn't stopped by itself. If no timeout is given, the server is not
stopped if doesn't stop by itself.
In hard stop, the server is basically just killed right away. An optional stop_type: "hard"
keyword argument can be used to perform the hard stop without first doing the soft stop.
A 200 OK
response will include an instance of Server
in the server
property. Note that the Server.state is still
started
in the response, and will need to be polled until it changes to stopped
once the
server has shut down.
serverApi.stop timeout: "60" { resp, err ->
assert resp?.server instanceof Server
}
args.stop_type
- Either soft
(default) or hard
.args.timeout
- If, after soft stop, this many seconds pass and the server hasn't stopped, a hard stop is performed.args
- Stop type arguments and request callbacks for the POST /server/${server.uuid}/stop
call.Modifies the configuration of an existing server.
A 202 Accepted
response will include an instance of Server
in the server
property.
import static fi.linuxbox.upcloud.resource.Builder.*
def web1 = server {
firewall = "on"
}
serverApi.update web1 { resp, err ->
assert resp?.server instanceof Server
}
resource
- Updated server resource.args
- Request callbacks for the PUT /server/${server.uuid}
call.