Class: DanarchySys::OpenStack::Compute
- Inherits:
-
Object
- Object
- DanarchySys::OpenStack::Compute
- Defined in:
- lib/danarchy_sys/openstack/compute.rb
Instance Method Summary collapse
- #compute_flavors ⇒ Object
- #compute_images ⇒ Object
- #compute_instances ⇒ Object
- #compute_keypairs ⇒ Object
- #compute_ssh(instance_name) ⇒ Object
-
#initialize(provider) ⇒ Compute
constructor
A new instance of Compute.
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
#compute_flavors ⇒ Object
28 29 30 |
# File 'lib/danarchy_sys/openstack/compute.rb', line 28 def compute_flavors ComputeFlavors.new(@compute) end |
#compute_images ⇒ Object
24 25 26 |
# File 'lib/danarchy_sys/openstack/compute.rb', line 24 def compute_images ComputeImages.new(@compute) end |
#compute_instances ⇒ Object
16 17 18 |
# File 'lib/danarchy_sys/openstack/compute.rb', line 16 def compute_instances ComputeInstances.new(@compute, @settings) end |
#compute_keypairs ⇒ Object
20 21 22 |
# File 'lib/danarchy_sys/openstack/compute.rb', line 20 def compute_keypairs ComputeKeypairs.new(@compute, @settings) end |
#compute_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 compute_ssh(instance_name) (comp_inst, comp_kp, comp_img) = compute_instances, compute_keypairs, compute_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 |