Class: DanarchySys::OpenStack::Compute
- Inherits:
-
Object
- Object
- DanarchySys::OpenStack::Compute
- Defined in:
- lib/danarchy_sys/openstack/compute.rb
Instance Method Summary collapse
- #flavors ⇒ Object
- #images ⇒ Object
-
#initialize(provider) ⇒ Compute
constructor
A new instance of Compute.
- #instances ⇒ Object
- #keypairs ⇒ Object
- #ssh(instance_name) ⇒ Object
Constructor Details
#initialize(provider) ⇒ Compute
Returns a new instance of Compute.
9 10 11 12 13 14 |
# File 'lib/danarchy_sys/openstack/compute.rb', line 9 def initialize(provider) danarchysys_config = DanarchySys::ConfigManager::Config.new connection = danarchysys_config[:connections][provider.to_sym] @settings = danarchysys_config[:global_settings] @compute = Fog::Compute::OpenStack.new(connection) end |
Instance Method Details
#flavors ⇒ Object
28 29 30 |
# File 'lib/danarchy_sys/openstack/compute.rb', line 28 def flavors ComputeFlavors.new(@compute) end |
#images ⇒ Object
24 25 26 |
# File 'lib/danarchy_sys/openstack/compute.rb', line 24 def images ComputeImages.new(@compute) end |
#instances ⇒ Object
16 17 18 |
# File 'lib/danarchy_sys/openstack/compute.rb', line 16 def instances ComputeInstances.new(@compute, @settings) end |
#keypairs ⇒ Object
20 21 22 |
# File 'lib/danarchy_sys/openstack/compute.rb', line 20 def keypairs ComputeKeypairs.new(@compute, @settings) end |
#ssh(instance_name) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/danarchy_sys/openstack/compute.rb', line 32 def ssh(instance_name) (comp_inst, comp_kp, comp_img) = instances, keypairs, images instance = comp_inst.get_instance(instance_name) keypair_name = instance.key_name pemfile = comp_kp.pemfile_path(keypair_name) # Define user by image_id image_info = instance.image image_id = image_info['id'] image = comp_img.get_image_by_id(image_id) # CoreOS is an exception with user as simply 'core' and not 'coreos' user = '' if image.name =~ /CoreOS/i user = 'core' else user = image.name.downcase.split('-')[0] end ipv4, ipv6 = comp_inst.get_addresses(instance_name) ssh = "ssh #{user}@#{ipv4} -i '#{pemfile}'" system(ssh) end |