| Class | OpenStack::Compute::Server |
| In: |
lib/openstack/compute/server.rb
|
| Parent: | Object |
| accessipv4 | [R] | |
| accessipv6 | [R] | |
| addresses | [R] | |
| adminPass | [RW] | |
| created | [R] | |
| fault | [R] | |
| flavor | [R] | |
| hostId | [R] | |
| id | [R] | |
| image | [R] | |
| key_name | [R] | |
| libvirt_id | [R] | |
| metadata | [R] | |
| name | [R] | |
| progress | [R] | |
| security_groups | [R] | |
| state | [R] | |
| status | [R] |
This class is the representation of a single Server object. The constructor finds the server identified by the specified ID number, accesses the API via the populate method to get information about that server, and returns the object.
Will be called via the get_server or create_server methods on the OpenStack::Compute::Connection object, and will likely not be called directly.
>> server = cs.get_server(110917) => #<OpenStack::Compute::Server:0x1014e5438 ....> >> server.name => "RenamedRubyTest"
Add a fixed ip from a specific network to the instance
Returns true if the API call succeeds.
>> server.add_fixed_ip => true
After a server resize is complete, calling this method will confirm the resize with the OpenStack API, and discard the fallback/original image.
Returns true if the API call succeeds.
>> server.confirm_resize! => true
Takes a snapshot of the server and creates a server image from it. That image can then be used to build new servers. The snapshot is saved asynchronously. Check the image status to make sure that it is ACTIVE before attempting to perform operations on it.
A name string for the saved image must be provided. A new OpenStack::Compute::Image object for the saved image is returned.
The image is saved as a backup, of which there are only three available slots. If there are no backup slots available, A OpenStack::Exception::OpenStackComputeFault will be raised.
>> image = server.create_image(:name => "My Rails Server") =>
Removes a specific security group from the server.
>> server.delete_security_group('default')
=> true
Creates a new interface on this server.
>> server.interface_create => array
Sends an API request to pause this server.
Returns true if the API call succeeds.
>> server.pause => true
Makes the actual API call to get information about the given server object. If you are attempting to track the status or project of a server object (for example, when rebuilding, creating, or resizing a server), you will likely call this method within a loop until the status becomes "ACTIVE" or other conditions are met.
Returns true if the API call succeeds.
>> server.refresh => true
Sends an API request to reboot this server. Takes an optional argument for the type of reboot, which can be "SOFT" (graceful shutdown) or "HARD" (power cycle). The hard reboot is also triggered by server.reboot!, so that may be a better way to call it.
Returns true if the API call succeeds.
>> server.reboot => true
The rebuild function removes all data on the server and replaces it with the specified image. The serverRef and all IP addresses will remain the same. If name and metadata are specified, they will replace existing values, otherwise they will not change. A rebuild operation always removes data injected into the file system via server personality. You may reinsert data into the filesystem during the rebuild.
This method expects a hash of the form: {
:imageRef => "https://foo.com/v1.1/images/2",
:name => "newName",
:metadata => { :values => { :foo : "bar" } },
:personality => [
{
:path => "/etc/banner.txt",
:contents => : "ICAgpY2hhcmQgQmFjaA=="
}
]
}
This will wipe and rebuild the server, but keep the server ID number, name, and IP addresses the same.
Returns true if the API call succeeds.
>> server.rebuild! => true
Remove a specific fixed ip from the instance
Returns true if the API call succeeds.
>> server.remove_fixed_ip => true
Sends an API request to rescue this server.
Returns true if the API call succeeds.
>> server.rescue => true
Resizes the server to the size contained in the server flavor found at ID flavorRef. The server name, ID number, and IP addresses will remain the same. After the resize is done, the server.status will be set to "VERIFY_RESIZE" until the resize is confirmed or reverted.
Refreshes the OpenStack::Compute::Server object, and returns true if the API call succeeds.
>> server.resize!(1) => true
Sends an API request to resume this server.
Returns true if the API call succeeds.
>> server.resume => true
Sends an API request to suspend this server.
Returns true if the API call succeeds.
>> server.suspend => true
Sends an API request to unpause this server.
Returns true if the API call succeeds.
>> server.unpause => true
Sends an API request to unrescue this server.
Returns true if the API call succeeds.
>> server.unrescue => true
Updates various parameters about the server. Currently, the only operations supported are changing the server name (not the actual hostname on the server, but simply the label in the Servers API) and the administrator password (note: changing the admin password will trigger a reboot of the server). Other options are ignored. One or both key/value pairs may be provided. Keys are case-sensitive.
Input hash key values are :name and :adminPass. Returns true if the API call succeeds.
>> server.update(:name => "MyServer", :adminPass => "12345") => true >> server.name => "MyServer"