appfog-vmc-plugin 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MTYwZGMwNDRmMzRkYWRlY2I2ZDAwZTliZTZmYjUwMmEyYjU1NzUzMw==
4
+ N2Y0N2M1MGVlNzMyNWUzYjM3YzI2ZDJkNzdlZjYxZTkwZTU4MzlmMA==
5
5
  data.tar.gz: !binary |-
6
- ZWY2NDliZmYyYzZmY2M4NDg0M2UzNjg5NTEwNDJkZDE1YjRlNDgzYw==
6
+ MzA3ODY0MDEzODJkZWMxNmU3MGU3ZWExZjQwMGMxZTE3ZjZlYjkyYQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- MGViZmM4NWI2Njc2YWI1NjNkMmEyOTk1MDBkNTMzYTBiNTE2ZDI4MDM4OWE0
10
- OWNkNmY2ZWJkY2FhNDEyN2U1ZTU2NzhlYjBlODE3ZWY4MDY1OTk1YTU2YzNk
11
- MDgwM2UzM2EyMzFkM2JhMTZmY2M3ZTE5ODY2ZjNiNjkxMTk1NTk=
9
+ ODQyOWUwOTIxYTI5MzU1OWY1NmVhNjQwNWVkMzNkMTczYjU4M2U1ZjgwZjAy
10
+ NDZhN2FiN2EzY2U4YzhkYWY3MTMwYjZiMGI5MmY0NTIzNmI5MmI2Njc3OWRj
11
+ NTkzZjdiNWUxZTViNjViNjE1MGYxN2UyOWUyOTUyOTljZDkzNWM=
12
12
  data.tar.gz: !binary |-
13
- MjUzZjY5OWVjMDcxNzE5NjY4YzE4ODkzOTZjOTQ2NTIzY2I3NTgzNDIyMTI3
14
- YTFhODUyM2JkMDMzMWM2ODMzNmMyYjBmY2UyNWU0ZjA2ODQzNjczZDQ1YzU2
15
- MmM5MjdjYTFmNTNiMjgxYzVhNzIxZTdhYjRjYTRhOGYzYTJmNmI=
13
+ YjRlOTExOTZlNzBiNDg0ZmM1NjBkZDk0ZTg4MTllNjhmYzU4OWUzOWFiZDgw
14
+ ZjA5NzdlNTY0MDE5ZTMyYjE0MjA5NjJmNGJmZjQwY2JhMTQ3OGQ4ZmFlNzZl
15
+ MzkzZDFjNTZkOTJjZWUwZjM4YTE1OGZiMWZiYmM1YTU1NDYzNWI=
@@ -0,0 +1,29 @@
1
+ module CFoundry
2
+ class BaseClient
3
+ def get(*args)
4
+ options = args.reduce({}) do |opts, arg|
5
+ arg.is_a?(Hash) ? arg : opts
6
+ end
7
+ tries = options.has_key?(:retry) && options[:retry] == false ? 1 : 3
8
+ delay = options.has_key?(:delay) ? options[:delay] : 10
9
+ with_retry(tries, delay, [CFoundry::TargetRefused, CFoundry::BadResponse]) do
10
+ request("GET", *args)
11
+ end
12
+ end
13
+
14
+ def with_retry(tries, delay=2, exceptions=[])
15
+ try_count = 0
16
+ loop do
17
+ begin
18
+ try_count += 1
19
+ return yield
20
+ rescue Exception => e
21
+ if try_count > tries || !exceptions.include?(e.class)
22
+ raise e
23
+ end
24
+ sleep delay * try_count
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -74,7 +74,7 @@ module CFoundry::V1
74
74
  end
75
75
 
76
76
  def export_service(service_name)
77
- @base.get("services", "export", service_name, :accept => :json)
77
+ @base.get("services", "export", service_name, :accept => :json, :retry => false)
78
78
  end
79
79
 
80
80
  def import_service(service_name, uri)
@@ -1,4 +1,4 @@
1
- command_files = "../cfoundry/*/*.rb"
1
+ command_files = "../cfoundry/**/*.rb"
2
2
  Dir[File.expand_path(command_files, __FILE__)].each do |file|
3
3
  require file
4
4
  end
@@ -5,7 +5,7 @@ module VMCAppfog
5
5
  input :service, :desc => "Service to export", :argument => :optional,
6
6
  :from_given => by_name(:service_instance, "service")
7
7
  def export_service
8
- service = input[:export_service]
8
+ service = input[:service]
9
9
 
10
10
  export_info =
