ruby-amt 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. data/AUTHORS +1 -0
  2. data/COPYING +15 -0
  3. data/ChangeLog +392 -0
  4. data/GPL +674 -0
  5. data/Rakefile +292 -0
  6. data/VERSION +1 -0
  7. data/doc/default.css +211 -0
  8. data/doc/default.template +78 -0
  9. data/doc/documentation.page +40 -0
  10. data/doc/img/bg.jpg +0 -0
  11. data/doc/img/image.jpg +0 -0
  12. data/doc/img/line.jpg +0 -0
  13. data/doc/img/shadow.jpg +0 -0
  14. data/doc/index.page +61 -0
  15. data/doc/installation.page +115 -0
  16. data/doc/news.page +25 -0
  17. data/doc/news/release_0_1_0.page +16 -0
  18. data/doc/virtual +2 -0
  19. data/lib/amt/pt_status.rb +59 -0
  20. data/lib/amt/service.rb +16 -0
  21. data/lib/amt/service/basic.rb +159 -0
  22. data/lib/amt/service/hardware_asset.rb +83 -0
  23. data/lib/amt/service/hardware_asset/amt_information_table.rb +49 -0
  24. data/lib/amt/service/hardware_asset/asset.rb +118 -0
  25. data/lib/amt/service/hardware_asset/baseboard.rb +31 -0
  26. data/lib/amt/service/hardware_asset/bios.rb +65 -0
  27. data/lib/amt/service/hardware_asset/computer_system.rb +30 -0
  28. data/lib/amt/service/hardware_asset/fru.rb +37 -0
  29. data/lib/amt/service/hardware_asset/media_device.rb +63 -0
  30. data/lib/amt/service/hardware_asset/memory_module.rb +91 -0
  31. data/lib/amt/service/hardware_asset/portable_battery.rb +80 -0
  32. data/lib/amt/service/hardware_asset/processor.rb +123 -0
  33. data/lib/amt/service/hardware_asset/vpro_verification_table.rb +120 -0
  34. data/lib/amt/service/network_administration.rb +181 -0
  35. data/lib/amt/service/network_administration/structures.rb +29 -0
  36. data/lib/amt/service/remote_control.rb +73 -0
  37. data/lib/amt/service/remote_control/structures.rb +120 -0
  38. data/lib/amt/service/security_administration.rb +430 -0
  39. data/lib/amt/service/security_administration/structures.rb +117 -0
  40. data/lib/amt/system.rb +134 -0
  41. data/lib/amt/utility.rb +33 -0
  42. data/lib/amt/utility/bit_struct.rb +164 -0
  43. data/lib/amt/utility/enum.rb +119 -0
  44. data/lib/amt/version.rb +8 -0
  45. data/setup.rb +1585 -0
  46. metadata +125 -0
