Class: Kytoon::ServerGroup
- Inherits:
-
Object
- Object
- Kytoon::ServerGroup
- Defined in:
- lib/kytoon/server_group.rb
Constant Summary collapse
- @@group_class =
nil
Class Method Summary collapse
- .create(config_file) ⇒ Object
- .delete(id = nil) ⇒ Object
- .get(id = nil) ⇒ Object
- .index(options = {}) ⇒ Object
-
.init(group_type = ENV['GROUP_TYPE']) ⇒ Object
called to init the configured group class we will use.
Class Method Details
.create(config_file) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/kytoon/server_group.rb', line 43 def self.create(config_file) self.init if config_file.nil? then config_file = @@group_class::CONFIG_FILE end if not File.exists?(config_file) then raise ConfigException, "Please specify a valid GROUP_CONFIG." end sg = @@group_class.from_json(IO.read(config_file)) @@group_class.create(sg) end |
.delete(id = nil) ⇒ Object
60 61 62 63 64 |
# File 'lib/kytoon/server_group.rb', line 60 def self.delete(id=nil) self.init sg = @@group_class.get(:id => id) sg.delete end |
.get(id = nil) ⇒ Object
55 56 57 58 |
# File 'lib/kytoon/server_group.rb', line 55 def self.get(id=nil) self.init @@group_class.get(:id => id) end |
.index(options = {}) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/kytoon/server_group.rb', line 29 def self.index(={}) self.init server_groups = @@group_class.index() if server_groups.size > 0 puts "Server groups:" server_groups.sort { |a,b| b.id <=> a.id }.each do |sg| gw=sg.gateway_ip.nil? ? "" : " (#{sg.gateway_ip})" puts "\t :id => #{sg.id}, :name => #{sg.name} #{gw}" end else puts "No server groups." end end |
.init(group_type = ENV['GROUP_TYPE']) ⇒ Object
called to init the configured group class we will use
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/kytoon/server_group.rb', line 8 def self.init(group_type=ENV['GROUP_TYPE']) return if not @@group_class.nil? configs = Util.load_configs group_type = configs['group_type'] if group_type.nil? if group_type == "openstack" then require 'kytoon/providers/openstack' @@group_class = Kytoon::Providers::Openstack::ServerGroup elsif group_type == "xenserver" then require 'kytoon/providers/xenserver' @@group_class = Kytoon::Providers::Xenserver::ServerGroup elsif group_type == "libvirt" then require 'kytoon/providers/libvirt' @@group_class = Kytoon::Providers::Libvirt::ServerGroup elsif group_type == "cloud_server_vpc" or group_type == "cloud_servers_vpc" then require 'kytoon/providers/cloud_servers_vpc' @@group_class = Kytoon::Providers::CloudServersVPC::ServerGroup else raise ConfigException, "Invalid 'group_type' specified." end end |