107 Commits

Author SHA1 Message Date
Kostiantyn Kalynovskyi
0a5f1e2ca4 Reuse RemoteDirect function for redfish dell client
Change-Id: I17726cae6f4d1f99e1cec4fa7a29c1a9e1dee3d5
2021-02-04 01:11:09 +00:00
Kostiantyn Kalynovskyi
129fd7ffa6 Cleanup unused remote pkg code
Change-Id: Ie879b6c8947148ae15b1c7cb5e15a46e998ec05c
2021-01-22 20:23:08 +00:00
Kostiantyn Kalynovskyi
decc12b0a9 Move remotedirect method to remote interface
Please note that this is first commit in series and in next commits
remote/remote_direct* files will be remove completely, so if you
have any comments that address issues in these files, keep in mind
that they will be remove in next patchsets.

Change-Id: I52e9b8438a4f8e1a2395cbe90238b9cb654772d4
2021-01-21 23:09:54 +00:00
muly
d16ba90d34 Changed the return statements to go idiomatic way
Change-Id: I56f57d9e6ef385245b2a299d9d6d7bacd2266b68
2021-01-12 14:10:22 -05:00
Kostiantyn Kalynovskyi
bd1728405a Call correct client when building Host object
This will make sure that corect driver is used when managing
remote hosts via redfish.

Change-Id: Ic0d7f946ca4e64a6a8df1ab5bd65e4ecec130988
2021-01-07 19:27:43 +00:00
Anderson, Craig (ca846m)
2daacf5f2a image-builder integration for ISO builds
This introduces airshipctl integration with image-builder [0], which
replaces the existing isogen tool for ephemeral ISO generation.

The airshipctl isogen executor has been updated for building ephemeral
ISOs using the image-builder container. The ability for user-declared
filenames for cloud-init user data and network data was removed, since
the user's only interest is in supplying the relevant overrides, not in
transparent naming coordination with the image-builder container. A new
object is added to the document package to identify the document kind,
label, and key to retrieve data from since this is pattern we will
reuse elsewhere.

Progress flag removed as requsted. Progress is reported directly by the
image-builder container.

Isogen debug flag removed in favor of using log.DebugEnabled()

[0] https://review.opendev.org/#/c/730777/

Depends-On: https://review.opendev.org/c/airship/images/+/730777/
Change-Id: I545004feaf2116f8ffb29faf6f7f7f5fcfe24fff
2020-12-17 14:47:53 -08:00
Zuul
ab63c191b0 Merge "Move remote client interface to separate package" 2020-11-13 02:03:30 +00:00
Kostiantyn Kalynovskyi
d442e20dcb Move remote client interface to separate package
This will allow to add constructors that return interface
instead of struct.

Relates-To: #397
Relates-To: #362
Relates-To: #359

Change-Id: Ia750d5c9472041b34ab74a2935ef77ae955a016e
2020-11-11 16:24:29 +00:00
Kostiantyn Kalynovskyi
f2e305a56d Fix missing authentication for redfish dell client
Change-Id: Iffd26171b75ce10dd15d66583b6bda249156c34d
Closes: #396
2020-11-11 15:08:45 +00:00
Kostiantyn Kalynovskyi
690d8d88c1 Remove context from BMH object.
This is first step in refactoring remote package to support
future inventory interface, also relates to remote-direct
executor, as it simplifies usage of Host objects

Relates-To: #362

Change-Id: Ief2fece134a465916ce461960cd7d16c9e237eb7
Relates-To: #362
2020-10-26 10:25:44 -05:00
Vladimir Kozhukalov
dc68640389 Phase docs are targetPath + phaseRepo + phase.DocumentEntrypoint
Change-Id: I1d5ea75d1c19eb4ebaf37b28918ccde771bcef85
Relates-To: #356
2020-10-15 13:55:59 +03:00
Ruslan Aliev
07c44eedb7 Add ability to perform baremetal operation against all nodes
If no name or label filter specified baremetal operation will
be performed against all nodes with baremetalhost kind. Also,
baremeral cmd code was refactored and combined, which allowed
to remove duplicated code and slighlty improve test coverage
by reducing the number of untestable lines.

Change-Id: Ieadafdb9f55b995d4b47aeff1dc7233325f3191c
Signed-off-by: Ruslan Aliev <raliev@mirantis.com>
Relates-To: #361
Closes: #361
2020-10-05 00:29:40 -05:00
Kostiantyn Kalynovskyi
e6e56ffa2e Use BundleFactory instead of bundle in executors
This will allow to avoid using nil bundle and performing
additional checks inside the executors

Change-Id: Ia061cccf7e0a7948bbc5c8fce24e0e6f8b3256e1
2020-09-28 19:39:05 -05:00
Zuul
0bdbd690db Merge "Fix typos" 2020-09-23 02:59:18 +00:00
Kostiantyn Kalynovskyi
2b30dd0d71 Stop using CurrentContextEntryPoint in remote pkg
Note this commit doesn't refactor remote package, it is only created
to shift from using CurrentContextEntryPoint function, which would
in turn allow us to refactor config package and get rid of cluster
types in airship config.

Relates-To: #349
Relates-To: #246
Relates-To: #265

Change-Id: I1c941c8ade3497b9911fb126465aa85c25567431
2020-09-22 12:29:37 -05:00
Ruslan Aliev
2e85043c20 Fix typos
Change-Id: I0ce87ec00d2b5974cf861d9c9685f23d7d0f5fc1
Signed-off-by: Ruslan Aliev <raliev@mirantis.com>
2020-09-21 02:49:33 -05:00
Ruslan Aliev
a2b8d45cb0 Refactor baremetal* commands
All the baremetal commands was refactored for usage with new config
factory. Config object now is being initialized in pkg module on demand,
which provides more flexibility and cleaner code.

Change-Id: If75cd3f1a8bc22fc47ea132188bd9fec989ee434
Signed-off-by: Ruslan Aliev <raliev@mirantis.com>
Relates-To: #327
2020-09-03 23:52:49 -05:00
Vladimir Kozhukalov
e9c8425c30 Move bootstrapInfo config section to manifests
This is a part of two activities
  * Refactor config and store all parameters to document model
  * Implement everything as phases (which are supposed to be purely document driven)

 This patch removes bootstrapInfo section from the airshipctl config and
 makes these to commands
  * airshipctl baremetal isogen
  * airthipctl baremetal remotedirect
 to take necessary parameters from documents

 We introduce two airship API kinds ImageGenerator and RemoteDirect.
 Instead of storing config parameters in cm/secrets we use these two
 API objects.

Relates-To: #246
Closes: #254
Change-Id: I42903c45dce1c73da184c07277fec76fd88c700f
2020-08-31 16:54:46 +03:00
Alexander Noskov
068718e07d Proper error handling with Sushy emulator
This change adds a more informative error message in case of using airshipctl
with a Sushy emulator.

In the current implementation, by executing `airshipctl baremetal powerstatus`
command with invalid BMH configuration for example, returns:
redfish client encountered an error: BMC responded '500 INTERNAL SERVER ERROR'.

After this change the output looks like this:
redfish client encountered an error: BMC responded '500 INTERNAL SERVER ERROR'.
BMC responded: 'Error finding domain by name/UUID "air-ephemeral1" at libvirt
URI qemu:///system": Domain not found: no domain with matching name 'air-ephemeral1''

In case of using airshipctl with baremetal BMC, extendedInfo contains a valid
error message, so there are no issues.

Relates-To: #320

Change-Id: I437f50d5df4b0561f352804f269b0319badcc755
2020-08-26 15:22:33 -05:00
Alexander Noskov
582894d389 Switch to Ubuntu focal (20.04) based image
Since we have switched from debian to ubuntu based image and changed the
name (in https://review.opendev.org/733078) we need to align it with
airshipctl repository.
Renaming the following names:
1) debian-custom.iso -> ubuntu-focal.iso
2) quay.io/airshipit/isogen:latest-debian_stable -> quay.io/airshipit/isogen:latest-ubuntu_focal

Updating the following packages and resources:
1) k8s 1.17.3 -> 1.18.6
2) docker 19.03.9 -> 19.03.12
3) Calico 3.9 -> 3.15

Change-Id: I7eaf382acb79016a511db6e0955fa932c02963c4
2020-08-13 13:11:25 -05:00
Ian Howell
c030bcb034 Remove AirshipError
This removes the common, as it doesn't add any additional information
when an error occurs

