Initial commit
This commit is contained in:
commit
1b51716d1b
72 changed files with 8204 additions and 0 deletions
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
.redfish.log
|
||||||
|
.vscode/
|
||||||
|
.coverage
|
||||||
|
__pycache__
|
||||||
|
dist/
|
||||||
674
LICENSE
Normal file
674
LICENSE
Normal file
|
|
@ -0,0 +1,674 @@
|
||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The GNU General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
the GNU General Public License is intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains free
|
||||||
|
software for all its users. We, the Free Software Foundation, use the
|
||||||
|
GNU General Public License for most of our software; it applies also to
|
||||||
|
any other work released this way by its authors. You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to prevent others from denying you
|
||||||
|
these rights or asking you to surrender the rights. Therefore, you have
|
||||||
|
certain responsibilities if you distribute copies of the software, or if
|
||||||
|
you modify it: responsibilities to respect the freedom of others.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must pass on to the recipients the same
|
||||||
|
freedoms that you received. You must make sure that they, too, receive
|
||||||
|
or can get the source code. And you must show them these terms so they
|
||||||
|
know their rights.
|
||||||
|
|
||||||
|
Developers that use the GNU GPL protect your rights with two steps:
|
||||||
|
(1) assert copyright on the software, and (2) offer you this License
|
||||||
|
giving you legal permission to copy, distribute and/or modify it.
|
||||||
|
|
||||||
|
For the developers' and authors' protection, the GPL clearly explains
|
||||||
|
that there is no warranty for this free software. For both users' and
|
||||||
|
authors' sake, the GPL requires that modified versions be marked as
|
||||||
|
changed, so that their problems will not be attributed erroneously to
|
||||||
|
authors of previous versions.
|
||||||
|
|
||||||
|
Some devices are designed to deny users access to install or run
|
||||||
|
modified versions of the software inside them, although the manufacturer
|
||||||
|
can do so. This is fundamentally incompatible with the aim of
|
||||||
|
protecting users' freedom to change the software. The systematic
|
||||||
|
pattern of such abuse occurs in the area of products for individuals to
|
||||||
|
use, which is precisely where it is most unacceptable. Therefore, we
|
||||||
|
have designed this version of the GPL to prohibit the practice for those
|
||||||
|
products. If such problems arise substantially in other domains, we
|
||||||
|
stand ready to extend this provision to those domains in future versions
|
||||||
|
of the GPL, as needed to protect the freedom of users.
|
||||||
|
|
||||||
|
Finally, every program is threatened constantly by software patents.
|
||||||
|
States should not allow patents to restrict development and use of
|
||||||
|
software on general-purpose computers, but in those that do, we wish to
|
||||||
|
avoid the special danger that patents applied to a free program could
|
||||||
|
make it effectively proprietary. To prevent this, the GPL assures that
|
||||||
|
patents cannot be used to render the program non-free.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Use with the GNU Affero General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU Affero General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the special requirements of the GNU Affero General Public License,
|
||||||
|
section 13, concerning interaction through a network will apply to the
|
||||||
|
combination as such.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
state the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program does terminal interaction, make it output a short
|
||||||
|
notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
|
<program> Copyright (C) <year> <name of author>
|
||||||
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, your program's commands
|
||||||
|
might be different; for a GUI interface, you would use an "about box".
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
|
For more information on this, and how to apply and follow the GNU GPL, see
|
||||||
|
<https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
The GNU General Public License does not permit incorporating your program
|
||||||
|
into proprietary programs. If your program is a subroutine library, you
|
||||||
|
may consider it more useful to permit linking proprietary applications with
|
||||||
|
the library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License. But first, please read
|
||||||
|
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||||
5
README.md
Normal file
5
README.md
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
# Redfish CLI
|
||||||
|
|
||||||
|
This is a set of scripts for interacting with servers using Redfish.
|
||||||
|
|
||||||
|
Currently tested against Dell T320s and Redfish version x.x but I plan to cover other vendors later.
|
||||||
20
docs/Makefile
Normal file
20
docs/Makefile
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
# Minimal makefile for Sphinx documentation
|
||||||
|
#
|
||||||
|
|
||||||
|
# You can set these variables from the command line, and also
|
||||||
|
# from the environment for the first two.
|
||||||
|
SPHINXOPTS ?=
|
||||||
|
SPHINXBUILD ?= sphinx-build
|
||||||
|
SOURCEDIR = .
|
||||||
|
BUILDDIR = _build
|
||||||
|
|
||||||
|
# Put it first so that "make" without argument is like "make help".
|
||||||
|
help:
|
||||||
|
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
||||||
|
|
||||||
|
.PHONY: help Makefile
|
||||||
|
|
||||||
|
# Catch-all target: route all unknown targets to Sphinx using the new
|
||||||
|
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
|
||||||
|
%: Makefile
|
||||||
|
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
||||||
28
docs/conf.py
Normal file
28
docs/conf.py
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
# Configuration file for the Sphinx documentation builder.
|
||||||
|
#
|
||||||
|
# For the full list of built-in configuration values, see the documentation:
|
||||||
|
# https://www.sphinx-doc.org/en/master/usage/configuration.html
|
||||||
|
|
||||||
|
# -- Project information -----------------------------------------------------
|
||||||
|
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
|
||||||
|
|
||||||
|
project = 'Redfish CLI'
|
||||||
|
copyright = '2023, Neill Cox'
|
||||||
|
author = 'Neill Cox'
|
||||||
|
release = '0.0.1'
|
||||||
|
|
||||||
|
# -- General configuration ---------------------------------------------------
|
||||||
|
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
|
||||||
|
|
||||||
|
extensions = []
|
||||||
|
|
||||||
|
templates_path = ['_templates']
|
||||||
|
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# -- Options for HTML output -------------------------------------------------
|
||||||
|
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
|
||||||
|
|
||||||
|
html_theme = 'alabaster'
|
||||||
|
html_static_path = ['_static']
|
||||||
20
docs/index.rst
Normal file
20
docs/index.rst
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
.. Redfish CLI documentation master file, created by
|
||||||
|
sphinx-quickstart on Wed Jun 28 19:38:08 2023.
|
||||||
|
You can adapt this file completely to your liking, but it should at least
|
||||||
|
contain the root `toctree` directive.
|
||||||
|
|
||||||
|
Welcome to Redfish CLI's documentation!
|
||||||
|
=======================================
|
||||||
|
|
||||||
|
.. toctree::
|
||||||
|
:maxdepth: 2
|
||||||
|
:caption: Contents:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Indices and tables
|
||||||
|
==================
|
||||||
|
|
||||||
|
* :ref:`genindex`
|
||||||
|
* :ref:`modindex`
|
||||||
|
* :ref:`search`
|
||||||
35
docs/make.bat
Normal file
35
docs/make.bat
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
@ECHO OFF
|
||||||
|
|
||||||
|
pushd %~dp0
|
||||||
|
|
||||||
|
REM Command file for Sphinx documentation
|
||||||
|
|
||||||
|
if "%SPHINXBUILD%" == "" (
|
||||||
|
set SPHINXBUILD=sphinx-build
|
||||||
|
)
|
||||||
|
set SOURCEDIR=.
|
||||||
|
set BUILDDIR=_build
|
||||||
|
|
||||||
|
%SPHINXBUILD% >NUL 2>NUL
|
||||||
|
if errorlevel 9009 (
|
||||||
|
echo.
|
||||||
|
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
|
||||||
|
echo.installed, then set the SPHINXBUILD environment variable to point
|
||||||
|
echo.to the full path of the 'sphinx-build' executable. Alternatively you
|
||||||
|
echo.may add the Sphinx directory to PATH.
|
||||||
|
echo.
|
||||||
|
echo.If you don't have Sphinx installed, grab it from
|
||||||
|
echo.https://www.sphinx-doc.org/
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
|
||||||
|
if "%1" == "" goto help
|
||||||
|
|
||||||
|
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
||||||
|
goto end
|
||||||
|
|
||||||
|
:help
|
||||||
|
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
||||||
|
|
||||||
|
:end
|
||||||
|
popd
|
||||||
31
pyproject.toml
Normal file
31
pyproject.toml
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
[build-system]
|
||||||
|
requires = ["hatchling"]
|
||||||
|
build-backend = "hatchling.build"
|
||||||
|
|
||||||
|
[project]
|
||||||
|
name = "redfish_cli"
|
||||||
|
version = "0.0.1"
|
||||||
|
authors = [
|
||||||
|
{ name="Neill Cox", email="neill@ingenious.com.au" },
|
||||||
|
]
|
||||||
|
description = "A set of command line scripts for interacting with servers via Redfish"
|
||||||
|
readme = "README.md"
|
||||||
|
requires-python = ">=3.8"
|
||||||
|
classifiers = [
|
||||||
|
"Programming Language :: Python :: 3",
|
||||||
|
"License :: OSI Approved :: MIT License",
|
||||||
|
"Operating System :: OS Independent",
|
||||||
|
]
|
||||||
|
dependencies = [
|
||||||
|
"requests",
|
||||||
|
"tabulate"
|
||||||
|
]
|
||||||
|
|
||||||
|
[project.urls]
|
||||||
|
"Homepage" = "https://gitlab.com/neillc/redfish_cli"
|
||||||
|
"Bug Tracker" = "https://gitlab.com/neillc/redfish_cli/issues"
|
||||||
|
|
||||||
|
[project.scripts]
|
||||||
|
# version = "redfish_cli.redfish:redfish_version"
|
||||||
|
rf_get = "redfish_cli.cli:get"
|
||||||
|
redfish = "redfish_cli.cli:redfish"
|
||||||
1380
redfish.log
Normal file
1380
redfish.log
Normal file
File diff suppressed because one or more lines are too long
0
src/redfish_cli/__init__.py
Normal file
0
src/redfish_cli/__init__.py
Normal file
86
src/redfish_cli/api/__init__.py
Normal file
86
src/redfish_cli/api/__init__.py
Normal file
|
|
@ -0,0 +1,86 @@
|
||||||
|
"""
|
||||||
|
This module provides the actual api for talking to a Dell iDRAC via redfish.
|
||||||
|
|
||||||
|
At some point in the future it will alos provide access to HP ILOMs and
|
||||||
|
possibly other vendor's redfish implementations but at present I only have a
|
||||||
|
Dell to test against.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import json
|
||||||
|
import logging
|
||||||
|
import time
|
||||||
|
|
||||||
|
|
||||||
|
from .exceptions import (
|
||||||
|
ResponseNotOK,
|
||||||
|
LogicalVolumeCreationFailure,
|
||||||
|
FailedToGetJobID,
|
||||||
|
DellOnly,
|
||||||
|
FailedToSetPowerState,
|
||||||
|
InvalidRaidLevel,
|
||||||
|
)
|
||||||
|
from .utils import delete, get, post, redfish_url
|
||||||
|
from .jobs import job_details, jobs_list
|
||||||
|
|
||||||
|
|
||||||
|
def chassis(server: str, username: str, password: str):
|
||||||
|
"""Get the list of chassis for a server."""
|
||||||
|
url = redfish_url(server, "Chassis")
|
||||||
|
|
||||||
|
response = get(server, url, username=username, password=password)
|
||||||
|
|
||||||
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
def chassis_details(server: str, username: str, password: str, chassis: str):
|
||||||
|
"""Get the details of a specific chassis in a server."""
|
||||||
|
# pylint: disable=redefined-outer-name
|
||||||
|
url = f"{redfish_url(server, 'Chassis')}/{chassis}"
|
||||||
|
|
||||||
|
response = get(server, url, username=username, password=password)
|
||||||
|
|
||||||
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
def firmware_version(args):
|
||||||
|
"""
|
||||||
|
Convert a firmware version from a string like 2.65.65.65 to an int so we
|
||||||
|
can take different actions depending on the firmware version.
|
||||||
|
|
||||||
|
This is incredibly Dell specific
|
||||||
|
"""
|
||||||
|
return int("".join(manager(args)["FirmwareVersion"].split(".")))
|
||||||
|
|
||||||
|
|
||||||
|
def manager(args):
|
||||||
|
"""Get the details of a manager"""
|
||||||
|
try:
|
||||||
|
if not args.manager:
|
||||||
|
args.manager = "iDRAC.Embedded.1"
|
||||||
|
except AttributeError:
|
||||||
|
args.manager = "iDRAC.Embedded.1"
|
||||||
|
|
||||||
|
url = f"Managers/{args.manager}"
|
||||||
|
|
||||||
|
return get(args.server, url, args.username, args.password)
|
||||||
|
|
||||||
|
|
||||||
|
def product(server):
|
||||||
|
"""Get the product description for a server"""
|
||||||
|
return get(server, "")["Product"]
|
||||||
|
|
||||||
|
|
||||||
|
def redfish_version(server: str):
|
||||||
|
"""Get the version of redfish implemented by the BMC"""
|
||||||
|
logging.debug("server=%s", server)
|
||||||
|
return get(server, "")["RedfishVersion"]
|
||||||
|
|
||||||
|
|
||||||
|
def service_tag(server: str):
|
||||||
|
"""Get the service tag of a (Dell) server"""
|
||||||
|
details = get(server, "")
|
||||||
|
|
||||||
|
if "Dell" not in details["Oem"]:
|
||||||
|
raise DellOnly
|
||||||
|
|
||||||
|
return details["Oem"]["Dell"]["ServiceTag"]
|
||||||
55
src/redfish_cli/api/exceptions.py
Normal file
55
src/redfish_cli/api/exceptions.py
Normal file
|
|
@ -0,0 +1,55 @@
|
||||||
|
"""Exceptions raised byu the api"""
|
||||||
|
|
||||||
|
|
||||||
|
class Unauthorized(Exception):
|
||||||
|
"""
|
||||||
|
An exception reaised when a redfish endpoint that requires authentication
|
||||||
|
is accessed without proper credentials.
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
class DellOnly(Exception):
|
||||||
|
"""
|
||||||
|
Raised when attempting to access an endpoint only available on Dells when
|
||||||
|
the BMC is from a different vendor.
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
class FailedToSetPowerState(Exception):
|
||||||
|
"""Raised when an invalid powerstate is set"""
|
||||||
|
|
||||||
|
def __init__(self, msg=None):
|
||||||
|
self.msg = msg
|
||||||
|
|
||||||
|
|
||||||
|
class FailedToGetJobID(Exception):
|
||||||
|
"""Raised when we fail to get a job id"""
|
||||||
|
|
||||||
|
def __init__(self, msg=None):
|
||||||
|
self.msg = msg
|
||||||
|
|
||||||
|
|
||||||
|
class InvalidRaidLevel(Exception):
|
||||||
|
"""Raised when an invalid raid level is specified"""
|
||||||
|
|
||||||
|
def __init__(self, msg=None):
|
||||||
|
self.msg = msg
|
||||||
|
|
||||||
|
|
||||||
|
class LogicalVolumeCreationFailure(Exception):
|
||||||
|
"""Raised when the POST to create a logical volume fails"""
|
||||||
|
|
||||||
|
# pylint: disable=dangerous-default-value
|
||||||
|
|
||||||
|
def __init__(self, json={}):
|
||||||
|
self.json = json
|
||||||
|
|
||||||
|
|
||||||
|
class ResponseNotOK(Exception):
|
||||||
|
"""
|
||||||
|
Raised when the reponse (from a requests api call) is not ok, if no more
|
||||||
|
specific exception is available.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, response=None):
|
||||||
|
self.response = response
|
||||||
20
src/redfish_cli/api/jobs.py
Normal file
20
src/redfish_cli/api/jobs.py
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
"""Interact with jobs on a manager. Probably very Dell specific"""
|
||||||
|
|
||||||
|
from .utils import get
|
||||||
|
|
||||||
|
|
||||||
|
def job_details(args):
|
||||||
|
"""Get the details of a job"""
|
||||||
|
url = f"Managers/{args.manager}/Jobs/{args.job_id}"
|
||||||
|
# Managers/iDRAC.Embedded.1/Jobs/JID_924369311959
|
||||||
|
return get(
|
||||||
|
args.server, url, username=args.username, password=args.password
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def jobs_list(args):
|
||||||
|
"""Get the list of jobs for a manager"""
|
||||||
|
url = f"Managers/{args.manager}/Jobs?$expand=.($levels=1)"
|
||||||
|
return get(
|
||||||
|
args.server, url, username=args.username, password=args.password
|
||||||
|
)
|
||||||
95
src/redfish_cli/api/power.py
Normal file
95
src/redfish_cli/api/power.py
Normal file
|
|
@ -0,0 +1,95 @@
|
||||||
|
"""Power related api functions"""
|
||||||
|
|
||||||
|
from .exceptions import FailedToSetPowerState, ResponseNotOK
|
||||||
|
from .systems import system_details
|
||||||
|
from .utils import post
|
||||||
|
|
||||||
|
|
||||||
|
def system_power_state(args):
|
||||||
|
"""Get the current power state of a system"""
|
||||||
|
details = system_details(
|
||||||
|
args.server, args.username, args.password, args.system
|
||||||
|
)
|
||||||
|
return details["PowerState"]
|
||||||
|
|
||||||
|
|
||||||
|
def system_power_states_allowed(args):
|
||||||
|
"""Get the list of allowed power states"""
|
||||||
|
details = system_details(
|
||||||
|
args.server, args.username, args.password, args.system
|
||||||
|
)
|
||||||
|
return details["Actions"]["#ComputerSystem.Reset"][
|
||||||
|
"ResetType@Redfish.AllowableValues"
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def system_set_power_state(args):
|
||||||
|
"""Set the power state of a system"""
|
||||||
|
url = f"Systems/{args.system}/Actions/ComputerSystem.Reset"
|
||||||
|
payload = {"ResetType": args.power_state}
|
||||||
|
|
||||||
|
try:
|
||||||
|
_ = post(
|
||||||
|
args.server,
|
||||||
|
url,
|
||||||
|
data=payload,
|
||||||
|
username=args.username,
|
||||||
|
password=args.password,
|
||||||
|
)
|
||||||
|
return f"Powerstate set to {args.power_state}"
|
||||||
|
except ResponseNotOK as exc:
|
||||||
|
raise FailedToSetPowerState(msg=exc.response.text) from exc
|
||||||
|
|
||||||
|
|
||||||
|
def system_reset(args):
|
||||||
|
"""Reset a system"""
|
||||||
|
url = f"Systems/{args.system}/Actions/ComputerSystem.Reset"
|
||||||
|
payload = {"ResetType": "ForceRestart"}
|
||||||
|
|
||||||
|
try:
|
||||||
|
_ = post(
|
||||||
|
args.server,
|
||||||
|
url,
|
||||||
|
data=payload,
|
||||||
|
username=args.username,
|
||||||
|
password=args.password,
|
||||||
|
)
|
||||||
|
return "System reset"
|
||||||
|
except ResponseNotOK as exc:
|
||||||
|
raise FailedToSetPowerState(msg=exc.response.text) from exc
|
||||||
|
|
||||||
|
|
||||||
|
def system_power_on(args):
|
||||||
|
"""Power on a system"""
|
||||||
|
url = f"Systems/{args.system}/Actions/ComputerSystem.Reset"
|
||||||
|
payload = {"ResetType": "On"}
|
||||||
|
|
||||||
|
try:
|
||||||
|
_ = post(
|
||||||
|
args.server,
|
||||||
|
url,
|
||||||
|
data=payload,
|
||||||
|
username=args.username,
|
||||||
|
password=args.password,
|
||||||
|
)
|
||||||
|
return f"{args.system} powered on"
|
||||||
|
except ResponseNotOK as exc:
|
||||||
|
raise FailedToSetPowerState(msg=exc.response.text) from exc
|
||||||
|
|
||||||
|
|
||||||
|
def system_power_off(args):
|
||||||
|
"""Power off a system"""
|
||||||
|
url = f"Systems/{args.system}/Actions/ComputerSystem.Reset"
|
||||||
|
payload = {"ResetType": "ForceOff"}
|
||||||
|
|
||||||
|
try:
|
||||||
|
_ = post(
|
||||||
|
args.server,
|
||||||
|
url,
|
||||||
|
data=payload,
|
||||||
|
username=args.username,
|
||||||
|
password=args.password,
|
||||||
|
)
|
||||||
|
return f"{args.system} powered off"
|
||||||
|
except ResponseNotOK as exc:
|
||||||
|
raise FailedToSetPowerState(msg=exc.response.text) from exc
|
||||||
303
src/redfish_cli/api/storage.py
Normal file
303
src/redfish_cli/api/storage.py
Normal file
|
|
@ -0,0 +1,303 @@
|
||||||
|
"""
|
||||||
|
Storage related functions
|
||||||
|
"""
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
|
from redfish_cli.api import delete, get, redfish_url
|
||||||
|
from redfish_cli import api
|
||||||
|
|
||||||
|
from .exceptions import (
|
||||||
|
FailedToGetJobID,
|
||||||
|
InvalidRaidLevel,
|
||||||
|
ResponseNotOK,
|
||||||
|
LogicalVolumeCreationFailure,
|
||||||
|
)
|
||||||
|
from .utils import post
|
||||||
|
|
||||||
|
|
||||||
|
def storage_controller_details(args):
|
||||||
|
"""
|
||||||
|
Get the details of a storage controllers (default to the first) for a system
|
||||||
|
(defaults to the first - and usually only - system in the server).
|
||||||
|
"""
|
||||||
|
logging.debug(
|
||||||
|
"server: %s username: %s system: %s controller: %s",
|
||||||
|
args.server,
|
||||||
|
args.username,
|
||||||
|
args.system,
|
||||||
|
args.controller,
|
||||||
|
)
|
||||||
|
|
||||||
|
if not args.controller:
|
||||||
|
controllers = list_storage_controllers(args)
|
||||||
|
args.controller = controllers["Members"][0]["@odata.id"].split("/")[-1]
|
||||||
|
|
||||||
|
url = f"{redfish_url(args.server, 'Systems')}/{args.system}/Storage/{args.controller}"
|
||||||
|
|
||||||
|
response = get(
|
||||||
|
args.server, url, username=args.username, password=args.password
|
||||||
|
)
|
||||||
|
|
||||||
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
def create_logical_volume(args):
|
||||||
|
"""Create a logical volume"""
|
||||||
|
# Raid levels - note this changes after Firmware 4.40, but I only have 2.65 to test against.
|
||||||
|
#
|
||||||
|
# From https://github.com/dell/iDRAC-Redfish-Scripting CreateVirtualDiskREDFISH.py L247
|
||||||
|
|
||||||
|
# pylint: disable=too-many-branches,too-many-statements
|
||||||
|
|
||||||
|
version = api.firmware_version(args)
|
||||||
|
|
||||||
|
if version < 4400000:
|
||||||
|
raid_levels = {
|
||||||
|
"0": "NonRedundant",
|
||||||
|
"1": "Mirrored",
|
||||||
|
"5": "StripedWithParity",
|
||||||
|
"10": "SpannedMirrors",
|
||||||
|
"50": "SpannedStripesWithParity",
|
||||||
|
}
|
||||||
|
else:
|
||||||
|
raid_levels = {
|
||||||
|
"0": "RAID0",
|
||||||
|
"1": "RAID1",
|
||||||
|
"5": "RAID5",
|
||||||
|
"6": "RAID6",
|
||||||
|
"10": "RAID10",
|
||||||
|
"50": "RAID50",
|
||||||
|
"60": "RAID60",
|
||||||
|
}
|
||||||
|
|
||||||
|
payload = {}
|
||||||
|
|
||||||
|
if version < 4400000:
|
||||||
|
volume_type_key = "VolumeType"
|
||||||
|
else:
|
||||||
|
volume_type_key = "RAIDType"
|
||||||
|
try:
|
||||||
|
volume_type = raid_levels[args.raid_level]
|
||||||
|
except KeyError as exc:
|
||||||
|
raise InvalidRaidLevel(
|
||||||
|
msg=f"{args.raid_level} is not a valid raid level. Valid choices are 0,1,5,10,50"
|
||||||
|
) from exc
|
||||||
|
|
||||||
|
payload[volume_type_key] = volume_type
|
||||||
|
|
||||||
|
if args.size:
|
||||||
|
payload["CapacityBytes"] = args.size
|
||||||
|
|
||||||
|
if args.stripe_size:
|
||||||
|
payload["OptimumIOSizeBytes"] = args.stripe_size
|
||||||
|
|
||||||
|
if args.name:
|
||||||
|
payload["Name"] = args.name
|
||||||
|
|
||||||
|
if args.secure:
|
||||||
|
payload["Encrypted"] = True
|
||||||
|
if args.disk_cache_policy:
|
||||||
|
payload["Oem"] = {
|
||||||
|
"Dell": {"DellVolume": {"DiskCachePolicy": args.disk_cache_policy}}
|
||||||
|
}
|
||||||
|
if args.read_cache_policy:
|
||||||
|
payload["ReadCachePolicy"] = args.read_cache_policy
|
||||||
|
if args.write_cache_policy:
|
||||||
|
payload["WriteCachePolicy"] = args.write_cache_policy
|
||||||
|
|
||||||
|
disks = [
|
||||||
|
{
|
||||||
|
"@odata.id": (
|
||||||
|
f"/redfish/v1/Systems/{args.system}/"
|
||||||
|
f"Storage/Drives/{disk}:{args.controller}"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
for disk in args.disk
|
||||||
|
]
|
||||||
|
payload["Drives"] = disks
|
||||||
|
|
||||||
|
url = f"Systems/{args.system}/Storage/{args.controller}/Volumes"
|
||||||
|
|
||||||
|
try:
|
||||||
|
response = post(
|
||||||
|
args.server,
|
||||||
|
url,
|
||||||
|
data=payload,
|
||||||
|
username=args.username,
|
||||||
|
password=args.password,
|
||||||
|
)
|
||||||
|
except ResponseNotOK as exc:
|
||||||
|
raise LogicalVolumeCreationFailure(json=exc.response.json()) from exc
|
||||||
|
try:
|
||||||
|
job_id = response.headers["Location"].split("/")[-1]
|
||||||
|
except KeyError as exc:
|
||||||
|
logging.error("- FAIL, unable to locate job ID in JSON headers output")
|
||||||
|
raise FailedToGetJobID from exc
|
||||||
|
|
||||||
|
return {"job_id": job_id}
|
||||||
|
|
||||||
|
|
||||||
|
def delete_logical_volume(args):
|
||||||
|
"""Delete a logical volume"""
|
||||||
|
url = redfish_url(
|
||||||
|
args.server, f"Systems/System.Embedded.1/Storage/Volumes/{args.disk}"
|
||||||
|
)
|
||||||
|
response = delete(
|
||||||
|
args.server,
|
||||||
|
url,
|
||||||
|
username=args.username,
|
||||||
|
password=args.password,
|
||||||
|
verify=args.verify,
|
||||||
|
)
|
||||||
|
|
||||||
|
result = response
|
||||||
|
|
||||||
|
try:
|
||||||
|
job_id = result.headers["Location"].split("/")[-1]
|
||||||
|
except KeyError as exc:
|
||||||
|
logging.error("unable to locate job ID in JSON headers output")
|
||||||
|
raise FailedToGetJobID(msg=response.text) from exc
|
||||||
|
|
||||||
|
return {"job_id": job_id}
|
||||||
|
|
||||||
|
|
||||||
|
def list_logical_volumes(args):
|
||||||
|
"""
|
||||||
|
Get a list of the logical volumes for a specirfic storage controller
|
||||||
|
(defaulting to the first on in the system) for a specific system
|
||||||
|
(defaulting to the first one).
|
||||||
|
"""
|
||||||
|
# If no controller has been specified,get the first one.
|
||||||
|
|
||||||
|
if not args.controller:
|
||||||
|
args.controller = list_storage_controllers(args)["Members"][0][
|
||||||
|
"@odata.id"
|
||||||
|
].split("/")[-1]
|
||||||
|
|
||||||
|
url = f"Systems/{args.system}/Storage/{args.controller}/Volumes"
|
||||||
|
|
||||||
|
if args.expand:
|
||||||
|
url += "?$expand=.($levels=1)"
|
||||||
|
|
||||||
|
response = get(
|
||||||
|
args.server, url, username=args.username, password=args.password
|
||||||
|
)
|
||||||
|
|
||||||
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
def list_physical_volumes(args):
|
||||||
|
"""
|
||||||
|
Get a list of the physical volumes for a specific storage controller
|
||||||
|
(defaulting to the first on in the system) for a specific system
|
||||||
|
(defaulting to the first one).
|
||||||
|
"""
|
||||||
|
logging.debug(
|
||||||
|
"list_physical volumes - server %s username %s controller %s system %s",
|
||||||
|
args.server,
|
||||||
|
args.username,
|
||||||
|
args.controller,
|
||||||
|
args.system,
|
||||||
|
)
|
||||||
|
# If no controller has been specified,get the first one.
|
||||||
|
if not args.controller:
|
||||||
|
args.controller = list_storage_controllers(args)["Members"][0][
|
||||||
|
"@odata.id"
|
||||||
|
].split("/")[-1]
|
||||||
|
|
||||||
|
url = f"{redfish_url(args.server, 'Systems')}/{args.system}/Storage/{args.controller}"
|
||||||
|
|
||||||
|
response = get(
|
||||||
|
args.server, url, username=args.username, password=args.password
|
||||||
|
)
|
||||||
|
|
||||||
|
# Note this is probably Dell specific
|
||||||
|
result = []
|
||||||
|
for drive in response["Drives"]:
|
||||||
|
details = drive["@odata.id"].split("/")
|
||||||
|
result.append(
|
||||||
|
{
|
||||||
|
"system": details[4],
|
||||||
|
"drive": details[-1],
|
||||||
|
"url": drive["@odata.id"],
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def list_storage_controllers(args):
|
||||||
|
"""
|
||||||
|
Get the list of storage controllers for a system (defaults to the first -
|
||||||
|
and usually only - system in the server).
|
||||||
|
"""
|
||||||
|
url = f"{redfish_url(args.server, 'Systems')}/{args.system}/Storage"
|
||||||
|
response = get(
|
||||||
|
args.server, url, username=args.username, password=args.password
|
||||||
|
)
|
||||||
|
|
||||||
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
def logical_volume_details(args):
|
||||||
|
# server, username, password, drive, drive_index, system="System.Embedded.1"
|
||||||
|
# ):
|
||||||
|
"""
|
||||||
|
Get the details of a logical volume
|
||||||
|
"""
|
||||||
|
|
||||||
|
# pylint: disable=too-many-arguments
|
||||||
|
|
||||||
|
if not args.drive:
|
||||||
|
args.drive = list_logical_volumes(args)["Members"][0][
|
||||||
|
"@odata.id"
|
||||||
|
].split("/")[-1]
|
||||||
|
|
||||||
|
url = f"{redfish_url(args.server, 'Systems')}/{args.system}/Storage/Volumes/{args.drive}"
|
||||||
|
response = get(
|
||||||
|
args.server, url, username=args.username, password=args.password
|
||||||
|
)
|
||||||
|
|
||||||
|
if args.drive_index:
|
||||||
|
logging.warning("drive_index supplied, but not yet implemented.")
|
||||||
|
|
||||||
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
def physical_volume(args):
|
||||||
|
"""
|
||||||
|
Get the details of a physical volume for a specific storage controller
|
||||||
|
(defaulting to the first on in the system) for a specific system
|
||||||
|
(defaulting to the first one).
|
||||||
|
"""
|
||||||
|
logging.debug(
|
||||||
|
"physical volumes - server %s username %s "
|
||||||
|
"controller %s system %s drive %s",
|
||||||
|
args.server,
|
||||||
|
args.username,
|
||||||
|
args.controller,
|
||||||
|
args.system,
|
||||||
|
args.drive,
|
||||||
|
)
|
||||||
|
|
||||||
|
if not args.system:
|
||||||
|
args.system = "System.Embedded.1"
|
||||||
|
|
||||||
|
# If no controller has been specified,get the first one.
|
||||||
|
if not args.controller:
|
||||||
|
args.controller = list_storage_controllers(args)["Members"][0][
|
||||||
|
"@odata.id"
|
||||||
|
].split("/")[-1]
|
||||||
|
|
||||||
|
# If no drive has been specified,get the first one.
|
||||||
|
if not args.drive:
|
||||||
|
args.drive = list_physical_volumes(args)
|
||||||
|
|
||||||
|
url = f"{redfish_url(args.server, 'Systems')}/{args.system}/Storage/Drives/{args.drive}"
|
||||||
|
|
||||||
|
response = get(
|
||||||
|
args.server, url, username=args.username, password=args.password
|
||||||
|
)
|
||||||
|
|
||||||
|
return response
|
||||||
12
src/redfish_cli/api/systems.py
Normal file
12
src/redfish_cli/api/systems.py
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
"""Power related api functions"""
|
||||||
|
|
||||||
|
from .utils import get, redfish_url
|
||||||
|
|
||||||
|
|
||||||
|
def system_details(server: str, username: str, password: str, system: str):
|
||||||
|
"""Get the detailed information about a system"""
|
||||||
|
url = f"{redfish_url(server, 'Systems')}/{system}"
|
||||||
|
|
||||||
|
response = get(server, url, username=username, password=password)
|
||||||
|
|
||||||
|
return response
|
||||||
133
src/redfish_cli/api/utils.py
Normal file
133
src/redfish_cli/api/utils.py
Normal file
|
|
@ -0,0 +1,133 @@
|
||||||
|
"""
|
||||||
|
Utility functions for the api
|
||||||
|
"""
|
||||||
|
import json
|
||||||
|
import logging
|
||||||
|
|
||||||
|
|
||||||
|
import requests
|
||||||
|
from requests.auth import HTTPBasicAuth
|
||||||
|
|
||||||
|
|
||||||
|
from .exceptions import ResponseNotOK, Unauthorized
|
||||||
|
|
||||||
|
|
||||||
|
BASE_URL = "/redfish/v1"
|
||||||
|
|
||||||
|
|
||||||
|
def delete(
|
||||||
|
server: str,
|
||||||
|
url: str,
|
||||||
|
username=None,
|
||||||
|
password=None,
|
||||||
|
verify=False,
|
||||||
|
):
|
||||||
|
"""Process an HTTP delete action"""
|
||||||
|
basic = None
|
||||||
|
|
||||||
|
if username:
|
||||||
|
basic = HTTPBasicAuth(username, password)
|
||||||
|
|
||||||
|
headers = {"content-type": "application/json"}
|
||||||
|
|
||||||
|
response = requests.delete(
|
||||||
|
redfish_url(server, url),
|
||||||
|
auth=basic,
|
||||||
|
verify=verify,
|
||||||
|
headers=headers,
|
||||||
|
timeout=30,
|
||||||
|
)
|
||||||
|
|
||||||
|
if not response.ok:
|
||||||
|
raise ResponseNotOK(response=response)
|
||||||
|
|
||||||
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
def get(server: str, url: str, username=None, password=None):
|
||||||
|
"""Get an arbitrary url"""
|
||||||
|
logging.debug(
|
||||||
|
"args %s",
|
||||||
|
{
|
||||||
|
"server": server,
|
||||||
|
"url": url,
|
||||||
|
"username": username,
|
||||||
|
"password": "********",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
basic = None
|
||||||
|
|
||||||
|
if username:
|
||||||
|
basic = HTTPBasicAuth(username, password)
|
||||||
|
|
||||||
|
response = requests.get(
|
||||||
|
redfish_url(server, url), verify=False, auth=basic, timeout=30
|
||||||
|
)
|
||||||
|
|
||||||
|
if response.status_code == 401:
|
||||||
|
raise Unauthorized
|
||||||
|
|
||||||
|
if not response.ok:
|
||||||
|
logging.debug(response.text)
|
||||||
|
raise ResponseNotOK(response=response)
|
||||||
|
|
||||||
|
try:
|
||||||
|
result = json.loads(response.text)
|
||||||
|
return result
|
||||||
|
except json.decoder.JSONDecodeError:
|
||||||
|
print(response.text)
|
||||||
|
raise
|
||||||
|
|
||||||
|
|
||||||
|
def post(
|
||||||
|
server: str,
|
||||||
|
url: str,
|
||||||
|
data=None,
|
||||||
|
username=None,
|
||||||
|
password=None,
|
||||||
|
verify=False,
|
||||||
|
):
|
||||||
|
"""
|
||||||
|
Wrapper for requsts.post
|
||||||
|
"""
|
||||||
|
|
||||||
|
# pylint: disable=too-many-arguments
|
||||||
|
|
||||||
|
logging.warning(
|
||||||
|
"Processing post %s",
|
||||||
|
{"server": server, "url": url, "username": username, "data": data},
|
||||||
|
)
|
||||||
|
basic = None
|
||||||
|
|
||||||
|
if username:
|
||||||
|
basic = HTTPBasicAuth(username, password)
|
||||||
|
|
||||||
|
headers = {"content-type": "application/json"}
|
||||||
|
|
||||||
|
response = requests.post(
|
||||||
|
redfish_url(server, url),
|
||||||
|
auth=basic,
|
||||||
|
verify=verify,
|
||||||
|
data=json.dumps(data),
|
||||||
|
headers=headers,
|
||||||
|
timeout=30,
|
||||||
|
)
|
||||||
|
|
||||||
|
if response.status_code == 401:
|
||||||
|
raise Unauthorized
|
||||||
|
|
||||||
|
if not response.ok:
|
||||||
|
raise ResponseNotOK(response=response)
|
||||||
|
|
||||||
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
def redfish_url(server: str, url: str):
|
||||||
|
"""Helper function to make sure a redfish urls is properly formed."""
|
||||||
|
logging.debug("building url for %s %s", server, url)
|
||||||
|
if not url.startswith(BASE_URL):
|
||||||
|
url = f"{BASE_URL}/{url}"
|
||||||
|
|
||||||
|
url = f"https://{server}{url}"
|
||||||
|
logging.debug("Final url is %s", url)
|
||||||
|
return url
|
||||||
308
src/redfish_cli/cli/__init__.py
Normal file
308
src/redfish_cli/cli/__init__.py
Normal file
|
|
@ -0,0 +1,308 @@
|
||||||
|
"""
|
||||||
|
This module containts all the entry points for the redfish cli tools.
|
||||||
|
|
||||||
|
It uses argparse to add subparses.
|
||||||
|
|
||||||
|
All of this is developed and tested against Dell iDRACs at the moment. At some
|
||||||
|
point in its future there will be a lot of refactoring to deal with other OEMs
|
||||||
|
I expect.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import json
|
||||||
|
import logging
|
||||||
|
import sys
|
||||||
|
|
||||||
|
# PYTHON_ARGCOMPLETE_OK
|
||||||
|
import argcomplete
|
||||||
|
|
||||||
|
from redfish_cli import api
|
||||||
|
from redfish_cli.api import storage
|
||||||
|
import redfish_cli.cli.jobs
|
||||||
|
|
||||||
|
|
||||||
|
from .parsers import parse_args
|
||||||
|
from .utils import error, table, write_output
|
||||||
|
|
||||||
|
|
||||||
|
def chassis(args):
|
||||||
|
"""Entry point: get the list of chassis"""
|
||||||
|
details = api.chassis(args.server, args.username, args.password)
|
||||||
|
write_output(details, output_format=args.format)
|
||||||
|
|
||||||
|
|
||||||
|
def chassis_details(args):
|
||||||
|
"""Entry point: get the details of a chassis"""
|
||||||
|
details = api.chassis_details(
|
||||||
|
args.server, args.username, args.password, args.chassis
|
||||||
|
)
|
||||||
|
write_output(details, output_format=args.format)
|
||||||
|
|
||||||
|
|
||||||
|
def create_logical_volume(args):
|
||||||
|
"""Stub for the create logical volume command"""
|
||||||
|
|
||||||
|
try:
|
||||||
|
result = storage.create_logical_volume(args)
|
||||||
|
write_output(result)
|
||||||
|
except api.exceptions.InvalidRaidLevel as exc:
|
||||||
|
error(exc.msg)
|
||||||
|
except api.exceptions.LogicalVolumeCreationFailure as exc:
|
||||||
|
error(json.dumps(exc.json, indent=2))
|
||||||
|
|
||||||
|
|
||||||
|
def delete_logical_volume(args):
|
||||||
|
"""Delete a logical volume"""
|
||||||
|
logging.debug(args)
|
||||||
|
|
||||||
|
try:
|
||||||
|
result = api.storage.delete_logical_volume(args)
|
||||||
|
write_output(
|
||||||
|
result,
|
||||||
|
output_format=args.format,
|
||||||
|
)
|
||||||
|
# except api.exceptions.FailedToGetJobID as exc:
|
||||||
|
# details = exc.msg
|
||||||
|
# error_msg = (
|
||||||
|
# "An error has occured. The usual cause is that the disk "
|
||||||
|
# f"specified ({args.disk}) does not exist\n"
|
||||||
|
# f"{details}"
|
||||||
|
# )
|
||||||
|
# error(error_msg)
|
||||||
|
|
||||||
|
except api.exceptions.ResponseNotOK as exc:
|
||||||
|
details = exc.response.text
|
||||||
|
error_msg = (
|
||||||
|
"An error has occured. The usual cause is that the disk "
|
||||||
|
f"specified ({args.disk}) does not exist\n"
|
||||||
|
f"{details}"
|
||||||
|
)
|
||||||
|
error(error_msg)
|
||||||
|
|
||||||
|
|
||||||
|
def configure_logging(args):
|
||||||
|
"""Configure logging for the cli"""
|
||||||
|
log_format = (
|
||||||
|
"%(asctime)s - %(pathname)s:%(funcName)s - %(levelname)s - %(message)s"
|
||||||
|
)
|
||||||
|
|
||||||
|
logging.basicConfig(
|
||||||
|
filename="redfish.log",
|
||||||
|
level=getattr(logging, args.log_level.upper()),
|
||||||
|
format=log_format,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def get(args):
|
||||||
|
"""
|
||||||
|
Write the results of an arbitrary get on the specified url to stdout (using
|
||||||
|
print).
|
||||||
|
|
||||||
|
Currently it always dumps the results as json, but it should respect the
|
||||||
|
the output format in the args.
|
||||||
|
|
||||||
|
It will also just exit with an error message if a url requires
|
||||||
|
authentication and no username and password is supplied. This could be
|
||||||
|
handled better.
|
||||||
|
|
||||||
|
"""
|
||||||
|
url = args.url
|
||||||
|
if url is None:
|
||||||
|
url = ""
|
||||||
|
|
||||||
|
if args.expand:
|
||||||
|
url += "?$expand=.($levels=1)"
|
||||||
|
try:
|
||||||
|
result = api.utils.get(
|
||||||
|
args.server,
|
||||||
|
url,
|
||||||
|
username=args.username,
|
||||||
|
password=args.password,
|
||||||
|
)
|
||||||
|
write_output(
|
||||||
|
result,
|
||||||
|
output_format=args.format,
|
||||||
|
)
|
||||||
|
|
||||||
|
except api.exceptions.Unauthorized:
|
||||||
|
error("This url requires authentication\n")
|
||||||
|
except api.exceptions.ResponseNotOK as exc:
|
||||||
|
error(json.dumps(json.loads(exc.response.text), indent=2))
|
||||||
|
|
||||||
|
|
||||||
|
def logical_volume(args):
|
||||||
|
"""
|
||||||
|
Entry point: get the details of a logical volume.
|
||||||
|
|
||||||
|
By default the first logical drive in the first storage controller of the
|
||||||
|
first system.
|
||||||
|
|
||||||
|
"""
|
||||||
|
logging.debug(
|
||||||
|
"server: %s username: %s system: %s controller: %s drive: %s",
|
||||||
|
args.server,
|
||||||
|
args.username,
|
||||||
|
args.system,
|
||||||
|
args.controller,
|
||||||
|
args.drive,
|
||||||
|
)
|
||||||
|
|
||||||
|
try:
|
||||||
|
write_output(
|
||||||
|
storage.logical_volume_details(args),
|
||||||
|
output_format=args.format,
|
||||||
|
)
|
||||||
|
except api.exceptions.ResponseNotOK as exc:
|
||||||
|
error(json.dumps(json.loads(exc.response.text), indent=2))
|
||||||
|
|
||||||
|
|
||||||
|
def logical_volumes(args):
|
||||||
|
"""
|
||||||
|
Entry point: get the list of logical volumes attached to a storage
|
||||||
|
controller (which in turn is part of a system)
|
||||||
|
"""
|
||||||
|
|
||||||
|
try:
|
||||||
|
result = storage.list_logical_volumes(args)
|
||||||
|
write_output(
|
||||||
|
result,
|
||||||
|
output_format=args.format,
|
||||||
|
)
|
||||||
|
except api.exceptions.ResponseNotOK as exc:
|
||||||
|
error(json.dumps(json.loads(exc.response.text), indent=2))
|
||||||
|
|
||||||
|
|
||||||
|
def physical_volume(args):
|
||||||
|
"""
|
||||||
|
Entry point: get the list of physical volumes attached to a storage
|
||||||
|
controller (which in turn is part of a system)
|
||||||
|
"""
|
||||||
|
data = storage.physical_volume(args)
|
||||||
|
|
||||||
|
# if args.format == "text":
|
||||||
|
# result = "\n".join([ f"{x['system']} {x['drive']}" for x in data])
|
||||||
|
# elif args.format == "json":
|
||||||
|
# result = data
|
||||||
|
# elif args.format == "table":
|
||||||
|
# if args.verbose:
|
||||||
|
# table = [ [x['system'], x['drive'], x['url']] for x in data]
|
||||||
|
# headers=["System", "Drive", "URL"]
|
||||||
|
# else:
|
||||||
|
# table = [ [x['system'], x['drive']] for x in data]
|
||||||
|
# headers=["System", "Drive"]
|
||||||
|
|
||||||
|
# result = tabulate(table, headers=headers, tablefmt="outline")
|
||||||
|
|
||||||
|
result = data
|
||||||
|
|
||||||
|
write_output(result, output_format=args.format)
|
||||||
|
|
||||||
|
|
||||||
|
def physical_volumes(args):
|
||||||
|
"""
|
||||||
|
Entry point: get the list of physical volumes attached to a storage
|
||||||
|
controller (which in turn is part of a system)
|
||||||
|
"""
|
||||||
|
data = storage.list_physical_volumes(args)
|
||||||
|
|
||||||
|
if args.format == "text":
|
||||||
|
result = "\n".join([f"{x['system']} {x['drive']}" for x in data])
|
||||||
|
elif args.format == "json":
|
||||||
|
result = data
|
||||||
|
elif args.format == "table":
|
||||||
|
if args.verbose:
|
||||||
|
data = [[x["system"], x["drive"], x["url"]] for x in data]
|
||||||
|
headers = ["System", "Drive", "URL"]
|
||||||
|
else:
|
||||||
|
data = [[x["system"], x["drive"]] for x in data]
|
||||||
|
headers = ["System", "Drive"]
|
||||||
|
|
||||||
|
result = table(data, headers=headers)
|
||||||
|
|
||||||
|
write_output(result, output_format=args.format)
|
||||||
|
|
||||||
|
|
||||||
|
def product(args):
|
||||||
|
"""Entry point: get the product name of a server"""
|
||||||
|
details = api.product(args.server)
|
||||||
|
write_output(details, output_format=args.format)
|
||||||
|
|
||||||
|
|
||||||
|
def redfish(args=None):
|
||||||
|
"""
|
||||||
|
Entrypoint: Base command, gets args from stdin unless they are passed in as
|
||||||
|
a parameter (which probably means we are being called from a test)
|
||||||
|
"""
|
||||||
|
if args is None:
|
||||||
|
args = parse_args(sys.argv[1:])
|
||||||
|
|
||||||
|
if args.debug:
|
||||||
|
args.log_level = "DEBUG"
|
||||||
|
|
||||||
|
configure_logging(args)
|
||||||
|
|
||||||
|
if "func" in args:
|
||||||
|
args.func(args)
|
||||||
|
else:
|
||||||
|
write_output(api.utils.get(args.server, ""), output_format=args.format)
|
||||||
|
|
||||||
|
|
||||||
|
def service_tag(args):
|
||||||
|
"""Entry point: get the service tag of a Dell server"""
|
||||||
|
try:
|
||||||
|
write_output(api.service_tag(args.server), output_format=args.format)
|
||||||
|
except api.exceptions.DellOnly:
|
||||||
|
error("Service tags are only available for Dell iDRACs")
|
||||||
|
|
||||||
|
|
||||||
|
def storage_controller(args):
|
||||||
|
"""Entry point: get the details of a storage controllers in a server"""
|
||||||
|
|
||||||
|
try:
|
||||||
|
result = storage.storage_controller_details(args)
|
||||||
|
write_output(
|
||||||
|
result,
|
||||||
|
output_format=args.format,
|
||||||
|
)
|
||||||
|
except api.exceptions.ResponseNotOK as exc:
|
||||||
|
error(json.dumps(json.loads(exc.response.text), indent=2))
|
||||||
|
|
||||||
|
|
||||||
|
def storage_controllers(args):
|
||||||
|
"""Entry point: get the list of storage controllers in a server"""
|
||||||
|
|
||||||
|
result = storage.list_storage_controllers(args)
|
||||||
|
|
||||||
|
if not args.verbose:
|
||||||
|
controller_list = []
|
||||||
|
for i in result["Members"]:
|
||||||
|
controller_list.append(i["@odata.id"].split("/")[-1])
|
||||||
|
|
||||||
|
result = controller_list
|
||||||
|
|
||||||
|
if args.format == "text":
|
||||||
|
result = "\n".join(result)
|
||||||
|
elif args.format == "table":
|
||||||
|
data = []
|
||||||
|
for row in result:
|
||||||
|
data.append([row])
|
||||||
|
result = table(data, headers=["Controller"])
|
||||||
|
|
||||||
|
write_output(
|
||||||
|
result,
|
||||||
|
output_format=args.format,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def system_details(args):
|
||||||
|
"""Entry point: get the details of a system in a server"""
|
||||||
|
details = api.power.system_details(
|
||||||
|
args.server, args.username, args.password, args.system
|
||||||
|
)
|
||||||
|
write_output(details, output_format=args.format)
|
||||||
|
|
||||||
|
|
||||||
|
def version(args):
|
||||||
|
"""Entry point: get the verion of redfish implemented by the BMC"""
|
||||||
|
redfish_version = api.redfish_version(args.server)
|
||||||
|
|
||||||
|
write_output(redfish_version, output_format=args.format)
|
||||||
75
src/redfish_cli/cli/jobs.py
Normal file
75
src/redfish_cli/cli/jobs.py
Normal file
|
|
@ -0,0 +1,75 @@
|
||||||
|
"""Commands to interact with jobs on a manager. Probably very Dell specific."""
|
||||||
|
|
||||||
|
from redfish_cli.cli.utils import write_output, table
|
||||||
|
from redfish_cli.api import jobs
|
||||||
|
|
||||||
|
|
||||||
|
def jobs_list(args):
|
||||||
|
"""Get the list of jobs"""
|
||||||
|
result = jobs.jobs_list(args)
|
||||||
|
|
||||||
|
# import bpdb;bpdb.set_trace()
|
||||||
|
if not args.all_jobs:
|
||||||
|
result["Members"] = [
|
||||||
|
member
|
||||||
|
for member in result["Members"]
|
||||||
|
if member["PercentComplete"] < 100
|
||||||
|
]
|
||||||
|
result["Members@odata.count"] = len(result["Members"])
|
||||||
|
result["Note"] = "Only showing incomplete jobs"
|
||||||
|
|
||||||
|
if args.format != "json":
|
||||||
|
result = [
|
||||||
|
[
|
||||||
|
j["Id"],
|
||||||
|
j["JobType"],
|
||||||
|
j["PercentComplete"],
|
||||||
|
j["Name"],
|
||||||
|
j["JobState"],
|
||||||
|
]
|
||||||
|
for j in result["Members"]
|
||||||
|
]
|
||||||
|
|
||||||
|
if args.format == "table":
|
||||||
|
result = table(
|
||||||
|
result,
|
||||||
|
headers=["Job ID", "Job Type", "Pcnt Complete", "Name", "State"],
|
||||||
|
)
|
||||||
|
elif args.format == "text":
|
||||||
|
result = "\n".join(
|
||||||
|
[f"{row[0]} {row[1]} {row[2]} {row[3]} {row[4]}" for row in result]
|
||||||
|
)
|
||||||
|
|
||||||
|
write_output(result, output_format=args.format)
|
||||||
|
|
||||||
|
|
||||||
|
def job_details(args):
|
||||||
|
"""Get the details of a job"""
|
||||||
|
result = jobs.job_details(args)
|
||||||
|
|
||||||
|
write_output(result, output_format=args.format)
|
||||||
|
|
||||||
|
|
||||||
|
def watch_job(args):
|
||||||
|
"""Watch the progress of a job until it finishes or the user cancels"""
|
||||||
|
try:
|
||||||
|
while True:
|
||||||
|
result = jobs.job_details(args)
|
||||||
|
output = result
|
||||||
|
|
||||||
|
if args.format == "text":
|
||||||
|
output = " ".join(
|
||||||
|
[
|
||||||
|
result["Id"],
|
||||||
|
result["Name"],
|
||||||
|
result["JobState"],
|
||||||
|
str(result["PercentComplete"]),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
write_output(output, output_format=args.format)
|
||||||
|
|
||||||
|
if result["PercentComplete"] == 100:
|
||||||
|
break
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
write_output("Ctrl^C detected. Exiting")
|
||||||
71
src/redfish_cli/cli/parsers/__init__.py
Normal file
71
src/redfish_cli/cli/parsers/__init__.py
Normal file
|
|
@ -0,0 +1,71 @@
|
||||||
|
"""
|
||||||
|
Code to set up the parser and subparsers for the cli
|
||||||
|
"""
|
||||||
|
# pylint: disable=cyclic-import
|
||||||
|
# Note should really think about the cyclic import more, but it works for now.
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
|
||||||
|
# PYTHON_ARGCOMPLETE_OK
|
||||||
|
import argcomplete
|
||||||
|
|
||||||
|
from redfish_cli import cli
|
||||||
|
|
||||||
|
from . import base
|
||||||
|
from . import chassis
|
||||||
|
from . import dell
|
||||||
|
from . import jobs
|
||||||
|
from . import power
|
||||||
|
from . import storage
|
||||||
|
from . import system
|
||||||
|
|
||||||
|
# from .utils import add_authenticated_subparser, ArgumentTuple, EnvDefault
|
||||||
|
|
||||||
|
|
||||||
|
def parse_args(args):
|
||||||
|
"""Parse thge arguments supplied"""
|
||||||
|
parser = argparse.ArgumentParser(
|
||||||
|
description="Interact with servers via RedFish. Only Dells supported at the moment"
|
||||||
|
)
|
||||||
|
parser.add_argument("-s", "--server", required=True, dest="server")
|
||||||
|
parser.add_argument(
|
||||||
|
"-f",
|
||||||
|
"--format",
|
||||||
|
choices=["json", "table", "text"],
|
||||||
|
default="json",
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--log-level",
|
||||||
|
default="WARN",
|
||||||
|
dest="log_level",
|
||||||
|
choices=[
|
||||||
|
"critical",
|
||||||
|
"fatal",
|
||||||
|
"error",
|
||||||
|
"warning",
|
||||||
|
"warn",
|
||||||
|
"info",
|
||||||
|
"debug",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
parser.add_argument("--debug", action="store_true")
|
||||||
|
parser.add_argument("-l", "--log-file", default="redfish.log")
|
||||||
|
parser.add_argument("-v", "--verbose", action="store_true")
|
||||||
|
parser.add_argument("-V", "--verify", action="store_true")
|
||||||
|
|
||||||
|
subparsers = parser.add_subparsers()
|
||||||
|
|
||||||
|
base.add_get(subparsers)
|
||||||
|
base.add_version_subparser(subparsers)
|
||||||
|
base.add_product_subparser(subparsers)
|
||||||
|
|
||||||
|
chassis.add_chassis_subparser(subparsers)
|
||||||
|
jobs.add_jobs_subparser(subparsers)
|
||||||
|
power.add_power_subparser(subparsers)
|
||||||
|
storage.add_storage_subparser(subparsers)
|
||||||
|
system.add_system_subparser(subparsers)
|
||||||
|
|
||||||
|
dell.add_service_tag_subparser(subparsers)
|
||||||
|
|
||||||
|
argcomplete.autocomplete(parser)
|
||||||
|
return parser.parse_args(args)
|
||||||
50
src/redfish_cli/cli/parsers/base.py
Normal file
50
src/redfish_cli/cli/parsers/base.py
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
"""Subparsers that don't seem to belong anywhere else"""
|
||||||
|
|
||||||
|
|
||||||
|
from redfish_cli import cli
|
||||||
|
|
||||||
|
from .utils import (
|
||||||
|
add_authenticated_subparser,
|
||||||
|
ArgumentTuple,
|
||||||
|
PositionalArgumentTuple,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def add_version_subparser(subparsers):
|
||||||
|
"""Utility function to add the subparser for the version command"""
|
||||||
|
version_subparser = subparsers.add_parser(
|
||||||
|
"version", help="Get the redfish version"
|
||||||
|
)
|
||||||
|
version_subparser.set_defaults(func=cli.version)
|
||||||
|
|
||||||
|
|
||||||
|
def add_get(subparsers):
|
||||||
|
"""Utility function to add the subparser for the get command."""
|
||||||
|
|
||||||
|
add_authenticated_subparser(
|
||||||
|
subparsers,
|
||||||
|
"get",
|
||||||
|
help_text="get an arbitrary url",
|
||||||
|
func=cli.get,
|
||||||
|
arguments=[
|
||||||
|
PositionalArgumentTuple(
|
||||||
|
name="url",
|
||||||
|
nargs="?",
|
||||||
|
),
|
||||||
|
ArgumentTuple(
|
||||||
|
short_flag="--E",
|
||||||
|
long_flag="--expand",
|
||||||
|
action="store_true",
|
||||||
|
required=False,
|
||||||
|
dest="expand",
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def add_product_subparser(subparsers):
|
||||||
|
"""Utility function to add the subparser for the product command."""
|
||||||
|
product_subparser = subparsers.add_parser(
|
||||||
|
"product", help="Get the product description"
|
||||||
|
)
|
||||||
|
product_subparser.set_defaults(func=cli.product)
|
||||||
44
src/redfish_cli/cli/parsers/chassis.py
Normal file
44
src/redfish_cli/cli/parsers/chassis.py
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
"""Subparsers related to chassis management"""
|
||||||
|
|
||||||
|
from redfish_cli import cli
|
||||||
|
|
||||||
|
from .utils import ArgumentTuple, add_authenticated_subparser, add_subparser
|
||||||
|
|
||||||
|
|
||||||
|
def add_chassis_subparser(subparsers):
|
||||||
|
"""Add the chassis subparser"""
|
||||||
|
subparser = add_authenticated_subparser(
|
||||||
|
subparsers, "chassis"
|
||||||
|
).add_subparsers()
|
||||||
|
|
||||||
|
add_list_chassis_subparser(subparser)
|
||||||
|
add_show_chassis_subparser(subparser)
|
||||||
|
|
||||||
|
|
||||||
|
def add_list_chassis_subparser(subparsers):
|
||||||
|
"""Utility function to add the subparser for the chassis command"""
|
||||||
|
add_subparser(
|
||||||
|
subparsers,
|
||||||
|
"list",
|
||||||
|
help_text="Get the list of chassis",
|
||||||
|
func=cli.chassis,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def add_show_chassis_subparser(subparsers):
|
||||||
|
"""Utility function to add the subparser for the chassis-details command."""
|
||||||
|
add_subparser(
|
||||||
|
subparsers,
|
||||||
|
"show",
|
||||||
|
func=cli.chassis_details,
|
||||||
|
help_text="Get the details of a chassis",
|
||||||
|
arguments=[
|
||||||
|
ArgumentTuple(
|
||||||
|
short_flag="-c",
|
||||||
|
long_flag="--chassis",
|
||||||
|
default="System.Embedded.1",
|
||||||
|
required=False,
|
||||||
|
dest="chassis",
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
14
src/redfish_cli/cli/parsers/dell.py
Normal file
14
src/redfish_cli/cli/parsers/dell.py
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
"""Subparsers that are Dell specific"""
|
||||||
|
|
||||||
|
from redfish_cli import cli
|
||||||
|
|
||||||
|
|
||||||
|
def add_service_tag_subparser(subparsers):
|
||||||
|
"""
|
||||||
|
Utility function to add the subparser for the service-tag command. This is
|
||||||
|
a Dell specific command
|
||||||
|
"""
|
||||||
|
service_tag_subparser = subparsers.add_parser(
|
||||||
|
"service-tag", help="Get the service tag (DELL only)"
|
||||||
|
)
|
||||||
|
service_tag_subparser.set_defaults(func=cli.service_tag)
|
||||||
93
src/redfish_cli/cli/parsers/jobs.py
Normal file
93
src/redfish_cli/cli/parsers/jobs.py
Normal file
|
|
@ -0,0 +1,93 @@
|
||||||
|
"""Subparsers related to job management"""
|
||||||
|
|
||||||
|
from .. import jobs
|
||||||
|
|
||||||
|
from .utils import (
|
||||||
|
ArgumentTuple,
|
||||||
|
PositionalArgumentTuple,
|
||||||
|
add_authenticated_subparser,
|
||||||
|
add_subparser,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def add_jobs_subparser(subparsers):
|
||||||
|
"""Add the storage subparser"""
|
||||||
|
subparser = add_authenticated_subparser(
|
||||||
|
subparsers, "jobs"
|
||||||
|
).add_subparsers()
|
||||||
|
|
||||||
|
add_job_details_subparser(subparser)
|
||||||
|
add_jobs_list_subparser(subparser)
|
||||||
|
add_watch_job_subparser(subparser)
|
||||||
|
|
||||||
|
|
||||||
|
def add_job_details_subparser(subparsers):
|
||||||
|
"""Utility function to add the subparser for the job-details command"""
|
||||||
|
add_subparser(
|
||||||
|
subparsers,
|
||||||
|
"show",
|
||||||
|
func=jobs.job_details,
|
||||||
|
help_text="Get the details of a job",
|
||||||
|
arguments=[
|
||||||
|
ArgumentTuple(
|
||||||
|
short_flag="-m",
|
||||||
|
long_flag="--manager",
|
||||||
|
default="iDRAC.Embedded.1",
|
||||||
|
required=False,
|
||||||
|
dest="manager",
|
||||||
|
),
|
||||||
|
ArgumentTuple(
|
||||||
|
short_flag="-j",
|
||||||
|
long_flag="--job-id",
|
||||||
|
required=True,
|
||||||
|
dest="job_id",
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def add_jobs_list_subparser(subparsers):
|
||||||
|
"""Utility function to add the subparser for the list-jobs command"""
|
||||||
|
add_subparser(
|
||||||
|
subparsers,
|
||||||
|
"list",
|
||||||
|
func=jobs.jobs_list,
|
||||||
|
help_text="List the jobs on a manager. Filters will be added to this later",
|
||||||
|
arguments=[
|
||||||
|
ArgumentTuple(
|
||||||
|
short_flag="-m",
|
||||||
|
long_flag="--manager",
|
||||||
|
default="iDRAC.Embedded.1",
|
||||||
|
required=False,
|
||||||
|
dest="manager",
|
||||||
|
),
|
||||||
|
ArgumentTuple(
|
||||||
|
short_flag="-a",
|
||||||
|
long_flag="--all",
|
||||||
|
action="store_true",
|
||||||
|
dest="all_jobs",
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def add_watch_job_subparser(subparsers):
|
||||||
|
"""Utility function to add the subparser for the watch-job command"""
|
||||||
|
add_subparser(
|
||||||
|
subparsers,
|
||||||
|
"watch",
|
||||||
|
func=jobs.watch_job,
|
||||||
|
help_text="Watch the process of a job until it completes or the user cancels",
|
||||||
|
arguments=[
|
||||||
|
ArgumentTuple(
|
||||||
|
short_flag="-m",
|
||||||
|
long_flag="--manager",
|
||||||
|
default="iDRAC.Embedded.1",
|
||||||
|
required=False,
|
||||||
|
dest="manager",
|
||||||
|
),
|
||||||
|
PositionalArgumentTuple(
|
||||||
|
name="job_id",
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
143
src/redfish_cli/cli/parsers/power.py
Normal file
143
src/redfish_cli/cli/parsers/power.py
Normal file
|
|
@ -0,0 +1,143 @@
|
||||||
|
"""Subparsers related to power management"""
|
||||||
|
|
||||||
|
from redfish_cli.cli import power
|
||||||
|
|
||||||
|
from .utils import (
|
||||||
|
ArgumentTuple,
|
||||||
|
PositionalArgumentTuple,
|
||||||
|
add_authenticated_subparser,
|
||||||
|
add_subparser,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def add_power_subparser(subparsers):
|
||||||
|
"""Add the chassis subparser"""
|
||||||
|
subparser = add_authenticated_subparser(
|
||||||
|
subparsers, "power"
|
||||||
|
).add_subparsers()
|
||||||
|
|
||||||
|
add_get_power_state(subparser)
|
||||||
|
add_list_power_states(subparser)
|
||||||
|
add_set_power_state(subparser)
|
||||||
|
add_reset_system(subparser)
|
||||||
|
add_power_off(subparser)
|
||||||
|
add_power_on(subparser)
|
||||||
|
|
||||||
|
|
||||||
|
def add_get_power_state(subparsers):
|
||||||
|
"""Utility function to add the subparser for the power get command"""
|
||||||
|
add_subparser(
|
||||||
|
subparsers,
|
||||||
|
"get",
|
||||||
|
help_text="Get the current power state of a system",
|
||||||
|
func=power.power_state,
|
||||||
|
arguments=[
|
||||||
|
ArgumentTuple(
|
||||||
|
short_flag="-s",
|
||||||
|
long_flag="--system",
|
||||||
|
default="System.Embedded.1",
|
||||||
|
required=False,
|
||||||
|
dest="system",
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def add_list_power_states(subparsers):
|
||||||
|
"""Utility function to add the subparser for the power list command"""
|
||||||
|
add_subparser(
|
||||||
|
subparsers,
|
||||||
|
"list",
|
||||||
|
help_text="Get the allowed power state of a system",
|
||||||
|
func=power.power_states,
|
||||||
|
arguments=[
|
||||||
|
ArgumentTuple(
|
||||||
|
short_flag="-s",
|
||||||
|
long_flag="--system",
|
||||||
|
default="System.Embedded.1",
|
||||||
|
required=False,
|
||||||
|
dest="system",
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def add_set_power_state(subparsers):
|
||||||
|
"""
|
||||||
|
Utility function to add the subparser for the set-power-states command
|
||||||
|
|
||||||
|
This command is dependent on the OEM implementation of redfish
|
||||||
|
|
||||||
|
It assumes that a valid power state has been passed in, but it should probably
|
||||||
|
do some validation to make the experience nicer.
|
||||||
|
|
||||||
|
Could do this by calling api.system_power_states_allowed maybe?
|
||||||
|
"""
|
||||||
|
add_subparser(
|
||||||
|
subparsers,
|
||||||
|
"set",
|
||||||
|
help_text=(
|
||||||
|
"Set the current power state of a system. Use get-power-state to find "
|
||||||
|
"allowable values"
|
||||||
|
),
|
||||||
|
func=power.set_power_state,
|
||||||
|
arguments=[
|
||||||
|
ArgumentTuple(
|
||||||
|
short_flag="-s",
|
||||||
|
long_flag="--system",
|
||||||
|
default="System.Embedded.1",
|
||||||
|
required=False,
|
||||||
|
dest="system",
|
||||||
|
),
|
||||||
|
PositionalArgumentTuple(name="power_state"),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def add_reset_system(subparsers):
|
||||||
|
"""Parse for the reset system command"""
|
||||||
|
add_subparser(
|
||||||
|
subparsers,
|
||||||
|
"reset",
|
||||||
|
help_text=("Reset a server. Convenience method"),
|
||||||
|
func=power.reset_system,
|
||||||
|
arguments=[
|
||||||
|
PositionalArgumentTuple(
|
||||||
|
name="system",
|
||||||
|
default="System.Embedded.1",
|
||||||
|
nargs="?",
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
def add_power_off(subparsers):
|
||||||
|
"""Parse for the power off command"""
|
||||||
|
add_subparser(
|
||||||
|
subparsers,
|
||||||
|
"off",
|
||||||
|
help_text=("Power on a server. Convenience method"),
|
||||||
|
func=power.power_off,
|
||||||
|
arguments=[
|
||||||
|
PositionalArgumentTuple(
|
||||||
|
name="system",
|
||||||
|
default="System.Embedded.1",
|
||||||
|
nargs="?",
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
def add_power_on(subparsers):
|
||||||
|
"""Parse for the power on command"""
|
||||||
|
add_subparser(
|
||||||
|
subparsers,
|
||||||
|
"on",
|
||||||
|
help_text=("Power on a server. Convenience method"),
|
||||||
|
func=power.power_on,
|
||||||
|
arguments=[
|
||||||
|
PositionalArgumentTuple(
|
||||||
|
name="system",
|
||||||
|
default="System.Embedded.1",
|
||||||
|
nargs="?",
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
332
src/redfish_cli/cli/parsers/storage.py
Normal file
332
src/redfish_cli/cli/parsers/storage.py
Normal file
|
|
@ -0,0 +1,332 @@
|
||||||
|
"""Subparsers related to storage management"""
|
||||||
|
|
||||||
|
from redfish_cli import cli
|
||||||
|
|
||||||
|
from .utils import ArgumentTuple, add_authenticated_subparser, add_subparser
|
||||||
|
|
||||||
|
|
||||||
|
def add_storage_subparser(subparsers):
|
||||||
|
"""Add the storage subparser"""
|
||||||
|
subparser = add_authenticated_subparser(
|
||||||
|
subparsers, "storage"
|
||||||
|
).add_subparsers()
|
||||||
|
|
||||||
|
add_logical_volumes_subparser(subparser)
|
||||||
|
add_physical_volumes_subparser(subparser)
|
||||||
|
add_controllers_subparser(subparser)
|
||||||
|
|
||||||
|
|
||||||
|
def add_create_logical_volume_subparser(subparsers):
|
||||||
|
"""Utility function to add the subparser for the chassis command"""
|
||||||
|
add_subparser(
|
||||||
|
subparsers,
|
||||||
|
"create",
|
||||||
|
help_text="Create a new logical volume",
|
||||||
|
func=cli.create_logical_volume,
|
||||||
|
arguments=[
|
||||||
|
ArgumentTuple(
|
||||||
|
long_flag="--system",
|
||||||
|
short_flag="-e",
|
||||||
|
dest="system",
|
||||||
|
default="System.Embedded.1",
|
||||||
|
),
|
||||||
|
ArgumentTuple(
|
||||||
|
long_flag="--manager",
|
||||||
|
short_flag="-m",
|
||||||
|
dest="manager",
|
||||||
|
default="iDRAC.Embedded.1",
|
||||||
|
),
|
||||||
|
ArgumentTuple(
|
||||||
|
long_flag="--controller",
|
||||||
|
short_flag="-c",
|
||||||
|
dest="controller",
|
||||||
|
required=True,
|
||||||
|
),
|
||||||
|
ArgumentTuple(
|
||||||
|
short_flag="-d",
|
||||||
|
long_flag="--disk",
|
||||||
|
required=True,
|
||||||
|
dest="disk",
|
||||||
|
nargs="?",
|
||||||
|
action="append",
|
||||||
|
),
|
||||||
|
ArgumentTuple(
|
||||||
|
short_flag="-r",
|
||||||
|
long_flag="--raid-level",
|
||||||
|
choices=["0", "1", "5", "6"],
|
||||||
|
required=True,
|
||||||
|
dest="raid_level",
|
||||||
|
),
|
||||||
|
ArgumentTuple(
|
||||||
|
short_flag="-n",
|
||||||
|
long_flag="--name",
|
||||||
|
required=False,
|
||||||
|
dest="name",
|
||||||
|
),
|
||||||
|
ArgumentTuple(
|
||||||
|
short_flag="-s",
|
||||||
|
long_flag="--size",
|
||||||
|
required=False,
|
||||||
|
dest="size",
|
||||||
|
type=int,
|
||||||
|
),
|
||||||
|
ArgumentTuple(
|
||||||
|
short_flag="-S",
|
||||||
|
long_flag="--stripe-size",
|
||||||
|
required=False,
|
||||||
|
dest="stripe_size",
|
||||||
|
type=int,
|
||||||
|
),
|
||||||
|
ArgumentTuple(
|
||||||
|
short_flag="-D",
|
||||||
|
long_flag="--disk-cache-policy",
|
||||||
|
required=False,
|
||||||
|
dest="disk_cache_policy",
|
||||||
|
choices=["Enabled", "Disabled"],
|
||||||
|
),
|
||||||
|
ArgumentTuple(
|
||||||
|
short_flag="-R",
|
||||||
|
long_flag="--read-cache-policy",
|
||||||
|
required=False,
|
||||||
|
dest="read_cache_policy",
|
||||||
|
choices=["Off", "ReadAhead", "AdaptiveReadAhead"],
|
||||||
|
),
|
||||||
|
ArgumentTuple(
|
||||||
|
short_flag="-W",
|
||||||
|
long_flag="--write-cache-policy",
|
||||||
|
required=False,
|
||||||
|
dest="write_cache_policy",
|
||||||
|
choices=[
|
||||||
|
"ProtectedWriteBack",
|
||||||
|
"UnprotectedWriteBack",
|
||||||
|
"WriteThrough",
|
||||||
|
],
|
||||||
|
),
|
||||||
|
ArgumentTuple(
|
||||||
|
short_flag="-Z",
|
||||||
|
long_flag="--secure",
|
||||||
|
required=False,
|
||||||
|
action="store_true",
|
||||||
|
dest="secure",
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def add_delete_logical_volume_subparser(subparsers):
|
||||||
|
"""Utility function to add the subparser for the delete logical volume command"""
|
||||||
|
add_subparser(
|
||||||
|
subparsers,
|
||||||
|
"delete",
|
||||||
|
help_text="Delete a logical volume",
|
||||||
|
func=cli.delete_logical_volume,
|
||||||
|
arguments=[
|
||||||
|
ArgumentTuple(
|
||||||
|
long_flag="--system",
|
||||||
|
short_flag="-e",
|
||||||
|
dest="system",
|
||||||
|
default="System.Embedded.1",
|
||||||
|
),
|
||||||
|
ArgumentTuple(
|
||||||
|
short_flag="-d",
|
||||||
|
long_flag="--disk",
|
||||||
|
required=True,
|
||||||
|
dest="disk",
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def add_logical_volume_subparser(subparsers):
|
||||||
|
"""Utility function to add the subparser for the logical-volume command."""
|
||||||
|
add_subparser(
|
||||||
|
subparsers,
|
||||||
|
"show",
|
||||||
|
func=cli.logical_volume,
|
||||||
|
arguments=[
|
||||||
|
ArgumentTuple(
|
||||||
|
"-S", "--system", "System.Embedded.1", False, "system"
|
||||||
|
),
|
||||||
|
ArgumentTuple(
|
||||||
|
short_flag="-c",
|
||||||
|
long_flag="--controller",
|
||||||
|
default=None,
|
||||||
|
required=False,
|
||||||
|
dest="controller",
|
||||||
|
),
|
||||||
|
ArgumentTuple(
|
||||||
|
short_flag="-d",
|
||||||
|
long_flag="--drive",
|
||||||
|
default=None,
|
||||||
|
required=False,
|
||||||
|
dest="drive",
|
||||||
|
),
|
||||||
|
ArgumentTuple(
|
||||||
|
short_flag="-i",
|
||||||
|
long_flag="--drive-index",
|
||||||
|
default=0,
|
||||||
|
required=False,
|
||||||
|
dest="drive_index",
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def add_list_logical_volumes_subparser(subparsers):
|
||||||
|
"""Utility function to add the subparser for the logical-volumes command."""
|
||||||
|
# logical-volumes subparser
|
||||||
|
add_subparser(
|
||||||
|
subparsers,
|
||||||
|
"list",
|
||||||
|
func=cli.logical_volumes,
|
||||||
|
arguments=[
|
||||||
|
ArgumentTuple(
|
||||||
|
"-S", "--system", "System.Embedded.1", False, "system"
|
||||||
|
),
|
||||||
|
ArgumentTuple(
|
||||||
|
short_flag="-c",
|
||||||
|
long_flag="--controller",
|
||||||
|
default=None,
|
||||||
|
required=False,
|
||||||
|
dest="controller",
|
||||||
|
),
|
||||||
|
ArgumentTuple(
|
||||||
|
short_flag="-e",
|
||||||
|
long_flag="--expand",
|
||||||
|
action="store_false",
|
||||||
|
required=False,
|
||||||
|
dest="expand",
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def add_physical_volume_subparser(subparsers):
|
||||||
|
"""Utility function to add the subparser for the physical-volumes command."""
|
||||||
|
add_subparser(
|
||||||
|
subparsers,
|
||||||
|
"show",
|
||||||
|
func=cli.physical_volume,
|
||||||
|
arguments=[
|
||||||
|
ArgumentTuple(
|
||||||
|
short_flag="-S",
|
||||||
|
long_flag="--system",
|
||||||
|
default=None,
|
||||||
|
required=False,
|
||||||
|
dest="system",
|
||||||
|
),
|
||||||
|
ArgumentTuple(
|
||||||
|
short_flag="-c",
|
||||||
|
long_flag="--controller",
|
||||||
|
default=None,
|
||||||
|
required=False,
|
||||||
|
dest="controller",
|
||||||
|
),
|
||||||
|
ArgumentTuple(
|
||||||
|
short_flag="-d",
|
||||||
|
long_flag="--drive",
|
||||||
|
default=None,
|
||||||
|
required=False,
|
||||||
|
dest="drive",
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def add_list_physical_volumes_subparser(subparsers):
|
||||||
|
"""Utility function to add the subparser for the physical-volumes command."""
|
||||||
|
add_subparser(
|
||||||
|
subparsers,
|
||||||
|
"list",
|
||||||
|
func=cli.physical_volumes,
|
||||||
|
arguments=[
|
||||||
|
ArgumentTuple(
|
||||||
|
"-S", "--system", "System.Embedded.1", False, "system"
|
||||||
|
),
|
||||||
|
ArgumentTuple(
|
||||||
|
short_flag="-c",
|
||||||
|
long_flag="--controller",
|
||||||
|
default=None,
|
||||||
|
required=False,
|
||||||
|
dest="controller",
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def add_show_controller_subparser(subparsers):
|
||||||
|
"""Utility function to add the subparser for the storage-controller command"""
|
||||||
|
add_subparser(
|
||||||
|
subparsers,
|
||||||
|
"show",
|
||||||
|
func=cli.storage_controller,
|
||||||
|
arguments=[
|
||||||
|
ArgumentTuple(
|
||||||
|
"-S",
|
||||||
|
"--system",
|
||||||
|
"System.Embedded.1",
|
||||||
|
False,
|
||||||
|
"system",
|
||||||
|
help_text=None,
|
||||||
|
),
|
||||||
|
ArgumentTuple(
|
||||||
|
"-c",
|
||||||
|
"--controller",
|
||||||
|
None,
|
||||||
|
False,
|
||||||
|
"controller",
|
||||||
|
help_text=None,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def add_list_controllers_subparser(subparsers):
|
||||||
|
"""Utility function to add the subparser for the storage-controllers command"""
|
||||||
|
add_subparser(
|
||||||
|
subparsers,
|
||||||
|
"list",
|
||||||
|
func=cli.storage_controllers,
|
||||||
|
arguments=[
|
||||||
|
ArgumentTuple(
|
||||||
|
"-S",
|
||||||
|
"--system",
|
||||||
|
"System.Embedded.1",
|
||||||
|
False,
|
||||||
|
"system",
|
||||||
|
help_text=None,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def add_logical_volumes_subparser(subparsers):
|
||||||
|
"""Add the storage logical volumes subparser"""
|
||||||
|
subparser = add_authenticated_subparser(
|
||||||
|
subparsers, "logical"
|
||||||
|
).add_subparsers()
|
||||||
|
|
||||||
|
add_logical_volume_subparser(subparser)
|
||||||
|
add_list_logical_volumes_subparser(subparser)
|
||||||
|
add_create_logical_volume_subparser(subparser)
|
||||||
|
add_delete_logical_volume_subparser(subparser)
|
||||||
|
|
||||||
|
|
||||||
|
def add_physical_volumes_subparser(subparsers):
|
||||||
|
"""Add the storage physical volumes subparser"""
|
||||||
|
subparser = add_authenticated_subparser(
|
||||||
|
subparsers, "physical"
|
||||||
|
).add_subparsers()
|
||||||
|
|
||||||
|
add_physical_volume_subparser(subparser)
|
||||||
|
add_list_physical_volumes_subparser(subparser)
|
||||||
|
|
||||||
|
|
||||||
|
def add_controllers_subparser(subparsers):
|
||||||
|
"""Add the storage controller ssubparser"""
|
||||||
|
subparser = add_authenticated_subparser(
|
||||||
|
subparsers, "controllers"
|
||||||
|
).add_subparsers()
|
||||||
|
|
||||||
|
add_list_controllers_subparser(subparser)
|
||||||
|
add_show_controller_subparser(subparser)
|
||||||
33
src/redfish_cli/cli/parsers/system.py
Normal file
33
src/redfish_cli/cli/parsers/system.py
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
"""Subparsers related to system management"""
|
||||||
|
|
||||||
|
from redfish_cli import cli
|
||||||
|
|
||||||
|
from .utils import ArgumentTuple, add_authenticated_subparser, add_subparser
|
||||||
|
|
||||||
|
|
||||||
|
def add_system_subparser(subparsers):
|
||||||
|
"""Add the chassis subparser"""
|
||||||
|
subparser = add_authenticated_subparser(
|
||||||
|
subparsers, "system"
|
||||||
|
).add_subparsers()
|
||||||
|
|
||||||
|
add_show_system_subparser(subparser)
|
||||||
|
|
||||||
|
|
||||||
|
def add_show_system_subparser(subparsers):
|
||||||
|
"""Utility function to add the subparser for the system-details command"""
|
||||||
|
add_subparser(
|
||||||
|
subparsers,
|
||||||
|
"show",
|
||||||
|
func=cli.system_details,
|
||||||
|
help_text="Get the details of a system",
|
||||||
|
arguments=[
|
||||||
|
ArgumentTuple(
|
||||||
|
short_flag="-s",
|
||||||
|
long_flag="--system",
|
||||||
|
default="System.Embedded.1",
|
||||||
|
required=False,
|
||||||
|
dest="system",
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
160
src/redfish_cli/cli/parsers/utils.py
Normal file
160
src/redfish_cli/cli/parsers/utils.py
Normal file
|
|
@ -0,0 +1,160 @@
|
||||||
|
"""Utilities used by many parsers"""
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
from collections import namedtuple
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
ArgumentTuple = namedtuple(
|
||||||
|
"argument_tuple",
|
||||||
|
[
|
||||||
|
"short_flag",
|
||||||
|
"long_flag",
|
||||||
|
"default",
|
||||||
|
"required",
|
||||||
|
"dest",
|
||||||
|
"action",
|
||||||
|
"envvar",
|
||||||
|
"help_text",
|
||||||
|
"nargs",
|
||||||
|
"choices",
|
||||||
|
"type",
|
||||||
|
],
|
||||||
|
defaults=[None, None, None, None, None, None, None, None, None],
|
||||||
|
)
|
||||||
|
|
||||||
|
PositionalArgumentTuple = namedtuple(
|
||||||
|
"argument_tuple",
|
||||||
|
[
|
||||||
|
"name",
|
||||||
|
"default",
|
||||||
|
"action",
|
||||||
|
"help_text",
|
||||||
|
"nargs",
|
||||||
|
"choices",
|
||||||
|
"type",
|
||||||
|
],
|
||||||
|
defaults=[None, None, None, None, None, None, None],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class EnvDefault(argparse.Action):
|
||||||
|
"""Thanks to https://stackoverflow.com/questions/10551117/"""
|
||||||
|
|
||||||
|
# pylint: disable=too-few-public-methods
|
||||||
|
|
||||||
|
def __init__(self, envvar, required=True, default=None, **kwargs):
|
||||||
|
if not default and envvar:
|
||||||
|
if envvar in os.environ:
|
||||||
|
default = os.environ[envvar]
|
||||||
|
if required and default:
|
||||||
|
required = False
|
||||||
|
super().__init__(default=default, required=required, **kwargs)
|
||||||
|
|
||||||
|
def __call__(self, parser, namespace, values, option_string=None):
|
||||||
|
setattr(namespace, self.dest, values)
|
||||||
|
|
||||||
|
|
||||||
|
def add_authenticated_subparser(
|
||||||
|
subparsers: argparse.ArgumentParser,
|
||||||
|
name: str,
|
||||||
|
help_text: str = "",
|
||||||
|
func: any = None,
|
||||||
|
arguments: list = None,
|
||||||
|
):
|
||||||
|
"""Add a subparser for a command that requires authentication"""
|
||||||
|
|
||||||
|
if arguments is None:
|
||||||
|
arguments = []
|
||||||
|
|
||||||
|
arguments = [
|
||||||
|
ArgumentTuple(
|
||||||
|
short_flag="-p",
|
||||||
|
long_flag="--password",
|
||||||
|
required=True,
|
||||||
|
default=os.environ.get("RF_PASSWORD"),
|
||||||
|
dest="password",
|
||||||
|
action=EnvDefault,
|
||||||
|
envvar="RF_PASSWORD",
|
||||||
|
),
|
||||||
|
ArgumentTuple(
|
||||||
|
short_flag="-u",
|
||||||
|
long_flag="--username",
|
||||||
|
required=True,
|
||||||
|
dest="username",
|
||||||
|
action=EnvDefault,
|
||||||
|
default=os.environ.get("RF_USERNAME"),
|
||||||
|
),
|
||||||
|
] + arguments
|
||||||
|
subparser = add_subparser(
|
||||||
|
subparsers, name, help_text=help_text, func=func, arguments=arguments
|
||||||
|
)
|
||||||
|
|
||||||
|
return subparser
|
||||||
|
|
||||||
|
|
||||||
|
def add_subparser(
|
||||||
|
subparsers: argparse.ArgumentParser,
|
||||||
|
name: str,
|
||||||
|
help_text: str = "",
|
||||||
|
func: any = None,
|
||||||
|
arguments: list = None,
|
||||||
|
):
|
||||||
|
"""Utility function to make adding a subparser easier."""
|
||||||
|
|
||||||
|
if arguments is None:
|
||||||
|
arguments = []
|
||||||
|
|
||||||
|
subparser = subparsers.add_parser(name, help=help_text)
|
||||||
|
|
||||||
|
for argument in arguments:
|
||||||
|
if isinstance(argument, ArgumentTuple):
|
||||||
|
if argument.action == EnvDefault:
|
||||||
|
subparser.add_argument(
|
||||||
|
argument.short_flag,
|
||||||
|
argument.long_flag,
|
||||||
|
required=argument.required,
|
||||||
|
dest=argument.dest,
|
||||||
|
default=argument.default,
|
||||||
|
help=argument.help_text,
|
||||||
|
action=argument.action,
|
||||||
|
envvar=argument.envvar,
|
||||||
|
choices=argument.choices,
|
||||||
|
type=argument.type,
|
||||||
|
)
|
||||||
|
elif argument.action:
|
||||||
|
subparser.add_argument(
|
||||||
|
argument.short_flag,
|
||||||
|
argument.long_flag,
|
||||||
|
required=argument.required,
|
||||||
|
dest=argument.dest,
|
||||||
|
default=argument.default,
|
||||||
|
help=argument.help_text,
|
||||||
|
action=argument.action,
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
subparser.add_argument(
|
||||||
|
argument.short_flag,
|
||||||
|
argument.long_flag,
|
||||||
|
required=argument.required,
|
||||||
|
dest=argument.dest,
|
||||||
|
default=argument.default,
|
||||||
|
help=argument.help_text,
|
||||||
|
nargs=argument.nargs,
|
||||||
|
action=argument.action,
|
||||||
|
choices=argument.choices,
|
||||||
|
type=argument.type,
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
subparser.add_argument(
|
||||||
|
argument.name,
|
||||||
|
default=argument.default,
|
||||||
|
help=argument.help_text,
|
||||||
|
nargs=argument.nargs,
|
||||||
|
action=argument.action,
|
||||||
|
choices=argument.choices,
|
||||||
|
type=argument.type,
|
||||||
|
)
|
||||||
|
|
||||||
|
subparser.set_defaults(func=func)
|
||||||
|
return subparser
|
||||||
62
src/redfish_cli/cli/power.py
Normal file
62
src/redfish_cli/cli/power.py
Normal file
|
|
@ -0,0 +1,62 @@
|
||||||
|
"""Commands to do with power state"""
|
||||||
|
from redfish_cli.cli.utils import error, write_output
|
||||||
|
from redfish_cli.api import power
|
||||||
|
from redfish_cli.api.exceptions import FailedToSetPowerState
|
||||||
|
|
||||||
|
|
||||||
|
def reset_system(args):
|
||||||
|
"""Reboot a server - only tested against Dells"""
|
||||||
|
try:
|
||||||
|
result = power.system_reset(args)
|
||||||
|
|
||||||
|
write_output(result, output_format=args.format)
|
||||||
|
except FailedToSetPowerState as exc:
|
||||||
|
error(exc.msg)
|
||||||
|
|
||||||
|
|
||||||
|
def power_state(args):
|
||||||
|
"""
|
||||||
|
Entry point: get the powerstate of a server.
|
||||||
|
Looks like a duplicate of powerstate above
|
||||||
|
"""
|
||||||
|
details = power.system_power_state(args)
|
||||||
|
write_output(details, output_format=args.format)
|
||||||
|
|
||||||
|
|
||||||
|
def power_states(args):
|
||||||
|
"""Entry point: get the list of powerstates a server supports. OEM dependant"""
|
||||||
|
details = power.system_power_states_allowed(args)
|
||||||
|
write_output(details, output_format=args.format)
|
||||||
|
|
||||||
|
|
||||||
|
def set_power_state(args):
|
||||||
|
"""
|
||||||
|
Entry point: set the powerstate of a server
|
||||||
|
|
||||||
|
Valid powerstates are OEM dependant.
|
||||||
|
|
||||||
|
TODO: Better doco
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
details = power.system_set_power_state(args)
|
||||||
|
write_output(details, output_format=args.format)
|
||||||
|
except FailedToSetPowerState:
|
||||||
|
error(f"Failed to set powerstate to {args.power_state}")
|
||||||
|
|
||||||
|
|
||||||
|
def power_off(args):
|
||||||
|
"""Power off a system. Stub"""
|
||||||
|
try:
|
||||||
|
details = power.system_power_off(args)
|
||||||
|
write_output(details, output_format=args.format)
|
||||||
|
except FailedToSetPowerState as exc:
|
||||||
|
error(exc.msg)
|
||||||
|
|
||||||
|
|
||||||
|
def power_on(args):
|
||||||
|
"""Power on a system. Stub"""
|
||||||
|
try:
|
||||||
|
details = power.system_power_on(args)
|
||||||
|
write_output(details, output_format=args.format)
|
||||||
|
except FailedToSetPowerState as exc:
|
||||||
|
error(exc.msg)
|
||||||
39
src/redfish_cli/cli/utils.py
Normal file
39
src/redfish_cli/cli/utils.py
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
"""Utility functions for the cli"""
|
||||||
|
import json
|
||||||
|
import logging
|
||||||
|
import sys
|
||||||
|
|
||||||
|
import tabulate
|
||||||
|
|
||||||
|
|
||||||
|
def error(message, output_format="text", exit_code=1):
|
||||||
|
"""
|
||||||
|
Write an error message to stderr, and by default exit with a return code
|
||||||
|
|
||||||
|
By default it will exit with rc 1. If rc is not truthy then sys.exit will
|
||||||
|
not be called and exectution will continue.
|
||||||
|
"""
|
||||||
|
if output_format == "json":
|
||||||
|
sys.stderr.write(json.dumps(message, indent=2))
|
||||||
|
else:
|
||||||
|
sys.stderr.write(message)
|
||||||
|
|
||||||
|
sys.stderr.write("\n")
|
||||||
|
|
||||||
|
if exit_code:
|
||||||
|
sys.exit(exit_code)
|
||||||
|
|
||||||
|
|
||||||
|
def write_output(output: str, output_format="text"):
|
||||||
|
"""Write output in the specified format - either text (default) or json"""
|
||||||
|
|
||||||
|
logging.debug("format: %s data: %s", output_format, output)
|
||||||
|
if output_format == "json":
|
||||||
|
print(json.dumps(output, indent=2))
|
||||||
|
else:
|
||||||
|
print(output)
|
||||||
|
|
||||||
|
|
||||||
|
def table(data, headers=None, tablefmt="outline"):
|
||||||
|
"""Wrap tabulate"""
|
||||||
|
return tabulate.tabulate(data, headers=headers, tablefmt=tablefmt)
|
||||||
0
src/redfish_cli/redfish.py
Normal file
0
src/redfish_cli/redfish.py
Normal file
0
tests/__init__.py
Normal file
0
tests/__init__.py
Normal file
18
tests/api/__init__.py
Normal file
18
tests/api/__init__.py
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
"""API related tests"""
|
||||||
|
from argparse import Namespace
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def secrets():
|
||||||
|
"""Deprecated"""
|
||||||
|
return {"server": "idrac-01", "username": "root", "password": "secrete"}
|
||||||
|
|
||||||
|
|
||||||
|
def args(**kwargs):
|
||||||
|
"""Base args for tests"""
|
||||||
|
kwargs.update(
|
||||||
|
{"server": "idrac-01", "username": "root", "password": "secrete"}
|
||||||
|
)
|
||||||
|
return Namespace(**kwargs)
|
||||||
253
tests/api/test_api.py
Normal file
253
tests/api/test_api.py
Normal file
|
|
@ -0,0 +1,253 @@
|
||||||
|
"""
|
||||||
|
Tests of the api
|
||||||
|
"""
|
||||||
|
import argparse
|
||||||
|
import json
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
import requests
|
||||||
|
|
||||||
|
import redfish_cli.api
|
||||||
|
import redfish_cli.api.storage
|
||||||
|
import redfish_cli.api.systems
|
||||||
|
from redfish_cli.api.exceptions import (
|
||||||
|
ResponseNotOK,
|
||||||
|
Unauthorized,
|
||||||
|
)
|
||||||
|
|
||||||
|
from ..utils import get_test_json, MockRedfishResponse, MockResponse
|
||||||
|
|
||||||
|
|
||||||
|
# pylint: disable=missing-function-docstring,redefined-outer-name
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def secrets():
|
||||||
|
return {"server": "idrac-01", "username": "root", "password": "secrete"}
|
||||||
|
|
||||||
|
|
||||||
|
def test_chassis(monkeypatch, secrets):
|
||||||
|
def mock_get(*args, **kwargs):
|
||||||
|
# pylint: disable=unused-argument
|
||||||
|
mock_redfish = MockRedfishResponse()
|
||||||
|
mock_redfish.json_dict = get_test_json("api_chassis.json")
|
||||||
|
return MockResponse(content=mock_redfish.text)
|
||||||
|
|
||||||
|
monkeypatch.setattr(requests, "get", mock_get)
|
||||||
|
|
||||||
|
chassis = redfish_cli.api.chassis(**secrets)
|
||||||
|
assert chassis["Name"] == "Chassis Collection"
|
||||||
|
|
||||||
|
|
||||||
|
def test_chassis_details(monkeypatch, secrets):
|
||||||
|
def mock_get(*args, **kwargs):
|
||||||
|
# pylint: disable=unused-argument
|
||||||
|
mock_redfish = MockRedfishResponse()
|
||||||
|
mock_redfish.json_dict = get_test_json("api_chassis_details.json")
|
||||||
|
return MockResponse(content=mock_redfish.text)
|
||||||
|
|
||||||
|
monkeypatch.setattr(requests, "get", mock_get)
|
||||||
|
|
||||||
|
secrets.update({"chassis": "System.Embedded.1"})
|
||||||
|
chassis_details = redfish_cli.api.chassis_details(**secrets)
|
||||||
|
assert chassis_details["Name"] == "Computer System Chassis"
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_base_redfish(monkeypatch, secrets):
|
||||||
|
def mock_get(*args, **kwargs):
|
||||||
|
# pylint: disable=unused-argument
|
||||||
|
mock_redfish = MockRedfishResponse()
|
||||||
|
return MockResponse(content=mock_redfish.text)
|
||||||
|
|
||||||
|
monkeypatch.setattr(requests, "get", mock_get)
|
||||||
|
_ = redfish_cli.api.utils.get(secrets["server"], "")
|
||||||
|
assert "@odata.id" in redfish_cli.api.utils.get(secrets["server"], "")
|
||||||
|
|
||||||
|
monkeypatch.setattr(
|
||||||
|
requests, "get", lambda *args, **kwargs: MockResponse(ok=False)
|
||||||
|
)
|
||||||
|
with pytest.raises(ResponseNotOK):
|
||||||
|
_ = redfish_cli.api.utils.get(secrets["server"], "")
|
||||||
|
|
||||||
|
|
||||||
|
def test_invalid_json(monkeypatch, secrets):
|
||||||
|
"""Test processing of invalid json returned from a get"""
|
||||||
|
|
||||||
|
def mock_get(*args, **kwargs):
|
||||||
|
# pylint: disable=unused-argument
|
||||||
|
return MockResponse(content="{'a':'invalid json'}")
|
||||||
|
|
||||||
|
monkeypatch.setattr(requests, "get", mock_get)
|
||||||
|
secrets.update({"url": "/"})
|
||||||
|
|
||||||
|
with pytest.raises(json.decoder.JSONDecodeError):
|
||||||
|
_ = redfish_cli.api.utils.get(**secrets)
|
||||||
|
|
||||||
|
|
||||||
|
def test_post(monkeypatch, secrets):
|
||||||
|
def mock_get(*args, **kwargs):
|
||||||
|
# pylint: disable=unused-argument
|
||||||
|
_json = {"@odata.id": "dummy"}
|
||||||
|
return MockResponse(content=json.dumps(_json))
|
||||||
|
|
||||||
|
monkeypatch.setattr(requests, "post", mock_get)
|
||||||
|
_ = redfish_cli.api.utils.post(secrets["server"], "")
|
||||||
|
assert (
|
||||||
|
"@odata.id"
|
||||||
|
in redfish_cli.api.utils.post(
|
||||||
|
secrets["server"], "", username="test", password="test"
|
||||||
|
).json()
|
||||||
|
)
|
||||||
|
|
||||||
|
monkeypatch.setattr(
|
||||||
|
requests, "post", lambda *args, **kwargs: MockResponse(status_code=401)
|
||||||
|
)
|
||||||
|
with pytest.raises(Unauthorized):
|
||||||
|
_ = redfish_cli.api.utils.post(secrets["server"], "")
|
||||||
|
|
||||||
|
monkeypatch.setattr(
|
||||||
|
requests, "post", lambda *args, **kwargs: MockResponse(ok=False)
|
||||||
|
)
|
||||||
|
with pytest.raises(ResponseNotOK):
|
||||||
|
_ = redfish_cli.api.utils.post(secrets["server"], "")
|
||||||
|
|
||||||
|
monkeypatch.setattr(
|
||||||
|
requests,
|
||||||
|
"post",
|
||||||
|
lambda *args, **kwargs: MockResponse(content="Invalid json"),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_product(monkeypatch, secrets):
|
||||||
|
def mock_get(*args, **kwargs):
|
||||||
|
# pylint: disable=unused-argument
|
||||||
|
mock_redfish = MockRedfishResponse()
|
||||||
|
return MockResponse(content=mock_redfish.text)
|
||||||
|
|
||||||
|
monkeypatch.setattr(requests, "get", mock_get)
|
||||||
|
|
||||||
|
assert (
|
||||||
|
redfish_cli.api.product(secrets["server"])
|
||||||
|
== "Integrated Dell Remote Access Controller"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_response_not_ok():
|
||||||
|
try:
|
||||||
|
raise ResponseNotOK
|
||||||
|
except ResponseNotOK as exc:
|
||||||
|
assert exc.response is None
|
||||||
|
|
||||||
|
|
||||||
|
def test_service_tag(monkeypatch, secrets):
|
||||||
|
def mock_get(*args, **kwargs):
|
||||||
|
# pylint: disable=unused-argument
|
||||||
|
mock_redfish = MockRedfishResponse()
|
||||||
|
return MockResponse(content=mock_redfish.text)
|
||||||
|
|
||||||
|
monkeypatch.setattr(requests, "get", mock_get)
|
||||||
|
assert "JYYZY42" in redfish_cli.api.service_tag(secrets["server"])
|
||||||
|
|
||||||
|
def mock_get_hp(*args, **kwargs):
|
||||||
|
# pylint: disable=unused-argument
|
||||||
|
mock_redfish = MockRedfishResponse()
|
||||||
|
mock_redfish.json_dict["Oem"] = {"HPE": {}}
|
||||||
|
return MockResponse(content=mock_redfish.text)
|
||||||
|
|
||||||
|
monkeypatch.setattr(requests, "get", mock_get_hp)
|
||||||
|
with pytest.raises(redfish_cli.api.exceptions.DellOnly):
|
||||||
|
assert "JYYZY42" in redfish_cli.api.service_tag(secrets["server"])
|
||||||
|
|
||||||
|
|
||||||
|
def test_system_details(monkeypatch, secrets):
|
||||||
|
def mock_get(*args, **kwargs):
|
||||||
|
# pylint: disable=unused-argument
|
||||||
|
mock_redfish = MockRedfishResponse()
|
||||||
|
mock_redfish.json_dict = get_test_json("system_details.json")
|
||||||
|
return MockResponse(content=mock_redfish.text)
|
||||||
|
|
||||||
|
monkeypatch.setattr(requests, "get", mock_get)
|
||||||
|
|
||||||
|
assert (
|
||||||
|
"/redfish/v1/Systems/System.Embedded.1"
|
||||||
|
== redfish_cli.api.systems.system_details(
|
||||||
|
secrets["server"],
|
||||||
|
secrets["username"],
|
||||||
|
secrets["password"],
|
||||||
|
"System.Embedded.1",
|
||||||
|
)["@odata.id"]
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_unauthorized(monkeypatch, secrets):
|
||||||
|
def mock_get(*args, **kwargs):
|
||||||
|
# pylint: disable=unused-argument
|
||||||
|
mock_redfish = MockRedfishResponse()
|
||||||
|
return MockResponse(status_code=401, content=mock_redfish.text)
|
||||||
|
|
||||||
|
monkeypatch.setattr(requests, "get", mock_get)
|
||||||
|
secrets.update({"url": "/"})
|
||||||
|
|
||||||
|
with pytest.raises(redfish_cli.api.exceptions.Unauthorized):
|
||||||
|
_ = redfish_cli.api.utils.get(**secrets)
|
||||||
|
|
||||||
|
|
||||||
|
def test_version(monkeypatch, secrets):
|
||||||
|
def mock_get(*args, **kwargs):
|
||||||
|
# pylint: disable=unused-argument
|
||||||
|
mock_redfish = MockRedfishResponse()
|
||||||
|
return MockResponse(content=mock_redfish.text)
|
||||||
|
|
||||||
|
monkeypatch.setattr(requests, "get", mock_get)
|
||||||
|
|
||||||
|
assert redfish_cli.api.redfish_version(secrets["server"]) == "1.4.0"
|
||||||
|
|
||||||
|
|
||||||
|
def test_manager(monkeypatch, secrets):
|
||||||
|
def mock_get(*args, **kwargs):
|
||||||
|
# pylint: disable=unused-argument
|
||||||
|
mock_redfish = MockRedfishResponse()
|
||||||
|
mock_redfish.json_dict = get_test_json("api_manager.json")
|
||||||
|
return MockResponse(content=mock_redfish.text)
|
||||||
|
|
||||||
|
monkeypatch.setattr(requests, "get", mock_get)
|
||||||
|
|
||||||
|
args = argparse.Namespace()
|
||||||
|
args.server = secrets["server"]
|
||||||
|
args.username = secrets["username"]
|
||||||
|
args.password = secrets["password"]
|
||||||
|
args.manager = None
|
||||||
|
|
||||||
|
assert (
|
||||||
|
redfish_cli.api.manager(args)["@odata.id"]
|
||||||
|
== "/redfish/v1/Managers/iDRAC.Embedded.1"
|
||||||
|
)
|
||||||
|
|
||||||
|
args = argparse.Namespace()
|
||||||
|
args.server = secrets["server"]
|
||||||
|
args.username = secrets["username"]
|
||||||
|
args.password = secrets["password"]
|
||||||
|
|
||||||
|
assert (
|
||||||
|
redfish_cli.api.manager(args)["@odata.id"]
|
||||||
|
== "/redfish/v1/Managers/iDRAC.Embedded.1"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_firmware_version(monkeypatch, secrets):
|
||||||
|
def mock_get(*args, **kwargs):
|
||||||
|
# pylint: disable=unused-argument
|
||||||
|
mock_redfish = MockRedfishResponse()
|
||||||
|
mock_redfish.json_dict = get_test_json("api_manager.json")
|
||||||
|
return MockResponse(content=mock_redfish.text)
|
||||||
|
|
||||||
|
monkeypatch.setattr(requests, "get", mock_get)
|
||||||
|
|
||||||
|
args = argparse.Namespace()
|
||||||
|
args.server = secrets["server"]
|
||||||
|
args.username = secrets["username"]
|
||||||
|
args.password = secrets["password"]
|
||||||
|
args.manager = None
|
||||||
|
|
||||||
|
assert redfish_cli.api.firmware_version(args) == 2656565
|
||||||
40
tests/api/test_jobs.py
Normal file
40
tests/api/test_jobs.py
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
"""Tests relating to the jobs api"""
|
||||||
|
import requests
|
||||||
|
|
||||||
|
from redfish_cli.api import jobs
|
||||||
|
|
||||||
|
from tests.api import args
|
||||||
|
|
||||||
|
from ..utils import MockResponse, get_test_content
|
||||||
|
|
||||||
|
|
||||||
|
def test_job_details(monkeypatch):
|
||||||
|
"""Test getting job details"""
|
||||||
|
monkeypatch.setattr(
|
||||||
|
requests,
|
||||||
|
"get",
|
||||||
|
lambda args, auth=None, verify=None, data=None, headers=None, timeout=None: MockResponse(
|
||||||
|
content=get_test_content("api_job_details.json")
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
_args = args(manager="Manager.1", job_id="JOB12345xdz")
|
||||||
|
|
||||||
|
result = jobs.job_details(_args)
|
||||||
|
assert result["Id"] == "JID_924369311959"
|
||||||
|
|
||||||
|
|
||||||
|
def test_job_list(monkeypatch):
|
||||||
|
"""Test getting job details"""
|
||||||
|
monkeypatch.setattr(
|
||||||
|
requests,
|
||||||
|
"get",
|
||||||
|
lambda args, auth=None, verify=None, data=None, headers=None, timeout=None: MockResponse(
|
||||||
|
content=get_test_content("jobs_list.json")
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
_args = args(manager="Manager.1")
|
||||||
|
|
||||||
|
result = jobs.jobs_list(_args)
|
||||||
|
assert result["Members@odata.count"] == 5
|
||||||
104
tests/api/test_power.py
Normal file
104
tests/api/test_power.py
Normal file
|
|
@ -0,0 +1,104 @@
|
||||||
|
"""Tests for the power related API functions"""
|
||||||
|
import pytest
|
||||||
|
import requests
|
||||||
|
|
||||||
|
from redfish_cli.api import power
|
||||||
|
from redfish_cli.api.exceptions import FailedToSetPowerState
|
||||||
|
from tests.api import args
|
||||||
|
|
||||||
|
from ..utils import get_test_json, MockRedfishResponse, MockResponse
|
||||||
|
|
||||||
|
|
||||||
|
def test_power_state(monkeypatch):
|
||||||
|
"""Test the get power_state API call"""
|
||||||
|
|
||||||
|
def mock_get(*aargs, **kwargs):
|
||||||
|
# pylint: disable=unused-argument
|
||||||
|
mock_redfish = MockRedfishResponse()
|
||||||
|
mock_redfish.json_dict = get_test_json("api_power_state.json")
|
||||||
|
return MockResponse(content=mock_redfish.text)
|
||||||
|
|
||||||
|
monkeypatch.setattr(requests, "get", mock_get)
|
||||||
|
|
||||||
|
_args = args()
|
||||||
|
_args.system = "System.Embedded.1"
|
||||||
|
|
||||||
|
power_state = power.system_power_state(_args)
|
||||||
|
assert power_state == "Off"
|
||||||
|
|
||||||
|
|
||||||
|
def test_power_states_allowed(monkeypatch):
|
||||||
|
"""Test the poert starts allowed API function"""
|
||||||
|
|
||||||
|
def mock_get(*aargs, **kwargs):
|
||||||
|
# pylint: disable=unused-argument
|
||||||
|
mock_redfish = MockRedfishResponse()
|
||||||
|
mock_redfish.json_dict = get_test_json("power_states_allowed.json")
|
||||||
|
return MockResponse(content=mock_redfish.text)
|
||||||
|
|
||||||
|
monkeypatch.setattr(requests, "get", mock_get)
|
||||||
|
|
||||||
|
_args = args()
|
||||||
|
_args.system = "system"
|
||||||
|
|
||||||
|
power_states = power.system_power_states_allowed(_args)
|
||||||
|
assert power_states == [
|
||||||
|
"On",
|
||||||
|
"ForceOff",
|
||||||
|
"ForceRestart",
|
||||||
|
"GracefulShutdown",
|
||||||
|
"PushPowerButton",
|
||||||
|
"Nmi",
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def test_set_power_state(monkeypatch):
|
||||||
|
"""Test the set power state API call"""
|
||||||
|
|
||||||
|
def mock_post(*aargs, **kwargs):
|
||||||
|
# pylint: disable=unused-argument
|
||||||
|
return MockResponse(content="{}")
|
||||||
|
|
||||||
|
monkeypatch.setattr(requests, "post", mock_post)
|
||||||
|
|
||||||
|
_args = args()
|
||||||
|
_args.system = "System.Embedded.1"
|
||||||
|
_args.power_state = "On"
|
||||||
|
|
||||||
|
result = power.system_set_power_state(_args)
|
||||||
|
assert result == "Powerstate set to On"
|
||||||
|
|
||||||
|
monkeypatch.setattr(
|
||||||
|
requests, "post", lambda *args, **kwargs: MockResponse(ok=False)
|
||||||
|
)
|
||||||
|
with pytest.raises(FailedToSetPowerState):
|
||||||
|
_ = power.system_set_power_state(_args)
|
||||||
|
|
||||||
|
|
||||||
|
def test_system_reset(monkeypatch):
|
||||||
|
"""Test resetting a system"""
|
||||||
|
monkeypatch.setattr(
|
||||||
|
requests,
|
||||||
|
"post",
|
||||||
|
lambda args, auth=None, verify=None, data=None, headers=None, timeout=None: MockResponse(
|
||||||
|
content="{}"
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
_args = args(
|
||||||
|
system="System.Embedded.1",
|
||||||
|
)
|
||||||
|
|
||||||
|
result = power.system_reset(_args)
|
||||||
|
assert result == "System reset"
|
||||||
|
|
||||||
|
monkeypatch.setattr(
|
||||||
|
requests,
|
||||||
|
"post",
|
||||||
|
lambda args, auth=None, verify=None, data=None, headers=None, timeout=None: MockResponse(
|
||||||
|
ok=False
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
with pytest.raises(FailedToSetPowerState):
|
||||||
|
result = power.system_reset(_args)
|
||||||
210
tests/api/test_storage.py
Normal file
210
tests/api/test_storage.py
Normal file
|
|
@ -0,0 +1,210 @@
|
||||||
|
"""Tests relating to the storage api"""
|
||||||
|
import pytest
|
||||||
|
import requests
|
||||||
|
|
||||||
|
import redfish_cli
|
||||||
|
from redfish_cli.api import storage
|
||||||
|
from redfish_cli.api.exceptions import ResponseNotOK
|
||||||
|
|
||||||
|
from tests.api import args
|
||||||
|
|
||||||
|
from ..utils import (
|
||||||
|
MockRedfishResponse,
|
||||||
|
MockResponse,
|
||||||
|
get_test_content,
|
||||||
|
get_test_json,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_create_logical_volume(monkeypatch):
|
||||||
|
"""Test creating a logical volume"""
|
||||||
|
monkeypatch.setattr(
|
||||||
|
requests,
|
||||||
|
"post",
|
||||||
|
lambda args, auth=None, verify=None, data=None, headers=None, timeout=None: MockResponse(
|
||||||
|
content="{}", headers={"Location": "/JOB12345"}
|
||||||
|
),
|
||||||
|
)
|
||||||
|
monkeypatch.setattr(redfish_cli.api, "firmware_version", lambda args: 2)
|
||||||
|
|
||||||
|
_args = args(
|
||||||
|
raid_level="0",
|
||||||
|
size=None,
|
||||||
|
stripe_size=None,
|
||||||
|
name="test",
|
||||||
|
secure=None,
|
||||||
|
disk_cache_policy=None,
|
||||||
|
read_cache_policy=None,
|
||||||
|
write_cache_policy=None,
|
||||||
|
disk=["one"],
|
||||||
|
system="System.Embedded.1",
|
||||||
|
controller="Raid-Controller-1",
|
||||||
|
)
|
||||||
|
|
||||||
|
result = storage.create_logical_volume(_args)
|
||||||
|
assert result["job_id"] == "JOB12345"
|
||||||
|
|
||||||
|
monkeypatch.setattr(
|
||||||
|
redfish_cli.api, "firmware_version", lambda args: 445445445
|
||||||
|
)
|
||||||
|
result = storage.create_logical_volume(_args)
|
||||||
|
assert result["job_id"] == "JOB12345"
|
||||||
|
|
||||||
|
# Test setting size
|
||||||
|
_args.size = 300000000
|
||||||
|
result = storage.create_logical_volume(_args)
|
||||||
|
assert result["job_id"] == "JOB12345"
|
||||||
|
|
||||||
|
# Test setting stripe_size
|
||||||
|
_args.stripe_size = 3000
|
||||||
|
result = storage.create_logical_volume(_args)
|
||||||
|
assert result["job_id"] == "JOB12345"
|
||||||
|
|
||||||
|
# Test setting other parameters
|
||||||
|
_args.secure = "Something"
|
||||||
|
_args.disk_cache_policy = "Something"
|
||||||
|
_args.read_cache_policy = "Something"
|
||||||
|
_args.write_cache_policy = "Something"
|
||||||
|
result = storage.create_logical_volume(_args)
|
||||||
|
assert result["job_id"] == "JOB12345"
|
||||||
|
|
||||||
|
monkeypatch.setattr(
|
||||||
|
requests,
|
||||||
|
"post",
|
||||||
|
lambda args, auth=None, verify=None, data=None, headers=None, timeout=None: MockResponse(
|
||||||
|
content="{}", headers={"NoLocation": "/JOB12345"}
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
with pytest.raises(redfish_cli.api.exceptions.FailedToGetJobID):
|
||||||
|
result = storage.create_logical_volume(_args)
|
||||||
|
|
||||||
|
monkeypatch.setattr(
|
||||||
|
requests,
|
||||||
|
"post",
|
||||||
|
lambda args, auth=None, verify=None, data=None, headers=None, timeout=None: MockResponse(
|
||||||
|
ok=False, content="{}", headers={"NoLocation": "/JOB12345"}
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
with pytest.raises(
|
||||||
|
redfish_cli.api.exceptions.LogicalVolumeCreationFailure
|
||||||
|
):
|
||||||
|
result = storage.create_logical_volume(_args)
|
||||||
|
|
||||||
|
_args.raid_level = "77"
|
||||||
|
monkeypatch.setattr(
|
||||||
|
requests,
|
||||||
|
"post",
|
||||||
|
lambda args, auth=None, verify=None, data=None, headers=None, timeout=None: MockResponse(
|
||||||
|
content="{}", headers={"NoLocation": "/JOB12345"}
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
with pytest.raises(redfish_cli.api.exceptions.InvalidRaidLevel):
|
||||||
|
result = storage.create_logical_volume(_args)
|
||||||
|
|
||||||
|
|
||||||
|
def test_delete_logical_volume(monkeypatch):
|
||||||
|
"""Test deleting a logical volume"""
|
||||||
|
monkeypatch.setattr(
|
||||||
|
requests,
|
||||||
|
"delete",
|
||||||
|
lambda args, auth=None, verify=None, data=None, headers=None, timeout=None: MockResponse(
|
||||||
|
content="{}", headers={"Location": "/JOB12345"}
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
_args = args(
|
||||||
|
disk="disk1",
|
||||||
|
verify=None,
|
||||||
|
)
|
||||||
|
|
||||||
|
result = storage.delete_logical_volume(_args)
|
||||||
|
assert result["job_id"] == "JOB12345"
|
||||||
|
|
||||||
|
monkeypatch.setattr(
|
||||||
|
requests,
|
||||||
|
"delete",
|
||||||
|
lambda args, auth=None, verify=None, data=None, headers=None, timeout=None: MockResponse(
|
||||||
|
content="{}", headers={}
|
||||||
|
),
|
||||||
|
)
|
||||||
|
with pytest.raises(redfish_cli.api.exceptions.FailedToGetJobID):
|
||||||
|
result = storage.delete_logical_volume(_args)
|
||||||
|
|
||||||
|
monkeypatch.setattr(
|
||||||
|
requests,
|
||||||
|
"delete",
|
||||||
|
lambda args, auth=None, verify=None, data=None, headers=None, timeout=None: MockResponse(
|
||||||
|
ok=False
|
||||||
|
),
|
||||||
|
)
|
||||||
|
with pytest.raises(ResponseNotOK):
|
||||||
|
result = storage.delete_logical_volume(_args)
|
||||||
|
|
||||||
|
|
||||||
|
def test_list_logical_volumes(monkeypatch):
|
||||||
|
"""Test the list logical volumes api call"""
|
||||||
|
monkeypatch.setattr(
|
||||||
|
requests,
|
||||||
|
"get",
|
||||||
|
lambda args, auth=None, verify=None, data=None, headers=None, timeout=None: MockResponse(
|
||||||
|
content=get_test_content("api_list_logical_volumes.json")
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
_args = args(
|
||||||
|
system="System.Embedded.1",
|
||||||
|
controller="RAID.Slot.6-1",
|
||||||
|
expand=True,
|
||||||
|
)
|
||||||
|
logical_volumes = redfish_cli.api.storage.list_logical_volumes(_args)
|
||||||
|
assert logical_volumes["Name"] == "Volume Collection"
|
||||||
|
|
||||||
|
_args.controller = ""
|
||||||
|
logical_volumes = redfish_cli.api.storage.list_logical_volumes(_args)
|
||||||
|
assert logical_volumes["Name"] == "Volume Collection"
|
||||||
|
|
||||||
|
|
||||||
|
def test_list_storage_controllers(monkeypatch):
|
||||||
|
"""Test the list storage controllers api call"""
|
||||||
|
|
||||||
|
def mock_get(*aargs, **kwargs):
|
||||||
|
# pylint: disable=unused-argument
|
||||||
|
mock_redfish = MockRedfishResponse()
|
||||||
|
mock_redfish.json_dict = get_test_json(
|
||||||
|
"api_list_storage_controllers.json"
|
||||||
|
)
|
||||||
|
return MockResponse(content=mock_redfish.text)
|
||||||
|
|
||||||
|
monkeypatch.setattr(requests, "get", mock_get)
|
||||||
|
|
||||||
|
_args = args(system="System.Embedded.1")
|
||||||
|
storage_controllers = redfish_cli.api.storage.list_storage_controllers(
|
||||||
|
_args
|
||||||
|
)
|
||||||
|
assert storage_controllers["Name"] == "Storage Collection"
|
||||||
|
|
||||||
|
|
||||||
|
def test_logical_volume_details(monkeypatch):
|
||||||
|
"""Test the logical volume details API call"""
|
||||||
|
|
||||||
|
def mock_get(*aargs, **kwargs):
|
||||||
|
# pylint: disable=unused-argument
|
||||||
|
mock_redfish = MockRedfishResponse()
|
||||||
|
mock_redfish.json_dict = get_test_json(
|
||||||
|
"api_logical_volume_details.json"
|
||||||
|
)
|
||||||
|
return MockResponse(content=mock_redfish.text)
|
||||||
|
|
||||||
|
monkeypatch.setattr(requests, "get", mock_get)
|
||||||
|
|
||||||
|
_args = args(
|
||||||
|
drive="Disk.Virtual.0:RAID.Slot.6-1", drive_index="0", system="system"
|
||||||
|
)
|
||||||
|
|
||||||
|
logical_volume_details = redfish_cli.api.storage.logical_volume_details(
|
||||||
|
_args
|
||||||
|
)
|
||||||
|
assert logical_volume_details["Name"] == "os"
|
||||||
105
tests/api/test_utils.py
Normal file
105
tests/api/test_utils.py
Normal file
|
|
@ -0,0 +1,105 @@
|
||||||
|
"""
|
||||||
|
Tests of the api
|
||||||
|
"""
|
||||||
|
import json
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
import requests
|
||||||
|
|
||||||
|
import redfish_cli.api
|
||||||
|
import redfish_cli.api.storage
|
||||||
|
import redfish_cli.api.systems
|
||||||
|
from redfish_cli.api.exceptions import (
|
||||||
|
ResponseNotOK,
|
||||||
|
Unauthorized,
|
||||||
|
)
|
||||||
|
|
||||||
|
from ..utils import MockResponse
|
||||||
|
from ..api import args
|
||||||
|
|
||||||
|
|
||||||
|
# pylint: disable=missing-function-docstring,redefined-outer-name
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def secrets():
|
||||||
|
return {"server": "idrac-01", "username": "root", "password": "secrete"}
|
||||||
|
|
||||||
|
|
||||||
|
def test_post(monkeypatch, secrets):
|
||||||
|
def mock_get(*args, **kwargs):
|
||||||
|
# pylint: disable=unused-argument
|
||||||
|
_json = {"@odata.id": "dummy"}
|
||||||
|
return MockResponse(content=json.dumps(_json))
|
||||||
|
|
||||||
|
monkeypatch.setattr(requests, "post", mock_get)
|
||||||
|
_ = redfish_cli.api.utils.post(secrets["server"], "")
|
||||||
|
assert (
|
||||||
|
"@odata.id"
|
||||||
|
in redfish_cli.api.utils.post(
|
||||||
|
secrets["server"], "", username="test", password="test"
|
||||||
|
).json()
|
||||||
|
)
|
||||||
|
|
||||||
|
monkeypatch.setattr(
|
||||||
|
requests, "post", lambda *args, **kwargs: MockResponse(status_code=401)
|
||||||
|
)
|
||||||
|
with pytest.raises(Unauthorized):
|
||||||
|
_ = redfish_cli.api.utils.post(secrets["server"], "")
|
||||||
|
|
||||||
|
monkeypatch.setattr(
|
||||||
|
requests, "post", lambda *args, **kwargs: MockResponse(ok=False)
|
||||||
|
)
|
||||||
|
with pytest.raises(ResponseNotOK):
|
||||||
|
_ = redfish_cli.api.utils.post(secrets["server"], "")
|
||||||
|
|
||||||
|
monkeypatch.setattr(
|
||||||
|
requests,
|
||||||
|
"post",
|
||||||
|
lambda *args, **kwargs: MockResponse(content="Invalid json"),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_delete(monkeypatch):
|
||||||
|
"""Test getting job details"""
|
||||||
|
monkeypatch.setattr(
|
||||||
|
requests,
|
||||||
|
"delete",
|
||||||
|
lambda args, auth=None, verify=None, data=None, headers=None, timeout=None: MockResponse(
|
||||||
|
content="Mock Delete"
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
_args = args()
|
||||||
|
|
||||||
|
url = redfish_cli.api.redfish_url(
|
||||||
|
_args.server, "Systems/System.Embedded.1/Storage/Volumes/Dummy"
|
||||||
|
)
|
||||||
|
|
||||||
|
_args.url = url
|
||||||
|
|
||||||
|
result = redfish_cli.api.utils.delete(
|
||||||
|
_args.server,
|
||||||
|
_args.url,
|
||||||
|
_args.username,
|
||||||
|
_args.password,
|
||||||
|
)
|
||||||
|
assert result.content == "Mock Delete"
|
||||||
|
|
||||||
|
with pytest.raises(ResponseNotOK):
|
||||||
|
# pylint: disable=line-too-long
|
||||||
|
monkeypatch.setattr(
|
||||||
|
requests,
|
||||||
|
"delete",
|
||||||
|
lambda args, auth=None, verify=None, data=None, headers=None, timeout=None: MockResponse(
|
||||||
|
ok=False
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
result = redfish_cli.api.utils.delete(
|
||||||
|
_args.server,
|
||||||
|
_args.url,
|
||||||
|
_args.username,
|
||||||
|
_args.password,
|
||||||
|
)
|
||||||
0
tests/cli/__init__.py
Normal file
0
tests/cli/__init__.py
Normal file
79
tests/cli/test_chassis.py
Normal file
79
tests/cli/test_chassis.py
Normal file
|
|
@ -0,0 +1,79 @@
|
||||||
|
"""Test for the cli componenets"""
|
||||||
|
# pylint: disable=redefined-outer-name, no-name-in-module, unused-import
|
||||||
|
|
||||||
|
import json
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
import requests
|
||||||
|
|
||||||
|
import redfish_cli.cli
|
||||||
|
from redfish_cli import api
|
||||||
|
from redfish_cli.api import storage
|
||||||
|
|
||||||
|
|
||||||
|
from ..utils import get_test_json, MockResponse, MockRedfishResponse
|
||||||
|
|
||||||
|
from .test_cli import secrets
|
||||||
|
|
||||||
|
|
||||||
|
def test_chassis(capsys, monkeypatch, secrets):
|
||||||
|
"""Test the cli chassis command"""
|
||||||
|
|
||||||
|
def mock_get(*args, **kwargs):
|
||||||
|
# pylint: disable=unused-argument
|
||||||
|
mock_redfish = MockRedfishResponse()
|
||||||
|
mock_redfish.json_dict = get_test_json("cli_chassis.json")
|
||||||
|
return MockResponse(status_code=200, content=mock_redfish.text)
|
||||||
|
|
||||||
|
monkeypatch.setattr(requests, "get", mock_get)
|
||||||
|
|
||||||
|
args = redfish_cli.cli.parse_args(
|
||||||
|
[
|
||||||
|
"-s",
|
||||||
|
secrets["server"],
|
||||||
|
"-f",
|
||||||
|
"json",
|
||||||
|
"chassis",
|
||||||
|
"-p",
|
||||||
|
secrets["password"],
|
||||||
|
"-u",
|
||||||
|
secrets["username"],
|
||||||
|
]
|
||||||
|
)
|
||||||
|
redfish_cli.cli.chassis(args)
|
||||||
|
captured = capsys.readouterr()
|
||||||
|
result = json.loads(captured.out)
|
||||||
|
assert result["@odata.id"] == "/redfish/v1/Chassis/System.Embedded.1"
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_chassis_details(capsys, monkeypatch):
|
||||||
|
"""Test the cli chassis-details command"""
|
||||||
|
_json = get_test_json("cli_chassis_details.json")
|
||||||
|
monkeypatch.setattr(
|
||||||
|
requests,
|
||||||
|
"get",
|
||||||
|
lambda *args, **kwargs: MockResponse(
|
||||||
|
content=json.dumps(_json), status_code=200
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
args = redfish_cli.cli.parse_args(
|
||||||
|
[
|
||||||
|
"-s",
|
||||||
|
"172.1.0.1",
|
||||||
|
"-f",
|
||||||
|
"json",
|
||||||
|
"chassis",
|
||||||
|
"--username",
|
||||||
|
"root",
|
||||||
|
"-p",
|
||||||
|
"password",
|
||||||
|
"show",
|
||||||
|
"-c",
|
||||||
|
"System.Embedded.1",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
redfish_cli.cli.redfish(args=args)
|
||||||
|
# captured = capsys.readouterr()
|
||||||
|
result = json.loads(capsys.readouterr().out)
|
||||||
|
assert result["Name"] == "Computer System Chassis"
|
||||||
307
tests/cli/test_cli.py
Normal file
307
tests/cli/test_cli.py
Normal file
|
|
@ -0,0 +1,307 @@
|
||||||
|
"""Test for the cli componenets"""
|
||||||
|
import argparse
|
||||||
|
import json
|
||||||
|
import os.path
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
import requests
|
||||||
|
|
||||||
|
import redfish_cli.cli
|
||||||
|
import redfish_cli.api
|
||||||
|
from redfish_cli.cli.parsers.utils import EnvDefault
|
||||||
|
|
||||||
|
from ..utils import get_test_json, MockResponse, MockRedfishResponse
|
||||||
|
|
||||||
|
# pylint: disable=redefined-outer-name
|
||||||
|
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
### Look at moving this into a shared file so we don't also define it in api
|
||||||
|
@pytest.fixture
|
||||||
|
def secrets():
|
||||||
|
"""
|
||||||
|
Secrets for use as a pytest fiixture. There aren't actually any secrets
|
||||||
|
here because everything is mocked now, but we still need some defaults when
|
||||||
|
testing the cli.
|
||||||
|
"""
|
||||||
|
with open(
|
||||||
|
os.path.join(os.path.dirname(__file__), "../test_secrets.json"),
|
||||||
|
encoding="utf-8",
|
||||||
|
) as secrets_file:
|
||||||
|
secrets = json.loads(" ".join(secrets_file.readlines()))
|
||||||
|
return secrets
|
||||||
|
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
|
||||||
|
def test_base_command(capsys, monkeypatch, secrets):
|
||||||
|
"""Test the base cli command"""
|
||||||
|
|
||||||
|
def mock_get(*args, **kwargs):
|
||||||
|
# pylint: disable=unused-argument
|
||||||
|
mock_redfish = MockRedfishResponse()
|
||||||
|
mock_redfish.json_dict = get_test_json("cli_base_command.json")
|
||||||
|
return MockResponse(status_code=200, content=mock_redfish.text)
|
||||||
|
|
||||||
|
monkeypatch.setattr(requests, "get", mock_get)
|
||||||
|
|
||||||
|
args = redfish_cli.cli.parse_args(
|
||||||
|
[
|
||||||
|
"-s",
|
||||||
|
secrets["server"],
|
||||||
|
"-f",
|
||||||
|
"json",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
redfish_cli.cli.redfish(args=args)
|
||||||
|
captured = capsys.readouterr()
|
||||||
|
result = json.loads(captured.out)
|
||||||
|
assert result["Name"] == "Root Service"
|
||||||
|
|
||||||
|
args = redfish_cli.cli.parse_args(
|
||||||
|
["-s", secrets["server"], "-f", "json", "version"]
|
||||||
|
)
|
||||||
|
redfish_cli.cli.redfish(args=args)
|
||||||
|
captured = capsys.readouterr()
|
||||||
|
result = json.loads(captured.out)
|
||||||
|
assert result == "1.4.0"
|
||||||
|
|
||||||
|
|
||||||
|
def test_get(capsys, monkeypatch, secrets):
|
||||||
|
"""Test the cli get command"""
|
||||||
|
|
||||||
|
def mock_get(*args, **kwargs):
|
||||||
|
# pylint: disable=unused-argument
|
||||||
|
mock_redfish = MockRedfishResponse()
|
||||||
|
mock_redfish.json_dict = get_test_json("cli_get.json")
|
||||||
|
return MockResponse(status_code=200, content=mock_redfish.text)
|
||||||
|
|
||||||
|
monkeypatch.setattr(requests, "get", mock_get)
|
||||||
|
|
||||||
|
args = redfish_cli.cli.parse_args(
|
||||||
|
[
|
||||||
|
"-s",
|
||||||
|
secrets["server"],
|
||||||
|
"-f",
|
||||||
|
"json",
|
||||||
|
"--debug",
|
||||||
|
"get",
|
||||||
|
"-p",
|
||||||
|
"password",
|
||||||
|
"-u",
|
||||||
|
"username",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
redfish_cli.cli.redfish(args=args)
|
||||||
|
captured = capsys.readouterr()
|
||||||
|
result = json.loads(captured.out)
|
||||||
|
assert result["Name"] == "Root Service"
|
||||||
|
|
||||||
|
monkeypatch.setattr(
|
||||||
|
requests, "get", lambda *args, **kwargs: MockResponse(status_code=401)
|
||||||
|
)
|
||||||
|
|
||||||
|
args = redfish_cli.cli.parse_args(
|
||||||
|
[
|
||||||
|
"-s",
|
||||||
|
secrets["server"],
|
||||||
|
"-f",
|
||||||
|
"json",
|
||||||
|
"get",
|
||||||
|
"-p",
|
||||||
|
"password",
|
||||||
|
"-u",
|
||||||
|
"username",
|
||||||
|
"--expand",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
try:
|
||||||
|
redfish_cli.cli.redfish(args=args)
|
||||||
|
except SystemExit:
|
||||||
|
captured = capsys.readouterr()
|
||||||
|
result = captured.err
|
||||||
|
assert result == "This url requires authentication\n\n"
|
||||||
|
|
||||||
|
monkeypatch.setattr(
|
||||||
|
requests,
|
||||||
|
"get",
|
||||||
|
lambda *args, **kwargs: MockResponse(
|
||||||
|
ok=False, content='"Invalid url"'
|
||||||
|
),
|
||||||
|
)
|
||||||
|
try:
|
||||||
|
redfish_cli.cli.redfish(args=args)
|
||||||
|
except SystemExit:
|
||||||
|
result = capsys.readouterr().err
|
||||||
|
assert result == '"Invalid url"\n'
|
||||||
|
|
||||||
|
|
||||||
|
def test_error():
|
||||||
|
"""Test the cli error function"""
|
||||||
|
|
||||||
|
with pytest.raises(SystemExit):
|
||||||
|
redfish_cli.cli.utils.error("This is an error")
|
||||||
|
|
||||||
|
with pytest.raises(SystemExit):
|
||||||
|
redfish_cli.cli.utils.error("This is an error", output_format="json")
|
||||||
|
|
||||||
|
|
||||||
|
def test_parser():
|
||||||
|
"""Test the cli parse_args function"""
|
||||||
|
args = redfish_cli.cli.parse_args(["-s", "xxxx", "version"])
|
||||||
|
assert args.server == "xxxx"
|
||||||
|
assert args.format == "json"
|
||||||
|
assert args.func.__name__ == "version"
|
||||||
|
|
||||||
|
|
||||||
|
def test_add_subparser():
|
||||||
|
"""Test a subparser with no args"""
|
||||||
|
parser = argparse.ArgumentParser(description="Test parser")
|
||||||
|
|
||||||
|
subparsers = parser.add_subparsers()
|
||||||
|
redfish_cli.cli.parsers.utils.add_subparser(
|
||||||
|
subparsers, "Dummy", arguments=None
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_product(capsys, monkeypatch):
|
||||||
|
"""Test the product cli command"""
|
||||||
|
_json = {"Product": "Integrated Dell Remote Access Controller"}
|
||||||
|
|
||||||
|
monkeypatch.setattr(
|
||||||
|
requests,
|
||||||
|
"get",
|
||||||
|
lambda *args, **kwargs: MockResponse(
|
||||||
|
content=json.dumps(_json), status_code=200
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
args = redfish_cli.cli.parse_args(
|
||||||
|
[
|
||||||
|
"-s",
|
||||||
|
"172.1.0.1",
|
||||||
|
"-f",
|
||||||
|
"json",
|
||||||
|
"product",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
redfish_cli.cli.redfish(args=args)
|
||||||
|
result = json.loads(capsys.readouterr().out)
|
||||||
|
assert result == "Integrated Dell Remote Access Controller"
|
||||||
|
|
||||||
|
|
||||||
|
def test_redfish():
|
||||||
|
"""Test the base redfish command"""
|
||||||
|
with pytest.raises(SystemExit):
|
||||||
|
redfish_cli.cli.redfish()
|
||||||
|
|
||||||
|
|
||||||
|
def test_service_tag(capsys, monkeypatch, secrets):
|
||||||
|
"""Test the service-tag cli command"""
|
||||||
|
_json = get_test_json("cli_service_tag.json")
|
||||||
|
|
||||||
|
def mock_get(*args, **kwargs):
|
||||||
|
# pylint: disable=unused-argument
|
||||||
|
mock_redfish = MockRedfishResponse()
|
||||||
|
mock_redfish.json_dict = _json
|
||||||
|
|
||||||
|
return MockResponse(status_code=200, content=mock_redfish.text)
|
||||||
|
|
||||||
|
monkeypatch.setattr(requests, "get", mock_get)
|
||||||
|
|
||||||
|
args = redfish_cli.cli.parse_args(
|
||||||
|
[
|
||||||
|
"-s",
|
||||||
|
secrets["server"],
|
||||||
|
"service-tag",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
redfish_cli.cli.service_tag(args)
|
||||||
|
captured = capsys.readouterr()
|
||||||
|
result = captured.out
|
||||||
|
assert result == '"JYYZY42"\n'
|
||||||
|
|
||||||
|
_json["Oem"]["NotDell"] = _json["Oem"]["Dell"]
|
||||||
|
del _json["Oem"]["Dell"]
|
||||||
|
|
||||||
|
monkeypatch.setattr(
|
||||||
|
requests,
|
||||||
|
"get",
|
||||||
|
lambda *args, **kwargs: MockResponse(
|
||||||
|
content=json.dumps(_json), status_code=200
|
||||||
|
),
|
||||||
|
)
|
||||||
|
args = redfish_cli.cli.parse_args(
|
||||||
|
[
|
||||||
|
"-s",
|
||||||
|
secrets["server"],
|
||||||
|
"service-tag",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
with pytest.raises(SystemExit):
|
||||||
|
redfish_cli.cli.service_tag(args)
|
||||||
|
captured = capsys.readouterr()
|
||||||
|
result = captured.err
|
||||||
|
|
||||||
|
assert result == "Service tags are only available for Dell iDRACs\n"
|
||||||
|
|
||||||
|
|
||||||
|
def test_version(capsys, monkeypatch, secrets):
|
||||||
|
"""Test the version command"""
|
||||||
|
|
||||||
|
def mock_get(*args, **kwargs):
|
||||||
|
# pylint: disable=unused-argument
|
||||||
|
mock_redfish = MockRedfishResponse()
|
||||||
|
mock_redfish.json_dict = get_test_json("cli_version.json")
|
||||||
|
return MockResponse(status_code=200, content=mock_redfish.text)
|
||||||
|
|
||||||
|
monkeypatch.setattr(requests, "get", mock_get)
|
||||||
|
|
||||||
|
args = redfish_cli.cli.parse_args(
|
||||||
|
[
|
||||||
|
"-s",
|
||||||
|
secrets["server"],
|
||||||
|
"version",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
redfish_cli.cli.version(args)
|
||||||
|
captured = capsys.readouterr()
|
||||||
|
result = captured.out
|
||||||
|
assert result == '"1.4.0"\n'
|
||||||
|
|
||||||
|
|
||||||
|
def test_write():
|
||||||
|
"""Test the cli write function"""
|
||||||
|
redfish_cli.cli.utils.write_output("This is not an error")
|
||||||
|
|
||||||
|
redfish_cli.cli.utils.write_output(
|
||||||
|
"This is not an error", output_format="json"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_env_var():
|
||||||
|
"""Test the envvar action parser action"""
|
||||||
|
parser = argparse.ArgumentParser(
|
||||||
|
description="Interact with servers via RedFish. Only Dells supported at the moment"
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"-s",
|
||||||
|
"--server",
|
||||||
|
required=True,
|
||||||
|
dest="server",
|
||||||
|
action=EnvDefault,
|
||||||
|
default=os.environ.get("RF_USERNAME"),
|
||||||
|
envvar="USER",
|
||||||
|
)
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
"-u",
|
||||||
|
"--user",
|
||||||
|
required=True,
|
||||||
|
dest="server",
|
||||||
|
help="Help",
|
||||||
|
action=EnvDefault,
|
||||||
|
envvar="USER",
|
||||||
|
)
|
||||||
204
tests/cli/test_jobs.py
Normal file
204
tests/cli/test_jobs.py
Normal file
|
|
@ -0,0 +1,204 @@
|
||||||
|
"""Test for the cli componenets"""
|
||||||
|
# pylint: disable=redefined-outer-name, no-name-in-module, unused-import
|
||||||
|
|
||||||
|
import json
|
||||||
|
from unittest import mock
|
||||||
|
|
||||||
|
import requests
|
||||||
|
|
||||||
|
from redfish_cli.cli import parse_args
|
||||||
|
from redfish_cli.cli.jobs import jobs_list, job_details, watch_job
|
||||||
|
|
||||||
|
from ..utils import get_test_content, MockResponse, MockWatchedJobResponse
|
||||||
|
|
||||||
|
|
||||||
|
def test_list_jobs(capsys, monkeypatch):
|
||||||
|
"""Test the list jobs command"""
|
||||||
|
# pylint: disable=fixme, unused-argument, unused-variable
|
||||||
|
|
||||||
|
args = parse_args(
|
||||||
|
[
|
||||||
|
"-s",
|
||||||
|
"172.1.0.1",
|
||||||
|
"-f",
|
||||||
|
"json",
|
||||||
|
"jobs",
|
||||||
|
"-u",
|
||||||
|
"root",
|
||||||
|
"-p",
|
||||||
|
"password123",
|
||||||
|
"list",
|
||||||
|
"--all",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
monkeypatch.setattr(
|
||||||
|
requests,
|
||||||
|
"get",
|
||||||
|
lambda args, auth=None, verify=None, data=None, headers=None, timeout=None: MockResponse(
|
||||||
|
content=get_test_content("jobs_list.json")
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
jobs_list(args=args)
|
||||||
|
captured = capsys.readouterr()
|
||||||
|
result = captured.out
|
||||||
|
assert 5 == json.loads(result)["Members@odata.count"]
|
||||||
|
|
||||||
|
args = parse_args(
|
||||||
|
[
|
||||||
|
"-s",
|
||||||
|
"172.1.0.1",
|
||||||
|
"-f",
|
||||||
|
"json",
|
||||||
|
"jobs",
|
||||||
|
"-u",
|
||||||
|
"root",
|
||||||
|
"-p",
|
||||||
|
"password123",
|
||||||
|
"list",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
jobs_list(args=args)
|
||||||
|
captured = capsys.readouterr()
|
||||||
|
result = captured.out
|
||||||
|
assert 0 == json.loads(result)["Members@odata.count"]
|
||||||
|
|
||||||
|
args = parse_args(
|
||||||
|
[
|
||||||
|
"-s",
|
||||||
|
"172.1.0.1",
|
||||||
|
"-f",
|
||||||
|
"text",
|
||||||
|
"jobs",
|
||||||
|
"-u",
|
||||||
|
"root",
|
||||||
|
"-p",
|
||||||
|
"password123",
|
||||||
|
"list",
|
||||||
|
"--all",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
jobs_list(args=args)
|
||||||
|
captured = capsys.readouterr()
|
||||||
|
result = captured.out
|
||||||
|
assert (
|
||||||
|
"JID_878659984891 RAIDConfiguration 100 Config:RAID:RAID.Slot.6-1 Completed\n"
|
||||||
|
"JID_878682850779 RAIDConfiguration 100 Config:RAID:RAID.Slot.6-1 Completed\n"
|
||||||
|
"JID_920326518992 RAIDConfiguration 100 Config:RAID:RAID.Slot.6-1 Completed\n"
|
||||||
|
"JID_923469653542 RAIDConfiguration 100 Config:RAID:RAID.Slot.6-1 Completed\n"
|
||||||
|
"JID_924369311959 RAIDConfiguration 100 Config:RAID:RAID.Slot.6-1 Completed\n"
|
||||||
|
) == result
|
||||||
|
|
||||||
|
args = parse_args(
|
||||||
|
[
|
||||||
|
"-s",
|
||||||
|
"172.1.0.1",
|
||||||
|
"-f",
|
||||||
|
"table",
|
||||||
|
"jobs",
|
||||||
|
"-u",
|
||||||
|
"root",
|
||||||
|
"-p",
|
||||||
|
"password123",
|
||||||
|
"list",
|
||||||
|
"--all",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
jobs_list(args=args)
|
||||||
|
captured = capsys.readouterr()
|
||||||
|
result = captured.out
|
||||||
|
expected = get_test_content("job_list_table.txt")
|
||||||
|
assert expected == result
|
||||||
|
|
||||||
|
|
||||||
|
def test_job_details(capsys, monkeypatch):
|
||||||
|
"""Test the list jobs command"""
|
||||||
|
# pylint: disable=fixme, unused-argument, unused-variable
|
||||||
|
|
||||||
|
args = parse_args(
|
||||||
|
[
|
||||||
|
"-s",
|
||||||
|
"172.1.0.1",
|
||||||
|
"-f",
|
||||||
|
"json",
|
||||||
|
"jobs",
|
||||||
|
"-u",
|
||||||
|
"root",
|
||||||
|
"-p",
|
||||||
|
"password123",
|
||||||
|
"show",
|
||||||
|
"-j",
|
||||||
|
"JID_924369311959",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
monkeypatch.setattr(
|
||||||
|
requests,
|
||||||
|
"get",
|
||||||
|
lambda args, auth=None, verify=None, data=None, headers=None, timeout=None: MockResponse(
|
||||||
|
content=get_test_content("api_job_details.json")
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
job_details(args=args)
|
||||||
|
captured = capsys.readouterr()
|
||||||
|
result = captured.out
|
||||||
|
assert "2023-08-20T05:59:24" == json.loads(result)["CompletionTime"]
|
||||||
|
|
||||||
|
|
||||||
|
def test_watch_jobs(capsys, monkeypatch):
|
||||||
|
"""Test the list jobs command"""
|
||||||
|
# pylint: disable=fixme, unused-argument, unused-variable
|
||||||
|
|
||||||
|
response = MockWatchedJobResponse()
|
||||||
|
args = parse_args(
|
||||||
|
[
|
||||||
|
"-s",
|
||||||
|
"172.1.0.1",
|
||||||
|
"-f",
|
||||||
|
"json",
|
||||||
|
"jobs",
|
||||||
|
"-u",
|
||||||
|
"root",
|
||||||
|
"-p",
|
||||||
|
"password123",
|
||||||
|
"show",
|
||||||
|
"-j",
|
||||||
|
"JID_924369311959",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
monkeypatch.setattr(
|
||||||
|
requests,
|
||||||
|
"get",
|
||||||
|
lambda args, auth=None, verify=None, data=None, headers=None, timeout=None: response,
|
||||||
|
)
|
||||||
|
|
||||||
|
watch_job(args=args)
|
||||||
|
captured = capsys.readouterr()
|
||||||
|
result = captured.out
|
||||||
|
assert '"PercentComplete": 100,' in result
|
||||||
|
|
||||||
|
response.accessed = 0
|
||||||
|
args = parse_args(
|
||||||
|
[
|
||||||
|
"-s",
|
||||||
|
"172.1.0.1",
|
||||||
|
"-f",
|
||||||
|
"text",
|
||||||
|
"jobs",
|
||||||
|
"-u",
|
||||||
|
"root",
|
||||||
|
"-p",
|
||||||
|
"password123",
|
||||||
|
"show",
|
||||||
|
"-j",
|
||||||
|
"JID_924369311959",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
watch_job(args=args)
|
||||||
|
captured = capsys.readouterr()
|
||||||
|
result = captured.out
|
||||||
|
assert "Completed 100\n" in result
|
||||||
|
|
||||||
|
# Test that watch jobs catches a KeyboardInterrup and exits cleanly
|
||||||
|
with mock.patch("requests.get", side_effect=KeyboardInterrupt):
|
||||||
|
watch_job(args=args)
|
||||||
255
tests/cli/test_power.py
Normal file
255
tests/cli/test_power.py
Normal file
|
|
@ -0,0 +1,255 @@
|
||||||
|
"""Test for the cli componenets"""
|
||||||
|
# pylint: disable=redefined-outer-name, no-name-in-module, unused-import
|
||||||
|
|
||||||
|
import json
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
import requests
|
||||||
|
|
||||||
|
import redfish_cli.cli
|
||||||
|
import redfish_cli.cli.power
|
||||||
|
from redfish_cli import api
|
||||||
|
|
||||||
|
from ..utils import get_test_json, MockResponse, MockRedfishResponse
|
||||||
|
|
||||||
|
|
||||||
|
def test_set_power_state(capsys, monkeypatch):
|
||||||
|
"""Test the set-power-state cli command"""
|
||||||
|
|
||||||
|
monkeypatch.setattr(
|
||||||
|
requests,
|
||||||
|
"post",
|
||||||
|
lambda *args, **kwargs: MockResponse(content="{}", status_code=200),
|
||||||
|
)
|
||||||
|
|
||||||
|
args = redfish_cli.cli.parse_args(
|
||||||
|
[
|
||||||
|
"-s",
|
||||||
|
"172.1.0.1",
|
||||||
|
"-f",
|
||||||
|
"json",
|
||||||
|
"power",
|
||||||
|
"-u",
|
||||||
|
"root",
|
||||||
|
"-p",
|
||||||
|
"password123",
|
||||||
|
"set",
|
||||||
|
"On",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
redfish_cli.cli.power.set_power_state(args=args)
|
||||||
|
out = capsys.readouterr().out
|
||||||
|
result = out
|
||||||
|
assert result == '"Powerstate set to On"\n'
|
||||||
|
|
||||||
|
monkeypatch.setattr(
|
||||||
|
requests, "post", lambda *args, **kwargs: MockResponse(ok=False)
|
||||||
|
)
|
||||||
|
try:
|
||||||
|
redfish_cli.cli.power.set_power_state(args)
|
||||||
|
except SystemExit:
|
||||||
|
result = capsys.readouterr().err
|
||||||
|
assert result == "Failed to set powerstate to On\n"
|
||||||
|
|
||||||
|
|
||||||
|
def test_power_state(capsys, monkeypatch):
|
||||||
|
"""Test the get power state cli command"""
|
||||||
|
_json = {"PowerState": "Off"}
|
||||||
|
|
||||||
|
monkeypatch.setattr(
|
||||||
|
requests,
|
||||||
|
"get",
|
||||||
|
lambda *args, **kwargs: MockResponse(
|
||||||
|
content=json.dumps(_json), status_code=200
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
args = redfish_cli.cli.parse_args(
|
||||||
|
[
|
||||||
|
"-s",
|
||||||
|
"172.1.0.1",
|
||||||
|
"-f",
|
||||||
|
"json",
|
||||||
|
"power",
|
||||||
|
"-u",
|
||||||
|
"root",
|
||||||
|
"-p",
|
||||||
|
"password123",
|
||||||
|
"get",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
redfish_cli.cli.power.power_state(args=args)
|
||||||
|
out = capsys.readouterr().out
|
||||||
|
result = json.loads(out)
|
||||||
|
assert result == "Off"
|
||||||
|
|
||||||
|
|
||||||
|
def test_list_power_states(capsys, monkeypatch):
|
||||||
|
"""Test the product cli command"""
|
||||||
|
# pylint: disable=duplicate-code
|
||||||
|
|
||||||
|
# This code is similar to the direct api test. Disable the pylint warning.
|
||||||
|
|
||||||
|
_json = get_test_json("power_states_allowed.json")
|
||||||
|
|
||||||
|
monkeypatch.setattr(
|
||||||
|
requests,
|
||||||
|
"get",
|
||||||
|
lambda *args, **kwargs: MockResponse(
|
||||||
|
content=json.dumps(_json), status_code=200
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
args = redfish_cli.cli.parse_args(
|
||||||
|
[
|
||||||
|
"-s",
|
||||||
|
"172.1.0.1",
|
||||||
|
"-f",
|
||||||
|
"json",
|
||||||
|
"power",
|
||||||
|
"-u",
|
||||||
|
"root",
|
||||||
|
"-p",
|
||||||
|
"password123",
|
||||||
|
"list",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
redfish_cli.cli.power.power_states(args)
|
||||||
|
result = json.loads(capsys.readouterr().out)
|
||||||
|
assert result == [
|
||||||
|
"On",
|
||||||
|
"ForceOff",
|
||||||
|
"ForceRestart",
|
||||||
|
"GracefulShutdown",
|
||||||
|
"PushPowerButton",
|
||||||
|
"Nmi",
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def test_system_reset(capsys, monkeypatch):
|
||||||
|
"""Test resetting a system"""
|
||||||
|
monkeypatch.setattr(
|
||||||
|
requests,
|
||||||
|
"post",
|
||||||
|
lambda args, auth=None, verify=None, data=None, headers=None, timeout=None: MockResponse(
|
||||||
|
content="{}"
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
args = redfish_cli.cli.parse_args(
|
||||||
|
[
|
||||||
|
"-s",
|
||||||
|
"172.1.0.1",
|
||||||
|
"-f",
|
||||||
|
"json",
|
||||||
|
"power",
|
||||||
|
"-u",
|
||||||
|
"root",
|
||||||
|
"-p",
|
||||||
|
"password123",
|
||||||
|
"reset",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
redfish_cli.cli.power.reset_system(args=args)
|
||||||
|
out = capsys.readouterr().out
|
||||||
|
result = json.loads(out)
|
||||||
|
assert result == "System reset"
|
||||||
|
|
||||||
|
monkeypatch.setattr(
|
||||||
|
requests,
|
||||||
|
"post",
|
||||||
|
lambda *args, **kwargs: MockResponse(
|
||||||
|
ok=False, content="Failed to set power state"
|
||||||
|
),
|
||||||
|
)
|
||||||
|
try:
|
||||||
|
redfish_cli.cli.power.reset_system(args)
|
||||||
|
except SystemExit:
|
||||||
|
result = capsys.readouterr().err
|
||||||
|
assert result == "Failed to set power state\n"
|
||||||
|
|
||||||
|
|
||||||
|
def test_power_on(capsys, monkeypatch):
|
||||||
|
"""Test resetting a system"""
|
||||||
|
monkeypatch.setattr(
|
||||||
|
requests,
|
||||||
|
"post",
|
||||||
|
lambda args, auth=None, verify=None, data=None, headers=None, timeout=None: MockResponse(
|
||||||
|
content="{}"
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
args = redfish_cli.cli.parse_args(
|
||||||
|
[
|
||||||
|
"-s",
|
||||||
|
"172.1.0.1",
|
||||||
|
"-f",
|
||||||
|
"json",
|
||||||
|
"power",
|
||||||
|
"-u",
|
||||||
|
"root",
|
||||||
|
"-p",
|
||||||
|
"password123",
|
||||||
|
"on",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
redfish_cli.cli.power.power_on(args=args)
|
||||||
|
out = capsys.readouterr().out
|
||||||
|
result = json.loads(out)
|
||||||
|
assert result == "System.Embedded.1 powered on"
|
||||||
|
|
||||||
|
monkeypatch.setattr(
|
||||||
|
requests,
|
||||||
|
"post",
|
||||||
|
lambda *args, **kwargs: MockResponse(
|
||||||
|
ok=False, content="Failed to power on"
|
||||||
|
),
|
||||||
|
)
|
||||||
|
try:
|
||||||
|
redfish_cli.cli.power.power_on(args)
|
||||||
|
except SystemExit:
|
||||||
|
result = capsys.readouterr().err
|
||||||
|
assert result == "Failed to power on\n"
|
||||||
|
|
||||||
|
|
||||||
|
def test_power_off(capsys, monkeypatch):
|
||||||
|
"""Test resetting a system"""
|
||||||
|
monkeypatch.setattr(
|
||||||
|
requests,
|
||||||
|
"post",
|
||||||
|
lambda args, auth=None, verify=None, data=None, headers=None, timeout=None: MockResponse(
|
||||||
|
content="{}"
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
args = redfish_cli.cli.parse_args(
|
||||||
|
[
|
||||||
|
"-s",
|
||||||
|
"172.1.0.1",
|
||||||
|
"-f",
|
||||||
|
"json",
|
||||||
|
"power",
|
||||||
|
"-u",
|
||||||
|
"root",
|
||||||
|
"-p",
|
||||||
|
"password123",
|
||||||
|
"off",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
redfish_cli.cli.power.power_off(args=args)
|
||||||
|
out = capsys.readouterr().out
|
||||||
|
result = json.loads(out)
|
||||||
|
assert result == "System.Embedded.1 powered off"
|
||||||
|
|
||||||
|
monkeypatch.setattr(
|
||||||
|
requests,
|
||||||
|
"post",
|
||||||
|
lambda *args, **kwargs: MockResponse(
|
||||||
|
ok=False, content="Failed to power off"
|
||||||
|
),
|
||||||
|
)
|
||||||
|
try:
|
||||||
|
redfish_cli.cli.power.power_off(args)
|
||||||
|
except SystemExit:
|
||||||
|
result = capsys.readouterr().err
|
||||||
|
assert result == "Failed to power off\n"
|
||||||
631
tests/cli/test_storage.py
Normal file
631
tests/cli/test_storage.py
Normal file
|
|
@ -0,0 +1,631 @@
|
||||||
|
"""Test for the cli componenets"""
|
||||||
|
# pylint: disable=redefined-outer-name, no-name-in-module, unused-import
|
||||||
|
|
||||||
|
import json
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
import requests
|
||||||
|
|
||||||
|
import redfish_cli.cli
|
||||||
|
from redfish_cli import api
|
||||||
|
from redfish_cli.api import storage
|
||||||
|
from redfish_cli.api.exceptions import LogicalVolumeCreationFailure
|
||||||
|
|
||||||
|
from ..utils import get_test_json, MockResponse, MockRedfishResponse
|
||||||
|
|
||||||
|
from .test_cli import secrets
|
||||||
|
|
||||||
|
|
||||||
|
def test_create_logical_volume(capsys, monkeypatch):
|
||||||
|
"""Test the create-logical-volume command"""
|
||||||
|
# pylint: disable=fixme, unused-argument, unused-variable
|
||||||
|
# TODO: Write actual tests when the create-logical-volume code is fixed
|
||||||
|
|
||||||
|
args = redfish_cli.cli.parse_args(
|
||||||
|
[
|
||||||
|
"-s",
|
||||||
|
"172.1.0.1",
|
||||||
|
"-f",
|
||||||
|
"json",
|
||||||
|
"storage",
|
||||||
|
"-u",
|
||||||
|
"root",
|
||||||
|
"-p",
|
||||||
|
"password123",
|
||||||
|
"logical",
|
||||||
|
"create",
|
||||||
|
"-c",
|
||||||
|
"controller",
|
||||||
|
"-d",
|
||||||
|
"disk",
|
||||||
|
"-r",
|
||||||
|
"0",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
monkeypatch.setattr(
|
||||||
|
requests,
|
||||||
|
"post",
|
||||||
|
lambda args, auth=None, verify=None, data=None, headers=None, timeout=None: MockResponse(
|
||||||
|
content="{}", headers={"Location": "/JOB12345"}
|
||||||
|
),
|
||||||
|
)
|
||||||
|
monkeypatch.setattr(redfish_cli.api, "firmware_version", lambda args: 2)
|
||||||
|
|
||||||
|
redfish_cli.cli.create_logical_volume(args=args)
|
||||||
|
captured = capsys.readouterr()
|
||||||
|
result = captured.out
|
||||||
|
assert "JOB12345" in result
|
||||||
|
|
||||||
|
with pytest.raises(SystemExit):
|
||||||
|
# pylint: disable=line-too-long
|
||||||
|
monkeypatch.setattr(
|
||||||
|
requests,
|
||||||
|
"post",
|
||||||
|
lambda args, auth=None, verify=None, data=None, headers=None, timeout=None: MockResponse(
|
||||||
|
ok=False, content='{"msg":"and error occurred"}'
|
||||||
|
),
|
||||||
|
)
|
||||||
|
redfish_cli.cli.create_logical_volume(args=args)
|
||||||
|
captured = capsys.readouterr()
|
||||||
|
result = captured.err
|
||||||
|
assert "JOB12345" in result
|
||||||
|
|
||||||
|
with pytest.raises(SystemExit):
|
||||||
|
args.raid_level = "zz"
|
||||||
|
redfish_cli.cli.create_logical_volume(args=args)
|
||||||
|
captured = capsys.readouterr()
|
||||||
|
result = captured.err
|
||||||
|
assert (
|
||||||
|
"zz is not a valid raid level. Valid choices are 0,1,5,10,50"
|
||||||
|
in result
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_delete_logical_volume(capsys, monkeypatch):
|
||||||
|
"""Test the create-logical-volume command"""
|
||||||
|
# pylint: disable=fixme, unused-argument, unused-variable
|
||||||
|
# TODO: Write actual tests when the create-logical-volume code is fixed
|
||||||
|
|
||||||
|
args = redfish_cli.cli.parse_args(
|
||||||
|
[
|
||||||
|
"-s",
|
||||||
|
"172.1.0.1",
|
||||||
|
"-f",
|
||||||
|
"json",
|
||||||
|
"storage",
|
||||||
|
"-u",
|
||||||
|
"root",
|
||||||
|
"-p",
|
||||||
|
"password123",
|
||||||
|
"logical",
|
||||||
|
"create",
|
||||||
|
"-c",
|
||||||
|
"controller",
|
||||||
|
"-d",
|
||||||
|
"disk",
|
||||||
|
"-r",
|
||||||
|
"0",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
monkeypatch.setattr(
|
||||||
|
requests,
|
||||||
|
"delete",
|
||||||
|
lambda args, auth=None, verify=None, data=None, headers=None, timeout=None: MockResponse(
|
||||||
|
content="{}", headers={"Location": "/JOB12345"}
|
||||||
|
),
|
||||||
|
)
|
||||||
|
monkeypatch.setattr(redfish_cli.api, "firmware_version", lambda args: 2)
|
||||||
|
|
||||||
|
redfish_cli.cli.delete_logical_volume(args=args)
|
||||||
|
captured = capsys.readouterr()
|
||||||
|
result = captured.out
|
||||||
|
assert "JOB12345" in result
|
||||||
|
|
||||||
|
with pytest.raises(SystemExit):
|
||||||
|
# pylint: disable=line-too-long
|
||||||
|
monkeypatch.setattr(
|
||||||
|
requests,
|
||||||
|
"delete",
|
||||||
|
lambda args, auth=None, verify=None, data=None, headers=None, timeout=None: MockResponse(
|
||||||
|
ok=False, content='{"msg":"and error occurred"}'
|
||||||
|
),
|
||||||
|
)
|
||||||
|
redfish_cli.cli.delete_logical_volume(args=args)
|
||||||
|
captured = capsys.readouterr()
|
||||||
|
result = captured.err
|
||||||
|
assert "JOB12345" in result
|
||||||
|
|
||||||
|
with pytest.raises(SystemExit):
|
||||||
|
args.raid_level = "zz"
|
||||||
|
redfish_cli.cli.create_logical_volume(args=args)
|
||||||
|
captured = capsys.readouterr()
|
||||||
|
result = captured.err
|
||||||
|
assert (
|
||||||
|
"zz is not a valid raid level. Valid choices are 0,1,5,10,50"
|
||||||
|
in result
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_show_logical_volume(capsys, monkeypatch):
|
||||||
|
"""Test the cli logical-volume command"""
|
||||||
|
_json = get_test_json("cli_logical_volume.json")
|
||||||
|
monkeypatch.setattr(
|
||||||
|
requests,
|
||||||
|
"get",
|
||||||
|
lambda *args, **kwargs: MockResponse(
|
||||||
|
content=json.dumps(_json), status_code=200
|
||||||
|
),
|
||||||
|
)
|
||||||
|
args = redfish_cli.cli.parse_args(
|
||||||
|
[
|
||||||
|
"-s",
|
||||||
|
"172.1.0.1",
|
||||||
|
"-f",
|
||||||
|
"json",
|
||||||
|
"storage",
|
||||||
|
"-u",
|
||||||
|
"root",
|
||||||
|
"-p",
|
||||||
|
"password123",
|
||||||
|
"logical",
|
||||||
|
"show",
|
||||||
|
"-d",
|
||||||
|
"Disk.Virtual.0:RAID.Slot.6-1",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
redfish_cli.cli.redfish(args=args)
|
||||||
|
result = json.loads(capsys.readouterr().out)
|
||||||
|
assert result["Id"] == "Disk.Virtual.0:RAID.Slot.6-1"
|
||||||
|
|
||||||
|
args = redfish_cli.cli.parse_args(
|
||||||
|
[
|
||||||
|
"-s",
|
||||||
|
"172.1.0.1",
|
||||||
|
"-f",
|
||||||
|
"json",
|
||||||
|
"storage",
|
||||||
|
"-u",
|
||||||
|
"root",
|
||||||
|
"-p",
|
||||||
|
"password123",
|
||||||
|
"logical",
|
||||||
|
"show",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
monkeypatch.setattr(
|
||||||
|
redfish_cli.api.storage,
|
||||||
|
"list_storage_controllers",
|
||||||
|
lambda *args, **kwargs: {
|
||||||
|
"Members": [
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/RAID.Slot.6-1"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
monkeypatch.setattr(
|
||||||
|
redfish_cli.api.storage,
|
||||||
|
"list_logical_volumes",
|
||||||
|
lambda *args, **kwargs: {
|
||||||
|
"Members": [
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/"
|
||||||
|
"Storage/Volumes/Disk.Virtual.0:RAID.Slot.6-1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1"
|
||||||
|
"/Storage/Volumes/Disk.Virtual.1:RAID.Slot.6-1"
|
||||||
|
},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
redfish_cli.cli.redfish(args=args)
|
||||||
|
result = json.loads(capsys.readouterr().out)
|
||||||
|
assert result["Id"] == "Disk.Virtual.0:RAID.Slot.6-1"
|
||||||
|
|
||||||
|
args = redfish_cli.cli.parse_args(
|
||||||
|
[
|
||||||
|
"-s",
|
||||||
|
"172.1.0.1",
|
||||||
|
"-f",
|
||||||
|
"json",
|
||||||
|
"storage",
|
||||||
|
"-u",
|
||||||
|
"root",
|
||||||
|
"-p",
|
||||||
|
"password123",
|
||||||
|
"logical",
|
||||||
|
"show",
|
||||||
|
"-c",
|
||||||
|
"RAID.Slot.6-1",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
redfish_cli.cli.redfish(args=args)
|
||||||
|
result = json.loads(capsys.readouterr().out)
|
||||||
|
assert result["Id"] == "Disk.Virtual.0:RAID.Slot.6-1"
|
||||||
|
|
||||||
|
monkeypatch.setattr(
|
||||||
|
requests,
|
||||||
|
"get",
|
||||||
|
lambda *args, **kwargs: MockResponse(
|
||||||
|
ok=False, content='"Invalid logical volume"'
|
||||||
|
),
|
||||||
|
)
|
||||||
|
try:
|
||||||
|
redfish_cli.cli.redfish(args=args)
|
||||||
|
except SystemExit:
|
||||||
|
result = capsys.readouterr().err
|
||||||
|
assert result == '"Invalid logical volume"\n'
|
||||||
|
|
||||||
|
|
||||||
|
def test_list_logical_volumes(capsys, monkeypatch):
|
||||||
|
"""Test the cli logical-volumes command"""
|
||||||
|
_json = get_test_json("cli_logical_volumes.json")
|
||||||
|
|
||||||
|
monkeypatch.setattr(
|
||||||
|
requests,
|
||||||
|
"get",
|
||||||
|
lambda *args, **kwargs: MockResponse(
|
||||||
|
content=json.dumps(_json), status_code=200
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
args = redfish_cli.cli.parse_args(
|
||||||
|
[
|
||||||
|
"-s",
|
||||||
|
"172.1.0.1",
|
||||||
|
"-f",
|
||||||
|
"json",
|
||||||
|
"storage",
|
||||||
|
"-u",
|
||||||
|
"root",
|
||||||
|
"-p",
|
||||||
|
"password123",
|
||||||
|
"logical",
|
||||||
|
"list",
|
||||||
|
"-c",
|
||||||
|
"RAID.Slot.6-1",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
redfish_cli.cli.redfish(args=args)
|
||||||
|
# err_out = capsys.readouterr().out
|
||||||
|
result = json.loads(capsys.readouterr().out)
|
||||||
|
assert result["Name"] == "Volume Collection"
|
||||||
|
|
||||||
|
monkeypatch.setattr(
|
||||||
|
requests,
|
||||||
|
"get",
|
||||||
|
lambda *args, **kwargs: MockResponse(ok=False, content='"Invalid"'),
|
||||||
|
)
|
||||||
|
try:
|
||||||
|
redfish_cli.cli.redfish(args=args)
|
||||||
|
except SystemExit:
|
||||||
|
result = capsys.readouterr().err
|
||||||
|
assert result == '"Invalid"\n'
|
||||||
|
|
||||||
|
|
||||||
|
def test_show_phsyical_volume(capsys, monkeypatch, secrets):
|
||||||
|
"""Test the physical_voume cli command"""
|
||||||
|
|
||||||
|
def mock_get(*args, **kwargs):
|
||||||
|
# pylint: disable=unused-argument
|
||||||
|
mock_redfish = MockRedfishResponse()
|
||||||
|
mock_redfish.json_dict = get_test_json("physical_volume.json")
|
||||||
|
return MockResponse(status_code=200, content=mock_redfish.text)
|
||||||
|
|
||||||
|
monkeypatch.setattr(requests, "get", mock_get)
|
||||||
|
monkeypatch.setattr(
|
||||||
|
storage,
|
||||||
|
"list_storage_controllers",
|
||||||
|
lambda *args, **kwargs: {"Members": [{"@odata.id": ""}]},
|
||||||
|
)
|
||||||
|
monkeypatch.setattr(
|
||||||
|
storage,
|
||||||
|
"list_physical_volumes",
|
||||||
|
lambda *args, **kwargs: [{"drive": "Dummy"}],
|
||||||
|
)
|
||||||
|
args = redfish_cli.cli.parse_args(
|
||||||
|
[
|
||||||
|
"-s",
|
||||||
|
secrets["server"],
|
||||||
|
"-f",
|
||||||
|
"json",
|
||||||
|
"storage",
|
||||||
|
"-u",
|
||||||
|
"root",
|
||||||
|
"-p",
|
||||||
|
"dummy",
|
||||||
|
"physical",
|
||||||
|
"show",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
redfish_cli.cli.physical_volume(args)
|
||||||
|
captured = capsys.readouterr()
|
||||||
|
result = json.loads(captured.out)
|
||||||
|
assert result["CapacityBytes"] == 299439751168
|
||||||
|
|
||||||
|
|
||||||
|
def test_list_phsyical_volumes(capsys, monkeypatch, secrets):
|
||||||
|
"""Test the physical_voume cli command"""
|
||||||
|
|
||||||
|
def mock_get(*args, **kwargs):
|
||||||
|
# pylint: disable=unused-argument
|
||||||
|
mock_redfish = MockRedfishResponse()
|
||||||
|
mock_redfish.json_dict = get_test_json("physical_volumes.json")
|
||||||
|
return MockResponse(status_code=200, content=mock_redfish.text)
|
||||||
|
|
||||||
|
monkeypatch.setattr(requests, "get", mock_get)
|
||||||
|
monkeypatch.setattr(
|
||||||
|
storage,
|
||||||
|
"list_storage_controllers",
|
||||||
|
lambda *args, **kwargs: {"Members": [{"@odata.id": ""}]},
|
||||||
|
)
|
||||||
|
|
||||||
|
args = redfish_cli.cli.parse_args(
|
||||||
|
[
|
||||||
|
"-s",
|
||||||
|
secrets["server"],
|
||||||
|
"-f",
|
||||||
|
"json",
|
||||||
|
"storage",
|
||||||
|
"-u",
|
||||||
|
"root",
|
||||||
|
"-p",
|
||||||
|
"dummy",
|
||||||
|
"physical",
|
||||||
|
"list",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
redfish_cli.cli.physical_volumes(args)
|
||||||
|
captured = capsys.readouterr()
|
||||||
|
result = json.loads(captured.out)
|
||||||
|
assert (
|
||||||
|
result[0]["drive"] == "Disk.Bay.0:Enclosure.Internal.0-1:RAID.Slot.6-1"
|
||||||
|
)
|
||||||
|
|
||||||
|
args = redfish_cli.cli.parse_args(
|
||||||
|
[
|
||||||
|
"-s",
|
||||||
|
secrets["server"],
|
||||||
|
"-f",
|
||||||
|
"text",
|
||||||
|
"storage",
|
||||||
|
"-u",
|
||||||
|
"root",
|
||||||
|
"-p",
|
||||||
|
"dummy",
|
||||||
|
"physical",
|
||||||
|
"list",
|
||||||
|
"-c",
|
||||||
|
"Storage.Controller.1",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
redfish_cli.cli.physical_volumes(args)
|
||||||
|
captured = capsys.readouterr()
|
||||||
|
result = captured.out
|
||||||
|
assert (
|
||||||
|
"System.Embedded.1 Disk.Bay.0:Enclosure.Internal.0-1:RAID.Slot.6-1\n"
|
||||||
|
in result
|
||||||
|
)
|
||||||
|
|
||||||
|
args = redfish_cli.cli.parse_args(
|
||||||
|
[
|
||||||
|
"-s",
|
||||||
|
secrets["server"],
|
||||||
|
"-f",
|
||||||
|
"table",
|
||||||
|
"storage",
|
||||||
|
"-u",
|
||||||
|
"root",
|
||||||
|
"-p",
|
||||||
|
"dummy",
|
||||||
|
"physical",
|
||||||
|
"list",
|
||||||
|
"-c",
|
||||||
|
"Storage.Controller.1",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
redfish_cli.cli.physical_volumes(args)
|
||||||
|
captured = capsys.readouterr()
|
||||||
|
result = captured.out
|
||||||
|
assert result.startswith("+-------------------+-------------------------")
|
||||||
|
assert "| Disk.Bay.0:Enclosure.Internal.0-1:RAID.Slot.6-1 |" in result
|
||||||
|
|
||||||
|
args = redfish_cli.cli.parse_args(
|
||||||
|
[
|
||||||
|
"-s",
|
||||||
|
secrets["server"],
|
||||||
|
"-v",
|
||||||
|
"-f",
|
||||||
|
"table",
|
||||||
|
"storage",
|
||||||
|
"-u",
|
||||||
|
"root",
|
||||||
|
"-p",
|
||||||
|
"dummy",
|
||||||
|
"physical",
|
||||||
|
"list",
|
||||||
|
"-c",
|
||||||
|
"Storage.Controller.1",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
redfish_cli.cli.physical_volumes(args)
|
||||||
|
captured = capsys.readouterr()
|
||||||
|
result = captured.out
|
||||||
|
assert result.startswith("+-------------------+-------------------------")
|
||||||
|
assert "| System.Embedded.1 | Disk.Bay.0:Enclosure.Internal.0-" in result
|
||||||
|
|
||||||
|
|
||||||
|
def test_storage_controller(capsys, monkeypatch, secrets):
|
||||||
|
"""Test the storage-controller cli command"""
|
||||||
|
|
||||||
|
def mock_get(*args, **kwargs):
|
||||||
|
# pylint: disable=unused-argument
|
||||||
|
mock_redfish = MockRedfishResponse()
|
||||||
|
mock_redfish.json_dict = get_test_json("storage_controller.json")
|
||||||
|
return MockResponse(status_code=200, content=mock_redfish.text)
|
||||||
|
|
||||||
|
monkeypatch.setattr(requests, "get", mock_get)
|
||||||
|
monkeypatch.setattr(
|
||||||
|
api.storage,
|
||||||
|
"list_storage_controllers",
|
||||||
|
lambda *args, **kwargs: {"Members": [{"@odata.id": "/"}]},
|
||||||
|
)
|
||||||
|
|
||||||
|
args = redfish_cli.cli.parse_args(
|
||||||
|
[
|
||||||
|
"-s",
|
||||||
|
secrets["server"],
|
||||||
|
"-f",
|
||||||
|
"json",
|
||||||
|
"storage",
|
||||||
|
"-u",
|
||||||
|
"root",
|
||||||
|
"-p",
|
||||||
|
"dummy",
|
||||||
|
"controllers",
|
||||||
|
"show",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
redfish_cli.cli.storage_controller(args)
|
||||||
|
captured = capsys.readouterr()
|
||||||
|
result = json.loads(captured.out)
|
||||||
|
assert result["Id"] == "RAID.Slot.6-1"
|
||||||
|
|
||||||
|
args = redfish_cli.cli.parse_args(
|
||||||
|
[
|
||||||
|
"-s",
|
||||||
|
secrets["server"],
|
||||||
|
"-f",
|
||||||
|
"text",
|
||||||
|
"storage",
|
||||||
|
"-u",
|
||||||
|
"root",
|
||||||
|
"-p",
|
||||||
|
"dummy",
|
||||||
|
"controllers",
|
||||||
|
"show",
|
||||||
|
"-c",
|
||||||
|
"RAID.Slot.6-1",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
redfish_cli.cli.storage_controller(args)
|
||||||
|
captured = capsys.readouterr()
|
||||||
|
result = captured.out
|
||||||
|
# Currently returns JSON(ish) will need to update test later
|
||||||
|
assert "'Id': 'RAID.Slot.6-1'" in result
|
||||||
|
|
||||||
|
args = redfish_cli.cli.parse_args(
|
||||||
|
[
|
||||||
|
"-s",
|
||||||
|
secrets["server"],
|
||||||
|
"-f",
|
||||||
|
"table",
|
||||||
|
"storage",
|
||||||
|
"-u",
|
||||||
|
"root",
|
||||||
|
"-p",
|
||||||
|
"dummy",
|
||||||
|
"controllers",
|
||||||
|
"show",
|
||||||
|
"-c",
|
||||||
|
"RAID.Slot.6-1",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
redfish_cli.cli.storage_controller(args)
|
||||||
|
captured = capsys.readouterr()
|
||||||
|
result = captured.out
|
||||||
|
# Currently returns JSON(ish) will need to update test later
|
||||||
|
assert "'Id': 'RAID.Slot.6-1'" in result
|
||||||
|
|
||||||
|
monkeypatch.setattr(
|
||||||
|
requests,
|
||||||
|
"get",
|
||||||
|
lambda *args, **kwargs: MockResponse(
|
||||||
|
ok=False, content='"Invalid storage controller"'
|
||||||
|
),
|
||||||
|
)
|
||||||
|
try:
|
||||||
|
redfish_cli.cli.redfish(args=args)
|
||||||
|
except SystemExit:
|
||||||
|
result = capsys.readouterr().err
|
||||||
|
assert result == '"Invalid storage controller"\n'
|
||||||
|
|
||||||
|
|
||||||
|
def test_list_storage_controllers(capsys, monkeypatch, secrets):
|
||||||
|
"""Test the storage-controllers cli command"""
|
||||||
|
|
||||||
|
def mock_get(*args, **kwargs):
|
||||||
|
# pylint: disable=unused-argument
|
||||||
|
mock_redfish = MockRedfishResponse()
|
||||||
|
mock_redfish.json_dict = get_test_json("cli_storage_controllers.json")
|
||||||
|
return MockResponse(status_code=200, content=mock_redfish.text)
|
||||||
|
|
||||||
|
monkeypatch.setattr(requests, "get", mock_get)
|
||||||
|
|
||||||
|
args = redfish_cli.cli.parse_args(
|
||||||
|
[
|
||||||
|
"-s",
|
||||||
|
secrets["server"],
|
||||||
|
"-f",
|
||||||
|
"json",
|
||||||
|
"storage",
|
||||||
|
"-u",
|
||||||
|
"root",
|
||||||
|
"-p",
|
||||||
|
"dummy",
|
||||||
|
"controllers",
|
||||||
|
"list",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
redfish_cli.cli.storage_controllers(args)
|
||||||
|
captured = capsys.readouterr()
|
||||||
|
result = json.loads(captured.out)
|
||||||
|
assert result == ["RAID.Slot.6-1"]
|
||||||
|
|
||||||
|
args = redfish_cli.cli.parse_args(
|
||||||
|
[
|
||||||
|
"-s",
|
||||||
|
secrets["server"],
|
||||||
|
"-f",
|
||||||
|
"text",
|
||||||
|
"storage",
|
||||||
|
"-u",
|
||||||
|
"root",
|
||||||
|
"-p",
|
||||||
|
"dummy",
|
||||||
|
"controllers",
|
||||||
|
"list",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
redfish_cli.cli.storage_controllers(args)
|
||||||
|
captured = capsys.readouterr()
|
||||||
|
result = captured.out
|
||||||
|
assert result == "RAID.Slot.6-1\n"
|
||||||
|
|
||||||
|
args = redfish_cli.cli.parse_args(
|
||||||
|
[
|
||||||
|
"-s",
|
||||||
|
secrets["server"],
|
||||||
|
"-f",
|
||||||
|
"table",
|
||||||
|
"storage",
|
||||||
|
"-u",
|
||||||
|
"root",
|
||||||
|
"-p",
|
||||||
|
"dummy",
|
||||||
|
"controllers",
|
||||||
|
"list",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
redfish_cli.cli.storage_controllers(args)
|
||||||
|
captured = capsys.readouterr()
|
||||||
|
result = captured.out
|
||||||
|
assert result == (
|
||||||
|
"+---------------+\n| Controller |\n+===============+\n| "
|
||||||
|
"RAID.Slot.6-1 |\n+---------------+\n"
|
||||||
|
)
|
||||||
43
tests/cli/test_system.py
Normal file
43
tests/cli/test_system.py
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
"""Test for the system cli components"""
|
||||||
|
# pylint: disable=redefined-outer-name, no-name-in-module, unused-import
|
||||||
|
|
||||||
|
import json
|
||||||
|
import requests
|
||||||
|
|
||||||
|
import redfish_cli.cli
|
||||||
|
|
||||||
|
from ..utils import get_test_json, MockResponse, MockRedfishResponse
|
||||||
|
|
||||||
|
from .test_cli import secrets
|
||||||
|
|
||||||
|
|
||||||
|
def test_system_details(capsys, monkeypatch, secrets):
|
||||||
|
"""Test system-details command"""
|
||||||
|
|
||||||
|
def mock_get(*args, **kwargs):
|
||||||
|
# pylint: disable=unused-argument
|
||||||
|
mock_redfish = MockRedfishResponse()
|
||||||
|
mock_redfish.json_dict = get_test_json("system_details.json")
|
||||||
|
return MockResponse(content=mock_redfish.text)
|
||||||
|
|
||||||
|
args = redfish_cli.cli.parse_args(
|
||||||
|
[
|
||||||
|
"-s",
|
||||||
|
secrets["server"],
|
||||||
|
"-f",
|
||||||
|
"json",
|
||||||
|
"system",
|
||||||
|
"-u",
|
||||||
|
"root",
|
||||||
|
"-p",
|
||||||
|
"dummy",
|
||||||
|
"show",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
monkeypatch.setattr(requests, "get", mock_get)
|
||||||
|
redfish_cli.cli.system_details(args)
|
||||||
|
captured = capsys.readouterr()
|
||||||
|
result = json.loads(captured.out)
|
||||||
|
assert result["@odata.id"] == "/redfish/v1/Systems/System.Embedded.1"
|
||||||
|
|
||||||
|
monkeypatch.setattr(requests, "get", mock_get)
|
||||||
16
tests/redfish_json/api_chassis.json
Normal file
16
tests/redfish_json/api_chassis.json
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
{
|
||||||
|
"@odata.context": "/redfish/v1/$metadata#ChassisCollection.ChassisCollection",
|
||||||
|
"@odata.id": "/redfish/v1/Chassis/",
|
||||||
|
"@odata.type": "#ChassisCollection.ChassisCollection",
|
||||||
|
"Description": "Collection of Chassis",
|
||||||
|
"Members": [
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Chassis/System.Embedded.1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Chassis/Enclosure.Internal.0-1:RAID.Slot.6-1"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Members@odata.count": 2,
|
||||||
|
"Name": "Chassis Collection"
|
||||||
|
}
|
||||||
111
tests/redfish_json/api_chassis_details.json
Normal file
111
tests/redfish_json/api_chassis_details.json
Normal file
|
|
@ -0,0 +1,111 @@
|
||||||
|
{
|
||||||
|
"@odata.context": "/redfish/v1/$metadata#Chassis.Chassis",
|
||||||
|
"@odata.id": "/redfish/v1/Chassis/System.Embedded.1",
|
||||||
|
"@odata.type": "#Chassis.v1_6_0.Chassis",
|
||||||
|
"Actions": {
|
||||||
|
"#Chassis.Reset": {
|
||||||
|
"ResetType@Redfish.AllowableValues": [
|
||||||
|
"On",
|
||||||
|
"ForceOff"
|
||||||
|
],
|
||||||
|
"target": "/redfish/v1/Chassis/System.Embedded.1/Actions/Chassis.Reset"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Assembly": {
|
||||||
|
"@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Assembly"
|
||||||
|
},
|
||||||
|
"AssetTag": "",
|
||||||
|
"ChassisType": "StandAlone",
|
||||||
|
"Description": "It represents the properties for physical components for any system.It represent racks, rackmount servers, blades, standalone, modular systems,enclosures, and all other containers.The non-cpu/device centric parts of the schema are all accessed either directly or indirectly through this resource.",
|
||||||
|
"Id": "System.Embedded.1",
|
||||||
|
"IndicatorLED": "Off",
|
||||||
|
"Links": {
|
||||||
|
"ComputerSystems": [
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"ComputerSystems@odata.count": 1,
|
||||||
|
"Contains": [
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Chassis/Enclosure.Internal.0-1:RAID.Slot.6-1"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Contains@odata.count": 1,
|
||||||
|
"CooledBy": [],
|
||||||
|
"CooledBy@odata.count": 0,
|
||||||
|
"Drives": [],
|
||||||
|
"Drives@odata.count": 0,
|
||||||
|
"ManagedBy": [
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"ManagedBy@odata.count": 1,
|
||||||
|
"ManagersInChassis": [
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"ManagersInChassis@odata.count": 1,
|
||||||
|
"PCIeDevices": [
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/6-0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/1-0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-29"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-31"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-28"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-26"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-3"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"PCIeDevices@odata.count": 9,
|
||||||
|
"PoweredBy": [],
|
||||||
|
"PoweredBy@odata.count": 0,
|
||||||
|
"Storage": [
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/RAID.Slot.6-1"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Storage@odata.count": 1
|
||||||
|
},
|
||||||
|
"Manufacturer": "Dell Inc.",
|
||||||
|
"Model": "PowerEdge T320",
|
||||||
|
"Name": "Computer System Chassis",
|
||||||
|
"NetworkAdapters": {
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/NetworkAdapters"
|
||||||
|
},
|
||||||
|
"PartNumber": "0MK701A02",
|
||||||
|
"Power": {
|
||||||
|
"@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Power"
|
||||||
|
},
|
||||||
|
"PowerState": "Off",
|
||||||
|
"SKU": "JYYZY42",
|
||||||
|
"SerialNumber": "CN747515150714",
|
||||||
|
"Status": {
|
||||||
|
"Health": "OK",
|
||||||
|
"HealthRollup": "OK",
|
||||||
|
"State": "Enabled"
|
||||||
|
},
|
||||||
|
"Thermal": {
|
||||||
|
"@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Thermal"
|
||||||
|
}
|
||||||
|
}
|
||||||
18
tests/redfish_json/api_job_details.json
Normal file
18
tests/redfish_json/api_job_details.json
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
"@odata.context": "/redfish/v1/$metadata#DellJob.DellJob",
|
||||||
|
"@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1/Jobs/JID_924369311959",
|
||||||
|
"@odata.type": "#DellJob.v1_0_1.DellJob",
|
||||||
|
"CompletionTime": "2023-08-20T05:59:24",
|
||||||
|
"Description": "Job Instance",
|
||||||
|
"EndTime": "TIME_NA",
|
||||||
|
"Id": "JID_924369311959",
|
||||||
|
"JobState": "Completed",
|
||||||
|
"JobType": "RAIDConfiguration",
|
||||||
|
"Message": "Job completed successfully.",
|
||||||
|
"MessageArgs": [],
|
||||||
|
"MessageId": "PR19",
|
||||||
|
"Name": "Config:RAID:RAID.Slot.6-1",
|
||||||
|
"PercentComplete": 100,
|
||||||
|
"StartTime": "TIME_NOW",
|
||||||
|
"TargetSettingsURI": null
|
||||||
|
}
|
||||||
16
tests/redfish_json/api_list_logical_volumes.json
Normal file
16
tests/redfish_json/api_list_logical_volumes.json
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
{
|
||||||
|
"@odata.context": "/redfish/v1/$metadata#VolumeCollection.VolumeCollection",
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/RAID.Slot.6-1/Volumes",
|
||||||
|
"@odata.type": "#VolumeCollection.VolumeCollection",
|
||||||
|
"Description": "Collection Of Volume",
|
||||||
|
"Members": [
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/Volumes/Disk.Virtual.0:RAID.Slot.6-1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/Volumes/Disk.Virtual.1:RAID.Slot.6-1"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Members@odata.count": 2,
|
||||||
|
"Name": "Volume Collection"
|
||||||
|
}
|
||||||
13
tests/redfish_json/api_list_storage_controllers.json
Normal file
13
tests/redfish_json/api_list_storage_controllers.json
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
{
|
||||||
|
"@odata.context": "/redfish/v1/$metadata#StorageCollection.StorageCollection",
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage",
|
||||||
|
"@odata.type": "#StorageCollection.StorageCollection",
|
||||||
|
"Description": "Collection Of Storage entities",
|
||||||
|
"Members": [
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/RAID.Slot.6-1"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Members@odata.count": 1,
|
||||||
|
"Name": "Storage Collection"
|
||||||
|
}
|
||||||
54
tests/redfish_json/api_logical_volume_details.json
Normal file
54
tests/redfish_json/api_logical_volume_details.json
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
{
|
||||||
|
"@Redfish.Settings": {
|
||||||
|
"@odata.context": "/redfish/v1/$metadata#Settings.Settings",
|
||||||
|
"@odata.type": "#Settings.v1_1_0.Settings",
|
||||||
|
"SettingsObject": {
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/Volumes/Disk.Virtual.0:RAID.Slot.6-1/Settings"
|
||||||
|
},
|
||||||
|
"SupportedApplyTimes": [
|
||||||
|
"Immediate",
|
||||||
|
"OnReset",
|
||||||
|
"AtMaintenanceWindowStart",
|
||||||
|
"InMaintenanceWindowOnReset"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"@odata.context": "/redfish/v1/$metadata#Volume.Volume",
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/Volumes/Disk.Virtual.0:RAID.Slot.6-1",
|
||||||
|
"@odata.type": "#Volume.v1_0_3.Volume",
|
||||||
|
"Actions": {
|
||||||
|
"#Volume.CheckConsistency": {
|
||||||
|
"target": "/redfish/v1/Systems/System.Embedded.1/Storage/Volumes/Disk.Virtual.0:RAID.Slot.6-1/Actions/Volume.CheckConsistency"
|
||||||
|
},
|
||||||
|
"#Volume.Initialize": {
|
||||||
|
"InitializeType@Redfish.AllowableValues": ["Fast", "Slow"],
|
||||||
|
"target": "/redfish/v1/Systems/System.Embedded.1/Storage/Volumes/Disk.Virtual.0:RAID.Slot.6-1/Actions/Volume.Initialize"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"BlockSizeBytes": 512,
|
||||||
|
"CapacityBytes": 299439751168,
|
||||||
|
"Description": "os",
|
||||||
|
"Encrypted": false,
|
||||||
|
"EncryptionTypes": ["NativeDriveEncryption"],
|
||||||
|
"Id": "Disk.Virtual.0:RAID.Slot.6-1",
|
||||||
|
"Identifiers": [],
|
||||||
|
"Links": {
|
||||||
|
"Drives": [
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/Drives/Disk.Bay.0:Enclosure.Internal.0-1:RAID.Slot.6-1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/Drives/Disk.Bay.1:Enclosure.Internal.0-1:RAID.Slot.6-1"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Drives@odata.count": 2
|
||||||
|
},
|
||||||
|
"Name": "os",
|
||||||
|
"Operations": [],
|
||||||
|
"OptimumIOSizeBytes": 65536,
|
||||||
|
"Status": {
|
||||||
|
"Health": "OK",
|
||||||
|
"HealthRollup": "OK",
|
||||||
|
"State": "Enabled"
|
||||||
|
},
|
||||||
|
"VolumeType": "Mirrored"
|
||||||
|
}
|
||||||
217
tests/redfish_json/api_manager.json
Normal file
217
tests/redfish_json/api_manager.json
Normal file
|
|
@ -0,0 +1,217 @@
|
||||||
|
{
|
||||||
|
"@odata.context": "/redfish/v1/$metadata#Manager.Manager",
|
||||||
|
"@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1",
|
||||||
|
"@odata.type": "#Manager.v1_3_3.Manager",
|
||||||
|
"Actions": {
|
||||||
|
"#Manager.Reset": {
|
||||||
|
"ResetType@Redfish.AllowableValues": [
|
||||||
|
"GracefulRestart"
|
||||||
|
],
|
||||||
|
"target": "/redfish/v1/Managers/iDRAC.Embedded.1/Actions/Manager.Reset"
|
||||||
|
},
|
||||||
|
"Oem": {
|
||||||
|
"OemManager.v1_1_0#OemManager.ExportSystemConfiguration": {
|
||||||
|
"ExportFormat@Redfish.AllowableValues": [
|
||||||
|
"XML",
|
||||||
|
"JSON"
|
||||||
|
],
|
||||||
|
"ExportUse@Redfish.AllowableValues": [
|
||||||
|
"Default",
|
||||||
|
"Clone",
|
||||||
|
"Replace"
|
||||||
|
],
|
||||||
|
"IncludeInExport@Redfish.AllowableValues": [
|
||||||
|
"Default",
|
||||||
|
"IncludeReadOnly",
|
||||||
|
"IncludePasswordHashValues",
|
||||||
|
"IncludeReadOnly,IncludePasswordHashValues"
|
||||||
|
],
|
||||||
|
"ShareParameters": {
|
||||||
|
"IgnoreCertificateWarning@Redfish.AllowableValues": [
|
||||||
|
"Disabled",
|
||||||
|
"Enabled"
|
||||||
|
],
|
||||||
|
"ProxySupport@Redfish.AllowableValues": [
|
||||||
|
"Disabled",
|
||||||
|
"EnabledProxyDefault",
|
||||||
|
"Enabled"
|
||||||
|
],
|
||||||
|
"ProxyType@Redfish.AllowableValues": [
|
||||||
|
"HTTP",
|
||||||
|
"SOCKS4"
|
||||||
|
],
|
||||||
|
"ShareType@Redfish.AllowableValues": [
|
||||||
|
"LOCAL",
|
||||||
|
"NFS",
|
||||||
|
"CIFS",
|
||||||
|
"HTTP",
|
||||||
|
"HTTPS"
|
||||||
|
],
|
||||||
|
"Target@Redfish.AllowableValues": [
|
||||||
|
"ALL",
|
||||||
|
"IDRAC",
|
||||||
|
"BIOS",
|
||||||
|
"NIC",
|
||||||
|
"RAID"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"target": "/redfish/v1/Managers/iDRAC.Embedded.1/Actions/Oem/EID_674_Manager.ExportSystemConfiguration"
|
||||||
|
},
|
||||||
|
"OemManager.v1_1_0#OemManager.ImportSystemConfiguration": {
|
||||||
|
"HostPowerState@Redfish.AllowableValues": [
|
||||||
|
"On",
|
||||||
|
"Off"
|
||||||
|
],
|
||||||
|
"ImportSystemConfiguration@Redfish.AllowableValues": [
|
||||||
|
"TimeToWait",
|
||||||
|
"ImportBuffer"
|
||||||
|
],
|
||||||
|
"ShareParameters": {
|
||||||
|
"IgnoreCertificateWarning@Redfish.AllowableValues": [
|
||||||
|
"Disabled",
|
||||||
|
"Enabled"
|
||||||
|
],
|
||||||
|
"ProxySupport@Redfish.AllowableValues": [
|
||||||
|
"Disabled",
|
||||||
|
"EnabledProxyDefault",
|
||||||
|
"Enabled"
|
||||||
|
],
|
||||||
|
"ProxyType@Redfish.AllowableValues": [
|
||||||
|
"HTTP",
|
||||||
|
"SOCKS4"
|
||||||
|
],
|
||||||
|
"ShareType@Redfish.AllowableValues": [
|
||||||
|
"LOCAL",
|
||||||
|
"NFS",
|
||||||
|
"CIFS",
|
||||||
|
"HTTP",
|
||||||
|
"HTTPS"
|
||||||
|
],
|
||||||
|
"Target@Redfish.AllowableValues": [
|
||||||
|
"ALL",
|
||||||
|
"IDRAC",
|
||||||
|
"BIOS",
|
||||||
|
"NIC",
|
||||||
|
"RAID"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"ShutdownType@Redfish.AllowableValues": [
|
||||||
|
"Graceful",
|
||||||
|
"Forced",
|
||||||
|
"NoReboot"
|
||||||
|
],
|
||||||
|
"target": "/redfish/v1/Managers/iDRAC.Embedded.1/Actions/Oem/EID_674_Manager.ImportSystemConfiguration"
|
||||||
|
},
|
||||||
|
"OemManager.v1_1_0#OemManager.ImportSystemConfigurationPreview": {
|
||||||
|
"ImportSystemConfigurationPreview@Redfish.AllowableValues": [
|
||||||
|
"ImportBuffer"
|
||||||
|
],
|
||||||
|
"ShareParameters": {
|
||||||
|
"IgnoreCertificateWarning@Redfish.AllowableValues": [
|
||||||
|
"Disabled",
|
||||||
|
"Enabled"
|
||||||
|
],
|
||||||
|
"ProxySupport@Redfish.AllowableValues": [
|
||||||
|
"Disabled",
|
||||||
|
"EnabledProxyDefault",
|
||||||
|
"Enabled"
|
||||||
|
],
|
||||||
|
"ProxyType@Redfish.AllowableValues": [
|
||||||
|
"HTTP",
|
||||||
|
"SOCKS4"
|
||||||
|
],
|
||||||
|
"ShareType@Redfish.AllowableValues": [
|
||||||
|
"LOCAL",
|
||||||
|
"NFS",
|
||||||
|
"CIFS",
|
||||||
|
"HTTP",
|
||||||
|
"HTTPS"
|
||||||
|
],
|
||||||
|
"Target@Redfish.AllowableValues": [
|
||||||
|
"ALL"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"target": "/redfish/v1/Managers/iDRAC.Embedded.1/Actions/Oem/EID_674_Manager.ImportSystemConfigurationPreview"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"CommandShell": {
|
||||||
|
"ConnectTypesSupported": [
|
||||||
|
"SSH",
|
||||||
|
"Telnet",
|
||||||
|
"IPMI"
|
||||||
|
],
|
||||||
|
"ConnectTypesSupported@odata.count": 3,
|
||||||
|
"MaxConcurrentSessions": 5,
|
||||||
|
"ServiceEnabled": true
|
||||||
|
},
|
||||||
|
"DateTime": "2023-08-24T10:23:53-05:00",
|
||||||
|
"DateTimeLocalOffset": "-05:00",
|
||||||
|
"Description": "BMC",
|
||||||
|
"EthernetInterfaces": {
|
||||||
|
"@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1/EthernetInterfaces"
|
||||||
|
},
|
||||||
|
"FirmwareVersion": "2.65.65.65",
|
||||||
|
"GraphicalConsole": {
|
||||||
|
"ConnectTypesSupported": [
|
||||||
|
"KVMIP"
|
||||||
|
],
|
||||||
|
"ConnectTypesSupported@odata.count": 1,
|
||||||
|
"MaxConcurrentSessions": 6,
|
||||||
|
"ServiceEnabled": true
|
||||||
|
},
|
||||||
|
"HostInterfaces": {
|
||||||
|
"@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1/HostInterfaces"
|
||||||
|
},
|
||||||
|
"Id": "iDRAC.Embedded.1",
|
||||||
|
"Links": {
|
||||||
|
"ManagerForChassis": [
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Chassis/System.Embedded.1"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"ManagerForChassis@odata.count": 1,
|
||||||
|
"ManagerForServers": [
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"ManagerForServers@odata.count": 1,
|
||||||
|
"Oem": {
|
||||||
|
"Dell": {
|
||||||
|
"@odata.type": "#DellManager.v1_0_0.DellManager",
|
||||||
|
"Jobs": {
|
||||||
|
"@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1/Jobs"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"LogServices": {
|
||||||
|
"@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1/LogServices"
|
||||||
|
},
|
||||||
|
"ManagerType": "BMC",
|
||||||
|
"Model": "12G Monolithic",
|
||||||
|
"Name": "Manager",
|
||||||
|
"NetworkProtocol": {
|
||||||
|
"@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1/NetworkProtocol"
|
||||||
|
},
|
||||||
|
"Redundancy": [],
|
||||||
|
"Redundancy@odata.count": 0,
|
||||||
|
"SerialConsole": {
|
||||||
|
"ConnectTypesSupported": [],
|
||||||
|
"ConnectTypesSupported@odata.count": 0,
|
||||||
|
"MaxConcurrentSessions": 0,
|
||||||
|
"ServiceEnabled": false
|
||||||
|
},
|
||||||
|
"SerialInterfaces": {
|
||||||
|
"@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1/SerialInterfaces"
|
||||||
|
},
|
||||||
|
"Status": {
|
||||||
|
"Health": "OK",
|
||||||
|
"State": "Enabled"
|
||||||
|
},
|
||||||
|
"UUID": "3234594f-c0b7-5180-4a10-00334c4c4544",
|
||||||
|
"VirtualMedia": {
|
||||||
|
"@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1/VirtualMedia"
|
||||||
|
}
|
||||||
|
}
|
||||||
1
tests/redfish_json/api_power_state.json
Normal file
1
tests/redfish_json/api_power_state.json
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{"PowerState":"Off"}
|
||||||
43
tests/redfish_json/cli_base_command.json
Normal file
43
tests/redfish_json/cli_base_command.json
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
{
|
||||||
|
"@odata.context": "/redfish/v1/$metadata#ServiceRoot.ServiceRoot",
|
||||||
|
"@odata.id": "/redfish/v1",
|
||||||
|
"@odata.type": "#ServiceRoot.v1_3_0.ServiceRoot",
|
||||||
|
"AccountService": {
|
||||||
|
"@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1/AccountService"
|
||||||
|
},
|
||||||
|
"Chassis": {"@odata.id": "/redfish/v1/Chassis"},
|
||||||
|
"Description": "Root Service",
|
||||||
|
"EventService": {"@odata.id": "/redfish/v1/EventService"},
|
||||||
|
"Fabrics": {"@odata.id": "/redfish/v1/Fabrics"},
|
||||||
|
"Id": "RootService",
|
||||||
|
"JsonSchemas": {"@odata.id": "/redfish/v1/JSONSchemas"},
|
||||||
|
"Links": {"Sessions": {"@odata.id": "/redfish/v1/Sessions"}},
|
||||||
|
"Managers": {"@odata.id": "/redfish/v1/Managers"},
|
||||||
|
"Name": "Root Service",
|
||||||
|
"Oem": {
|
||||||
|
"Dell": {
|
||||||
|
"@odata.type": "#DellServiceRoot.v1_0_0.ServiceRootSummary",
|
||||||
|
"IsBranded": 0,
|
||||||
|
"ManagerMACAddress": "54:9F:35:1A:0D:D8",
|
||||||
|
"ServiceTag": "JYYZY42"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Product": "Integrated Dell Remote Access Controller",
|
||||||
|
"ProtocolFeaturesSupported": {
|
||||||
|
"ExpandQuery": {
|
||||||
|
"ExpandAll": true,
|
||||||
|
"Levels": true,
|
||||||
|
"Links": true,
|
||||||
|
"MaxLevels": 1,
|
||||||
|
"NoLinks": true
|
||||||
|
},
|
||||||
|
"FilterQuery": true,
|
||||||
|
"SelectQuery": true
|
||||||
|
},
|
||||||
|
"RedfishVersion": "1.4.0",
|
||||||
|
"Registries": {"@odata.id": "/redfish/v1/Registries"},
|
||||||
|
"SessionService": {"@odata.id": "/redfish/v1/SessionService"},
|
||||||
|
"Systems": {"@odata.id": "/redfish/v1/Systems"},
|
||||||
|
"Tasks": {"@odata.id": "/redfish/v1/TaskService"},
|
||||||
|
"UpdateService": {"@odata.id": "/redfish/v1/UpdateService"}
|
||||||
|
}
|
||||||
106
tests/redfish_json/cli_chassis.json
Normal file
106
tests/redfish_json/cli_chassis.json
Normal file
|
|
@ -0,0 +1,106 @@
|
||||||
|
{
|
||||||
|
"@odata.context": "/redfish/v1/$metadata#Chassis.Chassis",
|
||||||
|
"@odata.id": "/redfish/v1/Chassis/System.Embedded.1",
|
||||||
|
"@odata.type": "#Chassis.v1_6_0.Chassis",
|
||||||
|
"Actions": {
|
||||||
|
"#Chassis.Reset": {
|
||||||
|
"ResetType@Redfish.AllowableValues": ["On", "ForceOff"],
|
||||||
|
"target": "/redfish/v1/Chassis/System.Embedded.1/Actions/Chassis.Reset"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Assembly": {
|
||||||
|
"@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Assembly"
|
||||||
|
},
|
||||||
|
"AssetTag": "",
|
||||||
|
"ChassisType": "StandAlone",
|
||||||
|
"Description": "It represents the properties for physical components for any system.It represent racks, rackmount servers, blades, standalone, modular systems,enclosures, and all other containers.The non-cpu/device centric parts of the schema are all accessed either directly or indirectly through this resource.",
|
||||||
|
"Id": "System.Embedded.1",
|
||||||
|
"IndicatorLED": "Off",
|
||||||
|
"Links": {
|
||||||
|
"ComputerSystems": [
|
||||||
|
{"@odata.id": "/redfish/v1/Systems/System.Embedded.1"}
|
||||||
|
],
|
||||||
|
"ComputerSystems@odata.count": 1,
|
||||||
|
"Contains": [
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Chassis/Enclosure.Internal.0-1:RAID.Slot.6-1"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Contains@odata.count": 1,
|
||||||
|
"CooledBy": [
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.Sys%201"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"CooledBy@odata.count": 1,
|
||||||
|
"Drives": [],
|
||||||
|
"Drives@odata.count": 0,
|
||||||
|
"ManagedBy": [
|
||||||
|
{"@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1"}
|
||||||
|
],
|
||||||
|
"ManagedBy@odata.count": 1,
|
||||||
|
"ManagersInChassis": [
|
||||||
|
{"@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1"}
|
||||||
|
],
|
||||||
|
"ManagersInChassis@odata.count": 1,
|
||||||
|
"PCIeDevices": [
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/6-0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/1-0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-29"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-31"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-28"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-26"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-3"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"PCIeDevices@odata.count": 9,
|
||||||
|
"PoweredBy": [],
|
||||||
|
"PoweredBy@odata.count": 0,
|
||||||
|
"Storage": [
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/RAID.Slot.6-1"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Storage@odata.count": 1
|
||||||
|
},
|
||||||
|
"Manufacturer": "Dell Inc.",
|
||||||
|
"Model": "PowerEdge T320",
|
||||||
|
"Name": "Computer System Chassis",
|
||||||
|
"NetworkAdapters": {
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/NetworkAdapters"
|
||||||
|
},
|
||||||
|
"PartNumber": "0MK701A02",
|
||||||
|
"Power": {
|
||||||
|
"@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Power"
|
||||||
|
},
|
||||||
|
"PowerState": "On",
|
||||||
|
"SKU": "JYYZY42",
|
||||||
|
"SerialNumber": "CN747515150714",
|
||||||
|
"Status": {
|
||||||
|
"Health": "Warning",
|
||||||
|
"HealthRollup": "Warning",
|
||||||
|
"State": "Enabled"
|
||||||
|
},
|
||||||
|
"Thermal": {
|
||||||
|
"@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Thermal"
|
||||||
|
}
|
||||||
|
}
|
||||||
104
tests/redfish_json/cli_chassis_details.json
Normal file
104
tests/redfish_json/cli_chassis_details.json
Normal file
|
|
@ -0,0 +1,104 @@
|
||||||
|
{
|
||||||
|
"@odata.context": "/redfish/v1/$metadata#Chassis.Chassis",
|
||||||
|
"@odata.id": "/redfish/v1/Chassis/System.Embedded.1",
|
||||||
|
"@odata.type": "#Chassis.v1_6_0.Chassis",
|
||||||
|
"Actions": {
|
||||||
|
"#Chassis.Reset": {
|
||||||
|
"ResetType@Redfish.AllowableValues": ["On", "ForceOff"],
|
||||||
|
"target": "/redfish/v1/Chassis/System.Embedded.1/Actions/Chassis.Reset"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Assembly": {
|
||||||
|
"@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Assembly"
|
||||||
|
},
|
||||||
|
"AssetTag": "",
|
||||||
|
"ChassisType": "StandAlone",
|
||||||
|
"Description": "It represents the properties for physical components for any system.It represent racks, rackmount servers, blades, standalone, modular systems,enclosures, and all other containers.The non-cpu/device centric parts of the schema are all accessed either directly or indirectly through this resource.",
|
||||||
|
"Id": "System.Embedded.1",
|
||||||
|
"IndicatorLED": "Off",
|
||||||
|
"Links": {
|
||||||
|
"ComputerSystems": [
|
||||||
|
{"@odata.id": "/redfish/v1/Systems/System.Embedded.1"}
|
||||||
|
],
|
||||||
|
"ComputerSystems@odata.count": 1,
|
||||||
|
"Contains": [
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Chassis/Enclosure.Internal.0-1:RAID.Slot.6-1"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Contains@odata.count": 1,
|
||||||
|
"CooledBy": [
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.Sys%201"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"CooledBy@odata.count": 1,
|
||||||
|
"Drives": [],
|
||||||
|
"Drives@odata.count": 0,
|
||||||
|
"ManagedBy": [
|
||||||
|
{"@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1"}
|
||||||
|
],
|
||||||
|
"ManagedBy@odata.count": 1,
|
||||||
|
"ManagersInChassis": [
|
||||||
|
{"@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1"}
|
||||||
|
],
|
||||||
|
"ManagersInChassis@odata.count": 1,
|
||||||
|
"PCIeDevices": [
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/6-0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/1-0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-29"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-31"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-28"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-26"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-3"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"PCIeDevices@odata.count": 9,
|
||||||
|
"PoweredBy": [],
|
||||||
|
"PoweredBy@odata.count": 0,
|
||||||
|
"Storage": [
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/RAID.Slot.6-1"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Storage@odata.count": 1
|
||||||
|
},
|
||||||
|
"Manufacturer": "Dell Inc.",
|
||||||
|
"Model": "PowerEdge T320",
|
||||||
|
"Name": "Computer System Chassis",
|
||||||
|
"NetworkAdapters": {
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/NetworkAdapters"
|
||||||
|
},
|
||||||
|
"PartNumber": "0MK701A02",
|
||||||
|
"Power": {"@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Power"},
|
||||||
|
"PowerState": "On",
|
||||||
|
"SKU": "JYYZY42",
|
||||||
|
"SerialNumber": "CN747515150714",
|
||||||
|
"Status": {
|
||||||
|
"Health": "Warning",
|
||||||
|
"HealthRollup": "Warning",
|
||||||
|
"State": "Enabled"
|
||||||
|
},
|
||||||
|
"Thermal": {
|
||||||
|
"@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Thermal"
|
||||||
|
}
|
||||||
|
}
|
||||||
43
tests/redfish_json/cli_get.json
Normal file
43
tests/redfish_json/cli_get.json
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
{
|
||||||
|
"@odata.context": "/redfish/v1/$metadata#ServiceRoot.ServiceRoot",
|
||||||
|
"@odata.id": "/redfish/v1",
|
||||||
|
"@odata.type": "#ServiceRoot.v1_3_0.ServiceRoot",
|
||||||
|
"AccountService": {
|
||||||
|
"@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1/AccountService"
|
||||||
|
},
|
||||||
|
"Chassis": {"@odata.id": "/redfish/v1/Chassis"},
|
||||||
|
"Description": "Root Service",
|
||||||
|
"EventService": {"@odata.id": "/redfish/v1/EventService"},
|
||||||
|
"Fabrics": {"@odata.id": "/redfish/v1/Fabrics"},
|
||||||
|
"Id": "RootService",
|
||||||
|
"JsonSchemas": {"@odata.id": "/redfish/v1/JSONSchemas"},
|
||||||
|
"Links": {"Sessions": {"@odata.id": "/redfish/v1/Sessions"}},
|
||||||
|
"Managers": {"@odata.id": "/redfish/v1/Managers"},
|
||||||
|
"Name": "Root Service",
|
||||||
|
"Oem": {
|
||||||
|
"Dell": {
|
||||||
|
"@odata.type": "#DellServiceRoot.v1_0_0.ServiceRootSummary",
|
||||||
|
"IsBranded": 0,
|
||||||
|
"ManagerMACAddress": "54:9F:35:1A:0D:D8",
|
||||||
|
"ServiceTag": "JYYZY42"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Product": "Integrated Dell Remote Access Controller",
|
||||||
|
"ProtocolFeaturesSupported": {
|
||||||
|
"ExpandQuery": {
|
||||||
|
"ExpandAll": true,
|
||||||
|
"Levels": true,
|
||||||
|
"Links": true,
|
||||||
|
"MaxLevels": 1,
|
||||||
|
"NoLinks": true
|
||||||
|
},
|
||||||
|
"FilterQuery": true,
|
||||||
|
"SelectQuery": true
|
||||||
|
},
|
||||||
|
"RedfishVersion": "1.4.0",
|
||||||
|
"Registries": {"@odata.id": "/redfish/v1/Registries"},
|
||||||
|
"SessionService": {"@odata.id": "/redfish/v1/SessionService"},
|
||||||
|
"Systems": {"@odata.id": "/redfish/v1/Systems"},
|
||||||
|
"Tasks": {"@odata.id": "/redfish/v1/TaskService"},
|
||||||
|
"UpdateService": {"@odata.id": "/redfish/v1/UpdateService"}
|
||||||
|
}
|
||||||
50
tests/redfish_json/cli_logical_volume.json
Normal file
50
tests/redfish_json/cli_logical_volume.json
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
{
|
||||||
|
"@Redfish.Settings": {
|
||||||
|
"@odata.context": "/redfish/v1/$metadata#Settings.Settings",
|
||||||
|
"@odata.type": "#Settings.v1_1_0.Settings",
|
||||||
|
"SettingsObject": {
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/Volumes/Disk.Virtual.0:RAID.Slot.6-1/Settings"
|
||||||
|
},
|
||||||
|
"SupportedApplyTimes": [
|
||||||
|
"Immediate",
|
||||||
|
"OnReset",
|
||||||
|
"AtMaintenanceWindowStart",
|
||||||
|
"InMaintenanceWindowOnReset"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"@odata.context": "/redfish/v1/$metadata#Volume.Volume",
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/Volumes/Disk.Virtual.0:RAID.Slot.6-1",
|
||||||
|
"@odata.type": "#Volume.v1_0_3.Volume",
|
||||||
|
"Actions": {
|
||||||
|
"#Volume.CheckConsistency": {
|
||||||
|
"target": "/redfish/v1/Systems/System.Embedded.1/Storage/Volumes/Disk.Virtual.0:RAID.Slot.6-1/Actions/Volume.CheckConsistency"
|
||||||
|
},
|
||||||
|
"#Volume.Initialize": {
|
||||||
|
"InitializeType@Redfish.AllowableValues": ["Fast", "Slow"],
|
||||||
|
"target": "/redfish/v1/Systems/System.Embedded.1/Storage/Volumes/Disk.Virtual.0:RAID.Slot.6-1/Actions/Volume.Initialize"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"BlockSizeBytes": 512,
|
||||||
|
"CapacityBytes": 299439751168,
|
||||||
|
"Description": "os",
|
||||||
|
"Encrypted": false,
|
||||||
|
"EncryptionTypes": ["NativeDriveEncryption"],
|
||||||
|
"Id": "Disk.Virtual.0:RAID.Slot.6-1",
|
||||||
|
"Identifiers": [],
|
||||||
|
"Links": {
|
||||||
|
"Drives": [
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/Drives/Disk.Bay.0:Enclosure.Internal.0-1:RAID.Slot.6-1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/Drives/Disk.Bay.1:Enclosure.Internal.0-1:RAID.Slot.6-1"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Drives@odata.count": 2
|
||||||
|
},
|
||||||
|
"Name": "os",
|
||||||
|
"Operations": [],
|
||||||
|
"OptimumIOSizeBytes": 65536,
|
||||||
|
"Status": {"Health": "OK", "HealthRollup": "OK", "State": "Enabled"},
|
||||||
|
"VolumeType": "Mirrored"
|
||||||
|
}
|
||||||
16
tests/redfish_json/cli_logical_volumes.json
Normal file
16
tests/redfish_json/cli_logical_volumes.json
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
{
|
||||||
|
"@odata.context": "/redfish/v1/$metadata#VolumeCollection.VolumeCollection",
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/RAID.Slot.6-1/Volumes",
|
||||||
|
"@odata.type": "#VolumeCollection.VolumeCollection",
|
||||||
|
"Description": "Collection Of Volume",
|
||||||
|
"Members": [
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/Volumes/Disk.Virtual.0:RAID.Slot.6-1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/Volumes/Disk.Virtual.1:RAID.Slot.6-1"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Members@odata.count": 2,
|
||||||
|
"Name": "Volume Collection"
|
||||||
|
}
|
||||||
43
tests/redfish_json/cli_service_tag.json
Normal file
43
tests/redfish_json/cli_service_tag.json
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
{
|
||||||
|
"@odata.context": "/redfish/v1/$metadata#ServiceRoot.ServiceRoot",
|
||||||
|
"@odata.id": "/redfish/v1",
|
||||||
|
"@odata.type": "#ServiceRoot.v1_3_0.ServiceRoot",
|
||||||
|
"AccountService": {
|
||||||
|
"@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1/AccountService"
|
||||||
|
},
|
||||||
|
"Chassis": {"@odata.id": "/redfish/v1/Chassis"},
|
||||||
|
"Description": "Root Service",
|
||||||
|
"EventService": {"@odata.id": "/redfish/v1/EventService"},
|
||||||
|
"Fabrics": {"@odata.id": "/redfish/v1/Fabrics"},
|
||||||
|
"Id": "RootService",
|
||||||
|
"JsonSchemas": {"@odata.id": "/redfish/v1/JSONSchemas"},
|
||||||
|
"Links": {"Sessions": {"@odata.id": "/redfish/v1/Sessions"}},
|
||||||
|
"Managers": {"@odata.id": "/redfish/v1/Managers"},
|
||||||
|
"Name": "Root Service",
|
||||||
|
"Oem": {
|
||||||
|
"Dell": {
|
||||||
|
"@odata.type": "#DellServiceRoot.v1_0_0.ServiceRootSummary",
|
||||||
|
"IsBranded": 0,
|
||||||
|
"ManagerMACAddress": "54:9F:35:1A:0D:D8",
|
||||||
|
"ServiceTag": "JYYZY42"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Product": "Integrated Dell Remote Access Controller",
|
||||||
|
"ProtocolFeaturesSupported": {
|
||||||
|
"ExpandQuery": {
|
||||||
|
"ExpandAll": true,
|
||||||
|
"Levels": true,
|
||||||
|
"Links": true,
|
||||||
|
"MaxLevels": 1,
|
||||||
|
"NoLinks": true
|
||||||
|
},
|
||||||
|
"FilterQuery": true,
|
||||||
|
"SelectQuery": true
|
||||||
|
},
|
||||||
|
"RedfishVersion": "1.4.0",
|
||||||
|
"Registries": {"@odata.id": "/redfish/v1/Registries"},
|
||||||
|
"SessionService": {"@odata.id": "/redfish/v1/SessionService"},
|
||||||
|
"Systems": {"@odata.id": "/redfish/v1/Systems"},
|
||||||
|
"Tasks": {"@odata.id": "/redfish/v1/TaskService"},
|
||||||
|
"UpdateService": {"@odata.id": "/redfish/v1/UpdateService"}
|
||||||
|
}
|
||||||
13
tests/redfish_json/cli_storage_controllers.json
Normal file
13
tests/redfish_json/cli_storage_controllers.json
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
{
|
||||||
|
"@odata.context": "/redfish/v1/$metadata#StorageCollection.StorageCollection",
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage",
|
||||||
|
"@odata.type": "#StorageCollection.StorageCollection",
|
||||||
|
"Description": "Collection Of Storage entities",
|
||||||
|
"Members": [
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/RAID.Slot.6-1"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Members@odata.count": 1,
|
||||||
|
"Name": "Storage Collection"
|
||||||
|
}
|
||||||
43
tests/redfish_json/cli_version.json
Normal file
43
tests/redfish_json/cli_version.json
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
{
|
||||||
|
"@odata.context": "/redfish/v1/$metadata#ServiceRoot.ServiceRoot",
|
||||||
|
"@odata.id": "/redfish/v1",
|
||||||
|
"@odata.type": "#ServiceRoot.v1_3_0.ServiceRoot",
|
||||||
|
"AccountService": {
|
||||||
|
"@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1/AccountService"
|
||||||
|
},
|
||||||
|
"Chassis": {"@odata.id": "/redfish/v1/Chassis"},
|
||||||
|
"Description": "Root Service",
|
||||||
|
"EventService": {"@odata.id": "/redfish/v1/EventService"},
|
||||||
|
"Fabrics": {"@odata.id": "/redfish/v1/Fabrics"},
|
||||||
|
"Id": "RootService",
|
||||||
|
"JsonSchemas": {"@odata.id": "/redfish/v1/JSONSchemas"},
|
||||||
|
"Links": {"Sessions": {"@odata.id": "/redfish/v1/Sessions"}},
|
||||||
|
"Managers": {"@odata.id": "/redfish/v1/Managers"},
|
||||||
|
"Name": "Root Service",
|
||||||
|
"Oem": {
|
||||||
|
"Dell": {
|
||||||
|
"@odata.type": "#DellServiceRoot.v1_0_0.ServiceRootSummary",
|
||||||
|
"IsBranded": 0,
|
||||||
|
"ManagerMACAddress": "54:9F:35:1A:0D:D8",
|
||||||
|
"ServiceTag": "JYYZY42"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Product": "Integrated Dell Remote Access Controller",
|
||||||
|
"ProtocolFeaturesSupported": {
|
||||||
|
"ExpandQuery": {
|
||||||
|
"ExpandAll": true,
|
||||||
|
"Levels": true,
|
||||||
|
"Links": true,
|
||||||
|
"MaxLevels": 1,
|
||||||
|
"NoLinks": true
|
||||||
|
},
|
||||||
|
"FilterQuery": true,
|
||||||
|
"SelectQuery": true
|
||||||
|
},
|
||||||
|
"RedfishVersion": "1.4.0",
|
||||||
|
"Registries": {"@odata.id": "/redfish/v1/Registries"},
|
||||||
|
"SessionService": {"@odata.id": "/redfish/v1/SessionService"},
|
||||||
|
"Systems": {"@odata.id": "/redfish/v1/Systems"},
|
||||||
|
"Tasks": {"@odata.id": "/redfish/v1/TaskService"},
|
||||||
|
"UpdateService": {"@odata.id": "/redfish/v1/UpdateService"}
|
||||||
|
}
|
||||||
9
tests/redfish_json/job_list_table.txt
Normal file
9
tests/redfish_json/job_list_table.txt
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
+------------------+-------------------+-----------------+---------------------------+-----------+
|
||||||
|
| Job ID | Job Type | Pcnt Complete | Name | State |
|
||||||
|
+==================+===================+=================+===========================+===========+
|
||||||
|
| JID_878659984891 | RAIDConfiguration | 100 | Config:RAID:RAID.Slot.6-1 | Completed |
|
||||||
|
| JID_878682850779 | RAIDConfiguration | 100 | Config:RAID:RAID.Slot.6-1 | Completed |
|
||||||
|
| JID_920326518992 | RAIDConfiguration | 100 | Config:RAID:RAID.Slot.6-1 | Completed |
|
||||||
|
| JID_923469653542 | RAIDConfiguration | 100 | Config:RAID:RAID.Slot.6-1 | Completed |
|
||||||
|
| JID_924369311959 | RAIDConfiguration | 100 | Config:RAID:RAID.Slot.6-1 | Completed |
|
||||||
|
+------------------+-------------------+-----------------+---------------------------+-----------+
|
||||||
101
tests/redfish_json/jobs_list.json
Normal file
101
tests/redfish_json/jobs_list.json
Normal file
|
|
@ -0,0 +1,101 @@
|
||||||
|
{
|
||||||
|
"@odata.context": "/redfish/v1/$metadata#DellJobCollection.DellJobCollection",
|
||||||
|
"@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1/Jobs",
|
||||||
|
"@odata.type": "#DellJobCollection.DellJobCollection",
|
||||||
|
"Description": "Collection of Job Instances",
|
||||||
|
"Id": "JobQueue",
|
||||||
|
"Members": [
|
||||||
|
{
|
||||||
|
"@odata.context": "/redfish/v1/$metadata#DellJob.DellJob",
|
||||||
|
"@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1/Jobs/JID_878659984891",
|
||||||
|
"@odata.type": "#DellJob.v1_0_1.DellJob",
|
||||||
|
"CompletionTime": "2023-06-27T06:53:33",
|
||||||
|
"Description": "Job Instance",
|
||||||
|
"EndTime": "TIME_NA",
|
||||||
|
"Id": "JID_878659984891",
|
||||||
|
"JobState": "Completed",
|
||||||
|
"JobType": "RAIDConfiguration",
|
||||||
|
"Message": "Job completed successfully.",
|
||||||
|
"MessageArgs": [],
|
||||||
|
"MessageId": "PR19",
|
||||||
|
"Name": "Config:RAID:RAID.Slot.6-1",
|
||||||
|
"PercentComplete": 100,
|
||||||
|
"StartTime": "TIME_NOW",
|
||||||
|
"TargetSettingsURI": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.context": "/redfish/v1/$metadata#DellJob.DellJob",
|
||||||
|
"@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1/Jobs/JID_878682850779",
|
||||||
|
"@odata.type": "#DellJob.v1_0_1.DellJob",
|
||||||
|
"CompletionTime": "2023-06-27T07:26:19",
|
||||||
|
"Description": "Job Instance",
|
||||||
|
"EndTime": "TIME_NA",
|
||||||
|
"Id": "JID_878682850779",
|
||||||
|
"JobState": "Completed",
|
||||||
|
"JobType": "RAIDConfiguration",
|
||||||
|
"Message": "Job completed successfully.",
|
||||||
|
"MessageArgs": [],
|
||||||
|
"MessageId": "PR19",
|
||||||
|
"Name": "Config:RAID:RAID.Slot.6-1",
|
||||||
|
"PercentComplete": 100,
|
||||||
|
"StartTime": "TIME_NOW",
|
||||||
|
"TargetSettingsURI": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.context": "/redfish/v1/$metadata#DellJob.DellJob",
|
||||||
|
"@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1/Jobs/JID_920326518992",
|
||||||
|
"@odata.type": "#DellJob.v1_0_1.DellJob",
|
||||||
|
"CompletionTime": "2023-08-14T12:14:58",
|
||||||
|
"Description": "Job Instance",
|
||||||
|
"EndTime": "TIME_NA",
|
||||||
|
"Id": "JID_920326518992",
|
||||||
|
"JobState": "Completed",
|
||||||
|
"JobType": "RAIDConfiguration",
|
||||||
|
"Message": "Job completed successfully.",
|
||||||
|
"MessageArgs": [],
|
||||||
|
"MessageId": "PR19",
|
||||||
|
"Name": "Config:RAID:RAID.Slot.6-1",
|
||||||
|
"PercentComplete": 100,
|
||||||
|
"StartTime": "TIME_NOW",
|
||||||
|
"TargetSettingsURI": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.context": "/redfish/v1/$metadata#DellJob.DellJob",
|
||||||
|
"@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1/Jobs/JID_923469653542",
|
||||||
|
"@odata.type": "#DellJob.v1_0_1.DellJob",
|
||||||
|
"CompletionTime": "2023-08-18T03:42:19",
|
||||||
|
"Description": "Job Instance",
|
||||||
|
"EndTime": "TIME_NA",
|
||||||
|
"Id": "JID_923469653542",
|
||||||
|
"JobState": "Completed",
|
||||||
|
"JobType": "RAIDConfiguration",
|
||||||
|
"Message": "Job completed successfully.",
|
||||||
|
"MessageArgs": [],
|
||||||
|
"MessageId": "PR19",
|
||||||
|
"Name": "Config:RAID:RAID.Slot.6-1",
|
||||||
|
"PercentComplete": 100,
|
||||||
|
"StartTime": "TIME_NOW",
|
||||||
|
"TargetSettingsURI": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.context": "/redfish/v1/$metadata#DellJob.DellJob",
|
||||||
|
"@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1/Jobs/JID_924369311959",
|
||||||
|
"@odata.type": "#DellJob.v1_0_1.DellJob",
|
||||||
|
"CompletionTime": "2023-08-20T05:59:24",
|
||||||
|
"Description": "Job Instance",
|
||||||
|
"EndTime": "TIME_NA",
|
||||||
|
"Id": "JID_924369311959",
|
||||||
|
"JobState": "Completed",
|
||||||
|
"JobType": "RAIDConfiguration",
|
||||||
|
"Message": "Job completed successfully.",
|
||||||
|
"MessageArgs": [],
|
||||||
|
"MessageId": "PR19",
|
||||||
|
"Name": "Config:RAID:RAID.Slot.6-1",
|
||||||
|
"PercentComplete": 100,
|
||||||
|
"StartTime": "TIME_NOW",
|
||||||
|
"TargetSettingsURI": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Members@odata.count": 5,
|
||||||
|
"Name": "JobQueue"
|
||||||
|
}
|
||||||
9
tests/redfish_json/list_power_states.json
Normal file
9
tests/redfish_json/list_power_states.json
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
[
|
||||||
|
"On",
|
||||||
|
"ForceOff",
|
||||||
|
"ForceRestart",
|
||||||
|
"GracefulShutdown",
|
||||||
|
"PushPowerButton",
|
||||||
|
"Nmi"
|
||||||
|
]
|
||||||
|
|
||||||
57
tests/redfish_json/physical_volume.json
Normal file
57
tests/redfish_json/physical_volume.json
Normal file
|
|
@ -0,0 +1,57 @@
|
||||||
|
{
|
||||||
|
"@odata.context": "/redfish/v1/$metadata#Drive.Drive",
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/Drives/Disk.Bay.0:Enclosure.Internal.0-1:RAID.Slot.6-1",
|
||||||
|
"@odata.type": "#Drive.v1_3_0.Drive",
|
||||||
|
"Actions": {
|
||||||
|
"#Drive.SecureErase": {
|
||||||
|
"target": "/redfish/v1/Systems/System.Embedded.1/Storage/Drives/Disk.Bay.0:Enclosure.Internal.0-1:RAID.Slot.6-1/Actions/Drive.SecureErase"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Assembly": {
|
||||||
|
"@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Assembly"
|
||||||
|
},
|
||||||
|
"BlockSizeBytes": 512,
|
||||||
|
"CapableSpeedGbs": 3,
|
||||||
|
"CapacityBytes": 299439751168,
|
||||||
|
"Description": "Physical Disk 0:1:0",
|
||||||
|
"EncryptionAbility": "None",
|
||||||
|
"EncryptionStatus": "Unencrypted",
|
||||||
|
"FailurePredicted": false,
|
||||||
|
"HotspareType": "None",
|
||||||
|
"Id": "Disk.Bay.0:Enclosure.Internal.0-1:RAID.Slot.6-1",
|
||||||
|
"Identifiers": [
|
||||||
|
{
|
||||||
|
"DurableName": "5000C50008F49F95",
|
||||||
|
"DurableNameFormat": "NAA"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Links": {
|
||||||
|
"Chassis": {
|
||||||
|
"@odata.id": "/redfish/v1/Chassis/Enclosure.Internal.0-1:RAID.Slot.6-1"
|
||||||
|
},
|
||||||
|
"Volumes": [
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/Volumes/Disk.Virtual.0:RAID.Slot.6-1"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Volumes@odata.count": 1
|
||||||
|
},
|
||||||
|
"Location": [],
|
||||||
|
"Manufacturer": "SEAGATE",
|
||||||
|
"MediaType": "HDD",
|
||||||
|
"Model": "ST3300655SS",
|
||||||
|
"Name": "Physical Disk 0:1:0",
|
||||||
|
"NegotiatedSpeedGbs": 3,
|
||||||
|
"Operations": [],
|
||||||
|
"PartNumber": "SG0HT9531253182B03FPA00",
|
||||||
|
"PredictedMediaLifeLeftPercent": null,
|
||||||
|
"Protocol": "SAS",
|
||||||
|
"Revision": "S527",
|
||||||
|
"RotationSpeedRPM": 0,
|
||||||
|
"SerialNumber": "3LM3M070",
|
||||||
|
"Status": {
|
||||||
|
"Health": null,
|
||||||
|
"HealthRollup": null,
|
||||||
|
"State": "Enabled"
|
||||||
|
}
|
||||||
|
}
|
||||||
82
tests/redfish_json/physical_volumes.json
Normal file
82
tests/redfish_json/physical_volumes.json
Normal file
|
|
@ -0,0 +1,82 @@
|
||||||
|
{
|
||||||
|
"@odata.context": "/redfish/v1/$metadata#Storage.Storage",
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/RAID.Slot.6-1",
|
||||||
|
"@odata.type": "#Storage.v1_4_0.Storage",
|
||||||
|
"Description": "PERC H710 Adapter",
|
||||||
|
"Drives": [
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/Drives/Disk.Bay.0:Enclosure.Internal.0-1:RAID.Slot.6-1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/Drives/Disk.Bay.1:Enclosure.Internal.0-1:RAID.Slot.6-1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/Drives/Disk.Bay.2:Enclosure.Internal.0-1:RAID.Slot.6-1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/Drives/Disk.Bay.3:Enclosure.Internal.0-1:RAID.Slot.6-1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/Drives/Disk.Bay.4:Enclosure.Internal.0-1:RAID.Slot.6-1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/Drives/Disk.Bay.5:Enclosure.Internal.0-1:RAID.Slot.6-1"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Drives@odata.count": 6,
|
||||||
|
"Id": "RAID.Slot.6-1",
|
||||||
|
"Links": {
|
||||||
|
"Enclosures": [
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Chassis/Enclosure.Internal.0-1:RAID.Slot.6-1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Chassis/System.Embedded.1"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Enclosures@odata.count": 2
|
||||||
|
},
|
||||||
|
"Name": "PERC H710 Adapter",
|
||||||
|
"Status": {
|
||||||
|
"Health": null,
|
||||||
|
"HealthRollup": null,
|
||||||
|
"State": "Enabled"
|
||||||
|
},
|
||||||
|
"StorageControllers": [
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/StorageControllers/RAID.Slot.6-1",
|
||||||
|
"Assembly": {
|
||||||
|
"@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Assembly"
|
||||||
|
},
|
||||||
|
"FirmwareVersion": "21.3.0-0009",
|
||||||
|
"Identifiers": [
|
||||||
|
{
|
||||||
|
"DurableName": "544A842004DB1500",
|
||||||
|
"DurableNameFormat": "NAA"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Links": {},
|
||||||
|
"Manufacturer": "DELL",
|
||||||
|
"MemberId": "RAID.Slot.6-1",
|
||||||
|
"Model": "PERC H710 Adapter",
|
||||||
|
"Name": "PERC H710 Adapter",
|
||||||
|
"SpeedGbps": 6,
|
||||||
|
"Status": {
|
||||||
|
"Health": null,
|
||||||
|
"HealthRollup": null,
|
||||||
|
"State": "Enabled"
|
||||||
|
},
|
||||||
|
"SupportedControllerProtocols": [
|
||||||
|
"PCIe"
|
||||||
|
],
|
||||||
|
"SupportedDeviceProtocols": [
|
||||||
|
"SAS",
|
||||||
|
"SATA"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"StorageControllers@odata.count": 1,
|
||||||
|
"Volumes": {
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/RAID.Slot.6-1/Volumes"
|
||||||
|
}
|
||||||
|
}
|
||||||
9
tests/redfish_json/power_states_allowed.json
Normal file
9
tests/redfish_json/power_states_allowed.json
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
"Actions":{
|
||||||
|
"#ComputerSystem.Reset":{
|
||||||
|
"ResetType@Redfish.AllowableValues":[
|
||||||
|
"On", "ForceOff", "ForceRestart", "GracefulShutdown", "PushPowerButton", "Nmi"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
82
tests/redfish_json/storage_controller.json
Normal file
82
tests/redfish_json/storage_controller.json
Normal file
|
|
@ -0,0 +1,82 @@
|
||||||
|
{
|
||||||
|
"@odata.context": "/redfish/v1/$metadata#Storage.Storage",
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/RAID.Slot.6-1",
|
||||||
|
"@odata.type": "#Storage.v1_4_0.Storage",
|
||||||
|
"Description": "PERC H710 Adapter",
|
||||||
|
"Drives": [
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/Drives/Disk.Bay.0:Enclosure.Internal.0-1:RAID.Slot.6-1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/Drives/Disk.Bay.1:Enclosure.Internal.0-1:RAID.Slot.6-1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/Drives/Disk.Bay.2:Enclosure.Internal.0-1:RAID.Slot.6-1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/Drives/Disk.Bay.3:Enclosure.Internal.0-1:RAID.Slot.6-1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/Drives/Disk.Bay.4:Enclosure.Internal.0-1:RAID.Slot.6-1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/Drives/Disk.Bay.5:Enclosure.Internal.0-1:RAID.Slot.6-1"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Drives@odata.count": 6,
|
||||||
|
"Id": "RAID.Slot.6-1",
|
||||||
|
"Links": {
|
||||||
|
"Enclosures": [
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Chassis/Enclosure.Internal.0-1:RAID.Slot.6-1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Chassis/System.Embedded.1"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Enclosures@odata.count": 2
|
||||||
|
},
|
||||||
|
"Name": "PERC H710 Adapter",
|
||||||
|
"Status": {
|
||||||
|
"Health": null,
|
||||||
|
"HealthRollup": null,
|
||||||
|
"State": "Enabled"
|
||||||
|
},
|
||||||
|
"StorageControllers": [
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/StorageControllers/RAID.Slot.6-1",
|
||||||
|
"Assembly": {
|
||||||
|
"@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Assembly"
|
||||||
|
},
|
||||||
|
"FirmwareVersion": "21.3.0-0009",
|
||||||
|
"Identifiers": [
|
||||||
|
{
|
||||||
|
"DurableName": "544A842004DB1500",
|
||||||
|
"DurableNameFormat": "NAA"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Links": {},
|
||||||
|
"Manufacturer": "DELL",
|
||||||
|
"MemberId": "RAID.Slot.6-1",
|
||||||
|
"Model": "PERC H710 Adapter",
|
||||||
|
"Name": "PERC H710 Adapter",
|
||||||
|
"SpeedGbps": 6,
|
||||||
|
"Status": {
|
||||||
|
"Health": null,
|
||||||
|
"HealthRollup": null,
|
||||||
|
"State": "Enabled"
|
||||||
|
},
|
||||||
|
"SupportedControllerProtocols": [
|
||||||
|
"PCIe"
|
||||||
|
],
|
||||||
|
"SupportedDeviceProtocols": [
|
||||||
|
"SAS",
|
||||||
|
"SATA"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"StorageControllers@odata.count": 1,
|
||||||
|
"Volumes": {
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/RAID.Slot.6-1/Volumes"
|
||||||
|
}
|
||||||
|
}
|
||||||
220
tests/redfish_json/system_details.json
Normal file
220
tests/redfish_json/system_details.json
Normal file
|
|
@ -0,0 +1,220 @@
|
||||||
|
{
|
||||||
|
"@odata.context": "/redfish/v1/$metadata#ComputerSystem.ComputerSystem",
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1",
|
||||||
|
"@odata.type": "#ComputerSystem.v1_5_0.ComputerSystem",
|
||||||
|
"Actions": {
|
||||||
|
"#ComputerSystem.Reset": {
|
||||||
|
"ResetType@Redfish.AllowableValues": [
|
||||||
|
"On",
|
||||||
|
"ForceOff",
|
||||||
|
"ForceRestart",
|
||||||
|
"GracefulShutdown",
|
||||||
|
"PushPowerButton",
|
||||||
|
"Nmi"
|
||||||
|
],
|
||||||
|
"target": "/redfish/v1/Systems/System.Embedded.1/Actions/ComputerSystem.Reset"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"AssetTag": "",
|
||||||
|
"Bios": {
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Bios"
|
||||||
|
},
|
||||||
|
"BiosVersion": "2.4.2",
|
||||||
|
"Boot": {
|
||||||
|
"BootOptions": {
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/BootOptions"
|
||||||
|
},
|
||||||
|
"BootOrder": [
|
||||||
|
"Optical.SATAEmbedded.E-1",
|
||||||
|
"NIC.Embedded.1-1-1",
|
||||||
|
"HardDisk.List.1-1"
|
||||||
|
],
|
||||||
|
"BootOrder@odata.count": 3,
|
||||||
|
"BootSourceOverrideEnabled": "Once",
|
||||||
|
"BootSourceOverrideMode": "UEFI",
|
||||||
|
"BootSourceOverrideTarget": "None",
|
||||||
|
"BootSourceOverrideTarget@Redfish.AllowableValues": [
|
||||||
|
"None",
|
||||||
|
"Pxe",
|
||||||
|
"Cd",
|
||||||
|
"Floppy",
|
||||||
|
"Hdd",
|
||||||
|
"BiosSetup",
|
||||||
|
"Utilities",
|
||||||
|
"UefiTarget",
|
||||||
|
"SDCard",
|
||||||
|
"UefiHttp"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"Description": "Computer System which represents a machine (physical or virtual) and the local resources such as memory, cpu and other devices that can be accessed from that machine.",
|
||||||
|
"EthernetInterfaces": {
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/EthernetInterfaces"
|
||||||
|
},
|
||||||
|
"HostName": "JCHV02",
|
||||||
|
"HostWatchdogTimer": {
|
||||||
|
"FunctionEnabled": false,
|
||||||
|
"Status": {
|
||||||
|
"State": "Disabled"
|
||||||
|
},
|
||||||
|
"TimeoutAction": "None"
|
||||||
|
},
|
||||||
|
"Id": "System.Embedded.1",
|
||||||
|
"IndicatorLED": "Off",
|
||||||
|
"Links": {
|
||||||
|
"Chassis": [
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Chassis/System.Embedded.1"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Chassis@odata.count": 1,
|
||||||
|
"CooledBy": [],
|
||||||
|
"CooledBy@odata.count": 0,
|
||||||
|
"ManagedBy": [
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"ManagedBy@odata.count": 1,
|
||||||
|
"Oem": {
|
||||||
|
"DELL": {
|
||||||
|
"@odata.type": "#DellComputerSystem.v1_0_0.DellComputerSystem",
|
||||||
|
"BootOrder": {
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/BootSources"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"PoweredBy": [],
|
||||||
|
"PoweredBy@odata.count": 0
|
||||||
|
},
|
||||||
|
"Manufacturer": "Dell Inc.",
|
||||||
|
"Memory": {
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Memory"
|
||||||
|
},
|
||||||
|
"MemorySummary": {
|
||||||
|
"Status": {
|
||||||
|
"Health": null,
|
||||||
|
"HealthRollup": null,
|
||||||
|
"State": "Enabled"
|
||||||
|
},
|
||||||
|
"TotalSystemMemoryGiB": 89.407008
|
||||||
|
},
|
||||||
|
"Model": "PowerEdge T320",
|
||||||
|
"Name": "System",
|
||||||
|
"NetworkInterfaces": {
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/NetworkInterfaces"
|
||||||
|
},
|
||||||
|
"PCIeDevices": [
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/6-0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/1-0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-29"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-31"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-28"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/8-0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-26"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-3"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"PCIeDevices@odata.count": 10,
|
||||||
|
"PCIeFunctions": [
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeFunction/6-0-0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeFunction/1-0-0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeFunction/0-0-0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeFunction/0-29-0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeFunction/0-31-0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeFunction/0-31-2"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeFunction/0-1-0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeFunction/0-1-1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeFunction/0-28-4"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeFunction/8-0-0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeFunction/1-0-1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeFunction/0-26-0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeFunction/0-3-0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeFunction/0-28-0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeFunction/0-28-6"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeFunction/0-28-7"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"PCIeFunctions@odata.count": 16,
|
||||||
|
"PartNumber": "0MK701A02",
|
||||||
|
"PowerState": "Off",
|
||||||
|
"ProcessorSummary": {
|
||||||
|
"Count": 1,
|
||||||
|
"LogicalProcessorCount": 4,
|
||||||
|
"Model": "Intel(R) Xeon(R) CPU E5-2407 v2 @ 2.40GHz",
|
||||||
|
"Status": {
|
||||||
|
"Health": null,
|
||||||
|
"HealthRollup": null,
|
||||||
|
"State": "Enabled"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Processors": {
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Processors"
|
||||||
|
},
|
||||||
|
"SKU": "JYYZY42",
|
||||||
|
"SerialNumber": "CN747515150714",
|
||||||
|
"SimpleStorage": {
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/SimpleStorage/Controllers"
|
||||||
|
},
|
||||||
|
"Status": {
|
||||||
|
"Health": "OK",
|
||||||
|
"HealthRollup": "OK",
|
||||||
|
"State": "StandbyOffline"
|
||||||
|
},
|
||||||
|
"Storage": {
|
||||||
|
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage"
|
||||||
|
},
|
||||||
|
"SystemType": "Physical",
|
||||||
|
"UUID": "4c4c4544-0059-5910-805a-cac04f593432"
|
||||||
|
}
|
||||||
5
tests/test_secrets.json
Normal file
5
tests/test_secrets.json
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"server": "idrac-73jqy42",
|
||||||
|
"password": "ht6a!nce",
|
||||||
|
"username": "root"
|
||||||
|
}
|
||||||
148
tests/utils.py
Normal file
148
tests/utils.py
Normal file
|
|
@ -0,0 +1,148 @@
|
||||||
|
"""Shared things for the tests"""
|
||||||
|
|
||||||
|
import json
|
||||||
|
|
||||||
|
import os
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
|
def redfish_json_path(file_name):
|
||||||
|
"""
|
||||||
|
Get the path to a json file based on the location of this test file -
|
||||||
|
basicaly ./redfish_json/file.json
|
||||||
|
"""
|
||||||
|
return (
|
||||||
|
Path(os.path.dirname(os.path.realpath(__file__)))
|
||||||
|
/ "redfish_json"
|
||||||
|
/ file_name
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def get_test_content(file_name):
|
||||||
|
"""Load json from a file"""
|
||||||
|
with open(redfish_json_path(file_name), encoding="utf-8") as json_file:
|
||||||
|
_data = json_file.read()
|
||||||
|
|
||||||
|
return _data
|
||||||
|
|
||||||
|
|
||||||
|
def get_test_json(file_name):
|
||||||
|
"""Load json from a file"""
|
||||||
|
with open(redfish_json_path(file_name), encoding="utf-8") as json_file:
|
||||||
|
_data = json_file.read()
|
||||||
|
_json = json.loads(_data)
|
||||||
|
|
||||||
|
return _json
|
||||||
|
|
||||||
|
|
||||||
|
class MockRedfishResponse:
|
||||||
|
"""Mock a RedFish response"""
|
||||||
|
|
||||||
|
json_dict: dict = {
|
||||||
|
"@odata.context": "/redfish/v1/$metadata#ServiceRoot.ServiceRoot",
|
||||||
|
"@odata.id": "/redfish/v1",
|
||||||
|
"@odata.type": "#ServiceRoot.v1_3_0.ServiceRoot",
|
||||||
|
"AccountService": {
|
||||||
|
"@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1/AccountService"
|
||||||
|
},
|
||||||
|
"Chassis": {"@odata.id": "/redfish/v1/Chassis"},
|
||||||
|
"Description": "Root Service",
|
||||||
|
"EventService": {"@odata.id": "/redfish/v1/EventService"},
|
||||||
|
"Fabrics": {"@odata.id": "/redfish/v1/Fabrics"},
|
||||||
|
"Id": "RootService",
|
||||||
|
"JsonSchemas": {"@odata.id": "/redfish/v1/JSONSchemas"},
|
||||||
|
"Links": {"Sessions": {"@odata.id": "/redfish/v1/Sessions"}},
|
||||||
|
"Managers": {"@odata.id": "/redfish/v1/Managers"},
|
||||||
|
"Name": "Root Service",
|
||||||
|
"Oem": {
|
||||||
|
"Dell": {
|
||||||
|
"@odata.type": "#DellServiceRoot.v1_0_0.ServiceRootSummary",
|
||||||
|
"IsBranded": 0,
|
||||||
|
"ManagerMACAddress": "54:9F:35:1A:0D:D8",
|
||||||
|
"ServiceTag": "JYYZY42",
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Product": "Integrated Dell Remote Access Controller",
|
||||||
|
"ProtocolFeaturesSupported": {
|
||||||
|
"ExpandQuery": {
|
||||||
|
"ExpandAll": True,
|
||||||
|
"Levels": True,
|
||||||
|
"Links": True,
|
||||||
|
"MaxLevels": 1,
|
||||||
|
"NoLinks": True,
|
||||||
|
},
|
||||||
|
"FilterQuery": True,
|
||||||
|
"SelectQuery": True,
|
||||||
|
},
|
||||||
|
"RedfishVersion": "1.4.0",
|
||||||
|
"Registries": {"@odata.id": "/redfish/v1/Registries"},
|
||||||
|
"SessionService": {"@odata.id": "/redfish/v1/SessionService"},
|
||||||
|
"Systems": {"@odata.id": "/redfish/v1/Systems"},
|
||||||
|
"Tasks": {"@odata.id": "/redfish/v1/TaskService"},
|
||||||
|
"UpdateService": {"@odata.id": "/redfish/v1/UpdateService"},
|
||||||
|
}
|
||||||
|
status_code = 200
|
||||||
|
|
||||||
|
def __init__(self, status_code=200, json_dict=None):
|
||||||
|
self.status_code = status_code
|
||||||
|
if json_dict is not None:
|
||||||
|
self.json_dict = json
|
||||||
|
|
||||||
|
@property
|
||||||
|
def text(self):
|
||||||
|
"""Return self.json_dict as a json string"""
|
||||||
|
return json.dumps(self.json_dict)
|
||||||
|
|
||||||
|
def update(self, update_dict):
|
||||||
|
"""Update self.json_dict with the specified dict"""
|
||||||
|
self.json_dict.update(update_dict)
|
||||||
|
|
||||||
|
|
||||||
|
class MockResponse:
|
||||||
|
"""A Mocked requests reponse"""
|
||||||
|
|
||||||
|
# pylint: disable=invalid-name,too-few-public-methods
|
||||||
|
|
||||||
|
def __init__(self, status_code=200, ok=True, content="", headers=None):
|
||||||
|
self.status_code = status_code
|
||||||
|
self._ok = ok
|
||||||
|
self.content = content
|
||||||
|
self._headers = headers
|
||||||
|
|
||||||
|
def json(self):
|
||||||
|
"""return json from the mocked response"""
|
||||||
|
return json.loads(self.content)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def text(self):
|
||||||
|
"""return text from the mocked response"""
|
||||||
|
return self.content
|
||||||
|
|
||||||
|
@property
|
||||||
|
def ok(self):
|
||||||
|
"""return the OK flag."""
|
||||||
|
return self._ok
|
||||||
|
|
||||||
|
@property
|
||||||
|
def headers(self):
|
||||||
|
"""Return the headers dict"""
|
||||||
|
return self._headers
|
||||||
|
|
||||||
|
|
||||||
|
class MockWatchedJobResponse:
|
||||||
|
"""Special class for testing watching a job"""
|
||||||
|
|
||||||
|
# pylint: disable=too-few-public-methods, invalid-name
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.accessed = 0
|
||||||
|
self._json = get_test_json("api_job_details.json")
|
||||||
|
self.status_code = 200
|
||||||
|
self.ok = True
|
||||||
|
|
||||||
|
@property
|
||||||
|
def text(self):
|
||||||
|
"""Return json, increment % complete each time"""
|
||||||
|
self._json["PercentComplete"] = self.accessed * 20
|
||||||
|
self.accessed += 1
|
||||||
|
return json.dumps(self._json)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue