Giter Club home page Giter Club logo

amt's People

Contributors

bodo-riediger avatar chenl avatar mikenawrocki avatar rixillo avatar sdague avatar taniokaeiji avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

amt's Issues

No pxeboot when power state is "off"

I find that the pxeboot command works if the target machine is in "standby", but fails if the machine is in state "off".

I offer the following explanation: the pxeboot command of amtctrl sends two wsman commands to the target machine, first a boot config setting of "PXE", followed by a power state change request of "reboot". I suspect it is not valid to send a "reboot" to a machine that is off.

With the old amttool program, I could branch to handle either state correctly (after initially querying to get power state).

if ($powerstate == 'off') { 
    amttool 10.0.0.xx powerup pxe
} elsif ($powerstate == 'standby') {
    amttool 10.0.0.xx powercycle pxe
}

amtctrl provides pxe-reboot capability, but not pxe-boot.

Below is the (unhandled) error message returned when the target machine was in state "off":

/usr/bin/amtctrl -p  10.0.0.142 pxeboot
<?xml version="1.0" ?>
<a:Envelope xmlns:a="http://www.w3.org/2003/05/soap-envelope" xmlns:b="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:c="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd" xmlns:d="http://schemas.xmlsoap.org/ws/2005/02/trust" xmlns:e="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:f="http://schemas.dmtf.org/wbem/wsman/1/cimbinding.xsd" xmlns:g="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_PowerManagementService" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <a:Header>
    <b:To>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</b:To>
    <b:RelatesTo>uuid:fc49c92a-8b5d-46e6-a695-e0baca76d80d</b:RelatesTo>
    <b:Action a:mustUnderstand="true">http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_PowerManagementService/RequestPowerStateChangeResponse</b:Action>
    <b:MessageID>uuid:00000000-8086-8086-8086-000000000047</b:MessageID>
    <c:ResourceURI>http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_PowerManagementService</c:ResourceURI>
  </a:Header>
  <a:Body>
    <g:RequestPowerStateChange_OUTPUT>
      <g:ReturnValue>2</g:ReturnValue>
    </g:RequestPowerStateChange_OUTPUT>
  </a:Body>
</a:Envelope>

The return value of 2 is an error code.
(reference: http://www.dmtf.org/sites/default/files/standards/documents/DSP1027_2.0.1.pdf)

Add support for VNC specific passwords

Any thoughts on adding support for a separate VNC specific password?

I ran into an issue where my AMT password did not meet the RFBPassword / VNC password requirements because it was > 8 characters.

Maybe prompt the user when enabling KVM/VNC and update hosts.cfg?

Let me know if this sounds reasonable and I'll submit a PR to add this functionality.

http status codes not handled

"amtctrl status" crashes with stack dump when it receives an http status code of 401 - Unauthorized.

I find the error handler in client.py, line 97:

        if resp.status_code == 200:
...
        else:
            print("Status: %s" % resp.status_code)
            print(pp_xml(resp.content))
            return 1

but seems it is not catching

Traceback (most recent call last):
  File "/usr/bin/amtctrl", line 5, in <module>
    pkg_resources.run_script('amt==0.6.0', 'amtctrl')
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 540, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 1455, in run_script
    execfile(script_filename, namespace, namespace)
  File "/usr/lib/python2.7/site-packages/amt-0.6.0-py2.7.egg/EGG-INFO/scripts/amtctrl", line 114, in <module>
    sys.exit(main())
  File "/usr/lib/python2.7/site-packages/amt-0.6.0-py2.7.egg/EGG-INFO/scripts/amtctrl", line 102, in main
    print(amt.wsman.friendly_power_state(client.power_status()))
  File "/usr/lib/python2.7/site-packages/amt-0.6.0-py2.7.egg/amt/client.py", line 145, in power_status
    "PowerState")
  File "/usr/lib/python2.7/site-packages/amt-0.6.0-py2.7.egg/amt/client.py", line 171, in _find_value
    doc = ElementTree.fromstring(content)
  File "/usr/lib64/python2.7/xml/etree/ElementTree.py", line 1300, in XML
    parser.feed(text)
  File "/usr/lib64/python2.7/xml/etree/ElementTree.py", line 1642, in feed
    self._raiseerror(v)
  File "/usr/lib64/python2.7/xml/etree/ElementTree.py", line 1506, in _raiseerror
    raise err
xml.etree.ElementTree.ParseError: syntax error: line 1, column 63

python 3 conversion

I finally accomplished building amt0.30 on CentOS7 and Fedora24. I had similar difficulties on both platforms, mainly due to the lack of available python3 prerequisites. Also, it seems that the amt package has been converted to python3 but there are still some remnants of py2 that caused it fail either at build time or run time.

I made several attempts to either build the prerequisites or pull them from various repositories, so I am a little confused now about which of various sources actually went into the final successful build of amt. However, I used the CentOS "ius" repository, "IUS Community Packages for Enterprise Linux 7 - x86_64" to install python35u and I used the Openwsman repository, http://download.opensuse.org/repositories/Openwsman/CentOS_CentOS-7/Openwsman.repo, to install libwsman3.

