lmcadm 0.5.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: '024983aa25fe084824563894b065eda2bf87be11'
4
+ data.tar.gz: 7e20162f4e167d80ecc74c372d8eca5522e36a24
5
+ SHA512:
6
+ metadata.gz: 6caa3ae89f743a5337ba4f7c5455c5676e54467800d02d8e32021518a31744996dcec4bb82edcd56f8ec970376849abef4d920083b447b87d7018af79f2f4791
7
+ data.tar.gz: 164dcab63eadabaa886a26ace7b65db8a8dc2c2b385fb7a97a8f1a9f7758ef17613fff78fc7464f40734efb5a807ee0abc4606af173e125ab1780dc4363cfad7
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ *.swp
2
+ /.bundle/
3
+ /.yardoc
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /.idea/workspace.xml
11
+ /.idea/tasks.xml
12
+ /.idea/.rakeTasks
13
+ /Gemfile.lock
14
+ /lmcadm-*.gem
data/.idea/lmcadm.iml ADDED
@@ -0,0 +1,27 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="RUBY_MODULE" version="4">
3
+ <component name="ModuleRunConfigurationManager">
4
+ <shared />
5
+ </component>
6
+ <component name="NewModuleRootManager">
7
+ <content url="file://$MODULE_DIR$" />
8
+ <orderEntry type="jdk" jdkName="rbenv: 2.4.1" jdkType="RUBY_SDK" />
9
+ <orderEntry type="sourceFolder" forTests="false" />
10
+ <orderEntry type="library" scope="PROVIDED" name="bundler (v1.16.1, rbenv: 2.4.1) [gem]" level="application" />
11
+ <orderEntry type="library" scope="PROVIDED" name="colorize (v0.8.1, rbenv: 2.4.1) [gem]" level="application" />
12
+ <orderEntry type="library" scope="PROVIDED" name="domain_name (v0.5.20170404, rbenv: 2.4.1) [gem]" level="application" />
13
+ <orderEntry type="library" scope="PROVIDED" name="gli (v2.17.1, rbenv: 2.4.1) [gem]" level="application" />
14
+ <orderEntry type="library" scope="PROVIDED" name="http-cookie (v1.0.3, rbenv: 2.4.1) [gem]" level="application" />
15
+ <orderEntry type="library" scope="PROVIDED" name="json (v2.1.0, rbenv: 2.4.1) [gem]" level="application" />
16
+ <orderEntry type="library" scope="PROVIDED" name="lmc (v0.2.0, rbenv: 2.4.1) [gem]" level="application" />
17
+ <orderEntry type="library" scope="PROVIDED" name="mime-types (v3.1, rbenv: 2.4.1) [gem]" level="application" />
18
+ <orderEntry type="library" scope="PROVIDED" name="mime-types-data (v3.2016.0521, rbenv: 2.4.1) [gem]" level="application" />
19
+ <orderEntry type="library" scope="PROVIDED" name="minitest (v5.11.3, rbenv: 2.4.1) [gem]" level="application" />
20
+ <orderEntry type="library" scope="PROVIDED" name="netrc (v0.11.0, rbenv: 2.4.1) [gem]" level="application" />
21
+ <orderEntry type="library" scope="PROVIDED" name="rake (v10.5.0, rbenv: 2.4.1) [gem]" level="application" />
22
+ <orderEntry type="library" scope="PROVIDED" name="rest-client (v2.0.2, rbenv: 2.4.1) [gem]" level="application" />
23
+ <orderEntry type="library" scope="PROVIDED" name="table_print (v1.5.6, rbenv: 2.4.1) [gem]" level="application" />
24
+ <orderEntry type="library" scope="PROVIDED" name="unf (v0.1.4, rbenv: 2.4.1) [gem]" level="application" />
25
+ <orderEntry type="library" scope="PROVIDED" name="unf_ext (v0.0.7.5, rbenv: 2.4.1) [gem]" level="application" />
26
+ </component>
27
+ </module>
data/.idea/misc.xml ADDED
@@ -0,0 +1,4 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectRootManager" version="2" project-jdk-name="rbenv: 1.9.3-p551" project-jdk-type="RUBY_SDK" />
4
+ </project>
data/.idea/modules.xml ADDED
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/lmcadm.iml" filepath="$PROJECT_DIR$/.idea/lmcadm.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
data/.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
+ </component>
6
+ </project>
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.4.1
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.1
5
+ before_install: gem install bundler -v 1.16.1
data/Gemfile ADDED
@@ -0,0 +1,9 @@
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 lmcadm.gemspec
6
+ gemspec
7
+ if ENV['LMCADM_PATH_DEP'] == "1" #File.directory? '../ruby-lmc'
8
+ gem 'lmc', :path => '../ruby-lmc/'
9
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1 @@
1
+
data/README.md ADDED
@@ -0,0 +1,45 @@
1
+ # Lmcadm
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/lmcadm`. 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 'lmcadm'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install lmcadm
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
+ ### Using a local version of the lmc gem
34
+
35
+ Set the environment variable LMCADM\_PATH\_DEP to 1 to use the _lmc_ gem from ../ruby-lmc.
36
+ Example:
37
+ $ LMCADM_PATH_DEP=1 bundle exec lmcadm --version
38
+
39
+ ## Contributing
40
+
41
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/lmcadm.
42
+
43
+ ## License
44
+
45
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
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 "lmcadm"
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
data/exe/lmcadm ADDED
@@ -0,0 +1,97 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'lmc'
4
+ require "lmcadm"
5
+ require 'gli'
6
+ require 'table_print'
7
+ require 'colorize'
8
+
9
+ module LMCAdm
10
+
11
+ # make gli dsl available
12
+ include GLI::App
13
+ extend self
14
+
15
+ program_desc 'LMC command line client'
16
+
17
+
18
+ version "#{LMCAdm::VERSION} (library version #{::LMC::VERSION})"
19
+
20
+ subcommand_option_handling :normal
21
+ arguments :strict
22
+
23
+ config_file '.lmcadm.rc'
24
+
25
+ commands_from "lmcadm/commands"
26
+
27
+ desc 'Be verbose'
28
+ switch [:v, :verbose]
29
+
30
+ desc 'debug'
31
+ switch [:debug]
32
+
33
+ desc 'Measure time taken for operations'
34
+ switch "take-time"
35
+
36
+ desc 'cloud host'
37
+ default_value "lmc-en"
38
+ flag :C, :cloud_host
39
+
40
+ desc 'Use encrypted connection'
41
+ default_value true
42
+ switch "use-tls"
43
+
44
+ desc 'Verify server certificate'
45
+ default_value true
46
+ switch "verify-tls"
47
+
48
+ desc 'username'
49
+ default_value "admin"
50
+ flag :U, :user
51
+
52
+ desc 'password'
53
+ default_value ""
54
+ flag [:P, :password], :mask => true
55
+
56
+
57
+ pre do |global, command, options, args|
58
+ # Pre logic here
59
+ # Return true to proceed; false to abort and not call the
60
+ # chosen command
61
+ # Use skips_pre before a command to skip this block
62
+ # on that command only
63
+ if global[:password] == ""
64
+ puts "Enter password for " + global[:user] + ":"
65
+ global[:password] = Helpers::read_pw
66
+ end
67
+ ::LMC::Cloud.cloud_host = global[:cloud_host]
68
+ ::LMC::Cloud.user = global[:user]
69
+ ::LMC::Cloud.password = global[:password]
70
+ ::LMC::Cloud.verbose = global[:verbose]
71
+ ::LMC::Cloud.debug = global[:debug]
72
+ ::LMC::Cloud.verify_tls = global["verify-tls"]
73
+ ::LMC::Cloud.use_tls = global["use-tls"]
74
+ LMCAdm::ProgressVisualizer.take_time = global["take-time"]
75
+ true
76
+ end
77
+
78
+ post do |global, command, options, args|
79
+ # Post logic here
80
+ # Use skips_post before a command to skip this
81
+ # block on that command only
82
+ end
83
+
84
+ on_error do |exception|
85
+ if LMC::Cloud.debug
86
+ puts "on_error handler"
87
+ puts exception
88
+ puts exception.backtrace
89
+ end
90
+ if exception.respond_to?(:response)
91
+ puts exception.response
92
+ end
93
+ true
94
+ end
95
+
96
+ exit run(ARGV)
97
+ end
@@ -0,0 +1,18 @@
1
+ require 'lmcadm/ProgressVisualizer.rb'
2
+ module LMCAdm
3
+ class ColoredProgressVisualizer < ProgressVisualizer
4
+ class << self
5
+ attr_accessor :take_time
6
+ end
7
+ def initialize(taskstring)
8
+ super "#{taskstring.bold}"
9
+ end
10
+ def success(endstring)
11
+ finished(endstring.green)
12
+ end
13
+ def done()
14
+ finished("done".green)
15
+ end
16
+ end
17
+
18
+ end
data/lib/lmcadm/Log.rb ADDED
@@ -0,0 +1,9 @@
1
+ class LMCADMLogger
2
+ def self.err
3
+ @err ||= Logger.new(STDERR)
4
+ end
5
+
6
+ #def self.error
7
+ #end
8
+
9
+ end
@@ -0,0 +1,52 @@
1
+ module LMCAdm
2
+ class ProgressVisualizer
3
+ class << self
4
+ attr_accessor :take_time
5
+ end
6
+
7
+ def initialize(taskstring)
8
+ print "#{taskstring} "
9
+ @itemized = false
10
+ @start = Time.now if ProgressVisualizer.take_time
11
+ end
12
+
13
+ def perform
14
+ print "#{taskstring} "
15
+ @itemized = false
16
+ @start = Time.now if ProgressVisualizer.take_time
17
+ end
18
+
19
+ def finished(endstring)
20
+ if @itemized
21
+ endstring = ' ' + endstring
22
+ end
23
+ if ProgressVisualizer.take_time
24
+ elapsed = (Time.now - @start) * 1000
25
+ endstring = endstring + " (" + elapsed.to_s + "ms)"
26
+ end
27
+ puts endstring
28
+ end
29
+
30
+ def success(endstring)
31
+ finished(endstring)
32
+ end
33
+
34
+ def done()
35
+ finished("done")
36
+ end
37
+
38
+ def itemize(str)
39
+ @itemized = true
40
+ print str
41
+ end
42
+
43
+ def X()
44
+ itemize "X"
45
+ end
46
+
47
+ def dot()
48
+ itemize "."
49
+ end
50
+ end
51
+
52
+ end
@@ -0,0 +1,30 @@
1
+ module LMCAdm
2
+ class LMCADMResultInterpreter
3
+ def self.get_final_word(code)
4
+ code_mappings = {
5
+ 200 => "Done",
6
+ 504 => "Timeout"
7
+ }
8
+ finalword = code_mappings[code]
9
+ finalword ||= "UNKNOWN STATUS CODE"
10
+ end
11
+
12
+ def self.interpret(result)
13
+ self.get_final_word(result.code)
14
+ end
15
+
16
+ def self.interpret_with_color(result)
17
+ code = result.code
18
+ finalword = self.get_final_word(code)
19
+ if code == 200
20
+ finalword = finalword.green
21
+ elsif code <= 400 && code < 500
22
+ finalword = finalword.yellow
23
+ elsif code >= 500 && code < 600
24
+ finalword = finalword.red
25
+ end
26
+ return finalword
27
+ end
28
+ end
29
+
30
+ end
@@ -0,0 +1,3 @@
1
+ class LMCADMUUID
2
+
3
+ end