plesk_kit 1.0.5 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/app/assets/javascripts/plesk_kit/application.js +15 -0
- data/app/assets/javascripts/plesk_kit/customer_accounts.js +2 -0
- data/app/assets/javascripts/plesk_kit/customers.js +2 -0
- data/app/assets/javascripts/plesk_kit/reseller_accounts.js +2 -0
- data/app/assets/javascripts/plesk_kit/servers.js +2 -0
- data/app/assets/javascripts/plesk_kit/subscriptions.js +2 -0
- data/app/assets/stylesheets/plesk_kit/application.css +13 -0
- data/app/assets/stylesheets/plesk_kit/customer_accounts.css +4 -0
- data/app/assets/stylesheets/plesk_kit/customers.css +4 -0
- data/app/assets/stylesheets/plesk_kit/reseller_accounts.css +4 -0
- data/app/assets/stylesheets/plesk_kit/servers.css +4 -0
- data/app/assets/stylesheets/plesk_kit/subscriptions.css +4 -0
- data/app/assets/stylesheets/scaffold.css +56 -0
- data/app/controllers/plesk_kit/application_controller.rb +4 -0
- data/app/controllers/plesk_kit/customer_accounts_controller.rb +87 -0
- data/app/controllers/plesk_kit/reseller_accounts_controller.rb +87 -0
- data/app/controllers/plesk_kit/servers_controller.rb +87 -0
- data/app/controllers/plesk_kit/subscriptions_controller.rb +87 -0
- data/app/helpers/plesk_kit/application_helper.rb +4 -0
- data/app/helpers/plesk_kit/customer_accounts_helper.rb +4 -0
- data/app/helpers/plesk_kit/reseller_accounts_helper.rb +4 -0
- data/app/helpers/plesk_kit/servers_helper.rb +4 -0
- data/app/helpers/plesk_kit/subscriptions_helper.rb +4 -0
- data/app/models/plesk_kit/client.rb +25 -0
- data/app/models/plesk_kit/communicator.rb +55 -0
- data/app/models/plesk_kit/customer_account.rb +70 -0
- data/app/models/plesk_kit/reseller_account.rb +72 -0
- data/app/models/plesk_kit/server.rb +30 -0
- data/app/models/plesk_kit/service_plan.rb +359 -0
- data/app/models/plesk_kit/subscription.rb +95 -0
- data/app/views/layouts/plesk_kit/application.html.erb +14 -0
- data/app/views/plesk_kit/customer_accounts/_form.html.erb +33 -0
- data/app/views/plesk_kit/customer_accounts/edit.html.erb +6 -0
- data/app/views/plesk_kit/customer_accounts/index.html.erb +29 -0
- data/app/views/plesk_kit/customer_accounts/new.html.erb +5 -0
- data/app/views/plesk_kit/customer_accounts/show.html.erb +25 -0
- data/app/views/plesk_kit/reseller_accounts/_form.html.erb +33 -0
- data/app/views/plesk_kit/reseller_accounts/edit.html.erb +6 -0
- data/app/views/plesk_kit/reseller_accounts/index.html.erb +29 -0
- data/app/views/plesk_kit/reseller_accounts/new.html.erb +5 -0
- data/app/views/plesk_kit/reseller_accounts/show.html.erb +25 -0
- data/app/views/plesk_kit/servers/_form.html.erb +37 -0
- data/app/views/plesk_kit/servers/edit.html.erb +6 -0
- data/app/views/plesk_kit/servers/index.html.erb +31 -0
- data/app/views/plesk_kit/servers/new.html.erb +5 -0
- data/app/views/plesk_kit/servers/show.html.erb +30 -0
- data/app/views/plesk_kit/subscriptions/_form.html.erb +49 -0
- data/app/views/plesk_kit/subscriptions/edit.html.erb +6 -0
- data/app/views/plesk_kit/subscriptions/index.html.erb +33 -0
- data/app/views/plesk_kit/subscriptions/new.html.erb +5 -0
- data/app/views/plesk_kit/subscriptions/show.html.erb +35 -0
- data/config/routes.rb +8 -0
- data/db/migrate/20130906033658_create_plesk_kit_customer_accounts.rb +14 -0
- data/db/migrate/20130906033745_create_plesk_kit_reseller_accounts.rb +15 -0
- data/db/migrate/20130906034225_create_plesk_kit_subscriptions.rb +16 -0
- data/db/migrate/20130906040817_create_plesk_kit_servers.rb +13 -0
- data/db/migrate/20130917012645_create_plesk_kit_service_plans.rb +13 -0
- data/db/migrate/20130925025125_add_platform_to_customer_account.rb +5 -0
- data/db/migrate/20130925025132_add_platform_to_reseller_account.rb +5 -0
- data/lib/plesk_kit/engine.rb +23 -0
- data/lib/plesk_kit/version.rb +3 -0
- data/lib/plesk_kit.rb +4 -0
- data/lib/tasks/plesk_kit_tasks.rake +4 -0
- data/test/dummy/README.rdoc +261 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +15 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/config/application.rb +59 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +37 -0
- data/test/dummy/config/environments/production.rb +67 -0
- data/test/dummy/config/environments/test.rb +37 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +15 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +4 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/migrate/20130906035255_create_plesk_kit_customer_accounts.plesk_kit.rb +13 -0
- data/test/dummy/db/migrate/20130906035256_create_plesk_kit_reseller_accounts.plesk_kit.rb +13 -0
- data/test/dummy/db/migrate/20130906035257_create_plesk_kit_subscriptions.plesk_kit.rb +17 -0
- data/test/dummy/db/migrate/20130906040830_create_plesk_kit_servers.plesk_kit.rb +14 -0
- data/test/dummy/db/migrate/20130917020158_create_plesk_kit_service_plans.plesk_kit.rb +14 -0
- data/test/dummy/db/schema.rb +82 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +9422 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +25 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/dummy/tmp/cache/assets/C5D/AF0/sprockets%2Faa100860897bd469c74972020e9d6966 +0 -0
- data/test/dummy/tmp/cache/assets/C83/800/sprockets%2F0892f1bdb69d260331b7b414298969c1 +0 -0
- data/test/dummy/tmp/cache/assets/C8A/850/sprockets%2F8729404d8f18dcc24e0523d37801589e +0 -0
- data/test/dummy/tmp/cache/assets/CC2/EF0/sprockets%2F756af5df20241589c464741d971fd7d8 +0 -0
- data/test/dummy/tmp/cache/assets/CC4/B50/sprockets%2F34e848818d05961fdc8c6c275e16629b +0 -0
- data/test/dummy/tmp/cache/assets/CD8/370/sprockets%2F357970feca3ac29060c1e3861e2c0953 +0 -0
- data/test/dummy/tmp/cache/assets/CE0/340/sprockets%2F4b6f8f760b2a1789f60289271d20c0be +0 -0
- data/test/dummy/tmp/cache/assets/CED/DE0/sprockets%2F18595c4734c4d7582dee3ae35b079a49 +0 -0
- data/test/dummy/tmp/cache/assets/CEE/F00/sprockets%2F891ac2c44b3be23865e990924a995fe2 +0 -0
- data/test/dummy/tmp/cache/assets/D10/EC0/sprockets%2F73e40114523e8419fcd0efa71d597c5d +0 -0
- data/test/dummy/tmp/cache/assets/D11/AE0/sprockets%2Fa1a95d724723a8f11e9037e8d2b28a8f +0 -0
- data/test/dummy/tmp/cache/assets/D13/380/sprockets%2F354af7b9709615f6f10e77d7e1b2da15 +0 -0
- data/test/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/test/dummy/tmp/cache/assets/D33/4D0/sprockets%2F14f2359cdf393c5e0b6401e233bb2ef5 +0 -0
- data/test/dummy/tmp/cache/assets/D3B/BF0/sprockets%2F3b7fb545a51edee1b772b818b2424d56 +0 -0
- data/test/dummy/tmp/cache/assets/D3C/B20/sprockets%2F1927fcaeaf1d200dab53e55b86526939 +0 -0
- data/test/dummy/tmp/cache/assets/D3F/2C0/sprockets%2F1ada6cc19aa84bf00164875127ef689e +0 -0
- data/test/dummy/tmp/cache/assets/D44/140/sprockets%2F341e589bb22dea2848665b989b2ba3ea +0 -0
- data/test/dummy/tmp/cache/assets/D4A/700/sprockets%2Fd56d83b8bbc98f0ce23f6263ff796020 +0 -0
- data/test/dummy/tmp/cache/assets/D4E/1B0/sprockets%2Ff7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/test/dummy/tmp/cache/assets/D51/190/sprockets%2F2a28b96857a9e16a74ee9dde52903dc7 +0 -0
- data/test/dummy/tmp/cache/assets/D51/610/sprockets%2F34de6f511191ffa00431d50cb5b31eac +0 -0
- data/test/dummy/tmp/cache/assets/D5A/EA0/sprockets%2Fd771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/test/dummy/tmp/cache/assets/D62/7B0/sprockets%2F39cdc1f2f8021136f2034ac5a9dab7f6 +0 -0
- data/test/dummy/tmp/cache/assets/D78/5D0/sprockets%2Feb7a1f999039a6136d9cfe25222fdcd5 +0 -0
- data/test/dummy/tmp/cache/assets/D7A/A30/sprockets%2F7e54a37cfb268f56b4c49b9f02029bff +0 -0
- data/test/dummy/tmp/cache/assets/D98/A30/sprockets%2Fd3cd57a8fade5aef376036123c5e11d6 +0 -0
- data/test/dummy/tmp/cache/assets/DA6/B80/sprockets%2F3fea63c0c7e19aae37d6037cd9d987e0 +0 -0
- data/test/dummy/tmp/cache/assets/DBA/730/sprockets%2F182cd97bf96da9ad7f037dcda77e8965 +0 -0
- data/test/dummy/tmp/cache/assets/DDC/400/sprockets%2Fcffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/test/dummy/tmp/cache/assets/DF9/B80/sprockets%2Fe87d27fca0c65097c5b652becc1eec0b +0 -0
- data/test/dummy/tmp/cache/assets/DFA/E90/sprockets%2F1fc47d21f6a426ae1e5d7b1dc9b39dbf +0 -0
- data/test/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/dummy/tmp/cache/assets/E28/3B0/sprockets%2Fce7fac4e9b4c46afa942e091b54c6aab +0 -0
- data/test/dummy/tmp/cache/assets/E3D/360/sprockets%2F19c6fbcf6aaed23dce100b1c1b2b0b8c +0 -0
- data/test/dummy/tmp/cache/assets/E89/270/sprockets%2F1bf1ee2ecfe1c679faf4002f4ea8bece +0 -0
- data/test/fixtures/plesk_kit/customer_accounts.yml +13 -0
- data/test/fixtures/plesk_kit/customers.yml +7 -0
- data/test/fixtures/plesk_kit/reseller_accounts.yml +13 -0
- data/test/fixtures/plesk_kit/servers.yml +15 -0
- data/test/fixtures/plesk_kit/service_plans.yml +13 -0
- data/test/fixtures/plesk_kit/subscriptions.yml +17 -0
- data/test/fixtures/plesk_kit/webspaces.yml +11 -0
- data/test/functional/plesk_kit/customer_accounts_controller_test.rb +51 -0
- data/test/functional/plesk_kit/customers_controller_test.rb +51 -0
- data/test/functional/plesk_kit/reseller_accounts_controller_test.rb +51 -0
- data/test/functional/plesk_kit/servers_controller_test.rb +51 -0
- data/test/functional/plesk_kit/subscriptions_controller_test.rb +51 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/plesk_kit_test.rb +7 -0
- data/test/test_helper.rb +15 -0
- data/test/unit/helpers/plesk_kit/customer_accounts_helper_test.rb +6 -0
- data/test/unit/helpers/plesk_kit/customers_helper_test.rb +6 -0
- data/test/unit/helpers/plesk_kit/reseller_accounts_helper_test.rb +6 -0
- data/test/unit/helpers/plesk_kit/servers_helper_test.rb +6 -0
- data/test/unit/helpers/plesk_kit/subscriptions_helper_test.rb +6 -0
- data/test/unit/plesk_kit/customer_account_test.rb +9 -0
- data/test/unit/plesk_kit/customer_test.rb +9 -0
- data/test/unit/plesk_kit/reseller_account_test.rb +9 -0
- data/test/unit/plesk_kit/server_test.rb +9 -0
- data/test/unit/plesk_kit/service_plan_test.rb +9 -0
- data/test/unit/plesk_kit/subscription_test.rb +9 -0
- data/test/unit/plesk_kit/webspace_test.rb +9 -0
- metadata +270 -13
@@ -0,0 +1,70 @@
|
|
1
|
+
module PleskKit
|
2
|
+
class CustomerAccount < ActiveRecord::Base
|
3
|
+
attr_accessible :cname, :login, :passwd, :pname, :server_id # TODO add plesk_id
|
4
|
+
has_many :subscriptions
|
5
|
+
belongs_to :server
|
6
|
+
validate :uniqueness_of_login_across_accounts
|
7
|
+
before_create :provision_in_plesk
|
8
|
+
|
9
|
+
def provision_in_plesk
|
10
|
+
PleskKit::Communicator.pack_and_play_with_customer_or_reseller self
|
11
|
+
true
|
12
|
+
end
|
13
|
+
|
14
|
+
# # #
|
15
|
+
# Methods for sending brand new customer account to Plesk
|
16
|
+
# # #
|
17
|
+
|
18
|
+
# Creates Object & Packet
|
19
|
+
def pack_this shell
|
20
|
+
xml = shell
|
21
|
+
xml.instruct!
|
22
|
+
xml.packet(:version => '1.6.3.5') {
|
23
|
+
xml.customer {
|
24
|
+
xml.add{
|
25
|
+
xml.gen_info{
|
26
|
+
xml.cname(self.cname)
|
27
|
+
xml.pname(self.pname)
|
28
|
+
xml.login(self.login)
|
29
|
+
xml.passwd(self.passwd)
|
30
|
+
#xml.status(status ? 0 : 1)
|
31
|
+
#xml.phone(phone)
|
32
|
+
#xml.fax(fax)
|
33
|
+
#xml.address(address)
|
34
|
+
#xml.city(city)
|
35
|
+
#xml.state(state)
|
36
|
+
#xml.pcode(pcode)
|
37
|
+
#xml.country(country)
|
38
|
+
}
|
39
|
+
}
|
40
|
+
}
|
41
|
+
}
|
42
|
+
return xml.target!
|
43
|
+
end
|
44
|
+
|
45
|
+
def analyse response_string, server_id
|
46
|
+
xml = REXML::Document.new(response_string)
|
47
|
+
status = xml.root.elements['//status'].text if xml.root.elements['//status'].present?
|
48
|
+
if status == "error"
|
49
|
+
code = xml.root.elements['//errcode'].text
|
50
|
+
message = xml.root.elements['//errtext'].text
|
51
|
+
raise "#{code}: #{message}"
|
52
|
+
else
|
53
|
+
plesk_id = xml.root.elements['//id'].text if xml.root.elements['//id'].present?
|
54
|
+
self.server_id = server_id
|
55
|
+
end
|
56
|
+
#self.save
|
57
|
+
return self # TODO save plesk_id
|
58
|
+
end
|
59
|
+
|
60
|
+
private
|
61
|
+
def uniqueness_of_login_across_accounts
|
62
|
+
if PleskKit::CustomerAccount.find_by_login(self.login).present?
|
63
|
+
errors.add(:base, "Login is not unique across Uber Plesk accounts")
|
64
|
+
elsif PleskKit::ResellerAccount.find_by_login(self.login).present?
|
65
|
+
errors.add(:base, "Login is not unique across Uber Plesk accounts")
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
module PleskKit
|
2
|
+
class ResellerAccount < ActiveRecord::Base
|
3
|
+
attr_accessible :cname, :login, :passwd, :pname, :plan_name, :service_plan_id, :server_id
|
4
|
+
validate :uniqueness_of_login_across_accounts
|
5
|
+
|
6
|
+
|
7
|
+
has_many :subscriptions
|
8
|
+
belongs_to :server
|
9
|
+
before_create :provision_in_plesk
|
10
|
+
|
11
|
+
def provision_in_plesk
|
12
|
+
PleskKit::Communicator.pack_and_play_with_customer_or_reseller self
|
13
|
+
end
|
14
|
+
|
15
|
+
# # #
|
16
|
+
# Methods for sending brand new customer account to Plesk
|
17
|
+
# # #
|
18
|
+
|
19
|
+
# Creates Object & Packet
|
20
|
+
def pack_this shell
|
21
|
+
xml = shell
|
22
|
+
xml.instruct!
|
23
|
+
xml.packet(:version => '1.6.3.5') {
|
24
|
+
xml.reseller {
|
25
|
+
xml.add{
|
26
|
+
xml.send(:'gen-info') {
|
27
|
+
xml.cname(self.cname)
|
28
|
+
xml.pname(self.pname)
|
29
|
+
xml.login(self.login)
|
30
|
+
xml.passwd(self.passwd)
|
31
|
+
#xml.status(status ? 0 : 1)
|
32
|
+
#xml.phone(phone)
|
33
|
+
#xml.fax(fax)
|
34
|
+
#xml.address(address)
|
35
|
+
#xml.city(city)
|
36
|
+
#xml.state(state)
|
37
|
+
#xml.pcode(pcode)
|
38
|
+
#xml.country(country)
|
39
|
+
}
|
40
|
+
xml.tag!('plan-name', self.plan_name)
|
41
|
+
}
|
42
|
+
}
|
43
|
+
}
|
44
|
+
return xml.target!
|
45
|
+
end
|
46
|
+
|
47
|
+
def analyse response_string, server_id
|
48
|
+
xml = REXML::Document.new(response_string)
|
49
|
+
status = xml.root.elements['//status'].text if xml.root.elements['//status'].present?
|
50
|
+
if status == "error"
|
51
|
+
code = xml.root.elements['//errcode'].text
|
52
|
+
message = xml.root.elements['//errtext'].text
|
53
|
+
raise "#{code}: #{message}"
|
54
|
+
else
|
55
|
+
plesk_id = xml.root.elements['//id'].text if xml.root.elements['//id'].present?
|
56
|
+
self.server_id = server_id
|
57
|
+
end
|
58
|
+
self.save
|
59
|
+
return self # TODO save plesk_id
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
private
|
64
|
+
def uniqueness_of_login_across_accounts
|
65
|
+
if PleskKit::CustomerAccount.find_by_login(self.login).present?
|
66
|
+
errors.add(:base, "Login is not unique across Uber Plesk accounts")
|
67
|
+
elsif PleskKit::ResellerAccount.find_by_login(self.login).present?
|
68
|
+
errors.add(:base, "Login is not unique across Uber Plesk accounts")
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module PleskKit
|
2
|
+
class Server < ActiveRecord::Base
|
3
|
+
attr_accessible :environment, :ghostname, :host, :password, :username
|
4
|
+
|
5
|
+
has_many :customer_accounts
|
6
|
+
has_many :reseller_accounts
|
7
|
+
|
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
|
+
|
10
|
+
|
11
|
+
def self.most_suitable_for_new_customer
|
12
|
+
servers = 'collect_ram_info_for_servers'
|
13
|
+
servers = 'sort_by_available_ram_descending(servers)'
|
14
|
+
until servers.blank?
|
15
|
+
if servers.first.starved_of_resources?
|
16
|
+
'remove from array of servers'
|
17
|
+
'throw error'
|
18
|
+
else
|
19
|
+
return s
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def starved_of_resources?
|
25
|
+
# TODO Check CPU, Diskspace, RAM. Return false if all met satisfactorily.
|
26
|
+
false
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,359 @@
|
|
1
|
+
module PleskKit
|
2
|
+
class ServicePlan < ActiveRecord::Base
|
3
|
+
attr_accessible :mailboxes, :domains, :name, :traffic, :storage
|
4
|
+
validates_presence_of :mailboxes, :domains, :name, :traffic, :storage
|
5
|
+
has_many :subscriptions
|
6
|
+
|
7
|
+
def find_or_push server
|
8
|
+
PleskKit::Communicator.get_service_plan self, server
|
9
|
+
end
|
10
|
+
|
11
|
+
def analyse response_string, server
|
12
|
+
xml = REXML::Document.new(response_string)
|
13
|
+
status = xml.root.elements['//status'].text if xml.root.elements['//status'].present?
|
14
|
+
puts response_string
|
15
|
+
if xml.root.elements['//get'].present?
|
16
|
+
if status == 'error'
|
17
|
+
PleskKit::Communicator.push_service_plan self, server
|
18
|
+
elsif status == 'ok'
|
19
|
+
return true
|
20
|
+
end
|
21
|
+
|
22
|
+
elsif xml.root.elements['//add'].present?
|
23
|
+
if status == "error"
|
24
|
+
code = xml.root.elements['//errcode'].text
|
25
|
+
message = xml.root.elements['//errtext'].text
|
26
|
+
raise "#{code}: #{message}"
|
27
|
+
elsif status == 'ok'
|
28
|
+
return true
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def build_xml_for_get shell
|
34
|
+
xml = shell
|
35
|
+
xml.instruct!
|
36
|
+
xml.packet(:version => '1.6.3.0') {
|
37
|
+
xml.tag!("service-plan") {
|
38
|
+
xml.get{
|
39
|
+
xml.filter{
|
40
|
+
xml.name("#{self.name}")
|
41
|
+
}
|
42
|
+
}
|
43
|
+
}
|
44
|
+
}
|
45
|
+
puts xml.target!
|
46
|
+
return xml.target!
|
47
|
+
end
|
48
|
+
|
49
|
+
def build_xml_for_add shell
|
50
|
+
xml = shell
|
51
|
+
xml.instruct!
|
52
|
+
xml.packet(:version => '1.6.3.0') {
|
53
|
+
xml.send(:"service-plan") {
|
54
|
+
xml.add{
|
55
|
+
xml.name("#{self.name.to_s}")
|
56
|
+
xml.mail{
|
57
|
+
xml.webmail('horde')
|
58
|
+
}
|
59
|
+
xml.limits{
|
60
|
+
xml.overuse('block')
|
61
|
+
|
62
|
+
xml.limit{
|
63
|
+
xml.name('max_site')
|
64
|
+
xml.value("#{self.domains.to_s}")
|
65
|
+
}
|
66
|
+
xml.limit{
|
67
|
+
xml.name('max_subdom')
|
68
|
+
xml.value('-1')
|
69
|
+
}
|
70
|
+
xml.limit{
|
71
|
+
xml.name('max_dom_aliases')
|
72
|
+
xml.value('-1')
|
73
|
+
}
|
74
|
+
xml.limit{
|
75
|
+
xml.name('disk_space')
|
76
|
+
xml.value("#{self.storage}") #10gb
|
77
|
+
}
|
78
|
+
xml.limit{
|
79
|
+
xml.name('disk_space_soft')
|
80
|
+
xml.value('0')
|
81
|
+
}
|
82
|
+
xml.limit{
|
83
|
+
xml.name('max_traffic')
|
84
|
+
xml.value("#{self.traffic.to_s}") # unlimited
|
85
|
+
}
|
86
|
+
xml.limit{
|
87
|
+
xml.name('max_traffic_soft')
|
88
|
+
xml.value('0')
|
89
|
+
}
|
90
|
+
xml.limit{
|
91
|
+
xml.name('max_wu')
|
92
|
+
xml.value('-1')
|
93
|
+
}
|
94
|
+
xml.limit{
|
95
|
+
xml.name('max_subftp_users')
|
96
|
+
xml.value('-1')
|
97
|
+
}
|
98
|
+
xml.limit{
|
99
|
+
xml.name('max_db')
|
100
|
+
xml.value('10')
|
101
|
+
}
|
102
|
+
xml.limit{
|
103
|
+
xml.name('max_box')
|
104
|
+
xml.value("#{self.mailboxes.to_s}") # mailboxes
|
105
|
+
}
|
106
|
+
xml.limit{
|
107
|
+
xml.name('mbox_quota')
|
108
|
+
xml.value('1073741824')
|
109
|
+
}
|
110
|
+
xml.limit{
|
111
|
+
xml.name('max_maillists')
|
112
|
+
xml.value('100')
|
113
|
+
}
|
114
|
+
xml.limit{
|
115
|
+
xml.name('max_webapps')
|
116
|
+
xml.value('0')
|
117
|
+
}
|
118
|
+
xml.limit{
|
119
|
+
xml.name('max_site_builder')
|
120
|
+
xml.value('1')
|
121
|
+
}
|
122
|
+
xml.limit{
|
123
|
+
xml.name('max_unity_mobile_sites')
|
124
|
+
xml.value('0')
|
125
|
+
}
|
126
|
+
xml.limit{
|
127
|
+
xml.name('expiration')
|
128
|
+
xml.value('-1')
|
129
|
+
}
|
130
|
+
xml.limit{
|
131
|
+
xml.name('upsell_site_builder')
|
132
|
+
xml.value('0')
|
133
|
+
}
|
134
|
+
|
135
|
+
}
|
136
|
+
xml.send(:"log-rotation"){
|
137
|
+
xml.on{
|
138
|
+
xml.send(:"log-condition"){
|
139
|
+
xml.tag!("log-bysize", "10485760")
|
140
|
+
}
|
141
|
+
xml.tag!("log-max-num-files", "10")
|
142
|
+
xml.tag!("log-compress", "true")
|
143
|
+
}
|
144
|
+
}
|
145
|
+
xml.preferences{
|
146
|
+
xml.stat('3')
|
147
|
+
xml.maillists('false')
|
148
|
+
xml.dns_zone_type('master')
|
149
|
+
}
|
150
|
+
xml.hosting{
|
151
|
+
xml.property{
|
152
|
+
xml.name('ssl')
|
153
|
+
xml.value('false')
|
154
|
+
}
|
155
|
+
xml.property{
|
156
|
+
xml.name('fp')
|
157
|
+
xml.value('false')
|
158
|
+
}
|
159
|
+
xml.property{
|
160
|
+
xml.name('fp_ssl')
|
161
|
+
xml.value('false')
|
162
|
+
}
|
163
|
+
xml.property{
|
164
|
+
xml.name('fp_auth')
|
165
|
+
xml.value('false')
|
166
|
+
}
|
167
|
+
xml.property{
|
168
|
+
xml.name('webstat')
|
169
|
+
xml.value('awstats')
|
170
|
+
}
|
171
|
+
xml.property{
|
172
|
+
xml.name('webstat_protected')
|
173
|
+
xml.value('true')
|
174
|
+
}
|
175
|
+
xml.property{
|
176
|
+
xml.name('wu_script')
|
177
|
+
xml.value('true')
|
178
|
+
}
|
179
|
+
xml.property{
|
180
|
+
xml.name('shell')
|
181
|
+
xml.value('/bin/false')
|
182
|
+
}
|
183
|
+
xml.property{
|
184
|
+
xml.name('ftp_quota')
|
185
|
+
xml.value('-1')
|
186
|
+
}
|
187
|
+
xml.property{
|
188
|
+
xml.name('php_handler_type')
|
189
|
+
xml.value('fastcgi')
|
190
|
+
}
|
191
|
+
xml.property{
|
192
|
+
xml.name('asp')
|
193
|
+
xml.value('false')
|
194
|
+
}
|
195
|
+
xml.property{
|
196
|
+
xml.name('ssi')
|
197
|
+
xml.value('false')
|
198
|
+
}
|
199
|
+
xml.property{
|
200
|
+
xml.name('php')
|
201
|
+
xml.value('true')
|
202
|
+
}
|
203
|
+
xml.property{
|
204
|
+
xml.name('cgi')
|
205
|
+
xml.value('true')
|
206
|
+
}
|
207
|
+
xml.property{
|
208
|
+
xml.name('perl')
|
209
|
+
xml.value('true')
|
210
|
+
}
|
211
|
+
xml.property{
|
212
|
+
xml.name('python')
|
213
|
+
xml.value('true')
|
214
|
+
}
|
215
|
+
xml.property{
|
216
|
+
xml.name('fastcgi')
|
217
|
+
xml.value('true')
|
218
|
+
}
|
219
|
+
xml.property{
|
220
|
+
xml.name('miva')
|
221
|
+
xml.value('false')
|
222
|
+
}
|
223
|
+
xml.property{
|
224
|
+
xml.name('coldfusion')
|
225
|
+
xml.value('false')
|
226
|
+
}
|
227
|
+
}
|
228
|
+
xml.performance{
|
229
|
+
xml.bandwidth('-1')
|
230
|
+
xml.max_connections('-1')
|
231
|
+
}
|
232
|
+
xml.permissions{
|
233
|
+
xml.permission{
|
234
|
+
xml.name('create_domains')
|
235
|
+
xml.value('true')
|
236
|
+
}
|
237
|
+
xml.permission{
|
238
|
+
xml.name('manage_phosting')
|
239
|
+
xml.value('false')
|
240
|
+
}
|
241
|
+
xml.permission{
|
242
|
+
xml.name('manage_php_settings')
|
243
|
+
xml.value('false')
|
244
|
+
}
|
245
|
+
xml.permission{
|
246
|
+
xml.name('manage_sh_access')
|
247
|
+
xml.value('false')
|
248
|
+
}
|
249
|
+
xml.permission{
|
250
|
+
xml.name('manage_not_chroot_shell')
|
251
|
+
xml.value('false')
|
252
|
+
}
|
253
|
+
xml.permission{
|
254
|
+
xml.name('manage_quota')
|
255
|
+
xml.value('false')
|
256
|
+
}
|
257
|
+
xml.permission{
|
258
|
+
xml.name('manage_subdomains')
|
259
|
+
xml.value('true')
|
260
|
+
}
|
261
|
+
xml.permission{
|
262
|
+
xml.name('manage_domain_aliases')
|
263
|
+
xml.value('false')
|
264
|
+
}
|
265
|
+
xml.permission{
|
266
|
+
xml.name('manage_log')
|
267
|
+
xml.value('true')
|
268
|
+
}
|
269
|
+
xml.permission{
|
270
|
+
xml.name('manage_anonftp')
|
271
|
+
xml.value('false')
|
272
|
+
}
|
273
|
+
xml.permission{
|
274
|
+
xml.name('manage_subftp')
|
275
|
+
xml.value('true')
|
276
|
+
}
|
277
|
+
xml.permission{
|
278
|
+
xml.name('manage_crontab')
|
279
|
+
xml.value('false')
|
280
|
+
}
|
281
|
+
xml.permission{
|
282
|
+
xml.name('manage_dns')
|
283
|
+
xml.value('true')
|
284
|
+
}
|
285
|
+
xml.permission{
|
286
|
+
xml.name('manage_webapps')
|
287
|
+
xml.value('false')
|
288
|
+
}
|
289
|
+
xml.permission{
|
290
|
+
xml.name('manage_webstat')
|
291
|
+
xml.value('true')
|
292
|
+
}
|
293
|
+
xml.permission{
|
294
|
+
xml.name('manage_mail_settings')
|
295
|
+
xml.value('true')
|
296
|
+
}
|
297
|
+
xml.permission{
|
298
|
+
xml.name('manage_maillists')
|
299
|
+
xml.value('true')
|
300
|
+
}
|
301
|
+
xml.permission{
|
302
|
+
xml.name('manage_spamfilter')
|
303
|
+
xml.value('true')
|
304
|
+
}
|
305
|
+
xml.permission{
|
306
|
+
xml.name('manage_virusfilter')
|
307
|
+
xml.value('true')
|
308
|
+
}
|
309
|
+
xml.permission{
|
310
|
+
xml.name('allow_local_backups')
|
311
|
+
xml.value('true')
|
312
|
+
}
|
313
|
+
xml.permission{
|
314
|
+
xml.name('allow_ftp_backups')
|
315
|
+
xml.value('true')
|
316
|
+
}
|
317
|
+
xml.permission{
|
318
|
+
xml.name('manage_performance')
|
319
|
+
xml.value('false')
|
320
|
+
}
|
321
|
+
xml.permission{
|
322
|
+
xml.name('select_db_server')
|
323
|
+
xml.value('false')
|
324
|
+
}
|
325
|
+
xml.permission{
|
326
|
+
xml.name('access_appcatalog')
|
327
|
+
xml.value('true')
|
328
|
+
}
|
329
|
+
xml.permission{
|
330
|
+
xml.name('allow_insecure_sites')
|
331
|
+
xml.value('true')
|
332
|
+
}
|
333
|
+
xml.permission{
|
334
|
+
xml.name('manage_website_maintenance')
|
335
|
+
xml.value('true')
|
336
|
+
}
|
337
|
+
xml.permission{
|
338
|
+
xml.name('manage_protected_dirs')
|
339
|
+
xml.value('true')
|
340
|
+
}
|
341
|
+
xml.permission{
|
342
|
+
xml.name('access_service_users')
|
343
|
+
xml.value('true')
|
344
|
+
}
|
345
|
+
xml.permission{
|
346
|
+
xml.name('allow_license_stubs')
|
347
|
+
xml.value('false')
|
348
|
+
}
|
349
|
+
}
|
350
|
+
}
|
351
|
+
}
|
352
|
+
}
|
353
|
+
puts xml.target!
|
354
|
+
return xml.target!
|
355
|
+
end
|
356
|
+
|
357
|
+
|
358
|
+
end
|
359
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
module PleskKit
|
2
|
+
class Subscription < ActiveRecord::Base
|
3
|
+
attr_accessible :ip_address, :name, :owner_id, :owner_login, :plan_name, :service_plan_id, :customer_account_id, :reseller_account_id
|
4
|
+
|
5
|
+
belongs_to :customer_account
|
6
|
+
belongs_to :reseller_account
|
7
|
+
belongs_to :service_plan
|
8
|
+
before_create :provision_in_plesk
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
def provision_in_plesk
|
13
|
+
|
14
|
+
account = (customer_account_id.present? ? customer_account : (reseller_account_id.present? ? reseller_account : raise(msg="no accounts?")))
|
15
|
+
plan = PleskKit::ServicePlan.find_by_name self.plan_name
|
16
|
+
self.service_plan_id = plan.id
|
17
|
+
if plan.find_or_push(account.server) == true
|
18
|
+
self.plan_name = self.plan_name
|
19
|
+
self.ip_address = account.server.host
|
20
|
+
self.owner_login = account.login
|
21
|
+
self.name = self.name
|
22
|
+
if account.class.to_s == 'PleskKit::ResellerAccount'
|
23
|
+
self.reseller_account_id = account.id
|
24
|
+
elsif account.class.to_s == 'PleskKit::CustomerAccount'
|
25
|
+
self.customer_account_id = account.id
|
26
|
+
end
|
27
|
+
guid = PleskKit::Communicator.pack_and_play_with_subscription self, account
|
28
|
+
PleskKit::Communicator.sync_subscription self, guid
|
29
|
+
self.id
|
30
|
+
else
|
31
|
+
return false
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def pack_this shell, customer
|
36
|
+
xml = shell
|
37
|
+
xml.instruct!
|
38
|
+
xml.packet(:version => '1.6.3.5') {
|
39
|
+
xml.webspace {
|
40
|
+
xml.add{
|
41
|
+
xml.gen_setup{
|
42
|
+
xml.name(self.name)
|
43
|
+
xml.tag! 'owner-login', self.owner_login
|
44
|
+
xml.ip_address(self.ip_address)
|
45
|
+
}
|
46
|
+
xml.hosting{
|
47
|
+
xml.vrt_hst{
|
48
|
+
xml.property{
|
49
|
+
xml.name('ftp_login')
|
50
|
+
xml.value("#{customer.login}#{rand(99).to_s}") #rand(36**8).to_s(36)
|
51
|
+
}
|
52
|
+
xml.property{
|
53
|
+
xml.name('ftp_password')
|
54
|
+
xml.value(customer.passwd)
|
55
|
+
}
|
56
|
+
xml.ip_address(self.ip_address)
|
57
|
+
}
|
58
|
+
}
|
59
|
+
xml.tag! 'plan-name', self.plan_name
|
60
|
+
}
|
61
|
+
}
|
62
|
+
}
|
63
|
+
puts xml.target!
|
64
|
+
return xml.target!
|
65
|
+
end
|
66
|
+
|
67
|
+
def sync_pack shell, sub_guid
|
68
|
+
xml = shell
|
69
|
+
xml.instruct!
|
70
|
+
xml.packet(:version => '1.6.3.5') {
|
71
|
+
xml.webspace{
|
72
|
+
xml.send(:"sync-subscription") {
|
73
|
+
xml.filter{
|
74
|
+
xml.guid(sub_guid)
|
75
|
+
}
|
76
|
+
}
|
77
|
+
}
|
78
|
+
}
|
79
|
+
end
|
80
|
+
|
81
|
+
def analyse response_string, customer = nil
|
82
|
+
xml = REXML::Document.new(response_string)
|
83
|
+
status = xml.root.elements['//status'].text if xml.root.elements['//status'].present?
|
84
|
+
if status == "error"
|
85
|
+
code = xml.root.elements['//errcode'].text
|
86
|
+
message = xml.root.elements['//errtext'].text
|
87
|
+
raise "#{code}: #{message}"
|
88
|
+
else
|
89
|
+
sub_guid = xml.root.elements['//guid'].text if xml.root.elements['//guid'].present?
|
90
|
+
end
|
91
|
+
return sub_guid || true # TODO save plesk_id? Probably not necessary as we have the customer login
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>PleskKit</title>
|
5
|
+
<%= stylesheet_link_tag "plesk_kit/application", :media => "all" %>
|
6
|
+
<%= javascript_include_tag "plesk_kit/application" %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
@@ -0,0 +1,33 @@
|
|
1
|
+
<%= form_for(@customer_account) do |f| %>
|
2
|
+
<% if @customer_account.errors.any? %>
|
3
|
+
<div id="error_explanation">
|
4
|
+
<h2><%= pluralize(@customer_account.errors.count, "error") %> prohibited this customer_account from being saved:</h2>
|
5
|
+
|
6
|
+
<ul>
|
7
|
+
<% @customer_account.errors.full_messages.each do |msg| %>
|
8
|
+
<li><%= msg %></li>
|
9
|
+
<% end %>
|
10
|
+
</ul>
|
11
|
+
</div>
|
12
|
+
<% end %>
|
13
|
+
|
14
|
+
<div class="field">
|
15
|
+
<%= f.label :cname %><br />
|
16
|
+
<%= f.text_field :cname %>
|
17
|
+
</div>
|
18
|
+
<div class="field">
|
19
|
+
<%= f.label :pname %><br />
|
20
|
+
<%= f.text_field :pname %>
|
21
|
+
</div>
|
22
|
+
<div class="field">
|
23
|
+
<%= f.label :login %><br />
|
24
|
+
<%= f.text_field :login %>
|
25
|
+
</div>
|
26
|
+
<div class="field">
|
27
|
+
<%= f.label :passwd %><br />
|
28
|
+
<%= f.text_field :passwd %>
|
29
|
+
</div>
|
30
|
+
<div class="actions">
|
31
|
+
<%= f.submit %>
|
32
|
+
</div>
|
33
|
+
<% end %>
|