Sha256: 6a7331274ff0ff666ce99f464ce00761d541c521bbbd5932b136e07f759134b4

Contents?: true

Size: 1.65 KB

Versions: 1

Compression:

Stored size: 1.65 KB

Contents

require "cloud_job_base/version"
require "abstract"
require "cloud_job_observable"

module CloudJobBase
    
    class CloudConnector
        abstract_method "region", :set_region
        abstract_method "log_level", :set_log_level
        abstract_method :check_credentials
        abstract_method :create_client
        
        def init(region, log_level)
            set_log_level(log_level)
            set_region(region)
            check_credentials
            create_client
        end
    end
    
    class VirtualMachine
        attr_accessor :instance_id
        attr_reader :series, :image
        
        def initialize(series="", image="", instance_id="")
            @series = series
            @image = image
            @instance_id = instance_id
        end
    end
    
    class VmHandler
        include CloudJobBaseObservable
        
        def initialize(cloudConnector, vm)
            @cloudConnector = cloudConnector
            @vm = vm
        end

        def get_vm_id
            @vm.instance_id
        end
        
        abstract_method :provision, :delete
        abstract_method "exe_bucket_key", :deploy_exe
        abstract_method "exe_bucket_key", :run_exe
        
        def provision_instance
            provision
            notify_observers
        end
        
        def delete_instance
            delete
            notify_observers
        end
        
        def deploy_exe_to_instance(exe_bucket_key)
            deploy_exe(exe_bucket_key)
            notify_observers
        end
        
        def run_exe_on_instance(exe_bucket_key)
            run_exe(exe_bucket_key)
            notify_observers
        end
    end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cloud_job_base-0.1.0 lib/cloud_job_base.rb