Change-Id: Id67e38604445a2a044aae949d933f556bb29b05c
2020-05-28 14:22:44 -05:00
Drew Walters
58ba1d94e0 Add management config validation
The management configuration does not have central validation, leading
to late validation errors. Additionally, there is an effort to provide
better config validation on a command-by-command basis.

This change adds central validation to the management configuration that
will be used several ways:

  1. For quicker validation today
  2. For a new CLI command that will be introduced in a future change
     that enables imperative modification of the management config
  3. Possibly in future efforts to provide command-by-command config
     validation by calling the exported Validate() function

Change-Id: I19eafddc818e8d478b9afd053d4ab387c7ad38b3
Signed-off-by: Drew Walters <andrew.walters@att.com>
2020-05-21 14:21:59 +00:00
Drew Walters
4017e9c221 Fix system power regressions
A change [0] recently merged that makes additional remote parameters
configurable; however, it changed the default wait value to two seconds
and made the wait value a duration in time between two nanoseconds.

This change restores the default wait value of thirty seconds and makes
the wait value representative of seconds again.

[0] https://review.opendev.org/717812

Change-Id: I9fad30d479419efe95fca7dc78154bfc3ca66697
Signed-off-by: Drew Walters <andrew.walters@att.com>
2020-05-11 20:33:50 +00:00
Vladislav Kuzmin
9c1724f6d8 Make remote parameters configurable
Remove constants and define these parameteres
in config file for remote configuration.

Closes: #138

Change-Id: Ib9250b8d39c01ef43a1262b62e4d37215481bc43
2020-05-08 17:23:59 +04:00
Drew Walters
bbb823306d Add mutual exclusivity to manager host selectors
Using a label selector and name when creating a manager will produce the
union of all host documents that match the criteria. While this is not
inherently a problem, it's not expected behavior. This change makes
using the label selector and name property mutually exclusive. When
creating a manger using both selectors, the manager will contain the
intersection of hosts, rather than the union.

Change-Id: I791e0460cea2ae3d60ea2cc24f900b925c36d9af
Signed-off-by: Drew Walters <andrew.walters@att.com>
2020-05-06 18:21:26 +00:00
Drew Walters
d126615f8b Add NoReboot param to Dell Redfish SCP import req
When importing a system configuration, iDRAC creates a job and reboots
the node for the changes to take effect; however, the reboot is already
handled by airshipctl, and there can be conflicts when the iDRAC reboots
the node at the same time as airshipctl.

This change disables the reboot functionality in the airshipctl SCP
request to insert the VCD-DVD media, allowing airshipctl to perform the
reboot.

Change-Id: Ic33b7ab0e44ff4f6e0d281db3b0455c252cc44f2
Signed-off-by: Drew Walters <andrew.walters@att.com>
2020-05-05 21:00:33 +00:00
Drew Walters
aeba847ffc Add Redfish SystemPowerOn/Off tests
The Redfish client functions SystemPowerOn and SystemPowerOff do not
have test cases. This change adds tests to verify their
functionality and bring their test coverage to 100%.

Change-Id: I84a9c3dfe9ed022c9e1086c22cb88497a5367863
Signed-off-by: Drew Walters <andrew.walters@att.com>
2020-05-04 20:55:04 +00:00
Drew Walters
ede8e8da4f Add state validation to Redfish shutdown/startup
The Redfish client reports success when Redfish returns success after a
shutdown or startup signal is sent; however, airshipctl needs to verify
that the host successfully reaches the desired power state before moving
on. This change adds the same wait functionality from reboot to the
power on and power off functionality.

Change-Id: I56c6696394b547f97da79cec56726002c3f225db
Signed-off-by: Drew Walters <andrew.walters@att.com>
2020-05-04 20:48:59 +00:00
Drew Walters
d7f0a19d41 Add SystemPowerStatus tests
The Redfish client function SystemPowerStatus does not have any test
cases. This change adds tests to verify its functionality and bring its
test coverage to 100%.

Change-Id: I985cdd6beffb4e41524d443113e1268dab1c8e16
Signed-off-by: Drew Walters <andrew.walters@att.com>
2020-05-04 20:48:35 +00:00
Ian Howell
3dc63e359a Add a mockable Sleep method to redfish client
This allows us to skip the wait times during unit tests.