11
11
  with_progress("Exporting service #{c(service.name, :name)}") do
@@ -6,7 +6,7 @@ module VMCAppfog
6
6
  :from_given => by_name(:service_instance, "service")
7
7
  input :url, :desc => "Data url to import", :argument => :optional
8
8
  def import_service
9
- service = input[:import_service]
9
+ service = input[:service]
10
10
  url = input[:url]
11
11
 
12
12
  import_info =
@@ -0,0 +1,30 @@
1
+ module VMCAppfog
2
+ class Map < VMC::CLI
3
+ def precondition; end
4
+
5
+ desc "Add a URL mapping"
6
+ group :apps, :info
7
+ input :app, :desc => "Application to add the URL to",
8
+ :argument => :optional, :from_given => by_name(:app)
9
+ input :url, :desc => "URL to map", :argument => :optional
10
+ def map
11
+ app = input[:app]
12
+ url = input[:url]
13
+
14
+ with_progress("Updating #{c(app.name, :name)}") do
15
+ app.urls << url
16
+ app.update!
17
+ end
18
+ end
19
+
20
+ private
21
+
22
+ def ask_app
23
+ ask("Which application?", :choices => client.apps, :display => proc(&:name))
24
+ end
25
+
26
+ def ask_url
27
+ ask("Enter URL?")
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,45 @@
1
+ module VMCAppfog
2
+ class Unmap < VMC::CLI
3
+ desc "Remove a URL mapping"
4
+ group :apps, :info
5
+ input :app, :desc => "Application to remove the URL from",
6
+ :argument => :optional, :from_given => by_name(:app)
7
+ input :url, :desc => "URL to unmap", :argument => :optional
8
+ input :all, :desc => "Act on all routes", :type => :boolean
9
+ def unmap
10
+ app = input[:app]
11
+
12
+ fail "No urls to unmap." if app.urls.empty?
13
+
14
+ url = input[:url, (app.urls.map{|url| OpenStruct.new({name: url})})] unless input[:all]
15
+ if url.is_a? String
16
+ url = OpenStruct.new({name: url})
17
+ end
18
+
19
+ with_progress("Updating #{c(app.name, :name)}") do |s|
20
+ if input[:all]
21
+ app.urls = []
22
+ else
23
+
24
+ simple = url.name.sub(/^https?:\/\/(.*)\/?/i, '\1')
25
+
26
+ unless app.urls.delete(simple)
27
+ fail "URL #{url.name} is not mapped to this application."
28
+ end
29
+ end
30
+
31
+ app.update!
32
+ end
33
+ end
34
+
35
+ private
36
+
37
+ def ask_app
38
+ ask("Which application?", :choices => client.apps, :display => proc(&:name))
39
+ end
40
+
41
+ def ask_url(choices)
42
+ ask("Which URL?", :choices => choices.sort_by(&:name), :display => proc(&:name))
43
+ end
44
+ end
45
+ end
@@ -1,3 +1,3 @@
1
1
  module VMCAppfog
2
- VERSION = "0.1.2".freeze
2
+ VERSION = "0.1.3".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appfog-vmc-plugin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Santeford
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-07 00:00:00.000000000 Z
12
+ date: 2013-03-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: cfoundry
@@ -33,6 +33,7 @@ extensions: []
33
33
  extra_rdoc_files: []
34
34
  files:
35
35
  - Rakefile
36
+ - lib/appfog-vmc-plugin/cfoundry/baseclient.rb
36
37
  - lib/appfog-vmc-plugin/cfoundry/upload_helpers.rb
37
38
  - lib/appfog-vmc-plugin/cfoundry/v1/app.rb
38
39
  - lib/appfog-vmc-plugin/cfoundry/v1/base.rb
@@ -48,8 +49,10 @@ files:
48
49
  - lib/appfog-vmc-plugin/commands/frameworks.rb
49
50
  - lib/appfog-vmc-plugin/commands/import.rb
50
51
  - lib/appfog-vmc-plugin/commands/infra.rb
52
+ - lib/appfog-vmc-plugin/commands/map.rb
51
53
  - lib/appfog-vmc-plugin/commands/pull.rb
52
54
  - lib/appfog-vmc-plugin/commands/runtimes.rb
55
+ - lib/appfog-vmc-plugin/commands/unmap.rb
53
56
  - lib/appfog-vmc-plugin/deprecated/env.rb
54
57
  - lib/appfog-vmc-plugin/deprecated/mem.rb
55
58
  - lib/appfog-vmc-plugin/help.rb