I needed to fix a couple of python2isms, which caused build or run-time fatalities on both CentOS7 and Fedora24. Here are the diffs:

client.py.patch.txt
hostdb.py.patch.txt

Thanks for this package. I've been crying ever since they broke my amttool.
Rix

Feature request: support graceful power off and reboot

I read on https://software.intel.com/en-us/articles/intel-active-management-technology-start-here-guide-intel-amt-9 that there are several "new" power state codes. I tried to use these codes with this package to send graceful off and graceful reset (specifically codes 12 - graceful shutdown, and 14 - graceful reset), but instead I get this XML into my std out:

(I apologise in advance for pasting XML)

<?xml version="1.0" ?>
<a:Envelope xmlns:a="http://www.w3.org/2003/05/soap-envelope" xmlns:b="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:c="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd" xmlns:d="http://schemas.xmlsoap.org/ws/2005/02/trust" xmlns:e="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:f="http://schemas.dmtf.org/wbem/wsman/1/cimbinding.xsd" xmlns:g="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_PowerManagementService" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <a:Header>
    <b:To>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</b:To>
    <b:RelatesTo>uuid:05202c7a-dd61-4a1a-96e3-246359a58410</b:RelatesTo>
    <b:Action a:mustUnderstand="true">http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_PowerManagementService/RequestPowerStateChangeResponse</b:Action>
    <b:MessageID>uuid:00000000-8086-8086-8086-000000000216</b:MessageID>
    <c:ResourceURI>http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_PowerManagementService</c:ResourceURI>
  </a:Header>
  <a:Body>
    <g:RequestPowerStateChange_OUTPUT>
      <g:ReturnValue>2</g:ReturnValue>
    </g:RequestPowerStateChange_OUTPUT>
  </a:Body>
</a:Envelope>

how to use in windows

Hello
I'm new in python, and I want to make simple python snippet code to check my Laptop support intel vPro or not,

Is this code can check that? if can how to use this package to check that

Thanks

logging and exceptions

Hi.
I want to use this lib to manage amt device.
But some issues stops me to start:

1 When i'm connecting to device if login\pass is incorrect the main way to understand it is to compare result with 1.
Why you did not raise any exceptions?
In Client.init ,for example, make an auth checking request and raise errors.

2 And also there are print statements. It is better to use logging that i can disable out put if needed.

Can i make pull request to fix that issues or you have another opinion for each?

thx for library :)

No configparser in Python2

Commit 94baded9ab19a8ea04ba17bdb9af98ba535d7e7e, while fixed Python3 support, broke it on Python2:

$ amtctrl -h   
Traceback (most recent call last):
  File "/home/chenl/src/amt/.env/bin/amtctrl", line 8, in <module>
    import amt.hostdb
  File "/home/chenl/src/amt/.env/local/lib/python2.7/site-packages/amt/hostdb.py", line 13, in <module>
    import configparser
ImportError: No module named configparser

not power off when run poweroff command

Thanks for the great project which simplify the mgmt greatly!

I'm trying to use the tool to shut down one 5i5MYHE NUC, but seems like it doesn't work. Below is the response message

$ bin/amtctrl windows off
<?xml version="1.0" ?>
<a:Envelope xmlns:a="http://www.w3.org/2003/05/soap-envelope" xmlns:b="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:c="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd" xmlns:d="http://schemas.xmlsoap.org/ws/2005/02/trust" xmlns:e="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:f="http://schemas.dmtf.org/wbem/wsman/1/cimbinding.xsd" xmlns:g="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_PowerManagementService" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <a:Header>
    <b:To>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</b:To>
    <b:RelatesTo>uuid:c86a90bb-66ae-401e-8e6f-4a48e06d4a4f</b:RelatesTo>
    <b:Action a:mustUnderstand="true">http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_PowerManagementService/RequestPowerStateChangeResponse</b:Action>
    <b:MessageID>uuid:00000000-8086-8086-8086-0000000000C1</b:MessageID>
    <c:ResourceURI>http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_PowerManagementService</c:ResourceURI>
  </a:Header>
  <a:Body>
    <g:RequestPowerStateChange_OUTPUT>
      <g:ReturnValue>2</g:ReturnValue>
    </g:RequestPowerStateChange_OUTPUT>
  </a:Body>
</a:Envelope>

From the DASH spec https://www.dmtf.org/sites/default/files/standards/documents/DSP1027_1.0.2.pdf, seems like the return value 2 means

8.1.4 ManagedElement
383 The ManagedElement parameter indicates the reference to the instance of CIM_ComputerSystem that
384 represents the target computer system whose power state is to be set.
385 If the instance of CIM_ComputerSystem is not associated with the instance of
386 CIM_PowerManagementService through the CIM_AssociatedPowerManagementService association, the
387 RequestPowerStateChange( ) method shall return 2 (Error Occurred).

