plesk_kit 1.0.9 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/app/models/plesk_kit/communicator.rb +10 -5
- data/app/models/plesk_kit/server.rb +34 -12
- data/app/models/plesk_kit/subscription.rb +2 -2
- data/lib/plesk_kit/version.rb +1 -1
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/migrate/20130925230903_add_platform_to_customer_account.plesk_kit.rb +6 -0
- data/test/dummy/db/migrate/20130925230904_add_platform_to_reseller_account.plesk_kit.rb +6 -0
- data/test/dummy/db/migrate/20130925230905_add_platform_to_server.plesk_kit.rb +6 -0
- data/test/dummy/db/schema.rb +4 -1
- data/test/dummy/log/development.log +36 -0
- metadata +7 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZTQ2MWY4YTVlZDI0MDhhODRmODNhZTU1ZDRmMzczNmMwYzc3NDk4Yw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YzJhNzhhYzkyMjljOTZiZDE0ZjU0NGM0NGE4MDM5ZThhOGQ4OTdhMA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZDk5MDRkMTZhMzAwZTA3ZTM3MTJlYjM5M2MyOTRjZjhjNTA3YmVmMGZhNTgw
|
10
|
+
NTZmZDFlNmQ4MDYzYWFiZTExZTRmOTE4ZGE0ODQ3NTlhOGM0MTVlODVkYzU5
|
11
|
+
NzI5NmQ3NTY1ZjQ3ODFkNmU4ZjZiOTQ4ZDFhYjgwY2VkODIwYjI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
N2M2NjRlNmViNDcwZDU5NzYzZjUxMTE3OTlhYzlhNGJiODljOWViMGYxNDAz
|
14
|
+
MDZlNTg2NGY5ZDljOWUyYjlkODVmYmI4M2FkZjQ3ZGY5MmJkN2FiNzZjMTJh
|
15
|
+
NzQzYmY4NjdlZDQyYmExZjFhNzkzNmQ4YzZlOWM0OTYwMDZiY2E=
|
@@ -11,7 +11,7 @@ module PleskKit
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def self.pack_and_play_with_customer_or_reseller account
|
14
|
-
server = PleskKit::Server.
|
14
|
+
server = PleskKit::Server.most_suitable_for_new_customer(account.platform)
|
15
15
|
packet = account.pack_this shell
|
16
16
|
response = transportation_for packet,server
|
17
17
|
account.analyse response[0], server.id
|
@@ -24,27 +24,32 @@ module PleskKit
|
|
24
24
|
subscription.analyse response[0],customer_account
|
25
25
|
end
|
26
26
|
|
27
|
-
def self.sync_subscription sub, sub_guid
|
28
|
-
server =
|
27
|
+
def self.sync_subscription sub, sub_guid, customer_account
|
28
|
+
server = customer_account.server
|
29
29
|
packet = sub.sync_pack shell,sub_guid
|
30
30
|
response = transportation_for packet,server
|
31
31
|
sub.analyse response[0]
|
32
32
|
end
|
33
33
|
|
34
34
|
def self.get_service_plan service_plan, server
|
35
|
-
server = PleskKit::Server.first
|
36
35
|
packet = service_plan.build_xml_for_get shell
|
37
36
|
response = transportation_for packet, server
|
38
37
|
service_plan.analyse response[0], server
|
39
38
|
end
|
40
39
|
|
41
40
|
def self.push_service_plan service_plan, server
|
42
|
-
server = PleskKit::Server.first
|
43
41
|
packet = service_plan.build_xml_for_add shell
|
44
42
|
response = transportation_for packet, server
|
45
43
|
service_plan.analyse response[0], server
|
46
44
|
end
|
47
45
|
|
46
|
+
def self.get_server_stats server
|
47
|
+
packet = server.pack_this shell
|
48
|
+
response = transportation_for(packet,server)
|
49
|
+
server.analyse_this response[0]
|
50
|
+
#response[0]
|
51
|
+
end
|
52
|
+
|
48
53
|
# Sends packet to plesk
|
49
54
|
def self.transportation_for packet, server
|
50
55
|
c = PleskKit::Client.new(server)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module PleskKit
|
2
2
|
class Server < ActiveRecord::Base
|
3
|
-
attr_accessible :environment, :ghostname, :host, :password, :username
|
3
|
+
attr_accessible :environment, :ghostname, :host, :password, :username, :platform
|
4
4
|
|
5
5
|
has_many :customer_accounts
|
6
6
|
has_many :reseller_accounts
|
@@ -8,17 +8,12 @@ module PleskKit
|
|
8
8
|
validates :environment, :host, :username, :password, :presence => {:message => 'Cannot be blank! Requires, at minimum, environment (dev,staging,production), host without a port, username, and password'}
|
9
9
|
|
10
10
|
|
11
|
-
def self.most_suitable_for_new_customer
|
12
|
-
|
13
|
-
servers =
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
'throw error'
|
18
|
-
else
|
19
|
-
return s
|
20
|
-
end
|
21
|
-
end
|
11
|
+
def self.most_suitable_for_new_customer(platform)
|
12
|
+
server_list = PleskKit::Server.where(:environment => Rails.env.to_s, :platform => platform)
|
13
|
+
servers = []
|
14
|
+
server_list.each { |s| servers << PleskKit::Communicator.get_server_stats(server=s) }
|
15
|
+
servers = servers.sort_by { |hsh| hsh[:ram] }.reverse
|
16
|
+
PleskKit::Server.find servers.first[:id]
|
22
17
|
end
|
23
18
|
|
24
19
|
def starved_of_resources?
|
@@ -26,5 +21,32 @@ module PleskKit
|
|
26
21
|
false
|
27
22
|
end
|
28
23
|
|
24
|
+
def pack_this shell
|
25
|
+
xml = shell
|
26
|
+
xml.instruct!
|
27
|
+
xml.packet(:version => '1.6.3.5') {
|
28
|
+
xml.server{
|
29
|
+
xml.get{
|
30
|
+
xml.stat()
|
31
|
+
}
|
32
|
+
}
|
33
|
+
}
|
34
|
+
return xml.target!
|
35
|
+
end
|
36
|
+
|
37
|
+
def analyse_this response
|
38
|
+
xml = REXML::Document.new(response)
|
39
|
+
free_ram = cpu = nil
|
40
|
+
ram = xml.root.elements['//mem']
|
41
|
+
ram.each do |r|
|
42
|
+
if r.name == 'free'
|
43
|
+
free_ram = r.text
|
44
|
+
end
|
45
|
+
end
|
46
|
+
cpu = xml.root.elements['//l15'].text
|
47
|
+
return {id:self.id,ram:free_ram,cpu:cpu}
|
48
|
+
end
|
49
|
+
|
50
|
+
|
29
51
|
end
|
30
52
|
end
|
@@ -25,7 +25,7 @@ module PleskKit
|
|
25
25
|
self.customer_account_id = account.id
|
26
26
|
end
|
27
27
|
guid = PleskKit::Communicator.pack_and_play_with_subscription self, account
|
28
|
-
PleskKit::Communicator.sync_subscription self, guid
|
28
|
+
PleskKit::Communicator.sync_subscription self, guid, account
|
29
29
|
self.id
|
30
30
|
else
|
31
31
|
return false
|
@@ -47,7 +47,7 @@ module PleskKit
|
|
47
47
|
xml.vrt_hst{
|
48
48
|
xml.property{
|
49
49
|
xml.name('ftp_login')
|
50
|
-
xml.value("#{customer.login}#{rand(99).to_s}") #rand(36**8).to_s(36)
|
50
|
+
xml.value("#{customer.login}#{rand(99).to_s}#{(0...2).map { (65 + rand(26)).chr }.join}") #rand(36**8).to_s(36)
|
51
51
|
}
|
52
52
|
xml.property{
|
53
53
|
xml.name('ftp_password')
|
data/lib/plesk_kit/version.rb
CHANGED
Binary file
|
data/test/dummy/db/schema.rb
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
#
|
12
12
|
# It's strongly recommended to check this file into your version control system.
|
13
13
|
|
14
|
-
ActiveRecord::Schema.define(:version =>
|
14
|
+
ActiveRecord::Schema.define(:version => 20130925230905) do
|
15
15
|
|
16
16
|
create_table "plesk_kit_customer_accounts", :force => true do |t|
|
17
17
|
t.string "cname"
|
@@ -21,6 +21,7 @@ ActiveRecord::Schema.define(:version => 20130917020158) do
|
|
21
21
|
t.integer "server_id"
|
22
22
|
t.datetime "created_at", :null => false
|
23
23
|
t.datetime "updated_at", :null => false
|
24
|
+
t.string "platform"
|
24
25
|
end
|
25
26
|
|
26
27
|
create_table "plesk_kit_customers", :force => true do |t|
|
@@ -39,6 +40,7 @@ ActiveRecord::Schema.define(:version => 20130917020158) do
|
|
39
40
|
t.string "plan_name"
|
40
41
|
t.datetime "created_at", :null => false
|
41
42
|
t.datetime "updated_at", :null => false
|
43
|
+
t.string "platform"
|
42
44
|
end
|
43
45
|
|
44
46
|
create_table "plesk_kit_servers", :force => true do |t|
|
@@ -49,6 +51,7 @@ ActiveRecord::Schema.define(:version => 20130917020158) do
|
|
49
51
|
t.string "ghostname"
|
50
52
|
t.datetime "created_at", :null => false
|
51
53
|
t.datetime "updated_at", :null => false
|
54
|
+
t.string "platform"
|
52
55
|
end
|
53
56
|
|
54
57
|
create_table "plesk_kit_service_plans", :force => true do |t|
|
@@ -9420,3 +9420,39 @@ Connecting to database specified by database.yml
|
|
9420
9420
|
Connecting to database specified by database.yml
|
9421
9421
|
Connecting to database specified by database.yml
|
9422
9422
|
Connecting to database specified by database.yml
|
9423
|
+
Connecting to database specified by database.yml
|
9424
|
+
Connecting to database specified by database.yml
|
9425
|
+
Connecting to database specified by database.yml
|
9426
|
+
Connecting to database specified by database.yml
|
9427
|
+
Connecting to database specified by database.yml
|
9428
|
+
Connecting to database specified by database.yml
|
9429
|
+
Connecting to database specified by database.yml
|
9430
|
+
Connecting to database specified by database.yml
|
9431
|
+
Connecting to database specified by database.yml
|
9432
|
+
Connecting to database specified by database.yml
|
9433
|
+
Connecting to database specified by database.yml
|
9434
|
+
[1m[36m (18.6ms)[0m [1mSELECT "schema_migrations"."version" FROM "schema_migrations" [0m
|
9435
|
+
Migrating to CreatePleskKitCustomerAccounts (20130906035255)
|
9436
|
+
Migrating to CreatePleskKitResellerAccounts (20130906035256)
|
9437
|
+
Migrating to CreatePleskKitSubscriptions (20130906035257)
|
9438
|
+
Migrating to CreatePleskKitServers (20130906040830)
|
9439
|
+
Migrating to CreatePleskKitServicePlans (20130917020158)
|
9440
|
+
Migrating to AddPlatformToCustomerAccount (20130925230903)
|
9441
|
+
[1m[35m (0.0ms)[0m select sqlite_version(*)
|
9442
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
9443
|
+
[1m[35m (0.3ms)[0m ALTER TABLE "plesk_kit_customer_accounts" ADD "platform" varchar(255)
|
9444
|
+
[1m[36m (0.1ms)[0m [1mINSERT INTO "schema_migrations" ("version") VALUES ('20130925230903')[0m
|
9445
|
+
[1m[35m (1.6ms)[0m commit transaction
|
9446
|
+
Migrating to AddPlatformToResellerAccount (20130925230904)
|
9447
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
9448
|
+
[1m[35m (0.3ms)[0m ALTER TABLE "plesk_kit_reseller_accounts" ADD "platform" varchar(255)
|
9449
|
+
[1m[36m (0.1ms)[0m [1mINSERT INTO "schema_migrations" ("version") VALUES ('20130925230904')[0m
|
9450
|
+
[1m[35m (1.7ms)[0m commit transaction
|
9451
|
+
Migrating to AddPlatformToServer (20130925230905)
|
9452
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
9453
|
+
[1m[35m (0.2ms)[0m ALTER TABLE "plesk_kit_servers" ADD "platform" varchar(255)
|
9454
|
+
[1m[36m (0.1ms)[0m [1mINSERT INTO "schema_migrations" ("version") VALUES ('20130925230905')[0m
|
9455
|
+
[1m[35m (1.5ms)[0m commit transaction
|
9456
|
+
[1m[36m (0.1ms)[0m [1mSELECT "schema_migrations"."version" FROM "schema_migrations" [0m
|
9457
|
+
Connecting to database specified by database.yml
|
9458
|
+
Connecting to database specified by database.yml
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: plesk_kit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dionne Saunders
|
@@ -136,6 +136,9 @@ files:
|
|
136
136
|
- test/dummy/db/migrate/20130906035257_create_plesk_kit_subscriptions.plesk_kit.rb
|
137
137
|
- test/dummy/db/migrate/20130906040830_create_plesk_kit_servers.plesk_kit.rb
|
138
138
|
- test/dummy/db/migrate/20130917020158_create_plesk_kit_service_plans.plesk_kit.rb
|
139
|
+
- test/dummy/db/migrate/20130925230903_add_platform_to_customer_account.plesk_kit.rb
|
140
|
+
- test/dummy/db/migrate/20130925230904_add_platform_to_reseller_account.plesk_kit.rb
|
141
|
+
- test/dummy/db/migrate/20130925230905_add_platform_to_server.plesk_kit.rb
|
139
142
|
- test/dummy/db/schema.rb
|
140
143
|
- test/dummy/db/test.sqlite3
|
141
144
|
- test/dummy/log/development.log
|
@@ -261,6 +264,9 @@ test_files:
|
|
261
264
|
- test/dummy/db/migrate/20130906035257_create_plesk_kit_subscriptions.plesk_kit.rb
|
262
265
|
- test/dummy/db/migrate/20130906040830_create_plesk_kit_servers.plesk_kit.rb
|
263
266
|
- test/dummy/db/migrate/20130917020158_create_plesk_kit_service_plans.plesk_kit.rb
|
267
|
+
- test/dummy/db/migrate/20130925230903_add_platform_to_customer_account.plesk_kit.rb
|
268
|
+
- test/dummy/db/migrate/20130925230904_add_platform_to_reseller_account.plesk_kit.rb
|
269
|
+
- test/dummy/db/migrate/20130925230905_add_platform_to_server.plesk_kit.rb
|
264
270
|
- test/dummy/db/schema.rb
|
265
271
|
- test/dummy/db/test.sqlite3
|
266
272
|
- test/dummy/log/development.log
|