af 0.3.18.2 → 0.3.18.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -22,6 +22,7 @@ MIT license, please see the LICENSE file. All rights reserved._
22
22
 
23
23
  Application Creation
24
24
  push [appname] Create, push, map, and start a new application
25
+ push [appname] --infra Push application to specified infrastructure
25
26
  push [appname] --path Push application from specified path
26
27
  push [appname] --url Set the url for the application
27
28
  push [appname] --instances <N> Set the expected number <N> of instances
@@ -57,6 +58,7 @@ MIT license, please see the LICENSE file. All rights reserved._
57
58
  Services
58
59
  services Lists of services available and provisioned
59
60
  create-service <service> [--name,--bind] Create a provisioned service
61
+ create-service <service> --infra Create a provisioned service on a specified infrastructure
60
62
  create-service <service> <name> Create a provisioned service and assign it <name>
61
63
  create-service <service> <name> <app> Create a provisioned service and assign it <name>, and bind to <app>
62
64
  delete-service [servicename] Delete a provisioned service
@@ -76,6 +78,7 @@ MIT license, please see the LICENSE file. All rights reserved._
76
78
  System
77
79
  runtimes Display the supported runtimes of the target system
78
80
  frameworks Display the recognized frameworks of the target system
81
+ infras Display the available infrastructures
79
82
 
80
83
  Micro Cloud Foundry
81
84
  micro status Display Micro Cloud Foundry VM status
@@ -208,7 +208,15 @@ module VMC::Cli::Command
208
208
  rescue VMC::Client::NotFound, VMC::Client::TargetError
209
209
  err 'No such file or directory'
210
210
  end
211
-
211
+
212
+ def pull(appname, path=nil)
213
+ path = File.expand_path(path || appname)
214
+ banner = "Pulling last pushed source code: "
215
+ display banner, false
216
+ client.app_pull(appname, path)
217
+ display 'OK'.green
218
+ end
219
+
212
220
  def logs(appname)
213
221
  # Check if we have an app before progressing further
214
222
  client.app_info(appname)
@@ -80,6 +80,15 @@ module VMC::Cli::Command
80
80
  display rtable
81
81
  end
82
82
 
83
+ def infras
84
+ itable = table do |t|
85
+ t.headings = [ 'Name','Description' ]
86
+ VMC::Cli::InfraHelper.list.each { |i| t << [i[:name], i[:description]] }
87
+ end
88
+ display "\n"
89
+ display itable
90
+ end
91
+
83
92
  def frameworks
84
93
  raise VMC::Client::AuthError unless client.logged_in?
85
94
  return display JSON.pretty_generate(frameworks_info) if @options[:json]
@@ -20,6 +20,7 @@ module VMC::Cli::Command
20
20
  end
21
21
 
22
22
  def create_service(service=nil, name=nil, appname=nil)
23
+
23
24
  unless no_prompt || service
24
25
  services = client.services_info
25
26
  err 'No services available to provision' if services.empty?
@@ -38,6 +39,15 @@ module VMC::Cli::Command
38
39
  name = random_service_name(service)
39
40
  picked_name = true
40
41
  end
42
+
43
+ if client.infra_supported?
44
+ unless no_prompt || @options[:infra]
45
+ @options[:infra] = VMC::Cli::InfraHelper.name_for_description(
46
+ ask("Select Infrastructure",
47
+ :indexed => true, :choices => VMC::Cli::InfraHelper.infra_descriptions))
48
+ end
49
+ end
50
+
41
51
  create_service_banner(service, name, picked_name, @options[:infra])
42
52
  appname = @options[:bind] unless appname
43
53
  bind_service_banner(name, appname) if appname
@@ -5,6 +5,10 @@ module VMC::Cli
5
5
 
6
6
  class << self
7
7
 
8
+ def list
9
+ infras.values
10
+ end
11
+
8
12
  def base_for_infra(infra)
9
13
  infras.has_key?(infra) ? infras[infra][:base] : "aws.af.cm"
10
14
  end
@@ -13,13 +17,22 @@ module VMC::Cli
13
17
  infra && infras.has_key?(infra)
14
18
  end
15
19
 
20
+ def infra_descriptions
21
+ infras.map { |k,v| v[:description] }
22
+ end
23
+
24
+ def name_for_description(desc)
25
+ name, info = infras.detect { |k,v| v[:description] == desc }
26
+ name
27
+ end
28
+
16
29
  private
17
30
  def infras
18
31
  {
19
- "ap-aws" => { :base => "ap01.aws.af.cm" },
20
- "eu-aws" => { :base => "eu01.aws.af.cm" },
21
- "rs" => { :base => "rs.af.cm" },
22
- "aws" => { :base => "aws.af.cm" }
32
+ "ap-aws" => { :name => "ap-aws", :base => "ap01.aws.af.cm", :description => "AWS Asia SE - Singapore" },
33
+ "eu-aws" => { :name => "eu-aws", :base => "eu01.aws.af.cm", :description => "AWS EU West - Ireland" },
34
+ "rs" => { :name => "rs", :base => "rs.af.cm", :description => "Rackspace AZ 1 - Dallas" },
35
+ "aws" => { :name => "aws", :base => "aws.af.cm", :description => "AWS US East - Virginia" }
23
36
  }
24
37
  end
25
38
 
@@ -82,8 +82,6 @@ module VMC::Cli::ManifestHelper
82
82
  name = manifest("name") ||
83
83
  set(ask("Application Name", :default => manifest("name")), "name")
84
84
 
85
-
86
-
87
85
  if manifest "framework"
88
86
  framework = VMC::Cli::Framework.lookup_by_framework manifest("framework","name")
89
87
  else
@@ -107,6 +105,14 @@ module VMC::Cli::ManifestHelper
107
105
  default_command = manifest "command"
108
106
  set ask("Start Command", :default => default_command), "command" if framework.require_start_command?
109
107
 
108
+ if client.infra_supported?
109
+ infra = @options[:infra] || manifest("infra") ||
110
+ VMC::Cli::InfraHelper.name_for_description(
111
+ ask("Select Infrastructure",:indexed => true, :choices => VMC::Cli::InfraHelper.infra_descriptions))
112
+ set infra.dup, "infra"
113
+ VMC::Cli::Config.infra = infra
114
+ end
115
+
110
116
  url_template = manifest("url") || DEFAULTS["url"]
111
117
  url_resolved = url_template.dup
112
118
  resolve_lexically(url_resolved)
@@ -147,7 +153,7 @@ module VMC::Cli::ManifestHelper
147
153
  ), "instances"
148
154
 
149
155
  unless manifest "services"
150
- user_services = client.services
156
+ user_services = services_for_infra(manifest("infra"))
151
157
  user_services.sort! {|a, b| a[:name] <=> b[:name] }
152
158
 
153
159
  unless user_services.empty?
@@ -263,6 +269,14 @@ module VMC::Cli::ManifestHelper
263
269
  end
264
270
 
265
271
  private
272
+ def services_for_infra(infra)
273
+ if client.infra_supported?
274
+ client.services.select { |s| s[:infra] && s[:infra][:provider] == manifest("infra") }
275
+ else
276
+ client.services
277
+ end
278
+ end
279
+
266
280
  def ordered_by_deps(apps, abspaths = nil, processed = Set[])
267
281
  unless abspaths
268
282
  abspaths = {}
data/lib/cli/runner.rb CHANGED
@@ -186,6 +186,10 @@ class VMC::Cli::Runner
186
186
  usage('af frameworks')
187
187
  set_cmd(:misc, :frameworks)
188
188
 
189
+ when 'infras'
190
+ usage('af infras')
191
+ set_cmd(:misc, :infras)
192
+
189
193
  when 'user'
190
194
  usage('af user')
191
195
  set_cmd(:user, :info)
@@ -281,7 +285,15 @@ class VMC::Cli::Runner
281
285
  else
