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 15 |
# File 'lib/danarchy_sys/openstack/compute.rb', line 9 def initialize(provider) config = ConfigMgr.new danarchysys_config = config.load connection = danarchysys_config[:connections][provider] @settings = danarchysys_config[:settings] @compute = Fog::Compute::OpenStack.new(connection) end |
Instance Method Details
#compute_flavors ⇒ Object
29 30 31 |
# File 'lib/danarchy_sys/openstack/compute.rb', line 29 def compute_flavors ComputeFlavors.new(@compute) end |
#compute_images ⇒ Object
25 26 27 |
# File 'lib/danarchy_sys/openstack/compute.rb', line 25 def compute_images ComputeImages.new(@compute) end |
#compute_instances ⇒ Object
17 18 19 |
# File 'lib/danarchy_sys/openstack/compute.rb', line 17 def compute_instances ComputeInstances.new(@compute, @settings) end |
#compute_keypairs ⇒ Object
21 22 23 |
# File 'lib/danarchy_sys/openstack/compute.rb', line 21 def compute_keypairs ComputeKeypairs.new(@compute, @settings) end |
#compute_ssh(instance_name) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/danarchy_sys/openstack/compute.rb', line 33 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 = comp_inst.get_addresses(instance_name)[1]['addr'] ssh = "ssh #{user}@#{ipv4} -i '#{pemfile}'" system(ssh) end |