Please let me know if there is anything more I need do to make it work. Thanks again.

amtctrl not working after make install

Tonight I cloned your repo to my raspberry pi zero running the latest Raspbian Lite. I ran "sudo make install", which ran with no errors. When I attempted to call amtctrl, I received the following error message:

Traceback (most recent call last):
File "/usr/local/bin/amtctrl", line 7, in
import requests
ImportError: No module named requests

I don't know enough about python or Make to understand what's wrong here, I'm pretty new to all this.

Connection timeout error is unhandled

/usr/bin/amtctrl -p 10.0.0.xxx pxeboot

Traceback (most recent call last):
  File "/usr/bin/amtctrl", line 5, in <module>
    pkg_resources.run_script('amt==0.6.0', 'amtctrl')
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 540, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 1455, in run_script
    execfile(script_filename, namespace, namespace)
  File "/usr/lib/python2.7/site-packages/amt-0.6.0-py2.7.egg/EGG-INFO/scripts/amtctrl", line 119, in <module>
    sys.exit(main())
  File "/usr/lib/python2.7/site-packages/amt-0.6.0-py2.7.egg/EGG-INFO/scripts/amtctrl", line 102, in main
    client.pxe_next_boot()
  File "/usr/lib/python2.7/site-packages/amt-0.6.0-py2.7.egg/amt/client.py", line 118, in pxe_next_boot
    self.set_next_boot(boot_device='pxe')
  File "/usr/lib/python2.7/site-packages/amt-0.6.0-py2.7.egg/amt/client.py", line 126, in set_next_boot
    self.post(payload)
  File "/usr/lib/python2.7/site-packages/amt-0.6.0-py2.7.egg/amt/client.py", line 88, in post
    data=payload)
  File "/usr/lib/python2.7/site-packages/requests/api.py", line 108, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "/usr/lib/python2.7/site-packages/requests/api.py", line 50, in request
    response = session.request(method=method, url=url, **kwargs)
  File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 464, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 576, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python2.7/site-packages/requests/adapters.py", line 415, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', error(110, 'Connection timed out'))

enumerate functionality - possible contribution

Howdy,

I wanted to learn a bit more about the SOAP protocol, and possibly contribute to the project.

I've been working with Intel vPro PCs (AMT V12), not the NUCs.

I've been able to get an "enumerate request" working, and just wanted to know if it's worth putting in the pull request to the project or not.

Similar to runnung this winrm code on a windows command line:

winrm enumerate http://intel.com/wbem/wscim/1/amt-schema/1/AMT_RedirectionService -remote:https://mypc:16993/wsman -u:admin -p:password -a:Digest -encoding:utf-8 -skipCNCheck -skipRevocationCheck -skipCACheck

I've been hacking a lot of the code in this project:

  • moving some stuff around
  • making it more customizable,
  • making it more usable to different AMT Classes (CIM_, IPS_ and AMT_* -- matching the different namespace to the appropriate classes),
  • using requests.session instead of requests.post all over the place,
  • and making the requests code allow you to ignore certificate warnings, etc in SSL Mode (if you need to)

Lastly, I wondered if we want to keep the code Python 2 compatible or not (hopefully not considering its not really supported anymore).

A lot of the changes I've made likely aren't Python 2 compatible, but I wonder if Python2 compatability should really be a thing anymore or not.... However, I don't even have a test system with Python 2 anymore.

P.S. Thanks for showing me the auth and get methods, as that got me started on the "Enumeration"s.

Here's an example of the code reduced to a simple python script:

import getpass
import amt.client
import amt.wsman

if 'mypass' not in locals().keys() or not mypass:
    # I rerun this a lot and likely have set my password in a previous running
    mypass = getpass.getpass()

client = amt.client.Client('somepc.somedomain.local', mypass, vncpasswd=mypass, protocol="https", verify_ssl=False, disable_ssl_warnings=True)

class_name = 'CIM_ComputerSystem'
rows = client.enumerate(class_name)

output:

[{'CreationClassName': 'CIM_ComputerSystem',
  'Dedicated': '32',
  'ElementName': 'Managed System',
  'EnabledDefault': '5',
  'EnabledState': '2',
  'HealthState': '5',
  'IdentifyingDescriptions': 'CIM:GUID',
  'Name': 'ManagedSystem',
  'NameFormat': 'Other',
  'OperationalStatus': '0',
  'OtherIdentifyingInfo': 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
  'RequestedState': '12'},
 {'CreationClassName': 'CIM_ComputerSystem',
  'Dedicated': '14',
  'ElementName': 'Intel(r) AMT Subsystem',
  'EnabledDefault': '5',
  'EnabledState': '5',
  'HealthState': '5',
  'Name': 'Intel(r) AMT',
  'NameFormat': 'Other',
  'OperationalStatus': '0',
  'RequestedState': '12'}]

Please and Thank You,
Steven

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.