File: shell.rst

package info (click to toggle)
python-hpilo 4.4.3-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,784 kB
  • sloc: python: 3,418; ruby: 467; makefile: 122; sh: 31
file content (147 lines) | stat: -rw-r--r-- 5,429 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
Access from the shell
=====================

The commandline interface, :program:`hpilo_cli`,  allows you to make calls from
your shell or scripts written in another language than python. It supports all
methods that the library has.

``hpilo_cli`` usage
-------------------

.. highlight:: console

.. code-block:: console

    hpilo_cli [options] hostname method [args...] [ + method [args...]...]
    hpilo_cli download_rib_firmware ilotype version [version...]

Contacts the iLO, calls one or more methods and displays the output as if you
were using a python console.

Options:
    -l LOGIN, --login=LOGIN
                          Username to access the iLO
    -p PASSWORD, --password=PASSWORD
                          Password to access the iLO
    -i, --interactive     Prompt for username and/or password if they are not
                          specified.
    -c FILE, --config=FILE
                          File containing authentication and config details
    -t TIMEOUT, --timeout=TIMEOUT
                          Timeout for iLO connections
    -j, --json            Output a json document instead of a python dict
    -y, --yaml            Output a yaml document instead of a python dict
    -P PROTOCOL, --protocol=PROTOCOL
                          Use the specified protocol instead of autodetecting
    -d, --debug           Output debug information, repeat to see all XML data
    -o PORT, --port=PORT  SSL port to connect to
    --ssl-verify          Verify SSL certificates against the trusted CA's
    --ssl-ca-file=SSL_CA_FILE
                          CA bundle to validate iLO certificate against, instead
                          of the system CA's
    --ssl-ignore-hostname
                          Don't check if the hostname matches the certificate
                          when verifying SSL certificates
    -h, --help            show this help message or help for a method
    -H, --help-methods    show all supported methods

:program:`hpilo_cli` will read a config file (by default :file:`~/.ilo.conf`)
to find login information and any other variable you wish to set. This config
file is a simple ini file that should look like this

.. code-block:: ini

  [ilo]
  login = Administrator
  password = AdminPassword

Using such a file is recommended over using the login/password commandline
arguments.

Many methods that can be called require arguments. These arguments must be
specified as :data:`key=value` pairs on the command-line. These parameters can
also point to arbitrary configuration variables using the
:attr:`key='$section.option'` syntax.

Finally, you can also call multiple methods at once by separating them with a
:data:`+`

Examples
--------

As you can see, the :program:`hpilo_cli` program is quite versatile. Some
examples will make it clearer how to use this application properly.

Getting the status of the UID light::

  $ hpilo_cli example-server.int.kaarsemaker.net get_uid_status
  >>> print(my_ilo.get_uid_status())
  OFF

Getting virtual cdrom status in JSON format::

  $ hpilo_cli example-server.int.kaarsemaker.net get_vm_status --json
  {"write_protect": "NO", "vm_applet": "DISCONNECTED", "image_url": "", "boot_option": "NO_BOOT", "device": "CDROM", "image_inserted": "NO"}

Setting the name of the server::

  $ hpilo_cli example-server.int.kaarsemaker.net set_server_name name=example-server

Displaying help for the :func:`get_host_data` method::

  $ hpilo_cli --help get_host_data
  Ilo.get_host_data [decoded_only=True]:
  Get SMBIOS records that describe the host. By default only the ones
  where human readable information is available are returned. To get
  all records pass decoded_only=False

Methods like :func:`mod_network_data` method require dicts for some arguments
(e.g. :data:`static_route_`), you can use the following syntax::

  $ hpilo_cli example-server.int.kaarsemaker.net mod_network_settings static_route_1.dest=1.2.3.4 static_route_1.gateway=10.10.10.254

Calling multiple methods::

  $ hpilo_cli example-server.int.kaarsemaker.net get_uid_status + uid_control uid=No + get_uid_status
  >>> print(my_ilo.get_uid_status())
  ON
  >>> my_ilo.uid_control(uid="No")
  >>> print(my_ilo.get_uid_status())
  OFF

Setting a licence key defined in the config file::

  $ cat ~/.ilo.conf
  [ilo]
  login = Administrator
  password = AdminPass

  [license]
  ilo3_advanced = FAKEL-ICENS-EFORH-PILO3-XXXXX

  $ hpilo_cli example-server.int.kaarsemaker.net activate_license key='$license.ilo3_advanced'

Using hponcfg to talk to the local iLO device to reset the password without knowing it::

  $ hpilo_cli -P local localhost mod_user user_login=Administrator password=NewPassword

``-P local`` is optional when specifying localhost as hostname, so this works too::

  $ hpilo_cli localhost mod_user user_login=Administrator password=NewPassword

If hponcfg is not in the default install location and not in your :data:`$PATH`
or :data:`%PATH%`, you can set an alternative path in the configuration file.

.. code-block:: ini

  [ilo]
  hponcfg = /usr/local/bin/hponcfg

Available methods
-----------------
All methods available to the python API are also available to the command line.
These methods are documented separately in further pages here and in the `ilo
scripting guide`_ published by Hewlett Packard Enterprise.

.. _`hp`: http://www.hpe.com/info/ilo
.. _`ilo scripting guide`: http://www.hpe.com/support/ilo4_cli_gde_en