mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[brightbox] Adding *_server actions to ServerGroup model
* ServerGroup#add_servers * ServerGroup#remove_servers * ServerGroup#move_servers
This commit is contained in:
parent
ee93e0f87b
commit
6f32c0a38f
1 changed files with 48 additions and 18 deletions
|
@ -28,30 +28,60 @@ module Fog
|
|||
true
|
||||
end
|
||||
|
||||
# Add a server to the server group
|
||||
# Adds specified servers to this server group
|
||||
#
|
||||
# == Parameters:
|
||||
# identifiers::
|
||||
# An array of identifiers for the servers to add to the group
|
||||
#
|
||||
# == Returns:
|
||||
#
|
||||
# An excon response object representing the result
|
||||
#
|
||||
# <Excon::Response: ...
|
||||
#
|
||||
def add_servers(server_identifiers)
|
||||
# @param [Array] identifiers array of server identifier strings to add
|
||||
# @return [Fog::Compute::ServerGroup]
|
||||
def add_servers identifiers
|
||||
requires :identity
|
||||
server_references = server_identifiers.map {|ident| {"server" => ident} }
|
||||
options = {
|
||||
:servers => server_references
|
||||
:servers => server_references(identifiers)
|
||||
}
|
||||
data = connection.add_servers_server_group(identity, options)
|
||||
merge_attributes(data)
|
||||
data = connection.add_servers_server_group identity, options
|
||||
merge_attributes data
|
||||
end
|
||||
|
||||
# Removes specified servers from this server group
|
||||
#
|
||||
# @param [Array] identifiers array of server identifier strings to remove
|
||||
# @return [Fog::Compute::ServerGroup]
|
||||
def remove_servers identifiers
|
||||
requires :identity
|
||||
options = {
|
||||
:servers => server_references(identifiers)
|
||||
}
|
||||
data = connection.remove_servers_server_group identity, options
|
||||
merge_attributes data
|
||||
end
|
||||
|
||||
# Moves specified servers from this server group to the specified destination server group
|
||||
#
|
||||
# @param [Array] identifiers array of server identifier strings to move
|
||||
# @param [String] destination_group_id destination server group identifier
|
||||
# @return [Fog::Compute::ServerGroup]
|
||||
def move_servers identifiers, destination_group_id
|
||||
requires :identity
|
||||
options = {
|
||||
:servers => server_references(identifiers),
|
||||
:destination => destination_group_id
|
||||
}
|
||||
data = connection.move_servers_server_group identity, options
|
||||
merge_attributes data
|
||||
end
|
||||
|
||||
def destroy
|
||||
requires :identity
|
||||
connection.destroy_server_group(identity)
|
||||
true
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def server_references identifiers
|
||||
identifiers.map {|id| {"server" => id} }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue