app42 0.5.5 → 0.5.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,89 @@
1
+ require 'app42/command/base'
2
+ require 'terminal-table'
3
+
4
+ module App42
5
+ module Command
6
+ class Setup < Base
7
+
8
+ # Collect all required attributes for new App42 clould setup spawn
9
+ # required inputs are setup_name, vm_type, iaas, setup_type and flavour
10
+ def setup_cloud_api
11
+ setup_name = get_setup_name_and_check_setup_url_availability
12
+ vm_type = get_vm_types
13
+ iaas = get_iaas_providers
14
+ setup_type = get_setup_type
15
+ flavour = get_flavour
16
+ setup_cloud_api_res = App42::Command::Base.new.create_cloud_setup setup_name, iaas, vm_type, setup_type, flavour
17
+ exit! if setup_infra_res
18
+ end
19
+
20
+ # Delete App42 cloud API setup, return true or error code/message
21
+ def delete_cloud_api
22
+ @options[:name] = get_setup_name if @options[:name].nil?
23
+ response = delete_clouldapi @options[:name] if is_setup_name_exist? @options[:name]
24
+ exit! if response
25
+ end
26
+
27
+ # return setup type
28
+ def get_setup_type
29
+ setup_type_hash = {}
30
+ setup_type = App42::Command::Config.new.get_setup_type_fm_server
31
+
32
+ setup_type['setupTypes'].select {|each_setup_type| setup_type_hash["#{each_setup_type['id']}"] = each_setup_type['name']}
33
+ setup = input "Select Setup Type", setup_type_hash.values, true
34
+
35
+ setup_type_id = nil
36
+ setup_type_hash.each_pair{|type| setup_type_id = type[0] if type[1] == setup}
37
+ return setup_type_id
38
+ end
39
+
40
+ # return flavour
41
+ def get_flavour
42
+ flavour_hash = {}
43
+ flavour_type = App42::Command::Config.new.get_flavour_type_fm_server
44
+ flavour_type['flavours'].select {|each_flavour| flavour_hash["#{each_flavour['id']}"] = each_flavour['name']}
45
+ flavour = input "Select Flavour", flavour_hash.values, true
46
+
47
+ flavour_id = nil
48
+ flavour_hash.each_pair{|fl| flavour_id = fl[0] if fl[1] == flavour}
49
+ return flavour_id
50
+ end
51
+
52
+ # get details information of App42 cloud setup
53
+ def info
54
+ @options[:name] = get_setup_name if @options[:name].nil?
55
+ query_params = params
56
+ query_params.store('setupName', @options[:name])
57
+ setup_info = build_get_request query_params, 'setup', "#{@options[:name]}"
58
+ rows, rows_header_final, rows_header = [], [], nil
59
+ if setup_info && setup_info['setupInfo']
60
+ rows_header = setup_info['setupInfo'].keys
61
+ rows << setup_info['setupInfo'].values
62
+
63
+ rows_header.map { |e| rows_header_final << camel_case_to_whitespace(e) }
64
+
65
+ table = Terminal::Table.new :title => Paint["=== #{@options[:name]} Details ===", :green], :headings => rows_header_final, :rows => rows
66
+ puts table
67
+ end
68
+ end
69
+
70
+ # List all setups
71
+ def setups
72
+ query_params = params
73
+ setups = build_get_request query_params, 'setup', nil
74
+ rows, rows_header_final, rows_header = [], [], nil
75
+ if setups && setups['setups']
76
+ setups['setups'].each do |e|
77
+ rows_header = e.keys
78
+ rows << e.values
79
+ end
80
+
81
+ rows_header.map { |e| rows_header_final << camel_case_to_whitespace(e) }
82
+
83
+ table = Terminal::Table.new :title => Paint["=== Setups List ===", :green], :headings => rows_header_final, :rows => rows
84
+ puts table
85
+ end
86
+ end
87
+ end
88
+ end
89
+ end
data/lib/app42/version.rb CHANGED
@@ -3,7 +3,7 @@ module App42
3
3
  module VERSION
4
4
  MAJOR = 0
5
5
  MINOR = 5
6
- TINY = 5
6
+ TINY = 6
7
7
  PRE = "alpha"
8
8
 
9
9
  STRING = [MAJOR, MINOR, TINY].compact.join('.')
@@ -4,7 +4,7 @@ describe App42 do
4
4
 
5
5
  describe 'Constants' do
6
6
  it 'should return correct HOST url' do
7
- App42::HOST.should == 'http://54.218.127.212:8081/paas/1.0'
7
+ App42::HOST.should == 'http://api.app42paas.com/paas/1.0'
8
8
  end
9
9
  end
10
10
 
@@ -59,17 +59,17 @@ describe 'App42::Command' do
59
59
  end
60
60
 
61
61
  it 'Should return correct app information json' do
62
- respone = App42::Command::Base.new.app_information 'info', @app_name
62
+ response = App42::Command::Base.new.app_information 'info', @app_name
63
63
  path = "#{APP_ROOT}/app42/spec/data/info.yml"
64
64
  info = YAML.load_file(path)
65
- respone.should eql info
65
+ response.should eql info
66
66
  end
67
67
 
68
68
  it 'Should return correct app state json' do
69
- respone = App42::Command::Base.new.app_information 'state', @app_name
69
+ response = App42::Command::Base.new.app_information 'state', @app_name
70
70
  path = "#{APP_ROOT}/app42/spec/data/state.yml"
71
71
  info = YAML.load_file(path)
72
- respone.should eql info
72
+ response.should eql info
73
73
  end
74
74
 
75
75
  it 'Should delete app:' do
@@ -10,18 +10,18 @@ describe 'App42::Command' do
10
10
  context("with right app name") do
11
11
 
12
12
  it 'Should return correct app information json' do
13
- respone = App42::Command::Base.new.app_information 'info', @app_name
13
+ response = App42::Command::Base.new.app_information 'info', @app_name
14
14
  path = "#{APP_ROOT}/app42/spec/data/info.yml"
15
15
  info = YAML.load_file(path)
16
- respone.should eql info
16
+ response.should eql info
17
17
  end
18
18
 
19
19
  it 'Should return correct app state json' do
20
- respone = App42::Command::Base.new.app_information 'state', @app_name
20
+ response = App42::Command::Base.new.app_information 'state', @app_name
21
21
  path = "#{APP_ROOT}/app42/spec/data/state.yml"
22
22
  info = YAML.load_file(path)
23
- respone.should eql info
23
+ response.should eql info
24
24
  end
25
- end
25
+ end
26
26
  end
27
27
  end
@@ -36,7 +36,7 @@ describe 'App42::Command' do
36
36
  end
37
37
 
38
38
  it 'Should return correct service information json' do
39
- respone = App42::Command::Service.new.info
39
+ response = App42::Command::Service.new.info
40
40
  end
41
41
 
42
42
  it 'Should reset service password' do
@@ -73,21 +73,21 @@ describe 'App42::Command' do
73
73
  end
74
74
  end
75
75
 
76
- context "Create service, name contain special charrecter" do
76
+ context "Create service, name contain special character" do
77
77
  it "Service name should not contain any special character and it's length should be less than 30." do
78
78
  response = App42::Command::Base.new.create_service @service, @service_name_sc ,@database, @vm_type, @iaas, @vmconfig, @os
79
79
  end
80
80
  end
81
81
 
82
82
  # Unit testing
83
- it "Should return app42PaaS services josn" do
83
+ it "Should return app42PaaS services json" do
84
84
  response = App42::Command::Service.new.get_services
85
85
  path = "#{APP_ROOT}/app42/spec/data/services.yml"
86
86
  services = YAML.load_file(path)
87
87
  response.should eql services
88
88
  end
89
89
 
90
- it "Should return user services josn" do
90
+ it "Should return user services json" do
91
91
  response = App42::Command::Service.new.get_user_services
92
92
  path = "#{APP_ROOT}/app42/spec/data/user_services.yml"
93
93
  service = YAML.load_file(path)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: app42
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.5
4
+ version: 0.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - ShepHertz
@@ -191,7 +191,6 @@ files:
191
191
  - LICENSE.txt
192
192
  - README.md
193
193
  - Rakefile
194
- - TODO.txt
195
194
  - app42.gemspec
196
195
  - bin/app42
197
196
  - lib/app42.rb
@@ -210,6 +209,7 @@ files:
210
209
  - lib/app42/command/config.rb
211
210
  - lib/app42/command/info.rb
212
211
  - lib/app42/command/service.rb
212
+ - lib/app42/command/setup.rb
213
213
  - lib/app42/command/user.rb
214
214
  - lib/app42/command/user_key.rb
215
215
  - lib/app42/version.rb
data/TODO.txt DELETED
@@ -1,36 +0,0 @@
1
- - Authenticate user at entry point
2
- - Authenticate in parent class initializer
3
-
4
- - Auth methods should be instance
5
-
6
- - Move all app deploy interactive details to constants OR globe file
7
-
8
- Code should be enough smart to handle exceptions
9
- - BadTarget
10
- - AuthError
11
- - TargetError
12
-
13
-
14
-
15
-
16
- - We can store app_url details into local YML
17
- - Zip_code, should have proper dir(Probably app_name, May user will have multiple apps)
18
- - Rest multipart, should be dynamic for multiple calls
19
-
20
- - Need to improve help class
21
- - Need to improve helpers class, All common methods will move to helper.
22
- - App update need to work
23
- - Separate methods for root help and command help
24
- - Shell command and description should be dynamic(get from pass server)
25
-
26
- - Remove extarcted app dir from .app42
27
-
28
- - Exception for invalid argument
29
-
30
- - Rspec test case for all class and methods
31
-
32
-
33
- #app_name = 'demo'
34
- ##source_url = '/home/ubuntu/workspace/Deploycode/sinatra/test.zip'
35
- ##source_url = '/home/ubuntu/workspace/Deploycode/ruby/demo.zip'
36
- #source_url = '/home/ubuntu/workspace/Deploycode/java/Calendar.war'