export-af-cli-plugin 0.0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile ADDED
@@ -0,0 +1,47 @@
1
+ require "rake"
2
+
3
+ $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
4
+ require "export-af-cli-plugin/version"
5
+
6
+ task :default => :spec
7
+
8
+ desc "Run specs"
9
+ task :spec => ["bundler:install", "test:spec"]
10
+
11
+ desc "Run integration tests"
12
+ task :test => ["bundler:install", "test:integration"]
13
+
14
+ task :build do
15
+ sh "gem build export-af-cli-plugin.gemspec"
16
+ end
17
+
18
+ task :install => :build do
19
+ sh "gem install --local export-af-cli-plugin-#{AFCLIClone::VERSION}.gem"
20
+ end
21
+
22
+ task :uninstall do
23
+ sh "gem uninstall export-af-cli-plugin"
24
+ end
25
+
26
+ task :reinstall => [:uninstall, :install]
27
+
28
+ task :release => :build do
29
+ sh "gem push export-af-cli-plugin-#{AFCLIClone::VERSION}.gem"
30
+ end
31
+
32
+ namespace "bundler" do
33
+ desc "Install gems"
34
+ task "install" do
35
+ sh("bundle install")
36
+ end
37
+ end
38
+
39
+ namespace "test" do
40
+ task "spec" do |t|
41
+ # nothing
42
+ end
43
+
44
+ task "integration" do |t|
45
+ sh("cd spec && bundle exec rake spec")
46
+ end
47
+ end
@@ -0,0 +1,104 @@
1
+ require "vmc/cli"
2
+
3
+ module AFCLIExport
4
+ class Export < VMC::CLI
5
+ desc "Bind all services in one app to another."
6
+ group :services, :manage
7
+ input :src_app, :desc => "Source application", :argument => :optional,
8
+ :from_given => by_name(:app)
9
+ input :dest_app, :desc => "Destination application", :argument => :optional,
10
+ :from_given => by_name(:app)
11
+ def bind_services
12
+ src_app = input[:src_app]
13
+ fail "No services to bind." if src_app.services.empty?
14
+
15
+ dest_app = input[:dest_app]
16
+
17
+ src_app.services.each do |service|
18
+ with_progress("Binding service #{c(service.name, :name)} to #{c(dest_app.name, :name)}") do |s|
19
+ if dest_app.binds?(service)
20
+ s.skip do
21
+ err "App #{b(dest_app.name)} already binds #{b(service.name)}."
22
+ end
23
+ else
24
+ dest_app.bind(service)
25
+ end
26
+ end
27
+ end
28
+ end
29
+
30
+ desc "Export the data from a service"
31
+ group :services, :manage
32
+ input :export_service, :desc => "Service to export", :argument => :optional,
33
+ :from_given => by_name(:service_instance, "service")
34
+ def export_service
35
+ service = input[:export_service]
36
+
37
+ export_info =
38
+ with_progress("Exporting service #{c(service.name, :name)}") do
39
+ client.export_service(service.name)
40
+ end
41
+
42
+ line unless quiet?
43
+
44
+ line "#{c(service.name, :name)} exported to: #{export_info[:uri]}"
45
+ end
46
+
47
+ desc "Import data from url"
48
+ group :services, :manage
49
+ input :import_service, :desc => "Service to import data to", :argument => :optional,
50
+ :from_given => by_name(:service_instance, "service")
51
+ input :url, :desc => "Data url to import", :argument => :optional
52
+ def import_service
53
+ service = input[:import_service]
54
+ url = input[:url]
55
+
56
+ import_info =
57
+ with_progress("Importing data to service #{c(service.name, :name)}") do
58
+ client.import_service(service.name, url)
59
+ end
60
+
61
+ line unless quiet?
62
+
63
+ line "Data imported to #{c(service.name, :name)} successfully "
64
+ end
65
+
66
+ private
67
+
68
+ def ask_url
69
+ ask("Url to import from")
70
+ end
71
+
72
+ def ask_export_service
73
+ services = client.service_instances
74
+ fail "No services." if services.empty?
75
+
76
+ ask("Export which service?", :choices => services.sort_by(&:name),
77
+ :display => proc(&:name))
78
+ end
79
+
80
+ def ask_import_service
81
+ services = client.service_instances
82
+ fail "No services." if services.empty?
83
+
84
+ ask("Import to which service?", :choices => services.sort_by(&:name),
85
+ :display => proc(&:name))
86
+ end
87
+
88
+ def ask_src_app
89
+ apps = client.apps
90
+ fail "No applications." if apps.empty?
91
+
92
+ ask("Which source application?", :choices => apps.sort_by(&:name),
93
+ :display => proc(&:name))
94
+ end
95
+
96
+ def ask_dest_app
97
+ apps = client.apps
98
+ fail "No applications." if apps.empty?
99
+
100
+ ask("Which destination application?", :choices => apps.sort_by(&:name),
101
+ :display => proc(&:name))
102
+ end
103
+ end
104
+ end
@@ -0,0 +1,3 @@
1
+ module AFCLIExport
2
+ VERSION = "0.0.0.1".freeze
3
+ end
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: export-af-cli-plugin
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Tim Santeford
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-03-04 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: cfoundry
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.5.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 0.5.0
30
+ description:
31
+ email:
32
+ - tim@appfog.com
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ files:
37
+ - Rakefile
38
+ - lib/export-af-cli-plugin/plugin.rb
39
+ - lib/export-af-cli-plugin/version.rb
40
+ homepage: http://www.appfog.com/
41
+ licenses: []
42
+ post_install_message:
43
+ rdoc_options: []
44
+ require_paths:
45
+ - lib
46
+ required_ruby_version: !ruby/object:Gem::Requirement
47
+ none: false
48
+ requirements:
49
+ - - ! '>='
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ! '>='
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ requirements: []
59
+ rubyforge_project: export-af-cli-plugin
60
+ rubygems_version: 1.8.23
61
+ signing_key:
62
+ specification_version: 3
63
+ summary: Clones applications between infras
64
+ test_files: []