trucker-cli 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/LICENSE +1277 -0
- data/Rakefile +13 -0
- data/bin/truck +18 -0
- data/lib/admin/README.md +30 -0
- data/lib/admin/curl.rb +59 -0
- data/lib/admin/guid.rb +89 -0
- data/lib/admin/plugin.rb +8 -0
- data/lib/admin/service_auth_token.rb +93 -0
- data/lib/admin/service_broker/add.rb +54 -0
- data/lib/admin/service_broker/remove.rb +33 -0
- data/lib/admin/service_broker/service_brokers.rb +29 -0
- data/lib/admin/service_broker/update.rb +60 -0
- data/lib/admin/set_quota.rb +44 -0
- data/lib/cf.rb +14 -0
- data/lib/cf/cli.rb +495 -0
- data/lib/cf/cli/app/app.rb +43 -0
- data/lib/cf/cli/app/apps.rb +87 -0
- data/lib/cf/cli/app/base.rb +72 -0
- data/lib/cf/cli/app/delete.rb +95 -0
- data/lib/cf/cli/app/deprecated.rb +11 -0
- data/lib/cf/cli/app/env.rb +99 -0
- data/lib/cf/cli/app/events.rb +45 -0
- data/lib/cf/cli/app/files.rb +137 -0
- data/lib/cf/cli/app/health.rb +26 -0
- data/lib/cf/cli/app/instances.rb +53 -0
- data/lib/cf/cli/app/logs.rb +76 -0
- data/lib/cf/cli/app/push.rb +104 -0
- data/lib/cf/cli/app/push/create.rb +108 -0
- data/lib/cf/cli/app/push/interactions.rb +90 -0
- data/lib/cf/cli/app/push/sync.rb +57 -0
- data/lib/cf/cli/app/rename.rb +35 -0
- data/lib/cf/cli/app/restart.rb +31 -0
- data/lib/cf/cli/app/scale.rb +63 -0
- data/lib/cf/cli/app/start.rb +175 -0
- data/lib/cf/cli/app/stats.rb +66 -0
- data/lib/cf/cli/app/stop.rb +27 -0
- data/lib/cf/cli/domain/base.rb +9 -0
- data/lib/cf/cli/domain/domains.rb +40 -0
- data/lib/cf/cli/domain/map.rb +55 -0
- data/lib/cf/cli/domain/unmap.rb +56 -0
- data/lib/cf/cli/help.rb +15 -0
- data/lib/cf/cli/interactive.rb +104 -0
- data/lib/cf/cli/login_requirements.rb +13 -0
- data/lib/cf/cli/organization/base.rb +12 -0
- data/lib/cf/cli/organization/create.rb +36 -0
- data/lib/cf/cli/organization/delete.rb +61 -0
- data/lib/cf/cli/organization/org.rb +45 -0
- data/lib/cf/cli/organization/orgs.rb +30 -0
- data/lib/cf/cli/organization/rename.rb +36 -0
- data/lib/cf/cli/populators/base.rb +16 -0
- data/lib/cf/cli/populators/organization.rb +32 -0
- data/lib/cf/cli/populators/populator_methods.rb +64 -0
- data/lib/cf/cli/populators/space.rb +33 -0
- data/lib/cf/cli/populators/target.rb +14 -0
- data/lib/cf/cli/route/base.rb +9 -0
- data/lib/cf/cli/route/delete.rb +28 -0
- data/lib/cf/cli/route/map.rb +68 -0
- data/lib/cf/cli/route/routes.rb +26 -0
- data/lib/cf/cli/route/unmap.rb +56 -0
- data/lib/cf/cli/service/base.rb +9 -0
- data/lib/cf/cli/service/bind.rb +43 -0
- data/lib/cf/cli/service/create.rb +158 -0
- data/lib/cf/cli/service/delete.rb +82 -0
- data/lib/cf/cli/service/rename.rb +35 -0
- data/lib/cf/cli/service/service.rb +40 -0
- data/lib/cf/cli/service/service_helper.rb +25 -0
- data/lib/cf/cli/service/service_instance_helper.rb +100 -0
- data/lib/cf/cli/service/services.rb +110 -0
- data/lib/cf/cli/service/unbind.rb +36 -0
- data/lib/cf/cli/space/base.rb +27 -0
- data/lib/cf/cli/space/create.rb +66 -0
- data/lib/cf/cli/space/delete.rb +55 -0
- data/lib/cf/cli/space/rename.rb +38 -0
- data/lib/cf/cli/space/space.rb +66 -0
- data/lib/cf/cli/space/spaces.rb +57 -0
- data/lib/cf/cli/space/switch.rb +18 -0
- data/lib/cf/cli/start/base.rb +35 -0
- data/lib/cf/cli/start/colors.rb +13 -0
- data/lib/cf/cli/start/login.rb +104 -0
- data/lib/cf/cli/start/logout.rb +17 -0
- data/lib/cf/cli/start/target.rb +50 -0
- data/lib/cf/cli/start/target_prettifier.rb +35 -0
- data/lib/cf/cli/start/targets.rb +16 -0
- data/lib/cf/cli/user/base.rb +29 -0
- data/lib/cf/cli/user/create.rb +51 -0
- data/lib/cf/cli/user/passwd.rb +36 -0
- data/lib/cf/cli/user/register.rb +42 -0
- data/lib/cf/cli/user/users.rb +32 -0
- data/lib/cf/constants.rb +10 -0
- data/lib/cf/errors.rb +19 -0
- data/lib/cf/plugin.rb +56 -0
- data/lib/cf/spacing.rb +89 -0
- data/lib/cf/spec_helper.rb +1 -0
- data/lib/cf/test_support.rb +6 -0
- data/lib/cf/version.rb +3 -0
- data/lib/console/README.md +16 -0
- data/lib/console/console.rb +187 -0
- data/lib/console/plugin.rb +32 -0
- data/lib/manifests/errors.rb +35 -0
- data/lib/manifests/loader.rb +31 -0
- data/lib/manifests/loader/builder.rb +39 -0
- data/lib/manifests/loader/normalizer.rb +145 -0
- data/lib/manifests/loader/resolver.rb +79 -0
- data/lib/manifests/manifests.rb +343 -0
- data/lib/manifests/plugin.rb +140 -0
- data/lib/micro/README.md +25 -0
- data/lib/micro/errors.rb +4 -0
- data/lib/micro/micro.rb +56 -0
- data/lib/micro/plugin.rb +197 -0
- data/lib/micro/switcher/base.rb +79 -0
- data/lib/micro/switcher/darwin.rb +21 -0
- data/lib/micro/switcher/dummy.rb +15 -0
- data/lib/micro/switcher/linux.rb +16 -0
- data/lib/micro/switcher/windows.rb +31 -0
- data/lib/micro/vmrun.rb +175 -0
- data/lib/tasks/gem_release.rake +56 -0
- data/lib/tasks/windows_build.rake +14 -0
- data/lib/tunnel/README.md +29 -0
- data/lib/tunnel/config/clients.yml +17 -0
- data/lib/tunnel/helper-app/Gemfile +10 -0
- data/lib/tunnel/helper-app/Gemfile.lock +48 -0
- data/lib/tunnel/helper-app/server.rb +43 -0
- data/lib/tunnel/plugin.rb +183 -0
- data/lib/tunnel/tunnel.rb +295 -0
- data/spec/admin/curl_spec.rb +52 -0
- data/spec/admin/guid_spec.rb +85 -0
- data/spec/admin/service_broker/add_spec.rb +64 -0
- data/spec/admin/service_broker/remove_spec.rb +46 -0
- data/spec/admin/service_broker/service_brokers_spec.rb +34 -0
- data/spec/admin/service_broker/update_spec.rb +51 -0
- data/spec/admin/set_quota_spec.rb +89 -0
- data/spec/assets/env/Gemfile +4 -0
- data/spec/assets/env/Gemfile.lock +20 -0
- data/spec/assets/env/env_test.rb +58 -0
- data/spec/assets/hello-sinatra/Gemfile +3 -0
- data/spec/assets/hello-sinatra/Gemfile.lock +17 -0
- data/spec/assets/hello-sinatra/config.ru +3 -0
- data/spec/assets/hello-sinatra/fat-cat-makes-app-larger.png +0 -0
- data/spec/assets/hello-sinatra/main.rb +8 -0
- data/spec/assets/rails328_ruby187_app/Gemfile +39 -0
- data/spec/assets/rails328_ruby187_app/README.rdoc +261 -0
- data/spec/assets/rails328_ruby187_app/Rakefile +7 -0
- data/spec/assets/rails328_ruby187_app/app/assets/images/rails.png +0 -0
- data/spec/assets/rails328_ruby187_app/app/assets/javascripts/application.js +15 -0
- data/spec/assets/rails328_ruby187_app/app/assets/stylesheets/application.css +13 -0
- data/spec/assets/rails328_ruby187_app/app/controllers/application_controller.rb +3 -0
- data/spec/assets/rails328_ruby187_app/app/helpers/application_helper.rb +2 -0
- data/spec/assets/rails328_ruby187_app/app/views/layouts/application.html.erb +14 -0
- data/spec/assets/rails328_ruby187_app/config.ru +4 -0
- data/spec/assets/rails328_ruby187_app/config/application.rb +62 -0
- data/spec/assets/rails328_ruby187_app/config/boot.rb +6 -0
- data/spec/assets/rails328_ruby187_app/config/database.yml +25 -0
- data/spec/assets/rails328_ruby187_app/config/environment.rb +5 -0
- data/spec/assets/rails328_ruby187_app/config/environments/development.rb +37 -0
- data/spec/assets/rails328_ruby187_app/config/environments/production.rb +67 -0
- data/spec/assets/rails328_ruby187_app/config/environments/test.rb +37 -0
- data/spec/assets/rails328_ruby187_app/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/assets/rails328_ruby187_app/config/initializers/inflections.rb +15 -0
- data/spec/assets/rails328_ruby187_app/config/initializers/mime_types.rb +5 -0
- data/spec/assets/rails328_ruby187_app/config/initializers/secret_token.rb +7 -0
- data/spec/assets/rails328_ruby187_app/config/initializers/session_store.rb +8 -0
- data/spec/assets/rails328_ruby187_app/config/initializers/wrap_parameters.rb +14 -0
- data/spec/assets/rails328_ruby187_app/config/locales/en.yml +5 -0
- data/spec/assets/rails328_ruby187_app/config/routes.rb +58 -0
- data/spec/assets/rails328_ruby187_app/db/seeds.rb +7 -0
- data/spec/assets/rails328_ruby187_app/doc/README_FOR_APP +2 -0
- data/spec/assets/rails328_ruby187_app/manifest.yml +7 -0
- data/spec/assets/rails328_ruby187_app/public/404.html +26 -0
- data/spec/assets/rails328_ruby187_app/public/422.html +26 -0
- data/spec/assets/rails328_ruby187_app/public/500.html +25 -0
- data/spec/assets/rails328_ruby187_app/public/assets/application-7270767b2a9e9fff880aa5de378ca791.css +0 -0
- data/spec/assets/rails328_ruby187_app/public/assets/application-7270767b2a9e9fff880aa5de378ca791.css.gz +0 -0
- data/spec/assets/rails328_ruby187_app/public/assets/application-ccab98dc1abdf097c0af693e20aed861.js +17 -0
- data/spec/assets/rails328_ruby187_app/public/assets/application-ccab98dc1abdf097c0af693e20aed861.js.gz +0 -0
- data/spec/assets/rails328_ruby187_app/public/assets/application.css +0 -0
- data/spec/assets/rails328_ruby187_app/public/assets/application.css.gz +0 -0
- data/spec/assets/rails328_ruby187_app/public/assets/application.js +17 -0
- data/spec/assets/rails328_ruby187_app/public/assets/application.js.gz +0 -0
- data/spec/assets/rails328_ruby187_app/public/assets/manifest.yml +4 -0
- data/spec/assets/rails328_ruby187_app/public/assets/rails-be8732dac73d845ac5b142c8fb5f9fb0.png +0 -0
- data/spec/assets/rails328_ruby187_app/public/assets/rails.png +0 -0
- data/spec/assets/rails328_ruby187_app/public/favicon.ico +0 -0
- data/spec/assets/rails328_ruby187_app/public/index.html +241 -0
- data/spec/assets/rails328_ruby187_app/public/robots.txt +5 -0
- data/spec/assets/rails328_ruby187_app/script/rails +6 -0
- data/spec/assets/rails328_ruby187_app/test/performance/browsing_test.rb +12 -0
- data/spec/assets/rails328_ruby187_app/test/test_helper.rb +13 -0
- data/spec/cf/cli/app/base_spec.rb +17 -0
- data/spec/cf/cli/app/delete_spec.rb +197 -0
- data/spec/cf/cli/app/env_spec.rb +261 -0
- data/spec/cf/cli/app/events_spec.rb +72 -0
- data/spec/cf/cli/app/help_spec.rb +39 -0
- data/spec/cf/cli/app/instances_spec.rb +69 -0
- data/spec/cf/cli/app/push/create_spec.rb +444 -0
- data/spec/cf/cli/app/push/interactions_spec.rb +32 -0
- data/spec/cf/cli/app/push_spec.rb +332 -0
- data/spec/cf/cli/app/rename_spec.rb +108 -0
- data/spec/cf/cli/app/restart_spec.rb +47 -0
- data/spec/cf/cli/app/scale_spec.rb +63 -0
- data/spec/cf/cli/app/start_spec.rb +255 -0
- data/spec/cf/cli/app/stats_spec.rb +66 -0
- data/spec/cf/cli/domain/help_spec.rb +39 -0
- data/spec/cf/cli/domain/map_spec.rb +140 -0
- data/spec/cf/cli/domain/unmap_spec.rb +77 -0
- data/spec/cf/cli/help_spec.rb +21 -0
- data/spec/cf/cli/organization/create_spec.rb +121 -0
- data/spec/cf/cli/organization/delete_spec.rb +105 -0
- data/spec/cf/cli/organization/help_spec.rb +39 -0
- data/spec/cf/cli/organization/orgs_spec.rb +116 -0
- data/spec/cf/cli/organization/rename_spec.rb +116 -0
- data/spec/cf/cli/populators/organization_spec.rb +179 -0
- data/spec/cf/cli/populators/space_spec.rb +156 -0
- data/spec/cf/cli/populators/target_spec.rb +39 -0
- data/spec/cf/cli/route/delete_spec.rb +92 -0
- data/spec/cf/cli/route/help_spec.rb +32 -0
- data/spec/cf/cli/route/map_spec.rb +148 -0
- data/spec/cf/cli/route/unmap_spec.rb +114 -0
- data/spec/cf/cli/service/bind_spec.rb +25 -0
- data/spec/cf/cli/service/create_spec.rb +147 -0
- data/spec/cf/cli/service/delete_spec.rb +22 -0
- data/spec/cf/cli/service/help_spec.rb +39 -0
- data/spec/cf/cli/service/rename_spec.rb +103 -0
- data/spec/cf/cli/service/service_helper_spec.rb +66 -0
- data/spec/cf/cli/service/service_instance_helper_spec.rb +155 -0
- data/spec/cf/cli/service/service_spec.rb +23 -0
- data/spec/cf/cli/service/services_spec.rb +156 -0
- data/spec/cf/cli/service/unbind_spec.rb +25 -0
- data/spec/cf/cli/space/base_spec.rb +49 -0
- data/spec/cf/cli/space/create_spec.rb +144 -0
- data/spec/cf/cli/space/delete_spec.rb +109 -0
- data/spec/cf/cli/space/help_spec.rb +39 -0
- data/spec/cf/cli/space/rename_spec.rb +110 -0
- data/spec/cf/cli/space/space_spec.rb +80 -0
- data/spec/cf/cli/space/spaces_spec.rb +107 -0
- data/spec/cf/cli/space/switch_space_spec.rb +57 -0
- data/spec/cf/cli/start/help_spec.rb +39 -0
- data/spec/cf/cli/start/login_spec.rb +142 -0
- data/spec/cf/cli/start/logout_spec.rb +49 -0
- data/spec/cf/cli/start/target_prettifier_spec.rb +78 -0
- data/spec/cf/cli/start/target_spec.rb +123 -0
- data/spec/cf/cli/user/create_spec.rb +98 -0
- data/spec/cf/cli/user/help_spec.rb +32 -0
- data/spec/cf/cli/user/passwd_spec.rb +94 -0
- data/spec/cf/cli/user/register_spec.rb +145 -0
- data/spec/cf/cli_spec.rb +474 -0
- data/spec/console/console_spec.rb +189 -0
- data/spec/factories/cfoundry/v2/apps_factory.rb +12 -0
- data/spec/factories/cfoundry/v2/clients_factory.rb +7 -0
- data/spec/factories/cfoundry/v2/domains_factory.rb +8 -0
- data/spec/factories/cfoundry/v2/managed_service_instances_factory.rb +13 -0
- data/spec/factories/cfoundry/v2/organizations_factory.rb +14 -0
- data/spec/factories/cfoundry/v2/quota_definitions.rb +13 -0
- data/spec/factories/cfoundry/v2/routes_factory.rb +8 -0
- data/spec/factories/cfoundry/v2/service_bindings_factory.rb +11 -0
- data/spec/factories/cfoundry/v2/service_brokers_factory.rb +11 -0
- data/spec/factories/cfoundry/v2/service_plans_factory.rb +17 -0
- data/spec/factories/cfoundry/v2/services_factory.rb +14 -0
- data/spec/factories/cfoundry/v2/spaces_factory.rb +13 -0
- data/spec/factories/cfoundry/v2/stacks_factory.rb +11 -0
- data/spec/factories/cfoundry/v2/user_provided_service_instances_factory.rb +12 -0
- data/spec/factories/cfoundry/v2/users_factory.rb +7 -0
- data/spec/features/backspace_spec.rb +46 -0
- data/spec/features/create_user_spec.rb +74 -0
- data/spec/features/delete_orphaned_service_spec.rb +64 -0
- data/spec/features/login_spec.rb +65 -0
- data/spec/features/manifests_spec.rb +86 -0
- data/spec/features/org_spec.rb +50 -0
- data/spec/features/push_flow_spec.rb +169 -0
- data/spec/features/service_brokers_spec.rb +173 -0
- data/spec/features/services_spec.rb +122 -0
- data/spec/features/space_spec.rb +107 -0
- data/spec/features/switching_targets_spec.rb +70 -0
- data/spec/manifests/errors_spec.rb +43 -0
- data/spec/manifests/loader/builder_spec.rb +80 -0
- data/spec/manifests/loader/normalizer_spec.rb +158 -0
- data/spec/manifests/manifests_spec.rb +335 -0
- data/spec/manifests/plugin_spec.rb +410 -0
- data/spec/micro/plugin_spec.rb +64 -0
- data/spec/spec_helper.rb +69 -0
- data/spec/support/cli_helper.rb +87 -0
- data/spec/support/config_helper.rb +15 -0
- data/spec/support/factory_girl.rb +6 -0
- data/spec/support/fake_home_dir.rb +55 -0
- data/spec/support/features_helper.rb +99 -0
- data/spec/support/interact_helper.rb +27 -0
- data/spec/support/matchers.rb +16 -0
- data/spec/support/mock_commands/mock_restart.rb +16 -0
- data/spec/support/mock_commands/mock_start.rb +17 -0
- data/spec/support/shared_examples/errors.rb +40 -0
- data/spec/support/shared_examples/input.rb +14 -0
- data/spec/tunnel/plugin_spec.rb +31 -0
- data/spec/tunnel/tunnel_spec.rb +54 -0
- metadata +814 -0
@@ -0,0 +1,21 @@
|
|
1
|
+
require "micro/errors"
|
2
|
+
|
3
|
+
module CFMicro::Switcher
|
4
|
+
|
5
|
+
class Darwin < Base
|
6
|
+
def adminrun(command)
|
7
|
+
CFMicro.run_command("osascript", "-e 'do shell script \"#{command}\" with administrator privileges'")
|
8
|
+
end
|
9
|
+
|
10
|
+
def set_nameserver(domain, ip)
|
11
|
+
File.open("/tmp/#{domain}", 'w') { |file| file.write("nameserver #{ip}") }
|
12
|
+
adminrun("mkdir -p /etc/resolver;mv /tmp/#{domain} /etc/resolver/")
|
13
|
+
end
|
14
|
+
|
15
|
+
def unset_nameserver(domain, ip)
|
16
|
+
raise CFMicro::MCFError, "domain missing" unless domain
|
17
|
+
adminrun("rm -f /etc/resolver/#{domain}")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module CFMicro::Switcher
|
2
|
+
|
3
|
+
class Linux < Base
|
4
|
+
def set_nameserver(domain, ip)
|
5
|
+
CFMicro.run_command("sudo", "sed -i'.backup' '1 i nameserver #{ip}' /etc/resolv.conf")
|
6
|
+
# lock resolv.conf so Network Manager doesn't clear out the file when offline
|
7
|
+
CFMicro.run_command("sudo", "chattr +i /etc/resolv.conf")
|
8
|
+
end
|
9
|
+
|
10
|
+
def unset_nameserver(domain, ip)
|
11
|
+
CFMicro.run_command("sudo", "chattr -i /etc/resolv.conf")
|
12
|
+
CFMicro.run_command("sudo", "sed -i'.backup' '/#{ip}/d' /etc/resolv.conf")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module CFMicro::Switcher
|
2
|
+
|
3
|
+
class Windows < Base
|
4
|
+
def version
|
5
|
+
CFMicro.run_command("cmd", "/c ver").to_s.scan(/\d+\.\d+/).first.to_f
|
6
|
+
end
|
7
|
+
|
8
|
+
def adminrun(command, args=nil)
|
9
|
+
if version > 5.2
|
10
|
+
require 'win32ole'
|
11
|
+
shell = WIN32OLE.new("Shell.Application")
|
12
|
+
shell.ShellExecute(command, args, nil, "runas", 0)
|
13
|
+
else
|
14
|
+
# on older version this will try to run the command, and if you don't have
|
15
|
+
# admin privilges it will tell you so and exit
|
16
|
+
CFMicro.run_command(command, args)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
# TODO better method to figure out the interface name is to get the NAT ip and find the
|
21
|
+
# interface with the correct subnet
|
22
|
+
def set_nameserver(domain, ip)
|
23
|
+
adminrun("netsh", "interface ip set dns \"VMware Network Adapter VMnet8\" static #{ip}")
|
24
|
+
end
|
25
|
+
|
26
|
+
def unset_nameserver(domain, ip)
|
27
|
+
adminrun("netsh", "interface ip set dns \"VMware Network Adapter VMnet8\" static none")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
data/lib/micro/vmrun.rb
ADDED
@@ -0,0 +1,175 @@
|
|
1
|
+
require "micro/errors"
|
2
|
+
|
3
|
+
module CFMicro
|
4
|
+
class VMrun
|
5
|
+
attr_reader :vmx, :vmrun
|
6
|
+
|
7
|
+
def initialize(config)
|
8
|
+
@platform = config[:platform]
|
9
|
+
@user = 'root' # must use root as we muck around with system settings
|
10
|
+
@password = config[:password]
|
11
|
+
@vmrun = config[:vmrun]
|
12
|
+
@vmx = config[:vmx]
|
13
|
+
|
14
|
+
# TODO honor TMPDIR
|
15
|
+
if @platform == :windows
|
16
|
+
@temp_dir = ENV['temp']
|
17
|
+
else
|
18
|
+
@temp_dir = '/tmp'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def vmx
|
23
|
+
@vmx
|
24
|
+
end
|
25
|
+
|
26
|
+
def connection_type
|
27
|
+
read_variable('ethernet0.connectionType')
|
28
|
+
end
|
29
|
+
|
30
|
+
def connection_type=(type)
|
31
|
+
write_variable("ethernet0.connectionType", type)
|
32
|
+
end
|
33
|
+
|
34
|
+
def nat?
|
35
|
+
connection_type == "nat"
|
36
|
+
end
|
37
|
+
|
38
|
+
def bridged?
|
39
|
+
connection_type == "bridged"
|
40
|
+
end
|
41
|
+
|
42
|
+
def domain
|
43
|
+
# switch to Dir.mktmpdir
|
44
|
+
state_config = CFMicro.escape_path(File.join(@temp_dir, 'state.yml'))
|
45
|
+
run('CopyFileFromGuestToHost', "/var/vcap/bosh/state.yml #{state_config}")
|
46
|
+
bosh_config = YAML.load_file(state_config)
|
47
|
+
bosh_config['properties']['domain']
|
48
|
+
end
|
49
|
+
|
50
|
+
def ip
|
51
|
+
# switch to Dir.mktmpdir
|
52
|
+
path = CFMicro.escape_path(CFMicro.config_file('refresh_ip.rb'))
|
53
|
+
ip_file = CFMicro.escape_path(File.join(@temp_dir, 'ip.txt'))
|
54
|
+
run('CopyFileFromHostToGuest', "#{path} /tmp/refresh_ip.rb")
|
55
|
+
run('runProgramInGuest', '/tmp/refresh_ip.rb')
|
56
|
+
run('CopyFileFromGuestToHost', "/tmp/ip.txt #{ip_file}")
|
57
|
+
File.open(ip_file, 'r') { |file| file.read }
|
58
|
+
end
|
59
|
+
|
60
|
+
def list
|
61
|
+
vms = run("list")
|
62
|
+
vms.delete_if { |line| line =~ /^Total/ }
|
63
|
+
vms.map { |line| CFMicro.escape_path(File.expand_path(line)) }
|
64
|
+
end
|
65
|
+
|
66
|
+
def offline?
|
67
|
+
command = "-gu #{@user} -gp #{@password} runProgramInGuest"
|
68
|
+
args = '/usr/bin/test -e /var/vcap/micro/offline'
|
69
|
+
# why not use run_command?
|
70
|
+
result = %x{#{@vmrun} #{command} #{@vmx} #{args}}
|
71
|
+
|
72
|
+
if result.include?('Guest program exited with non-zero exit code: 1')
|
73
|
+
return false
|
74
|
+
elsif $?.exitstatus == 0
|
75
|
+
return true
|
76
|
+
else
|
77
|
+
raise CFMicro::MCFError, "failed to execute vmrun:\n#{result}"
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def offline!
|
82
|
+
path = CFMicro.escape_path(CFMicro.config_file('offline.conf'))
|
83
|
+
run('CopyFileFromHostToGuest', "#{path} /etc/dnsmasq.d/offline.conf")
|
84
|
+
run('runProgramInGuest', '/usr/bin/touch /var/vcap/micro/offline')
|
85
|
+
run('runProgramInGuest',
|
86
|
+
"/bin/sed -i -e 's/^[^#]/# &/g' /etc/dnsmasq.d/server || true")
|
87
|
+
restart_dnsmasq
|
88
|
+
end
|
89
|
+
|
90
|
+
def online!
|
91
|
+
run('runProgramInGuest', '/bin/rm -f /etc/dnsmasq.d/offline.conf')
|
92
|
+
run('runProgramInGuest', '/bin/rm -f /var/vcap/micro/offline')
|
93
|
+
run('runProgramInGuest',
|
94
|
+
"/bin/sed -i -e 's/^# //g' /etc/dnsmasq.d/server || true")
|
95
|
+
restart_dnsmasq
|
96
|
+
end
|
97
|
+
|
98
|
+
# check to see if the micro cloud has been configured
|
99
|
+
# uses default password to check
|
100
|
+
def ready?
|
101
|
+
command = "-gu root -gp 'ca$hc0w' runProgramInGuest"
|
102
|
+
args = '/usr/bin/test -e /var/vcap/micro/micro.json'
|
103
|
+
result = %x{#{@vmrun} #{command} #{@vmx} #{args}}
|
104
|
+
|
105
|
+
if result.include?('Invalid user name or password for the guest OS') || $?.exitstatus == 0
|
106
|
+
return true
|
107
|
+
elsif $?.exitstatus == 1
|
108
|
+
return false
|
109
|
+
else
|
110
|
+
raise CFMicro::MCFError, "failed to execute vmrun:\n#{result}"
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
def read_variable(var)
|
115
|
+
# TODO deal with non-ok return
|
116
|
+
run("readVariable", "runtimeConfig #{var}").first
|
117
|
+
end
|
118
|
+
|
119
|
+
def write_variable(var, value)
|
120
|
+
run('writeVariable', "runtimeConfig #{var} #{value}")
|
121
|
+
end
|
122
|
+
|
123
|
+
def reset
|
124
|
+
run('reset', 'soft')
|
125
|
+
end
|
126
|
+
|
127
|
+
def restart_dnsmasq
|
128
|
+
# restart command doesn't always work, start and stop seems to be more reliable
|
129
|
+
run('runProgramInGuest', '/etc/init.d/dnsmasq stop')
|
130
|
+
run('runProgramInGuest', '/etc/init.d/dnsmasq start')
|
131
|
+
end
|
132
|
+
|
133
|
+
def run(command, args=nil)
|
134
|
+
if command.include?('Guest')
|
135
|
+
command = "-gu #{@user} -gp #{@password} #{command}"
|
136
|
+
end
|
137
|
+
CFMicro.run_command(@vmrun, "#{command} #{@vmx} #{args}")
|
138
|
+
end
|
139
|
+
|
140
|
+
def running?
|
141
|
+
vms = list
|
142
|
+
if @platform == :windows
|
143
|
+
vms.any? { |x|
|
144
|
+
x.downcase == @vmx.downcase
|
145
|
+
}
|
146
|
+
else
|
147
|
+
# Handle vmx being in a symlinked dir.
|
148
|
+
real_path = nil
|
149
|
+
begin
|
150
|
+
real_path = File.realpath(@vmx)
|
151
|
+
rescue
|
152
|
+
end
|
153
|
+
vms.include?(@vmx) || (real_path && vms.include?(real_path))
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
def start!
|
158
|
+
run('start') unless running?
|
159
|
+
end
|
160
|
+
|
161
|
+
def stop!
|
162
|
+
run('stop') if running?
|
163
|
+
end
|
164
|
+
|
165
|
+
def self.locate(platform)
|
166
|
+
paths = YAML.load_file(CFMicro.config_file('paths.yml'))
|
167
|
+
vmrun_paths = paths[platform.to_s]['vmrun']
|
168
|
+
vmrun_exe = @platform == :windows ? 'vmrun.exe' : 'vmrun'
|
169
|
+
vmrun = CFMicro.locate_file(vmrun_exe, "VMware", vmrun_paths)
|
170
|
+
err "Unable to locate vmrun, please supply --vmrun option" unless vmrun
|
171
|
+
vmrun
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'active_support/time'
|
2
|
+
require 'active_support/core_ext'
|
3
|
+
|
4
|
+
namespace :gem do
|
5
|
+
desc "Bump gem version, push to RubyGems, push to Github, add release notes"
|
6
|
+
task :release, [:version] do |_, args|
|
7
|
+
version = args[:version] || 'rc'
|
8
|
+
old_version = gem_version
|
9
|
+
|
10
|
+
sh! "gem bump --version #{version} --no-commit"
|
11
|
+
|
12
|
+
print "About to bump version to #{gem_version}, continue? (Y): "
|
13
|
+
answer = STDIN.gets.strip
|
14
|
+
exit unless answer.length == 0 || answer.upcase.start_with?("Y")
|
15
|
+
|
16
|
+
sh! "git add lib/cf/version.rb"
|
17
|
+
|
18
|
+
print_with_purpose "Bumping to version #{gem_version}"
|
19
|
+
|
20
|
+
sh!("bundle")
|
21
|
+
sh!("git add Gemfile.lock")
|
22
|
+
|
23
|
+
generate_release_notes(old_version)
|
24
|
+
|
25
|
+
sh!("git commit -m 'Bumping to version #{gem_version}.'")
|
26
|
+
sh!("git push")
|
27
|
+
sh!("gem release --tag")
|
28
|
+
sh!("git tag -a -f latest-release -m 'Latest Release'")
|
29
|
+
sh!("git push -f origin latest-release:refs/tags/latest-release")
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def generate_release_notes(old_version)
|
35
|
+
print_with_purpose "Generating release notes..."
|
36
|
+
file_name = "release_#{gem_version}"
|
37
|
+
sh!("anchorman notes --name=#{file_name} --from=v#{old_version}")
|
38
|
+
sh!("git add release_notes")
|
39
|
+
end
|
40
|
+
|
41
|
+
def sh!(cmd)
|
42
|
+
`#{cmd}`
|
43
|
+
raise "borked with #{$?}" unless $?.success?
|
44
|
+
end
|
45
|
+
|
46
|
+
def print_with_purpose(text)
|
47
|
+
puts "\033[34m#{text}\033[0m"
|
48
|
+
end
|
49
|
+
|
50
|
+
def gem_version
|
51
|
+
silence_warnings do
|
52
|
+
load "lib/cf/version.rb"
|
53
|
+
end
|
54
|
+
Gem::Specification.load("cf.gemspec").version.to_s
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# In order for this to work you'll need to install the following on the Windows box:
|
2
|
+
# git
|
3
|
+
# RubyInstaller (1.9.3)
|
4
|
+
# DevKit from RubyInstaller (tdm 32-bit to match 1.9.3)
|
5
|
+
#
|
6
|
+
# gem install bundler
|
7
|
+
# bundle
|
8
|
+
# rake windows:build
|
9
|
+
namespace :windows do
|
10
|
+
desc "Create a Windows .exe file"
|
11
|
+
task :build do
|
12
|
+
system("ocra --console --no-autoload bin/cf")
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
[![Build Status](https://travis-ci.org/cloudfoundry/tunnel-cf-plugin.png)](https://travis-ci.org/cloudfoundry/tunnel-cf-plugin)
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/tunnel-cf-plugin.png)](http://badge.fury.io/rb/tunnel-cf-plugin)
|
3
|
+
|
4
|
+
## Tunnel
|
5
|
+
### Info
|
6
|
+
This plugin allows you to connect to a Cloud Foundry service using your own command line client. By default, the plugin supports *redis*, *mysql*, *mongodb*, and *postgresql*.
|
7
|
+
|
8
|
+
### Installation
|
9
|
+
```
|
10
|
+
gem install tunnel-cf-plugin
|
11
|
+
```
|
12
|
+
|
13
|
+
### Usage
|
14
|
+
```
|
15
|
+
tunnel [INSTANCE] [CLIENT] Create a local tunnel to a service.
|
16
|
+
```
|
17
|
+
|
18
|
+
You can add support for other command-line clients by providing a `~/.truck/tunnel-clients.yml` file with the following format:
|
19
|
+
|
20
|
+
```yaml
|
21
|
+
service_name:
|
22
|
+
client_program_name: command line arguments
|
23
|
+
client_program_name_2:
|
24
|
+
command: command line arguments
|
25
|
+
environment:
|
26
|
+
- ENV_VAR_NAME=env_var_value
|
27
|
+
```
|
28
|
+
|
29
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
redis:
|
2
|
+
redis-cli: -h ${host} -p ${port} -a ${password}
|
3
|
+
|
4
|
+
mysql:
|
5
|
+
mysql: --protocol=TCP --host=${host} --port=${port} --user=${user} --password=${password} ${name}
|
6
|
+
mysqldump: --protocol=TCP --host=${host} --port=${port} --user=${user} --password=${password} ${name} > ${ask Output file}
|
7
|
+
|
8
|
+
mongodb:
|
9
|
+
mongo: --host ${host} --port ${port} -u ${user} -p ${password} ${name}
|
10
|
+
mongodump: --host ${host} --port ${port} -u ${user} -p ${password} --db ${name}
|
11
|
+
mongorestore: --host ${host} --port ${port} -u ${user} -p ${password} --db ${name} ${ask Directory or filename to restore from}
|
12
|
+
|
13
|
+
postgresql:
|
14
|
+
psql:
|
15
|
+
command: -h ${host} -p ${port} -d ${name} -U ${user} -w
|
16
|
+
environment:
|
17
|
+
- PGPASSWORD='${password}'
|
@@ -0,0 +1,48 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
addressable (2.2.6)
|
5
|
+
async_sinatra (0.5.0)
|
6
|
+
rack (>= 1.2.1)
|
7
|
+
sinatra (>= 1.0)
|
8
|
+
caldecott (0.0.3)
|
9
|
+
addressable (= 2.2.6)
|
10
|
+
async_sinatra (= 0.5.0)
|
11
|
+
em-http-request (= 0.3.0)
|
12
|
+
em-websocket (= 0.3.1)
|
13
|
+
json (= 1.6.1)
|
14
|
+
uuidtools (= 2.1.2)
|
15
|
+
daemons (1.1.8)
|
16
|
+
em-http-request (0.3.0)
|
17
|
+
addressable (>= 2.0.0)
|
18
|
+
escape_utils
|
19
|
+
eventmachine (>= 0.12.9)
|
20
|
+
em-websocket (0.3.1)
|
21
|
+
addressable (>= 2.1.1)
|
22
|
+
eventmachine (>= 0.12.9)
|
23
|
+
escape_utils (0.2.4)
|
24
|
+
eventmachine (0.12.10)
|
25
|
+
json (1.6.1)
|
26
|
+
rack (1.2.5)
|
27
|
+
sinatra (1.2.8)
|
28
|
+
rack (~> 1.1)
|
29
|
+
tilt (>= 1.2.2, < 2.0)
|
30
|
+
thin (1.4.1)
|
31
|
+
daemons (>= 1.0.9)
|
32
|
+
eventmachine (>= 0.12.6)
|
33
|
+
rack (>= 1.0.0)
|
34
|
+
tilt (1.3.3)
|
35
|
+
uuidtools (2.1.2)
|
36
|
+
|
37
|
+
PLATFORMS
|
38
|
+
ruby
|
39
|
+
|
40
|
+
DEPENDENCIES
|
41
|
+
async_sinatra
|
42
|
+
bundler
|
43
|
+
caldecott (= 0.0.3)
|
44
|
+
em-websocket
|
45
|
+
json
|
46
|
+
rack (~> 1.2.0)
|
47
|
+
thin
|
48
|
+
uuidtools
|