Class: PleskKit::Client

Inherits:
Object
  • Object
show all
Defined in:
app/models/plesk_kit/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(server) ⇒ Client

Returns a new instance of Client.



4
5
6
# File 'app/models/plesk_kit/client.rb', line 4

def initialize(server)
  @host, @user, @pass, @timeout = server.host, server.username, server.password, 30
end

Instance Attribute Details

#hostObject

Returns the value of attribute host.



3
4
5
# File 'app/models/plesk_kit/client.rb', line 3

def host
  @host
end

#passObject

Returns the value of attribute pass.



3
4
5
# File 'app/models/plesk_kit/client.rb', line 3

def pass
  @pass
end

#rpc_versionObject

Returns the value of attribute rpc_version.



3
4
5
# File 'app/models/plesk_kit/client.rb', line 3

def rpc_version
  @rpc_version
end

#timeoutObject

Returns the value of attribute timeout.



3
4
5
# File 'app/models/plesk_kit/client.rb', line 3

def timeout
  @timeout
end

#userObject

Returns the value of attribute user.



3
4
5
# File 'app/models/plesk_kit/client.rb', line 3

def user
  @user
end

#xml_responseObject

Returns the value of attribute xml_response.



3
4
5
# File 'app/models/plesk_kit/client.rb', line 3

def xml_response
  @xml_response
end

#xml_targetObject

Returns the value of attribute xml_target.



3
4
5
# File 'app/models/plesk_kit/client.rb', line 3

def xml_target
  @xml_target
end

Instance Method Details

#send_to_plesk(xml) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/models/plesk_kit/client.rb', line 8

def send_to_plesk(xml)
  http = Net::HTTP.new(@host, 8443)
  puts http.inspect
  http.use_ssl = true
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE
  @headers = {
      'HTTP_AUTH_LOGIN' => @user,
      'HTTP_AUTH_PASSWD' => @pass,
      'Content-Type' => 'text/xml',
  }
  puts @headers
  path = "/enterprise/control/agent.php"
  res, data = http.post2(path, xml, @headers)
  puts res
  return res.body, xml
end