@@ -0,0 +1,78 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="{lang:}" lang="{lang:}">
3
+ <head>
4
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
5
+ <meta name="author" content="Thomas Leitner" />
6
+ <meta name="copyright" content="2009 Thomas Leitner" />
7
+ <meta name="description" content="ruby-amt is a library for accessing Intel AMT via SOAP" />
8
+ <meta name="keywords" content="ruby-amt,ruby amt,ruby vpro" />
9
+ <link href="{relocatable: default.css}" type="text/css" rel="stylesheet" media="screen,projection" />
10
+
11
+ <title>{title:} | ruby-amt</title>
12
+ </head>
13
+ <body>
14
+ <div id="layout">
15
+
16
+ <div id="header">
17
+
18
+ <h1 id="logo"><a href="{relocatable: /}" title="Homepage">ruby-amt <span class='slogan'>library for controlling Intel AMT devies via SOAP</span></a></h1>
19
+ <hr class="noscreen" />
20
+
21
+ </div>
22
+
23
+ <hr class="noscreen" />
24
+
25
+ <div id="nav" class="box">
26
+ {menu: {max_levels: 1, used_nodes: files}}
27
+ <hr class="noscreen" />
28
+ </div>
29
+
30
+ <div id="container" class="box">
31
+
32
+ <% if context.content_node.node_info[:page].blocks.has_key?('intro') %>
33
+ <div id="intro">
34
+ <div id="intro-in">
35
+ <webgen:block name="intro" node="first" />
36
+ </div>
37
+ </div>
38
+ <% end %>
39
+
40
+ <div id="main" class="content box">
41
+ <div class="in">
42
+ <div class="shadow">
43
+ <webgen:block name="content" />
44
+ </div>
45
+
46
+ <div class="clear"></div>
47
+
48
+ </div>
49
+ </div>
50
+
51
+ </div>
52
+
53
+ <div id="footer" class="shadow">
54
+ <div class="f-left">Copyright © 2009 Thomas Leitner</div>
55
+ <div class="f-right">Design by <a href="http://www.davidkohout.cz" title="Original template design">David Kohout</a></div>
56
+ </div>
57
+ </div>
58
+
59
+
60
+ <!-- Start of StatCounter Code -->
61
+ <script type="text/javascript">
62
+ var sc_project=5150506;
63
+ var sc_invisible=1;
64
+ var sc_partition=53;
65
+ var sc_click_stat=1;
66
+ var sc_security="172a794e";
67
+ </script>
68
+
69
+ <script type="text/javascript" src="http://www.statcounter.com/counter/counter_xhtml.js"></script>
70
+ <noscript><div class="statcounter">
71
+ <a title="website statistics" class="statcounter" href="http://www.statcounter.com/free_web_stats.html">
72
+ <img class="statcounter" src="http://c.statcounter.com/5150506/0/172a794e/1/" alt="website statistics" />
73
+ </a>
74
+ </div></noscript>
75
+ <!-- End of StatCounter Code -->
76
+
77
+ </body>
78
+ </html>
@@ -0,0 +1,40 @@
1
+ ---
2
+ title: Documentation
3
+ in_menu: true
4
+ sort_info: 20
5
+ ---
6
+
7
+ # Documentation
8
+
9
+ The ruby-amt library was developed for accessing AMT 5.0 clients which have been setup in SMB mode.
10
+ This has been tested and confirmed to work. Accesing AMT clients which have been setup in Enterprise
11
+ mode has not been tested and supporting such clients will probably need some extra effort.
12
+
13
+ Also, newer AMT versions are currently not supported and older AMT version will not be supported.
14
+
15
+ The current version does not contain interfaces to all available AMT 5.0 services and methods but it
16
+ is intended that this situation will be improved in the future.
17
+
18
+
19
+ ## API Documentation
20
+
21
+ In the [API documentation]({relocatable: /rdoc/index.html}) you will find all needed information for
22
+ using the ruby-amt library.
23
+
24
+
25
+ ## Usage Examples
26
+
27
+ All examples assume that the following commands have already been executed:
28
+
29
+ require 'amt/service'
30
+ hostname = 'pc1.example.com' # change to hostname of AMT device!
31
+ username = 'admin' # change to the used username!
32
+ password = 'MySecurePassword1!' # change to the real password!
33
+
34
+ * Retrieving the current power state and powering up the system if it is down.
35
+
36
+ rcs = AMT::Service::RemoteControl.new(hostname, username, password)
37
+ ps = rcs.get_system_power_state
38
+ if ps.power_state != :s0
39
+ rcs.remote_control(:power_up)
40
+ end
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,61 @@
1
+ ---
2
+ title: Home
3
+ in_menu: true
4
+ sort_info: 1
5
+ ---
6
+ ## What is Intel AMT?
7
+
8
+ Intel AMT (Active Management Technology) is part of the Intel vPro technology and provides
9
+ out-of-bound access to PCs, computers as well as notebooks. Once Intel AMT has been setup on the
10
+ target computer, a system administrator can remotely control the computer or get information about,
11
+ for example, its hardware inventory or its current power state. Since this works in an out-of-bound
12
+ manner this functionality is available even when the computer is powered down!
13
+
14
+ As one can easily see, Intel AMT is a very powerful tool. By default you only get a web frontend for
15
+ the most commonly used functionality. However, AMT also provides access to its whole functionality
16
+ via SOAP services and this is where ruby-amt comes in. ruby-amt implements the client side of these
17
+ SOAP services and therefore allows system administrators to include the whole AMT functionality in
18
+ their system management tools.
19
+
20
+ For more information about Intel AMT have a look at the [Intel AMT website][1].
21
+
22
+ [1]: http://www.intel.com/technology/platform-technology/intel-amt/
23
+
24
+
25
+ ## How do I get started?
26
+
27
+ First you need to install the library (see the [installation page]({relocatable:
28
+ installation.html}))! After that have a look at the [documentation page]({relocatable:
29
+ documentation.html}) which provides some example usage scenarios. For in-depth information on how to
30
+ use the library go to the [API documentation]({relocatable: /rdoc/index.html})!
31
+
32
+
33
+
34
+ <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
35
+ <input type="hidden" name="cmd" value="_s-xclick" />
36
+ <input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----MIIHJwYJKoZIhvcNAQcEoIIHGDCCBxQCAQExggEwMIIBLAIBADCBlDCBjjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtQYXlQYWwgSW5jLjETMBEGA1UECxQKbGl2ZV9jZXJ0czERMA8GA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GDn7Mn9VbLM+9fJ+AlkWFO1RHixPWqk38DyjZt1PB4sZFw/zuF7psN2EIwRpfPuhsF4lRkx8Kv0nrDak/09h1TF2+FozW4IyqxT/RE7+V4jcd0+PpCkXI=-----END PKCS7-----
37
+ " />
38
+ <input type="image" src="https://www.paypal.com/en_US/i/btn/btn_donate_SM.gif" border="0" name="submit" alt="Donate via PayPal" />
39
+ <img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1" />
40
+ </form>
41
+
42
+
43
+ --- name:intro
44
+
45
+ ## Welcome to the ruby-amt site
46
+
47
+ ruby-amt is a [Ruby](http://www.ruby-lang.org) library for controlling Intel AMT (Active Management
48
+ Technology) 5.0 devices (part of Intel vPro). It does this by implementing the client side of the
49
+ SOAP protocol defined by Intel for Intel AMT devices.
50
+
51
+ Although there are some [free][1] [implementations][2] of the client side of the AMT SOAP protocol,
52
+ none was available for Ruby and therefore I started this project. It aims to provide direct access
53
+ to all of the SOAP services but will also provide a high-level interface for the most commonly used
54
+ features.
55
+
56
+ <div class="a-center">
57
+ The latest version of ruby-amt is <b>0.1.0</b> and it was released on <b>2009-10-20</b>.
58
+ </div>
59
+
60
+ [1]: http://software.intel.com/en-us/blogs/2009/01/14/intel-amt-and-perl-get-your-scripts-here/
61
+ [2]: http://www.openamt.org/amt-developer-toolkit/
@@ -0,0 +1,115 @@
1
+ ---
2
+ title: Download &amp; Installation
3
+ in_menu: true
4
+ sort_info: 5
5
+ ---
6
+ # Download & Installation
7
+
8
+ ## Compatibility Notes
9
+
10
+ ruby-amt should work on any platform which supports Ruby. It has been successfully tested on the
11
+ following platforms:
12
+
13
+ * Linux with Ruby 1.8.6
14
+ * Mac OSX with Ruby 1.8.6, 1.8.7 and 1.9.1
15
+
16
+ See the platform specific installation notes for more information!
17
+
18
+ Furthermore, ruby-amt should probably also run on jruby but that has not been tested.
19
+
20
+ ## Platform Specific Installation Instructions
21
+
22
+ ### Linux
23
+
24
+ There are a variety of Linux distributions out there with different package management systems. So I
25
+ will focus on instructions for Ubuntu 9.04 here (which should probably also work for any recent
26
+ Debian based distribution).
27
+
28
+ After running the following commands, ruby-amt and all the mandatory dependencies are installed:
29
+
30
+ sudo aptitude install ruby rubygems
31
+ sudo gem1.8 install ruby-amt
32
+
33
+ > You will also need to add `export PATH=$PATH:/var/lib/gems/1.8/bin` to your `~/.bashrc` because
34
+ > this is the binary path the executable files get installed.
35
+
36
+ Also see the section on [Using Rubygems]({relocatable: '#rubygems'}).
37
+
38
+
39
+ ### Mac OS X
40
+
41
+ Mac OS Leopard comes with Ruby and Rubygems preinstalled. However, the Rubygems version is rather
42
+ old and needs to be updated. This can be done by running the following commands:
43
+
44
+ sudo gem install rubygems-update
45
+ sudo update_rubygems
46
+
47
+ After that your system is ready for installing ruby-amt:
48
+
49
+ sudo gem install ruby-amt
50
+
51
+ Also see the section on [Using Rubygems]({relocatable: '#rubygems'}).
52
+
53
+
54
+ ### Windows
55
+
56
+ You need to install Ruby first. This can easily be done by using the One-Click-Installer - just
57
+ download the *latest* installation binary from the [files section][1] of the One-Click-Installer
58
+ homepage and run it. After that open a command shell (select `Start -> Run...`, then enter `cmd` and
59
+ click on `Ok`) and type in the following:
60
+
61
+ gem install ruby-amt
62
+
63
+ Also see the section on [Using Rubygems]({relocatable: '#rubygems'}).
64
+
65
+ [1]: http://rubyforge.org/frs/?group_id=167
66
+
67
+
68
+ ## Generic Installation Instructions
69
+
70
+
71
+ ### Using Rubygems {#rubygems}
72
+
73
+ If you are using Rubygems, installing the latest version of ruby-amt is as simple as executing
74
+
75
+ gem install ruby-amt
76
+
77
+ > If the installation fails because the `handsoap` gem cannot be found, you have to run the following
78
+ > and then try again:
79
+ >
80
+ > gem install gemcutter
81
+ > gem tumble
82
+
83
+
84
+ ### Manual Installation
85
+
86
+ The latest version of ruby-amt can always be downloaded as `.tar.gz` or `.zip` from [its files
87
+ section on Rubyforge](http://rubyforge.org/frs/?group_id=9006). After the download the package needs
88
+ to be decompressed and then you can install ruby-amt using the included `setup.rb` installation
89
+ method:
90
+
91
+ $ ruby setup.rb config
92
+ $ ruby setup.rb setup
93
+ $ ruby setup.rb install
94
+
95
+ Make sure that you also install the needed dependencies!
96
+
97
+
98
+ ### Using the repository version
99
+
100
+ ruby-amt uses git as its versioning system and ruby-amt's repository is hosted on Rubyforge. The
101
+ repository always contains a clean state of the current development version of ruby-amt. To check
102
+ out ruby-amt use the following command:
103
+
104
+ git clone git://rubyforge.org/ruby-amt.git
105
+
106
+
107
+ ## Dependencies
108
+
109
+ Since ruby-amt is written in Ruby, you need the [Ruby interpreter](http://www.ruby-lang.org)
110
+ versions 1.8.6, 1.8.7 or 1.9.1.
111
+
112
+ Additionally, ruby-amt depends on the [handsoap](http://github.com/unwire/handsoap) library (tested
113
+ with version 1.1.1), and either the [httpclient](http://dev.ctor.org/http-access2) library or the
114
+ [curb](http://curb.rubyforge.org/) library (sothat digest authentication works). You can optionally
115
+ also install the [nokogiri](http://nokogiri.org/) library for faster XML parsing.
@@ -0,0 +1,25 @@
1
+ ---
2
+ title: News
3
+ in_menu: true
4
+ sort_info: 30
5
+ --- pipeline:blocks,fragments
6
+
7
+ <h1>News</h1>
8
+
9
+ <webgen:block name="newsdata" node="current" />
10
+
11
+ --- name:newsdata pipeline:erb
12
+ <%
13
+ context.content_node.tree.node_access[:alcn].select do |na,no|
14
+ na =~ /\/news\/.+/ && no.is_file?
15
+ end.collect {|na,no| no}.sort.reverse.each do |node|
16
+ %>
17
+
18
+ <div class='news-item'>
19
+ <div class="news-date f-right">
20
+ Published on <%= node['created_at'].strftime("%A, %d %B %Y") %>
21
+ </div>
22
+ <%= context.render_block(:name => 'content', :chain => [node]) %>
23
+ </div>
24
+
25
+ <% end %>
@@ -0,0 +1,16 @@
1
+ ---
2
+ no_output: true
3
+ sort_info: r0000
4
+ created_at: 2009-10-20 19:05:00 +02:00
5
+ modified_at: 2009-10-20 19:05:00 +02:00
6
+ ---
7
+ ## ruby-amt 0.1.0 released
8
+
9
+ This is the initial version of ruby-amt. Four AMT services are already available:
10
+
11
+ * NetworkAdministration - for getting and setting network related information
12
+ * HardwareAsset - for retrieving information about the installed hardware assets
13
+ * RemoteControl - for remotely controlling the power state
14
+ * SecurityAdministration - for security related tasks
15
+
16
+ The GeneralInfo, NetworkTime and UserAccessControl services will be implemented next.
@@ -0,0 +1,2 @@
1
+ rdoc/index.html:
2
+ title: API Documentation
@@ -0,0 +1,59 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ require 'amt/utility'
4
+
5
+ module AMT
6
+
7
+ # General status value returned by each AMT method. For more information on how to interpret a
8
+ # specific value when returned by a specific method, lookup the method in the "Network Interface
9
+ # Guide" of the Intel AMT SDK.
10
+ class PTStatus < Utility::Enum
11
+ multi_add(0x0 => :success,
12
+ 0x1 => :internal_error,
13
+ 0x2 => :not_ready,
14
+ 0x3 => :invalid_pt_mode,
15
+ 0xc => :invalid_name,
16
+ 0xf => :invalid_byte_count,
17
+ 0x10 => :not_permitted,
18
+ 0x17 => :max_limit_reached,
19
+ 0x18 => :invalid_auth_type,
20
+ 0x19 => :authentication_failure,
21
+ 0x1a => :invalid_dhcp_mode,
22
+ 0x1b => :invalid_ip_address,
23
+ 0x1c => :invalid_domain_name,
24
+ 0x20 => :invalid_provisioning_state,
25
+ 0x22 => :invalid_time,
26
+ 0x23 => :invalid_index,
27
+ 0x24 => :invalid_parameter,
28
+ 0x25 => :invalid_netmask,
29
+ 0x26 => :flash_write_limit_exceeded,
30
+ 0x400 => :disabled_by_policy,
31
+ 0x800 => :network_if_error_base,
32
+ 0x801 => :unsupported_oem_number,
33
+ 0x802 => :unsupported_boot_option,
34
+ 0x803 => :invalid_command,
35
+ 0x804 => :invalid_special_command,
36
+ 0x805 => :invalid_handle,
37
+ 0x806 => :invalid_password,
38
+ 0x807 => :invalid_realm,
39
+ 0x808 => :storage_acl_entry_in_use,
40
+ 0x809 => :data_missing,
41
+ 0x80a => :duplicate,
42
+ 0x80b => :eventlog_frozen,
43
+ 0x80c => :pki_missing_keys,
44
+ 0x80d => :pki_generating_keys,
45
+ 0x80e => :invalid_key,
46
+ 0x80f => :invalid_cert,
47
+ 0x810 => :cert_key_not_match,
48
+ 0x811 => :max_kerb_domain_reached,
49
+ 0x812 => :unsupported,
50
+ 0x813 => :invalid_priority,
51
+ 0x814 => :not_found,
52
+ 0x815 => :invalid_credentials,
53
+ 0x816 => :invalid_passphrase,
54
+ 0x818 => :no_association,
55
+ 0x81b => :audit_fail,
56
+ 0x81c => :blocking_component)
57
+ end
58
+
59
+ end
@@ -0,0 +1,16 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ module AMT
4
+
5
+ # This module contains classes for all implemented AMT SOAP services.
6
+ module Service
7
+
8
+ autoload :RemoteControl, 'amt/service/remote_control'
9
+ autoload :HardwareAsset, 'amt/service/hardware_asset'
10
+ autoload :NetworkAdministration, 'amt/service/network_administration'
11
+ autoload :SecurityAdministration, 'amt/service/security_administration'
12
+
13
+ end
14
+
15
+ end
16
+
@@ -0,0 +1,159 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ require 'handsoap'
4
+ require 'amt/pt_status'
5
+
6
+ begin
7
+ require 'curb'
8
+ Handsoap.http_driver = :curb
9
+ rescue LoadError
10
+ Handsoap.http_driver = :httpclient
11
+ end
12
+
13
+ begin
14
+ require 'nokogiri'
15
+ Handsoap.xml_query_driver = :nokogiri
16
+ rescue LoadError
17
+ Handsoap.xml_query_driver = :rexml
18
+ end
19
+
20
+
21
+ module AMT
22
+
23
+ # Raised when error invoking an AMT method was detected, i.e. when the status field of the SOAP
24
+ # response indicates an error condition.
25
+ class InvocationError < StandardError
26
+
27
+ # The AMT::PTStatus instance of the failed method.
28
+ attr_reader :status
29
+
30
+ # The response document.
31
+ attr_reader :document
32
+
33
+ # Create a new InvocationError object for the given +status+ and +document+.
34
+ def initialize(status, document)
35
+ super("Error invoking AMT method, status = #{status}")
36
+ @status, @document = @status, @document
37
+ end
38
+
39
+ end
40
+
41
+
42
+ module Service
43
+
44
+ # This is the base class for all AMT SOAP services, implemented as Handsoap::Service. It
45
+ # provides an implementation of the Handsoap::Service methods which are common to most or all
46
+ # AMT SOAP services (and therefore avoids duplication). These include:
47
+ #
48
+ # [#envelope_namespace]
49
+ # The envelope namespace used for AMT SOAP requests and responses. All AMT SOAP services have
50
+ # the same one.
51
+ #
52
+ # [#request_content_type]
53
+ # The content type for the SOAP request. All AMT SOAP services have the same one.
54
+ #
55
+ # [#uri]
56
+ # The endpoint URI of the SOAP service. It is automatically constructed from the #host, the
57
+ # #port and class name. There shouldn't be any need to override this method in subclasses.
58
+ #
59
+ # [#on_create_document, #on_response_document]
60
+ # These two Handsoap hooks are used to add the correct namespace to the request and response
61
+ # documents under the 'ns' alias. The namespace is stored in the +@namespace+ variable and
62
+ # automatically set on object creation to (+CLASS_NAME+ is the unqualified name of the
63
+ # subclass):
64
+ #
65
+ # "http://schemas.intel.com/platform/client/CLASS_NAME/2004/01"
66
+ #
67
+ # Not all AMT services follow this namespace scheme (the year/month part was normally changed
68
+ # when methods were added in newer versions of the service), so the +@namespace+ variable
69
+ # sometimes needs to be overwritten in the subclass initializer.
70
+ #
71
+ # [#on_after_create_http_request]
72
+ # Used to set the #username and #password on the HTTP transport object.
73
+ #
74
+ # Apart from that it provides a small wrapper method #soap_call which should be used instead of
75
+ # #invoke by subclasses for actually calling the remote SOAP method.
76
+ class Basic < Handsoap::Service
77
+
78
+ # The hostname or IP of the service endpoint.
79
+ attr_reader :host
80
+
81
+ # The port of the service endpoint.
82
+ attr_reader :port
83
+
84
+
85
+ # Create a new SOAP client by connecting to +host+ with +username+ and +password+ on the given
86
+ # +port+ (defaults to 16992 for non-SSL transport, use 16993 if you have configured SSL).
87
+ #
88
+ # The parameters +host+ and +port+ are used in #uri to construct the endpoint URI, +username+
89
+ # and +password+ are set on the HTTP transport object in #on_after_create_http_request.
90
+ def initialize(host, username, password, port = 16992)
91
+ @host, @port = host, port
92
+ @username, @password = username, password
93
+ @namespace = "http://schemas.intel.com/platform/client/#{self.class.name.sub(/^.*::/, '')}/2004/01"
94
+ end
95
+
96
+
97
+ # Utility function for calling a SOAP method - should be used by subclasses for *all* remote
98
+ # SOAP method invocations.
99
+ #
100
+ # Calls #invoke for the given SOAP method +soap_method+. The body of the SOAP message is yielded
101
+ # exactly like with #invoke.
102
+ #
103
+ # Returns the response which is augmented with a #process method that yields the response node
104
+ # if a block is given or otherwise just returns a hash with the method invocation status.
105
+ #
106
+ # If the method invocation failed (determined by looking at the +status_name+ entry in the
107
+ # response), an AMT::InvocationError is raised.
108
+ def soap_call(soap_method, status_name = 'StatusCode')
109
+ response = invoke("ns:#{soap_method}", "#{@namespace}/#{soap_method}") do |msg|
110
+ yield(msg) if block_given?
111
+ end
112
+
113
+ status = AMT::PTStatus.for(response.document.xpath("//ns:#{soap_method}Response/ns:#{status_name}/text()").to_i)
114
+ raise AMT::InvocationError.new(status, response.document) unless status == :success
115
+
116
+ def response.soap_method=(sm); @sm = sm; end
117
+ def response.process; yield(document.xpath("//ns:#{@sm}Response")) if block_given?; end
118
+ response.soap_method = soap_method
119
+ response
120
+ end
121
+
122
+ protected
123
+
124
+ # The common envelope namespace.
125
+ def envelope_namespace
126
+ 'http://schemas.xmlsoap.org/soap/envelope/'
127
+ end
128
+
129
+ # The correct request content type for AMT SOAP methods.
130
+ def request_content_type
131
+ 'text/xml'
132
+ end
133
+
134
+ # The endpoint URI is created from the #host and #port values as well as the class name.
135
+ def uri
136
+ "http://#{host}:#{port}/#{self.class.name.sub(/^.*::/, '')}Service"
137
+ end
138
+
139
+ # Add the correct namespace to the request document under the 'ns' alias.
140
+ def on_create_document(doc)
141
+ doc.alias('ns', @namespace)
142
+ doc.xml_header = false
143
+ end
144
+
145
+ # Add the correct namespace to the response document under the 'ns' alias.
146
+ def on_response_document(doc)
147
+ doc.add_namespace('ns', @namespace)
148
+ end
149
+
150
+ # Set the #username and #password on the HTTP transport object.
151
+ def on_after_create_http_request(request)
152
+ request.set_auth(@username, @password)
153
+ end
154
+
155
+ end
156
+
157
+ end
158
+
159
+ end