cloud_job_base 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 62d657f1552b806bb4f62c2b377df7271a6a80f0
4
+ data.tar.gz: 4b8ea0b56fb4120fdda6d7dff7c9662d0b40417b
5
+ SHA512:
6
+ metadata.gz: e3e91babe53240dd515186d63c8b9c81b218d77688c437ecea539b0364b36bdee97a16eb67dd8435ef487a0b097054cdaa848316a18e76ef494721c33734c4e4
7
+ data.tar.gz: cfe36963dd98b325b47b37580a37539ccf385181bec669d7e0a9d6316b228973c48956403be02d8b4db4b45345cc753e909eca18cf6f30a9c12160bd94e92ae5
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.0
5
+ before_install: gem install bundler -v 1.15.4
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in cloud_job_base.gemspec
6
+ gemspec
7
+
8
+ gem "abstract"
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # CloudJobBase
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/cloud_job_base`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'cloud_job_base'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install cloud_job_base
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/cloud_job_base.
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "cloud_job_base"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "cloud_job_base/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "cloud_job_base"
8
+ spec.version = CloudJobBase::VERSION
9
+ spec.authors = ["Elena Evdokimenko"]
10
+ spec.email = ["x17102782@student.ncirl.ie"]
11
+
12
+ spec.summary = 'Abstract and base classes for managing cloud instances'
13
+ spec.description = 'Abstract and base classes for managing cloud instances'
14
+ #spec.homepage = 'http://mygemserver.com'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.15"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "minitest", "~> 5.0"
26
+ end
@@ -0,0 +1,69 @@
1
+ require "cloud_job_base/version"
2
+ require "abstract"
3
+ require "cloud_job_observable"
4
+
5
+ module CloudJobBase
6
+
7
+ class CloudConnector
8
+ abstract_method "region", :set_region
9
+ abstract_method "log_level", :set_log_level
10
+ abstract_method :check_credentials
11
+ abstract_method :create_client
12
+
13
+ def init(region, log_level)
14
+ set_log_level(log_level)
15
+ set_region(region)
16
+ check_credentials
17
+ create_client
18
+ end
19
+ end
20
+
21
+ class VirtualMachine
22
+ attr_accessor :instance_id
23
+ attr_reader :series, :image
24
+
25
+ def initialize(series="", image="", instance_id="")
26
+ @series = series
27
+ @image = image
28
+ @instance_id = instance_id
29
+ end
30
+ end
31
+
32
+ class VmHandler
33
+ include CloudJobBaseObservable
34
+
35
+ def initialize(cloudConnector, vm)
36
+ @cloudConnector = cloudConnector
37
+ @vm = vm
38
+ end
39
+
40
+ def get_vm_id
41
+ @vm.instance_id
42
+ end
43
+
44
+ abstract_method :provision, :delete
45
+ abstract_method "exe_bucket_key", :deploy_exe
46
+ abstract_method "exe_bucket_key", :run_exe
47
+
48
+ def provision_instance
49
+ provision
50
+ notify_observers
51
+ end
52
+
53
+ def delete_instance
54
+ delete
55
+ notify_observers
56
+ end
57
+
58
+ def deploy_exe_to_instance(exe_bucket_key)
59
+ deploy_exe(exe_bucket_key)
60
+ notify_observers
61
+ end
62
+
63
+ def run_exe_on_instance(exe_bucket_key)
64
+ run_exe(exe_bucket_key)
65
+ notify_observers
66
+ end
67
+ end
68
+
69
+ end
@@ -0,0 +1,3 @@
1
+ module CloudJobBase
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,22 @@
1
+ module CloudJobBaseObservable
2
+ attr_accessor :status, :exception
3
+
4
+ def add_observer(observer)
5
+ raise NoMethodError if !(observer.respond_to? :update)
6
+ @observers = [] if !(defined? @observers)
7
+ @observers << observer
8
+ end
9
+
10
+ def delete_observer(observer)
11
+ observers.delete(observer) if defined? @observers
12
+ end
13
+
14
+ def notify_observers
15
+ if defined? @observers
16
+ @observers.each do |observer|
17
+ puts "\n notify_observers"
18
+ observer.update(self)
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,10 @@
1
+ module CloudJobBaseObserver
2
+ attr_reader :job_stage, :job_log_id
3
+
4
+ def initialize(job_stage, job_log_id)
5
+ @job_stage = job_stage
6
+ @job_log_id = job_log_id
7
+ end
8
+
9
+ abstract_method "object", :update
10
+ end
@@ -0,0 +1,26 @@
1
+ require "abstract"
2
+ require "cloud_job_observable"
3
+
4
+ module CloudJobBase
5
+
6
+ class InternalStorageHandler
7
+ include CloudJobBaseObservable
8
+
9
+ def self.instance
10
+ Mutex.new.synchronize {
11
+ if !(defined? @@instance)
12
+ @@instance = new
13
+ @@instance.init_connection
14
+ end
15
+ }
16
+ return @@instance
17
+ end
18
+
19
+ private_class_method :new
20
+
21
+ abstract_method :init_connection
22
+ abstract_method "file_path",:put_file
23
+ abstract_method "file_url",:read_file
24
+ end
25
+
26
+ end
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cloud_job_base
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Elena Evdokimenko
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-12-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.15'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.15'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.0'
55
+ description: Abstract and base classes for managing cloud instances
56
+ email:
57
+ - x17102782@student.ncirl.ie
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".travis.yml"
64
+ - Gemfile
65
+ - README.md
66
+ - Rakefile
67
+ - bin/console
68
+ - bin/setup
69
+ - cloud_job_base.gemspec
70
+ - lib/cloud_job_base.rb
71
+ - lib/cloud_job_base/version.rb
72
+ - lib/cloud_job_observable.rb
73
+ - lib/cloud_job_observer.rb
74
+ - lib/cloud_storage_handler.rb
75
+ homepage:
76
+ licenses: []
77
+ metadata: {}
78
+ post_install_message:
79
+ rdoc_options: []
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ requirements: []
93
+ rubyforge_project:
94
+ rubygems_version: 2.6.8
95
+ signing_key:
96
+ specification_version: 4
97
+ summary: Abstract and base classes for managing cloud instances
98
+ test_files: []