Change-Id: Ie28cccee9315a9503ab9554b6e6ce6a0e7c58430
2020-05-01 16:41:47 -05:00
Zuul
71b06db819 Merge "Add system power status check to remotedirect" 2020-05-01 18:30:51 +00:00
Zuul
8387ba7aa5 Merge "Add strong typing for baremetal power statuses" 2020-05-01 18:28:11 +00:00
Drew Walters
4b729998e9 Add system power status check to remotedirect
Invoking remotedirect on a host that is powered off will result in a
remotedirect failure; therefore, the power status of a host needs to be
verified before remotedirect can begin. This change adds a status check
of the ephemeral node before performing remotedirect. When the node is
off, airshipctl powers the node on.

NOTE: if the host does not power on quickly enough, remotedirect could
still fail. The redfish client will be updated to handle the startup and
shutdown waiting in another change.

Change-Id: I725cf79e070864956e2991f60261328ebd6a5fc5
Signed-off-by: Drew Walters <andrew.walters@att.com>
2020-05-01 17:25:57 +00:00
Drew Walters
69e8c886fe Add strong typing for baremetal power statuses
Baremetal host power statuses are handled as strings in airshipctl.
Invoking remotedirect on a host that is powered off will result in a
remotedirect failure; therefore, the power status of a host needs to be
verified before remotedirect can begin. This change adds strict typing
to baremetal power statuses so airshipctl can verify the status of a
remote host before performing remotedirect regardless of the client type
(e.g. redfish, other).

Change-Id: I22f1784006add018ee1d67c18f94499aa9544752
Signed-off-by: Drew Walters <andrew.walters@att.com>
2020-05-01 17:25:31 +00:00
Drew Walters
4b6d2328de Fix power command host selectors
Both host selectors are always passed to create a manager when a power
command is invoked; however, an empty label selector will include all
hosts.

This change adds a helper function to determine which selectors will be
used based on the flags passed to airshipctl. When a flag is not used, a
selector is not created for it.

Change-Id: I48684cdf6d16073bf85468f6286a22a0aba602f7
Signed-off-by: Drew Walters <andrew.walters@att.com>
2020-05-01 16:59:16 +00:00
Drew Walters
9ff4c67e05 Add additional debug logging to Redfish calls
When tracking down issues on baremetal nodes using remotedirect, it has
been difficult to pinpoint which Redfish calls fail. This change adds
additional debug logging to make the troubleshooting process simpler
during pre-alpha development.

Change-Id: Ic32d34d010c44b2e7e2a4dfe2b623a451ad94019
Signed-off-by: Drew Walters <andrew.walters@att.com>
2020-05-01 14:14:31 +00:00
Drew Walters
00f934af50 Fix unknown management type error
When using "redfish-dell" as the management type, airshipctl throws an
error due to a missing case statement. This change fixes the regression
by re-adding "redfish-dell" as a remote type.

Change-Id: I8314a1e356d1bb3bb1705762bbeda1adf1db41d2
Signed-off-by: Drew Walters <andrew.walters@att.com>
2020-04-30 16:58:52 +00:00
Zuul
c33e0a20ad Merge "Fix Lint warnings: Missing comments for functions" 2020-04-30 16:47:06 +00:00
Yasin, Siraj (SY495P)
8ed791e6e6 Fix Lint warnings: Use of basic type string as key
warning:
  * should not use basic type string as key in context.WithValue

Fix:
  * Define a separate type for context Key(numRetries) and use the
    same to pass value for it
  * Added a constant ctxKeyNumRetries to be used by entire package

Relates-To: #148
Change-Id: Ifd464346ae7a8ecd82a1f1073a026af1e182fbef
2020-04-29 17:00:10 -05:00
Yasin, Siraj (SY495P)
8902d93e02 Fix Lint warnings: Missing comments for functions
* Added comments wherever missing for exported functions/constants