282
286
  set_cmd(:apps, :files, 2)
283
287
  end
284
-
288
+
289
+ when 'pull'
290
+ usage('af pull <appname> [path]')
291
+ if @args.size == 1
292
+ set_cmd(:apps, :pull, 1)
293
+ else
294
+ set_cmd(:apps, :pull, 2)
295
+ end
296
+
285
297
  when 'logs'
286
298
  usage('af logs <appname> [--instance N] [--all] [--prefix]')
287
299
  set_cmd(:apps, :logs, 1)
data/lib/cli/usage.rb CHANGED
@@ -34,6 +34,7 @@ Currently available af commands are:
34
34
 
35
35
  Application Creation
36
36
  push [appname] Create, push, map, and start a new application
37
+ push [appname] --infra Push application to specified infrastructure
37
38
  push [appname] --path Push application from specified path
38
39
  push [appname] --url Set the url for the application
39
40
  push [appname] --instances <N> Set the expected number <N> of instances
@@ -42,6 +43,9 @@ Currently available af commands are:
42
43
  push [appname] --debug [MODE] Push application and start in a debug mode
43
44
  push [appname] --no-start Do not auto-start the application
44
45
 
46
+ Application Download
47
+ pull <appname> [path] Downloads last pushed source to <appname> or [path]
48
+
45
49
  Application Operations
46
50
  start <appname> [--debug [MODE]] Start the application
47
51
  stop <appname> Stop the application
@@ -62,7 +66,7 @@ Currently available af commands are:
62
66
  files <appname> [path] [--all] Display directory listing or file download for [path]
63
67
  stats <appname> Display resource usage for the application
64
68
  instances <appname> List application instances
65
-
69
+
66
70
  Application Environment
67
71
  env <appname> List application environment variables
68
72
  env-add <appname> <variable[=]value> Add an environment variable to an application
@@ -71,6 +75,7 @@ Currently available af commands are:
71
75
  Services
72
76
  services Lists of services available and provisioned
73
77
  create-service <service> [--name,--bind] Create a provisioned service
78
+ create-service <service> --infra Create a provisioned service on a specified infrastructure
74
79
  create-service <service> <name> Create a provisioned service and assign it <name>
75
80
  create-service <service> <name> <app> Create a provisioned service and assign it <name>, and bind to <app>
76
81
  delete-service [servicename] Delete a provisioned service
@@ -90,6 +95,7 @@ Currently available af commands are:
90
95
  System
91
96
  runtimes Display the supported runtimes of the target system
92
97
  frameworks Display the recognized frameworks of the target system
98
+ infras Display the available infrastructures
93
99
 
94
100
  Micro Cloud Foundry
95
101
  micro status Display Micro Cloud Foundry VM status
data/lib/cli/version.rb CHANGED
@@ -2,6 +2,6 @@ module VMC
2
2
  module Cli
3
3
  # This version number is used as the RubyGem release version.
4
4
  # The internal VMC version number is VMC::VERSION.
5
- VERSION = '0.3.18.2'
5
+ VERSION = '0.3.18.3'
6
6
  end
7
7
  end
data/lib/vmc/client.rb CHANGED
@@ -158,6 +158,17 @@ class VMC::Client
158
158
  _, body, headers = http_get(url)
159
159
  body
160
160
  end
161
+
162
+ def app_pull(name, dir)
163
+ check_login_status
164
+ url = path(VMC::APPS_PATH, name, "application")
165
+ status, body, headers = http_get(url,'application/octet-stream')
166
+ file = Tempfile.new(name)
167
+ file.write(body)
168
+ file.close
169
+ ::VMC::Cli::ZipUtil.unpack(file.path, dir)
170
+ file.unlink
171
+ end
161
172
 
162
173
  ######################################################
163
174
  # Services
@@ -208,7 +219,11 @@ class VMC::Client
208
219
 
209
220
  def bind_service(service, appname)
210
221
  check_login_status
222
+ svc = services.detect { |s| s[:name] == service }
211
223
  app = app_info(appname)
224
+ if infra_supported? && ! infras_match?(app,svc)
225
+ raise TargetError, "Service #{service} and App #{appname} are not on the same infra"
226
+ end
212
227
  services = app[:services] || []
213
228
  app[:services] = services << service
214
229
  update_app(appname, app)
@@ -325,6 +340,15 @@ class VMC::Client
325
340
  }.join("/")
326
341
  end
327
342
 
343
+ ######################################################
344
+
345
+ def infra_supported?
346
+ # FIXME should get this from proxy
347
+ target.match /^https?:\/\/api.appfog.com$/
348
+ end
349
+
350
+
351
+
328
352
  private
329
353
 
330
354
  def path(*args, &blk)
@@ -472,4 +496,8 @@ class VMC::Client
472
496
  raise AuthError unless @user || logged_in?
473
497
  end
474
498
 
499
+ def infras_match?(o1,o2)
500
+ o1 && o2 && ( o1[:infra] == o2[:infra])
501
+ end
502
+
475
503
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: af
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.18.2
4
+ version: 0.3.18.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,12 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-07 00:00:00.000000000 -07:00
13
- default_executable:
12
+ date: 2012-08-14 00:00:00.000000000Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: json_pure
17
- requirement: &2156374040 !ruby/object:Gem::Requirement
16
+ requirement: &70285973974440 !ruby/object:Gem::Requirement
18
17
  none: false
19
18
  requirements:
20
19
  - - ! '>='
@@ -25,10 +24,10 @@ dependencies:
25
24
  version: 1.7.0
26
25
  type: :runtime
27
26
  prerelease: false
28
- version_requirements: *2156374040
27
+ version_requirements: *70285973974440
29
28
  - !ruby/object:Gem::Dependency
30
29
  name: rubyzip
31
- requirement: &2156373200 !ruby/object:Gem::Requirement
30
+ requirement: &70285973973680 !ruby/object:Gem::Requirement
32
31
  none: false
33
32
  requirements:
34
33
  - - ~>
@@ -36,10 +35,10 @@ dependencies:
36
35
  version: 0.9.4
37
36
  type: :runtime
38
37
  prerelease: false
39
- version_requirements: *2156373200
38
+ version_requirements: *70285973973680
40
39
  - !ruby/object:Gem::Dependency
41
40
  name: rest-client
42
- requirement: &2156372660 !ruby/object:Gem::Requirement
41
+ requirement: &70285973973200 !ruby/object:Gem::Requirement
43
42
  none: false
44
43
  requirements:
45
44
  - - ! '>='
@@ -50,10 +49,10 @@ dependencies:
50
49
  version: 1.7.0
51
50
  type: :runtime
52
51
  prerelease: false
53
- version_requirements: *2156372660
52
+ version_requirements: *70285973973200
54
53
  - !ruby/object:Gem::Dependency
55
54
  name: terminal-table
56
- requirement: &2156371880 !ruby/object:Gem::Requirement
55
+ requirement: &70285973972480 !ruby/object:Gem::Requirement
57
56
  none: false
58
57
  requirements:
59
58
  - - ~>
@@ -61,10 +60,10 @@ dependencies:
61
60
  version: 1.4.2
62
61
  type: :runtime
63
62
  prerelease: false
64
- version_requirements: *2156371880
63
+ version_requirements: *70285973972480
65
64
  - !ruby/object:Gem::Dependency
66
65
  name: interact
67
- requirement: &2156371400 !ruby/object:Gem::Requirement
66
+ requirement: &70285973972020 !ruby/object:Gem::Requirement
68
67
  none: false
69
68
  requirements:
70
69
  - - ~>
@@ -72,10 +71,10 @@ dependencies:
72
71
  version: 0.4.0
73
72
  type: :runtime
74
73
  prerelease: false
75
- version_requirements: *2156371400
74
+ version_requirements: *70285973972020
76
75
  - !ruby/object:Gem::Dependency
77
76
  name: addressable
78
- requirement: &2156370940 !ruby/object:Gem::Requirement
77
+ requirement: &70285973971560 !ruby/object:Gem::Requirement
79
78
  none: false
80
79
  requirements:
81
80
  - - ~>
@@ -83,10 +82,10 @@ dependencies:
83
82
  version: 2.2.6
84
83
  type: :runtime
85
84
  prerelease: false
86
- version_requirements: *2156370940
85
+ version_requirements: *70285973971560
87
86
  - !ruby/object:Gem::Dependency
88
87
  name: uuidtools
89
- requirement: &2156370440 !ruby/object:Gem::Requirement
88
+ requirement: &70285973971100 !ruby/object:Gem::Requirement
90
89
  none: false
91
90
  requirements:
92
91
  - - ~>
@@ -94,10 +93,10 @@ dependencies:
94
93
  version: 2.1.0
95
94
  type: :runtime
96
95
  prerelease: false
97
- version_requirements: *2156370440
96
+ version_requirements: *70285973971100
98
97
  - !ruby/object:Gem::Dependency
99
98
  name: rb-readline
100
- requirement: &2156358900 !ruby/object:Gem::Requirement
99
+ requirement: &70285973970640 !ruby/object:Gem::Requirement
101
100
  none: false
102
101
  requirements:
103
102
  - - ~>
@@ -105,10 +104,10 @@ dependencies:
105
104
  version: 0.4.2
106
105
  type: :runtime
107
106
  prerelease: false
108
- version_requirements: *2156358900
107
+ version_requirements: *70285973970640
109
108
  - !ruby/object:Gem::Dependency
110
109
  name: rake
111
- requirement: &2156358520 !ruby/object:Gem::Requirement
110
+ requirement: &70285973970260 !ruby/object:Gem::Requirement
112
111
  none: false
113
112
  requirements:
114
113
  - - ! '>='
@@ -116,10 +115,10 @@ dependencies:
116
115
  version: '0'
117
116
  type: :development
118
117
  prerelease: false
119
- version_requirements: *2156358520
118
+ version_requirements: *70285973970260
120
119
  - !ruby/object:Gem::Dependency
121
120
  name: rspec
122
- requirement: &2156357960 !ruby/object:Gem::Requirement
121
+ requirement: &70285973969720 !ruby/object:Gem::Requirement
123
122
  none: false
124
123
  requirements:
125
124
  - - ~>
@@ -127,10 +126,10 @@ dependencies:
127
126
  version: 1.3.0
128
127
  type: :development
129
128
  prerelease: false
130
- version_requirements: *2156357960
129
+ version_requirements: *70285973969720
131
130
  - !ruby/object:Gem::Dependency
132
131
  name: webmock
133
- requirement: &2156357420 !ruby/object:Gem::Requirement
132
+ requirement: &70285973969220 !ruby/object:Gem::Requirement
134
133
  none: false
135
134
  requirements:
136
135
  - - ~>
@@ -138,7 +137,7 @@ dependencies:
138
137
  version: 1.5.0
139
138
  type: :development
140
139
  prerelease: false
141
- version_requirements: *2156357420
140
+ version_requirements: *70285973969220
142
141
  description: AppFog.com CLI
143
142
  email: support@appfog.com
144
143
  executables:
@@ -191,7 +190,6 @@ files:
191
190
  - caldecott_helper/Gemfile.lock
192
191
  - caldecott_helper/server.rb
193
192
  - bin/af
194
- has_rdoc: true
195
193
  homepage: http://appfog.com
196
194
  licenses: []
197
195
  post_install_message:
@@ -212,7 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
212
210
  version: '0'
213
211
  requirements: []
214
212
  rubyforge_project:
215
- rubygems_version: 1.6.2
213
+ rubygems_version: 1.8.6
216
214
  signing_key:
217
215
  specification_version: 3
218
216
  summary: AppFog.com CLI