webbynode 1.0.5.3 → 1.1.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of webbynode might be problematic. Click here for more details.
- data/.autotest +1 -0
- data/.bundle/config +2 -0
- data/.gitignore +4 -0
- data/.rvmrc +1 -0
- data/.travis.yml +9 -0
- data/Gemfile +1 -20
- data/Gemfile.lock +43 -50
- data/Manifest +0 -1
- data/Rakefile +1 -45
- data/bin/webbynode +0 -0
- data/bin/wn +0 -0
- data/lib/webbynode/api_client.rb +35 -63
- data/lib/webbynode/command.rb +2 -1
- data/lib/webbynode/commands/accounts.rb +11 -8
- data/lib/webbynode/commands/change_dns.rb +1 -1
- data/lib/webbynode/commands/database.rb +7 -7
- data/lib/webbynode/commands/dns_aliases.rb +6 -6
- data/lib/webbynode/commands/{guides.rb → docs.rb} +3 -2
- data/lib/webbynode/commands/help.rb +3 -3
- data/lib/webbynode/commands/init.rb +16 -16
- data/lib/webbynode/commands/push.rb +7 -7
- data/lib/webbynode/commands/remote.rb +1 -1
- data/lib/webbynode/commands/settings.rb +1 -1
- data/lib/webbynode/commands/tasks.rb +3 -3
- data/lib/webbynode/commands/user.rb +5 -5
- data/lib/webbynode/commands/version.rb +1 -1
- data/lib/webbynode/commands/webbies.rb +17 -22
- data/lib/webbynode/manager2_api_client.rb +94 -0
- data/lib/webbynode/manager_api_client.rb +94 -0
- data/lib/webbynode/models/webby.rb +3 -0
- data/lib/webbynode/notify.rb +1 -1
- data/lib/webbynode/server.rb +1 -1
- data/lib/webbynode/updater.rb +28 -8
- data/lib/webbynode/version.rb +8 -0
- data/lib/webbynode.rb +5 -5
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/spec/fixtures/manager2/webbies +11 -0
- data/spec/fixtures/manager2/webbies_unauthorized +10 -0
- data/spec/fixtures/manager2/zones +11 -0
- data/spec/fixtures/manager2/zones_a_record +11 -0
- data/spec/fixtures/manager2/zones_a_record_error +10 -0
- data/spec/fixtures/manager2/zones_new_zone +11 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/webbynode/api_client_spec.rb +15 -128
- data/spec/webbynode/command_spec.rb +6 -0
- data/spec/webbynode/commands/accounts_spec.rb +10 -4
- data/spec/webbynode/commands/apps_spec.rb +1 -0
- data/spec/webbynode/commands/database_spec.rb +4 -1
- data/spec/webbynode/commands/{guides_spec.rb → docs_spec.rb} +2 -2
- data/spec/webbynode/commands/init_spec.rb +27 -64
- data/spec/webbynode/commands/push_spec.rb +29 -15
- data/spec/webbynode/commands/remote_spec.rb +2 -0
- data/spec/webbynode/commands/version_spec.rb +1 -1
- data/spec/webbynode/commands/webbies_spec.rb +17 -2
- data/spec/webbynode/manager2_api_client_spec.rb +127 -0
- data/spec/webbynode/manager_api_client_spec.rb +136 -0
- data/webbynode.gemspec +30 -49
- metadata +297 -127
- data/PostInstall.txt +0 -45
- data/changelog.rdoc +0 -437
- data/cucumber.yml.old +0 -1
@@ -8,7 +8,7 @@ module Webbynode::Commands
|
|
8
8
|
option :engine, "Sets the application engine for the app", :validate => {
|
9
9
|
:in => ['php', 'rack', 'rails', 'rails3', 'html', 'wsgi', 'django', 'nodejs']
|
10
10
|
}
|
11
|
-
option :trial, "Initializes this app for
|
11
|
+
option :trial, "Initializes this app for Webbynode Trial"
|
12
12
|
|
13
13
|
def execute
|
14
14
|
unless params.any?
|
@@ -16,7 +16,7 @@ module Webbynode::Commands
|
|
16
16
|
return
|
17
17
|
end
|
18
18
|
|
19
|
-
io.log "#{"Webbynode
|
19
|
+
io.log "#{"Webbynode Deployment Tool".bright} - #{"http://docs.webbynode.com".underline}"
|
20
20
|
|
21
21
|
@overwrite = false
|
22
22
|
|
@@ -32,7 +32,7 @@ module Webbynode::Commands
|
|
32
32
|
|
33
33
|
check_git_clean if @git_present
|
34
34
|
|
35
|
-
io.log "Initializing application #{@app_name.
|
35
|
+
io.log "Initializing application #{@app_name.bright} #{@dns_entry ? "with dns #{@dns_entry.bright}" : ""}"
|
36
36
|
|
37
37
|
detect_engine
|
38
38
|
|
@@ -46,12 +46,12 @@ module Webbynode::Commands
|
|
46
46
|
|
47
47
|
handle_dns option(:dns) if option(:adddns)
|
48
48
|
|
49
|
-
io.log "Application #{@app_name.
|
49
|
+
io.log "Application #{@app_name.bright} ready for Rapid Deployment", :finish
|
50
50
|
|
51
51
|
rescue Net::SSH::HostKeyMismatch
|
52
52
|
io.log ""
|
53
53
|
io.log "Error pushing to your server:"
|
54
|
-
io.log " #{$!.to_s.
|
54
|
+
io.log " #{$!.to_s.bright}"
|
55
55
|
io.log ""
|
56
56
|
io.log "This usually happens because you redeployed the server and the fingerprint changed."
|
57
57
|
io.log ""
|
@@ -62,13 +62,13 @@ module Webbynode::Commands
|
|
62
62
|
io.log ""
|
63
63
|
|
64
64
|
rescue Webbynode::InvalidAuthentication
|
65
|
-
io.log "Could not connect to webby: invalid authentication.".
|
65
|
+
io.log "Could not connect to webby: invalid authentication.".bright, true
|
66
66
|
|
67
67
|
rescue Webbynode::PermissionError
|
68
|
-
io.log "Could not create an SSH key: permission error.".
|
68
|
+
io.log "Could not create an SSH key: permission error.".bright, true
|
69
69
|
|
70
70
|
rescue Webbynode::GitRemoteAlreadyExistsError
|
71
|
-
io.log "Application already initialized.".
|
71
|
+
io.log "Application already initialized.".bright
|
72
72
|
end
|
73
73
|
|
74
74
|
def create_pushand
|
@@ -84,7 +84,7 @@ module Webbynode::Commands
|
|
84
84
|
unless git.clean?
|
85
85
|
io.log ""
|
86
86
|
raise CommandError,
|
87
|
-
"#{"Cannot initialize:".
|
87
|
+
"#{"Cannot initialize:".bright} #{"git has pending changes.".bright}\nExecute a git commit or add changes to .gitignore and try again."
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
@@ -92,7 +92,7 @@ module Webbynode::Commands
|
|
92
92
|
return unless pushand_exists?
|
93
93
|
|
94
94
|
io.log ""
|
95
|
-
io.log "It seems this application was initialized before.".
|
95
|
+
io.log "It seems this application was initialized before.".bright
|
96
96
|
|
97
97
|
unless ask('Do you want to initialize it again (y/n)?').downcase == 'y'
|
98
98
|
puts ""
|
@@ -111,7 +111,7 @@ module Webbynode::Commands
|
|
111
111
|
@git_user = io.general_settings['rapp_username']
|
112
112
|
|
113
113
|
unless @git_user
|
114
|
-
@git_user = ask('Enter your
|
114
|
+
@git_user = ask('Enter your Webbynode trial user: ')
|
115
115
|
io.add_general_setting 'rapp_username', @git_user
|
116
116
|
end
|
117
117
|
|
@@ -133,7 +133,7 @@ module Webbynode::Commands
|
|
133
133
|
def delete_remote
|
134
134
|
return unless git.remote_exists?('webbynode')
|
135
135
|
|
136
|
-
io.log "Webbynode git integration already initialized.".
|
136
|
+
io.log "Webbynode git integration already initialized.".bright
|
137
137
|
if @overwrite || ask('Do you want to overwrite the current settings (y/n)?').downcase == 'y'
|
138
138
|
git.delete_remote('webbynode')
|
139
139
|
end
|
@@ -179,14 +179,14 @@ module Webbynode::Commands
|
|
179
179
|
webby = api_webbies[api_webbies.keys.first]
|
180
180
|
else
|
181
181
|
io.log ""
|
182
|
-
io.log "Current Webbies in your account:".
|
182
|
+
io.log "Current Webbies in your account:".bright
|
183
183
|
io.log ""
|
184
184
|
|
185
185
|
choices = []
|
186
186
|
api_webbies.keys.sort.each_with_index do |webby_key, i|
|
187
187
|
webby = api_webbies[webby_key]
|
188
188
|
choices << webby
|
189
|
-
io.log " #{i+1}. #{webby
|
189
|
+
io.log " #{i+1}. #{webby.name.bright} (#{webby.ip})"
|
190
190
|
end
|
191
191
|
|
192
192
|
io.log "", :simple
|
@@ -195,9 +195,9 @@ module Webbynode::Commands
|
|
195
195
|
end
|
196
196
|
|
197
197
|
io.log "", :simple
|
198
|
-
io.log "Set deployment Webby to #{webby
|
198
|
+
io.log "Set deployment Webby to #{webby.name.bright}."
|
199
199
|
|
200
|
-
return webby
|
200
|
+
return webby.ip
|
201
201
|
end
|
202
202
|
|
203
203
|
io.log "Retrieving IP for Webby #{webby}..."
|
@@ -37,11 +37,11 @@ module Webbynode::Commands
|
|
37
37
|
handle_semaphore
|
38
38
|
|
39
39
|
# Logs a initialization message to the user
|
40
|
-
io.log "Pushing #{app_name.
|
40
|
+
io.log "Pushing #{app_name.bright}", :start
|
41
41
|
|
42
42
|
# Checks for server-side updates
|
43
43
|
if check_for_updates
|
44
|
-
io.log "Note:
|
44
|
+
io.log "Note: Deployment Engine updated".bright
|
45
45
|
io.log ""
|
46
46
|
end
|
47
47
|
|
@@ -53,7 +53,7 @@ module Webbynode::Commands
|
|
53
53
|
after_tasks.read_tasks(Webbynode::Commands::Tasks::AfterPushTasksFile)
|
54
54
|
perform_after_tasks if after_tasks.has_tasks?
|
55
55
|
|
56
|
-
io.log "Finished pushing #{app_name.
|
56
|
+
io.log "Finished pushing #{app_name.bright}", :finish
|
57
57
|
end
|
58
58
|
|
59
59
|
def handle_semaphore
|
@@ -65,18 +65,18 @@ module Webbynode::Commands
|
|
65
65
|
|
66
66
|
# Performs the before push tasks locally
|
67
67
|
def perform_before_tasks
|
68
|
-
io.log "Performing #{"Before Push".
|
68
|
+
io.log "Performing #{"Before Push".bright} Tasks...", :action
|
69
69
|
before_tasks.session_tasks.each do |task|
|
70
|
-
io.log " Performing Task: #{task.
|
70
|
+
io.log " Performing Task: #{task.bright}", :action
|
71
71
|
io.exec(task)
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
75
|
# Performs the after push tasks remotely from the application root
|
76
76
|
def perform_after_tasks
|
77
|
-
io.log "Performing #{"After Push".
|
77
|
+
io.log "Performing #{"After Push".bright} Tasks...", :action
|
78
78
|
after_tasks.session_tasks.each do |task|
|
79
|
-
io.log " Performing Task: #{task.
|
79
|
+
io.log " Performing Task: #{task.bright}", :action
|
80
80
|
remote_executor.exec("cd #{pushand.parse_remote_app_name}; #{task}", true)
|
81
81
|
end
|
82
82
|
end
|
@@ -19,7 +19,7 @@ module Webbynode::Commands
|
|
19
19
|
remote_app_name = pushand.parse_remote_app_name
|
20
20
|
|
21
21
|
# Notify the user
|
22
|
-
io.log "Executing remote command...".
|
22
|
+
io.log "Executing remote command...".bright
|
23
23
|
|
24
24
|
# Executes the command on the remote server inside the application root folder
|
25
25
|
result = spinner {
|
@@ -117,11 +117,11 @@ module Webbynode::Commands
|
|
117
117
|
def show_tasks(from_file = false)
|
118
118
|
read_tasks(session_file, true) if from_file
|
119
119
|
if session_tasks.empty?
|
120
|
-
io.log_and_exit "You haven't set up any #{type.gsub('_',' ').capitalize.
|
120
|
+
io.log_and_exit "You haven't set up any #{type.gsub('_',' ').capitalize.bright} tasks yet."
|
121
121
|
end
|
122
|
-
io.log "#{type.gsub('_',' ').capitalize.
|
122
|
+
io.log "#{type.gsub('_',' ').capitalize.bright} tasks:"
|
123
123
|
session_tasks.each_with_index do |task, index|
|
124
|
-
io.log "[#{index}] #{task.
|
124
|
+
io.log "[#{index}] #{task.bright}"
|
125
125
|
end
|
126
126
|
end
|
127
127
|
|
@@ -1,14 +1,14 @@
|
|
1
1
|
module Webbynode::Commands
|
2
2
|
class User < Webbynode::Command
|
3
|
-
summary "Manages
|
3
|
+
summary "Manages Webbynode Trial user"
|
4
4
|
parameter :action, 'Action to perform', :validate => { :in => ['add', 'remove', 'show', 'password']}
|
5
5
|
|
6
6
|
def execute
|
7
|
-
io.log "
|
7
|
+
io.log "Webbynode Trial - http://trial.webbynode.com"
|
8
8
|
io.log ""
|
9
9
|
|
10
10
|
if user = io.general_settings['rapp_username']
|
11
|
-
io.log "User #{user} is already configured for
|
11
|
+
io.log "User #{user} is already configured for Webbynode Trial."
|
12
12
|
if ask('Do you want to overwrite this settings (y/n)?') != 'y'
|
13
13
|
io.log ""
|
14
14
|
io.log "Aborted."
|
@@ -16,7 +16,7 @@ module Webbynode::Commands
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
io.log "
|
19
|
+
io.log "Webbynode Trial is a good way to try Webbynode's Webbynode Engine without being a subscriber."
|
20
20
|
io.log "You can deploy your application and it will be online for up to 24 hours. We delete"
|
21
21
|
io.log "all applications at 2AM EST, but your user will remain valid."
|
22
22
|
io.log ""
|
@@ -28,7 +28,7 @@ module Webbynode::Commands
|
|
28
28
|
end until valid_email?(email)
|
29
29
|
|
30
30
|
io.log ""
|
31
|
-
io.log "Enter an username and password to start using
|
31
|
+
io.log "Enter an username and password to start using Webbynode Trial."
|
32
32
|
io.log ""
|
33
33
|
|
34
34
|
begin
|
@@ -2,7 +2,7 @@ module Webbynode::Commands
|
|
2
2
|
class Version < Webbynode::Command
|
3
3
|
summary "Displays current version of Webbynode Gem"
|
4
4
|
def execute
|
5
|
-
io.log "#{"Rapid Deployment Gem".
|
5
|
+
io.log "#{"Rapid Deployment Gem".bright} v#{Webbynode::Version::STRING.bright}"
|
6
6
|
end
|
7
7
|
end
|
8
8
|
end
|
@@ -6,33 +6,28 @@ module Webbynode::Commands
|
|
6
6
|
def execute
|
7
7
|
puts "Fetching list of your Webbies..."
|
8
8
|
puts ""
|
9
|
-
|
9
|
+
|
10
|
+
table(%w(Name IP Node Plan Status), %w(30 15 11 15 30)) { api.webbies }
|
11
|
+
end
|
12
|
+
|
13
|
+
def table(cols, sizes)
|
10
14
|
header = " "
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
header << " "
|
17
|
-
header << "Plan".ljust(15).color(:white).bright.underline
|
18
|
-
header << " "
|
19
|
-
header << "Status".ljust(14).color(:white).bright.underline
|
20
|
-
header << " "
|
21
|
-
|
22
|
-
puts header
|
15
|
+
cols.each_with_index do |col, i|
|
16
|
+
#header << col.ljust(sizes[i].to_i).bright.underline
|
17
|
+
header << col.ljust(sizes[i].to_i).bright.underline
|
18
|
+
header << " "
|
19
|
+
end
|
23
20
|
|
24
|
-
|
25
|
-
|
26
|
-
webbies.each_pair do |name, webby|
|
21
|
+
puts header
|
22
|
+
spinner { yield }.each_pair do |name, item|
|
27
23
|
str = " "
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
str << webby['plan'].ljust(16).color(:cyan).bright
|
32
|
-
str << (webby['status'] == 'on' ? "on".color(:cyan).bright : "off")
|
33
|
-
|
24
|
+
cols.each_with_index do |col, i|
|
25
|
+
str << item.send(col.downcase).ljust(sizes[i].to_i+1)
|
26
|
+
end
|
34
27
|
puts str
|
35
28
|
end
|
29
|
+
|
30
|
+
puts ""
|
36
31
|
end
|
37
32
|
end
|
38
33
|
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
module Webbynode
|
2
|
+
class Manager2ApiClient < ApiClient
|
3
|
+
base_uri "https://manager2.webbynode.com/api"
|
4
|
+
|
5
|
+
def zones
|
6
|
+
response = get("/zones.json")
|
7
|
+
if zones = response
|
8
|
+
zones.inject({}) { |h, zone| h[zone['name']] = zone; h }
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def create_zone(zone)
|
13
|
+
response = post("/zones.json", :query => {"zone[name]" => zone})
|
14
|
+
handle_error(response)
|
15
|
+
response
|
16
|
+
end
|
17
|
+
|
18
|
+
def create_record(record, ip)
|
19
|
+
original_record = record
|
20
|
+
|
21
|
+
url = Domainatrix.parse("http://#{record}")
|
22
|
+
record = url.subdomain
|
23
|
+
domain = "#{url.domain}.#{url.public_suffix}"
|
24
|
+
|
25
|
+
zone = zones[domain] || create_zone(domain)
|
26
|
+
|
27
|
+
create_a_record(zone['id'], record, ip, original_record)
|
28
|
+
end
|
29
|
+
|
30
|
+
def create_a_record(id, record, ip, original_record)
|
31
|
+
response = post("/zones/#{id}/records.json", :body => {"record[name]" => record, "record[type]" => "A", "record[content]" => ip})
|
32
|
+
if response["errors"] and format_error(response["errors"]) =~ /content has already been taken/
|
33
|
+
io.log "'#{original_record}' already exists in Webbynode DNS, make sure it's pointing to #{ip}", :warning
|
34
|
+
return
|
35
|
+
end
|
36
|
+
if response.code == 404
|
37
|
+
raise Manager2ApiClient::ApiError, "this domain was not found under your account"
|
38
|
+
end
|
39
|
+
|
40
|
+
handle_error(response)
|
41
|
+
response
|
42
|
+
end
|
43
|
+
|
44
|
+
def webbies
|
45
|
+
unless @webbies
|
46
|
+
response = get("/webbies.json") || {}
|
47
|
+
@webbies = response
|
48
|
+
end
|
49
|
+
|
50
|
+
@webbies.inject({}) { |h, webby| h[webby['hostname']] = create_webby(webby); h }
|
51
|
+
end
|
52
|
+
|
53
|
+
def create_webby(hash)
|
54
|
+
webby = Webby.new
|
55
|
+
webby.name = hash['hostname']
|
56
|
+
webby.ip = hash['mainipaddress']
|
57
|
+
webby.node = hash['node_name']
|
58
|
+
webby.plan = hash['plan']
|
59
|
+
webby.status = hash['status']
|
60
|
+
webby
|
61
|
+
end
|
62
|
+
|
63
|
+
def fix_credentials
|
64
|
+
{ :auth_token => credentials['token'] }
|
65
|
+
end
|
66
|
+
|
67
|
+
def get(uri, options={})
|
68
|
+
response = self.class.get(uri, { :query => fix_credentials }.merge(options))
|
69
|
+
if response.code == 401 or response.code == 411
|
70
|
+
raise Unauthorized, "You have provided the wrong credentials"
|
71
|
+
end
|
72
|
+
response
|
73
|
+
end
|
74
|
+
|
75
|
+
def post(uri, options={})
|
76
|
+
body = fix_credentials
|
77
|
+
body.merge!(options.delete(:body)||{})
|
78
|
+
|
79
|
+
response = self.class.post(uri, { :body => body }.merge(options))
|
80
|
+
if response.code == 401 or response.code == 411
|
81
|
+
raise Unauthorized, "You have provided the wrong credentials"
|
82
|
+
end
|
83
|
+
response
|
84
|
+
end
|
85
|
+
|
86
|
+
def check_auth(email, token)
|
87
|
+
simple_post("/webbies.json", :body => { :auth_token => token })
|
88
|
+
end
|
89
|
+
|
90
|
+
def simple_post(*args)
|
91
|
+
self.class.post *args
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
module Webbynode
|
2
|
+
class ManagerApiClient < ApiClient
|
3
|
+
base_uri "https://manager.webbynode.com/api/yaml"
|
4
|
+
|
5
|
+
def zones
|
6
|
+
response = post("/dns")
|
7
|
+
if zones = response["zones"]
|
8
|
+
zones.inject({}) { |h, zone| h[zone[:domain]] = zone; h }
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def create_record(record, ip)
|
13
|
+
original_record = record
|
14
|
+
|
15
|
+
url = Domainatrix.parse("http://#{record}")
|
16
|
+
record = url.subdomain
|
17
|
+
domain = "#{url.domain}.#{url.public_suffix}."
|
18
|
+
|
19
|
+
zone = zones[domain]
|
20
|
+
if zone
|
21
|
+
raise InactiveZone, domain unless zone[:status] == 'Active'
|
22
|
+
else
|
23
|
+
zone = create_zone(domain)
|
24
|
+
end
|
25
|
+
|
26
|
+
create_a_record(zone[:id], record, ip, original_record)
|
27
|
+
end
|
28
|
+
|
29
|
+
def create_zone(zone)
|
30
|
+
response = post("/dns/new", :query => {"zone[domain]" => zone, "zone[ttl]" => "86400"})
|
31
|
+
handle_error(response)
|
32
|
+
response
|
33
|
+
end
|
34
|
+
|
35
|
+
def create_a_record(id, record, ip, original_record)
|
36
|
+
response = post("/dns/#{id}/records/new", :query => {"record[name]" => record, "record[type]" => "A", "record[data]" => ip})
|
37
|
+
if response["errors"] and response["errors"] =~ /Data has already been taken/
|
38
|
+
io.log "'#{original_record}' is already setup on Webbynode DNS, make sure it's pointing to #{ip}", :warning
|
39
|
+
return
|
40
|
+
end
|
41
|
+
|
42
|
+
handle_error(response)
|
43
|
+
response["record"]
|
44
|
+
end
|
45
|
+
|
46
|
+
def webbies
|
47
|
+
unless @webbies
|
48
|
+
response = post("/webbies") || {}
|
49
|
+
|
50
|
+
@webbies = response
|
51
|
+
end
|
52
|
+
|
53
|
+
@webbies['webbies'].inject({}) { |h, webby| h[webby['name']] = create_webby(webby); h }
|
54
|
+
end
|
55
|
+
|
56
|
+
def create_webby(hash)
|
57
|
+
webby = Webby.new
|
58
|
+
webby.name = hash['name']
|
59
|
+
webby.ip = hash['ip']
|
60
|
+
webby.node = hash['node']
|
61
|
+
webby.plan = hash['plan']
|
62
|
+
webby.status = hash['status']
|
63
|
+
webby
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
def get(uri, options={})
|
68
|
+
response = self.class.get(uri, { :query => credentials }.merge(options))
|
69
|
+
if response.code == 401 or response.code == 411
|
70
|
+
raise Unauthorized, "You have provided the wrong credentials"
|
71
|
+
end
|
72
|
+
response
|
73
|
+
end
|
74
|
+
|
75
|
+
def post(uri, options={})
|
76
|
+
body = credentials
|
77
|
+
body.merge!(options.delete(:body)||{})
|
78
|
+
|
79
|
+
response = self.class.post(uri, { :body => body }.merge(options))
|
80
|
+
if response.code == 401 or response.code == 411
|
81
|
+
raise Unauthorized, "You have provided the wrong credentials"
|
82
|
+
end
|
83
|
+
response
|
84
|
+
end
|
85
|
+
|
86
|
+
def check_auth(email, token)
|
87
|
+
simple_post("/webbies", :body => { :email => email, :token => token })
|
88
|
+
end
|
89
|
+
|
90
|
+
def simple_post(*args)
|
91
|
+
self.class.post *args
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
data/lib/webbynode/notify.rb
CHANGED
@@ -8,7 +8,7 @@ module Webbynode
|
|
8
8
|
def self.message(message)
|
9
9
|
if self.installed? and !$testing
|
10
10
|
message = message.gsub(/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]/, "")
|
11
|
-
%x(growlnotify -t "#{TITLE}" -m "#{message}" --image "#{IMAGE_PATH}")
|
11
|
+
%x(growlnotify -t "#{TITLE}" -m "#{message}" --image "#{IMAGE_PATH}" 2>/dev/null)
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
data/lib/webbynode/server.rb
CHANGED
data/lib/webbynode/updater.rb
CHANGED
@@ -1,16 +1,36 @@
|
|
1
1
|
module Webbynode
|
2
2
|
module Updater
|
3
3
|
def check_for_updates
|
4
|
+
send "update_#{ApiClient.system}"
|
5
|
+
end
|
6
|
+
|
7
|
+
def update_manager
|
8
|
+
updated = remote_executor.exec(<<-EOS, false, true)
|
9
|
+
if [ ! -f /var/webbynode/update_rapp ]; then
|
10
|
+
cd /var/webbynode
|
11
|
+
wget http://repo.webbynode.com/rapidapps/update_rapp
|
12
|
+
chmod +x update_rapp
|
13
|
+
ln -s -f /var/webbynode/update_rapp /usr/bin/update_rapp
|
14
|
+
fi
|
15
|
+
|
16
|
+
/var/webbynode/update_rapp
|
17
|
+
if [ $? -eq 1 ]; then exit 1; fi
|
18
|
+
EOS
|
19
|
+
|
20
|
+
updated == 1
|
21
|
+
end
|
22
|
+
|
23
|
+
def update_manager2
|
4
24
|
updated = remote_executor.exec(<<-EOS, false, true)
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
25
|
+
if [ ! -f /var/webbynode/bin/check_update ]; then
|
26
|
+
cd /var/webbynode/bin
|
27
|
+
wget http://repo.webbynode.com/rapidapps/check_update
|
28
|
+
chmod +x check_update
|
29
|
+
ln -s -f /var/webbynode/bin/check_update /usr/bin/check_update
|
30
|
+
fi
|
11
31
|
|
12
|
-
|
13
|
-
|
32
|
+
/var/webbynode/bin/check_update
|
33
|
+
if [ $? -eq 1 ]; then exit 1; fi
|
14
34
|
EOS
|
15
35
|
|
16
36
|
updated == 1
|
data/lib/webbynode.rb
CHANGED
@@ -28,13 +28,17 @@ require File.join(File.dirname(__FILE__), 'webbynode', 'action_command')
|
|
28
28
|
require File.join(File.dirname(__FILE__), 'webbynode', 'option')
|
29
29
|
require File.join(File.dirname(__FILE__), 'webbynode', 'parameter')
|
30
30
|
require File.join(File.dirname(__FILE__), 'webbynode', 'api_client')
|
31
|
+
require File.join(File.dirname(__FILE__), 'webbynode', 'manager_api_client')
|
32
|
+
require File.join(File.dirname(__FILE__), 'webbynode', 'manager2_api_client')
|
31
33
|
require File.join(File.dirname(__FILE__), 'webbynode', 'remote_executor')
|
32
34
|
require File.join(File.dirname(__FILE__), 'webbynode', 'notify')
|
33
35
|
require File.join(File.dirname(__FILE__), 'webbynode', 'updater')
|
34
36
|
require File.join(File.dirname(__FILE__), 'webbynode', 'trial')
|
35
37
|
require File.join(File.dirname(__FILE__), 'webbynode', 'taps')
|
36
38
|
require File.join(File.dirname(__FILE__), 'webbynode', 'properties')
|
39
|
+
require File.join(File.dirname(__FILE__), 'webbynode', 'version')
|
37
40
|
require File.join(File.dirname(__FILE__), 'webbynode', 'attribute_accessors')
|
41
|
+
require File.join(File.dirname(__FILE__), 'webbynode', 'models', 'webby')
|
38
42
|
require File.join(File.dirname(__FILE__), 'webbynode', 'engines', 'engine')
|
39
43
|
require File.join(File.dirname(__FILE__), 'webbynode', 'engines', 'rails')
|
40
44
|
require File.join(File.dirname(__FILE__), 'webbynode', 'engines', 'rails3')
|
@@ -71,15 +75,11 @@ require File.join(File.dirname(__FILE__), 'webbynode', 'commands', 'settings')
|
|
71
75
|
require File.join(File.dirname(__FILE__), 'webbynode', 'commands', 'authorize_root')
|
72
76
|
require File.join(File.dirname(__FILE__), 'webbynode', 'commands', 'console')
|
73
77
|
require File.join(File.dirname(__FILE__), 'webbynode', 'commands', 'logs')
|
74
|
-
require File.join(File.dirname(__FILE__), 'webbynode', 'commands', '
|
78
|
+
require File.join(File.dirname(__FILE__), 'webbynode', 'commands', 'docs')
|
75
79
|
require File.join(File.dirname(__FILE__), 'webbynode', 'commands', 'ssh')
|
76
80
|
require File.join(File.dirname(__FILE__), 'webbynode', 'commands', 'database')
|
77
81
|
require File.join(File.dirname(__FILE__), 'webbynode', 'application')
|
78
82
|
|
79
|
-
module Webbynode
|
80
|
-
VERSION = '1.0.5.2'
|
81
|
-
end
|
82
|
-
|
83
83
|
class Array
|
84
84
|
def to_phrase(last_join="and")
|
85
85
|
return "" if empty?
|
data/script/console
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# File: script/console
|
3
|
+
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
|
4
|
+
|
5
|
+
libs = " -r irb/completion"
|
6
|
+
# Perhaps use a console_lib to store any extra methods I may want available in the cosole
|
7
|
+
# libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
|
8
|
+
libs << " -r #{File.dirname(__FILE__) + '/../lib/wn.rb'}"
|
9
|
+
puts "Loading wn gem"
|
10
|
+
exec "#{irb} #{libs} --simple-prompt"
|
data/script/destroy
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/destroy'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Destroy.new.run(ARGV)
|
data/script/generate
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/generate'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Generate.new.run(ARGV)
|
@@ -0,0 +1,11 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Content-Type: application/json; charset=utf-8
|
3
|
+
X-UA-Compatible: IE=Edge
|
4
|
+
ETag: "6a2662ac2678cf53e8f82265a0b5fd38"
|
5
|
+
Cache-Control: max-age=0, private, must-revalidate
|
6
|
+
Set-Cookie: _manager2_session=BAh7B0kiD3Nlc3Npb25faWQGOgZFRkkiJTAwZTUzMTkxMWNiZTRjMDZkZmM3Y2I3ZmIwOGI3YjE0BjsAVEkiGXdhcmRlbi51c2VyLnVzZXIua2V5BjsAVFsISSIJVXNlcgY7AEZbBmkCpRMw--7e55b7f8163de49e85750ed2ef358b3c980b9cc2; path=/; HttpOnly
|
7
|
+
X-Request-Id: e9f835937eb6a1de4cd9968b1b7409ff
|
8
|
+
X-Runtime: 0.440043
|
9
|
+
Transfer-Encoding: chunked
|
10
|
+
|
11
|
+
[{"id":71,"hostname":"webby6203.webbyapp.com","description":"sample server","plan":"Webbybeta","plan_id":3,"plan_name":"Webbybeta","power":"on","status":"online","available":true,"node_name":"local-01","mainipaddress":"192.168.183.200","internal_ip":null,"ram":"536870912","bandwidth":"10737418240","disk":"5368709120","bandwidthused":"","diskused":779324,"ram_size":"512 MB","disk_size":"5 GB","bandwidth_size":"10 GB","disk_space":"760 MB / 5 GB (15%)","bandwidth_overview":"0 Bytes / 10 GB (0%)","used_bandwidth_percent":0.0,"price":"$0.99","template":"ubuntu-12.04-x86_64","templatename":"Ubuntu 12.04 64-bit","groups":["All"],"loader":"<span class=\"loader hidden\"><img alt=\"Loader\" src=\"/assets/loader.gif\" /></span>","public_ips":null},{"id":71,"hostname":"sandbox.webbyapp.com","description":"sample server","plan":"Webbybeta","plan_id":3,"plan_name":"Webbybeta","power":"on","status":"online","available":true,"node_name":"local-01","mainipaddress":"201.81.121.201","internal_ip":null,"ram":"536870912","bandwidth":"10737418240","disk":"5368709120","bandwidthused":"","diskused":779324,"ram_size":"512 MB","disk_size":"5 GB","bandwidth_size":"10 GB","disk_space":"760 MB / 5 GB (15%)","bandwidth_overview":"0 Bytes / 10 GB (0%)","used_bandwidth_percent":0.0,"price":"$0.99","template":"ubuntu-12.04-x86_64","templatename":"Ubuntu 12.04 64-bit","groups":["All"],"loader":"<span class=\"loader hidden\"><img alt=\"Loader\" src=\"/assets/loader.gif\" /></span>","public_ips":null}]
|