Change-Id: Ibfcfe9c4d89c42e4bb7f72cfe6c894a33e7c6fba
Relates-To: #148
2020-04-29 16:54:01 -05:00
Zuul
3fc61f3969 Merge "Add baremetal ejectmedia command" 2020-04-29 15:26:24 +00:00
Zuul
90265072d1 Merge "Add baremetal host poweron command" 2020-04-29 15:22:05 +00:00
Zuul
3d10e1cde1 Merge "Move remote cmd functionality to baremetal cmd" 2020-04-29 15:21:24 +00:00
Ruslan Aliev
af9e46dfec Refactor CurrentContextEntryPoint function
Currently it takes ClusterType as first parameter, however
this parameter can be retrieved via appropriate function
CurrentContextClusterType in the same module.

Change-Id: I205fd7d00bf1745cada88d8fd972dac1dbe0fddf
2020-04-29 06:17:00 -05:00
Drew Walters
1ce5005cd6 Add baremetal ejectmedia command
Early airshipctl usage has identified the need to eject virtual media
on-demand using airshipctl in order to prevent booting from stuck media.
This change adds a command to eject all virtual media attached to a
baremetal node.

Change-Id: Id67fa00489093dcb84ce54216e0553fa6a737ea6
Signed-off-by: Drew Walters <andrew.walters@att.com>
2020-04-28 23:10:36 +00:00
Drew Walters
7ddb858135 Add baremetal host poweron command
This change introduces a command to power on baremetal hosts.

Closes: #5

Change-Id: Ie76cd7c044cc44629648ef0b02bb7e492ccccdcf
Signed-off-by: Drew Walters <andrew.walters@att.com>
2020-04-28 23:10:32 +00:00
Drew Walters
fd65389f1a Move remote cmd functionality to baremetal cmd
Early airshipctl usage has identified the need to change the power of
remote hosts directly from airshipctl. This functionality is typically
required during the bootstrapping phase of airshipctl; however, the
functionality could be used anytime. A logical home for this
functionality would be in a baremetal command, not a bootstrap command.
Since all functionality performed by the bootstrap command is performed on
baremetal hosts, a natural need has developed to group this
functionality together under one baremetal command.

This change moves all functionality from the remote command to a new
baremetal command.

Once all functionality is grouped within the new baremetal command, a
user can control hosts like this:

airshipctl baremetal isogen                    generate ephemeral node ISO
airshipctl baremetal remotedirect              bootstrap ephemeral node
airshipctl baremetal poweroff       [DOC_NAME] shutdown baremetal node
airshipctl baremetal poweron        [DOC_NAME] power on baremetal node
airshipctl baremetal reboot         [DOC_NAME] reboot baremetal node
airshipctl baremetal powerstatus    [DOC_NAME] retrieve baremetal node status

Relates-To: #5

Change-Id: I31239df1593aac5810e66e1918d8d3207b9f60fb
Signed-off-by: Drew Walters <andrew.walters@att.com>
2020-04-28 22:52:35 +00:00
Drew Walters
995538829e Add management support to non-ephemeral hosts
Management support is only available to the ephemeral host. This change
extends support of management features to hosts not labeled as the
ephemeral host.

Change-Id: I0ac917f2633f659e56e67cafc52d2db9d967754f
Signed-off-by: Drew Walters <andrew.walters@att.com>
2020-04-28 16:29:19 +00:00
Drew Walters
7ac6362350 Decode Redfish error responses as raw JSON
Some BMCs return response formats that differ from the DMTF Redfish
specification. When the response format varies, airshipctl is unable to
decode the extended information field, leaving the user with the
general, top-level error message "A general error has occurred. See
ExtendedInfo for more information".

This change introduces raw JSON processing for all Redfish error
responses so both observed formats can be handled until this issue is
addressed by the manufacturers.

Change-Id: I6a6e87ecda65292b3cd58a0525985105db350ab8
Signed-off-by: Drew Walters <andrew.walters@att.com>
2020-04-27 13:35:17 +00:00
Drew Walters
891a2b7f9d Add stricter Redfish error inspection
On some Redfish POST requests, the go-redfish library provides more
error messages. This changes adds the capability to screen for those
messages and provide them in a single, end user-consumable error.

NOTE: due to some malformed responses, some errors may not get more
information. A future change will further inspect the JSON to retrieve
those.

Change-Id: I941dbe8b76e879497a2d79f4657a995767862706
Signed-off-by: Drew Walters <andrew.walters@att.com>
2020-04-23 19:46:06 +00:00