Commit Graph

262 Commits

Author SHA1 Message Date
Oleg Ovcharuk 3919e6a52b Add an ability to hide sensitive data from http action logs
Opportunity to hide sensitive data from http action logs, such as:
* Request headers
* Request body
* Response body

Change-Id: I6d1b1844898343b8fa30f704761096e3d2936c4d
Implements: blueprint mistral-hide-sensitive-data-from-http-actions-logs
Signed-off-by: Oleg Ovcharuk <vgvoleg@gmail.com>
2023-01-24 21:54:00 +00:00
Renat Akhmerov a73fe5b8a3 Fix dynamic actions further
* Reworked /code_sources and /dynamic_actions API endpoints to
  simplify them. For now they don't work with multiple objects and
  they are consistent with other endpoints. If needed, we'll add
  support for multiple objects (i.e. adding multiple dynamic actions
  with a single request) later in a backwards compatible manner.
* Simplified unit tests.
* Got rid of services/*.py modules since they didn't do anything
  useful. They were just wrappers around DB API calls.

Change-Id: Ib5a53f1f1a185f0395ffae1ab0c401633fcdd0fc
2020-12-03 16:51:25 +07:00
Renat Akhmerov f78f33507e Code improvements after the dynamic actions patch
* Style improvements to make sure the code is compliant with the
  coding guidelines
* Fixing small but important things like the mismatch between the
  sinatures of the methods find_all() in the DynamicActionProvider
  class and the base ActionProvider interface.
* Improved the tests.
* Simplified the implementation of DynamicActionProvider.

Change-Id: Idbfb15b4c3bb415e7fa9c7ece27eabfe674b6059
2020-11-23 15:33:54 +07:00
ali 9be4f8e119 created a new Api endpoints and added dynamic actions
* added dynamic actions:
     these actions are created and modified in runtime,
     each action needs a code source to be imported from and a
     class name.

 - there are 2 new endpoints:
    - /v2/code_sources/:
       used to add new code sources to mistral.
    - /v2/dynamic_actions/:
      used to add dynamic actions to mistral in runtime

 - a new Action provider (DynamicActionProvider) was added:
    it provides the actions created from the dynamic actions api.

Change-Id: I9fe8c28ffdef71016d9dc13aea60a288c8ebaa0a
Signed-off-by: ali <ali.abdelal@nokia.com>
2020-11-18 10:15:26 +00:00
Eyal f0bc436618 The encoding parameter in json.loads has been removed in py3.9
It was ignored and deprecated before.

see https://docs.python.org/3/whatsnew/3.9.html#index-20:~:text=The%20encoding%20parameter%20of%20json.loads()%20has,(Contributed%20by%20Inada%20Naoki%20in%20bpo%2D39377)

Change-Id: I9cf37e1297d303e459bf9588f0493f6ca4a438c7
2020-11-16 03:15:30 +00:00
Renat Akhmerov d81dc75a3c Remove the module mistral/actions/action_factory.py
* This module was always a weird entity in the system having just
  one function that essentially creates a dynamic class. It was
  created just because we didn't understand where else to put this
  function. But now after the action provider refactoring we don't
  need it anymore. Action instantiation is now a responsibility of
  action descriptor classes.

Change-Id: Ic4b6a9a7ca2784a892d2998359edb220ff8c8911
2020-10-05 16:15:13 +07:00
Renat Akhmerov 06a0f33476 Refactor Mistral with Action Providers
* This patch refactors Mistral with the action provider concept
  that is responsible for delivering actions to the system. So
  it takes all the burden of managing action definitions w/o
  having to spread that across multiple subsystems like Engine
  and API and w/o having to assume that action definitions are
  always stored in DB.
* Added LegacyActionProvider  that represents the old way of
  delivering action definitions to the system. It pretty much just
  analyses what entries are configured in the entry point
  "mistral.actions" in setup.cfg and build a collection of
  corresponding Python action classes in memory accessible by names.
* The module mistral/services/actions.py is now renamed to
  adhoc_actions.py because it's effectively responsible only for
  ad-hoc actions (those defined in YAML).
* Added the new entry point in setup.cfg "mistral.action.providers"
  to register action provider classes
* Added the module mistral/services/actions.py that will be a facade
  for action providers. Engine and other subsystems will need to
  work with it.
* Other small code changes.

Depends-On: I13033253d5098655a001135c8702d1b1d13e76d4
Depends-On: Ic9108c9293731b3576081c75f2786e1156ba0ccd
Change-Id: I8e826657acb12bbd705668180f7a3305e1e597e2
2020-09-24 11:10:33 +00:00
Q.hongtao 4bc6162515 Remove six library
Remove six-library Replace the following items with Python 3 style code.
- six.interger_types
- six.itervalues
- six.text_type
- six.string_types
- six.StringIO
- six.next
- six.b
- six.PY3

Change-Id: I299c90d5cbeb41be0132691265b8dcbeae65520e
2020-09-23 10:27:12 +08:00
Q.hongtao da5ac25415 Remove six.moves
Remove six.moves Replace the following items with Python 3 style code.
- six.moves.urllib
- six.moves.queue
- six.moves.range
- six.moves.http_client

Subsequent patches will replace other six usages.

Change-Id: I80c713546fcc97391c64e95ef708830632e1ef32
2020-09-22 08:34:20 +08:00
Renat Akhmerov 0dbab33c4c Fix serialization of structures that might contain YAQL types
* When YAQL output data conversion is disabled there's still
  an issue caused by presence of not JSON-compatible types within
  a YAQL result. The internal Mistral code is already able to deal
  with that (due to the previous changes) by checking that and
  converting them to what's needed. However, JSON serialization
  may still not work if it's done via the standard "json" library.
  The library simply doesn't handle those non-standard types and
  raises an exception. We have a sanitizing function that all YAQL
  results go through, however, it doesn't make sense to do recursive
  sanitizing for performance reasons. It does make sense to convert
  data as late as possible to avoid redundant data manipulations. So
  the sanitizing function handles only the root object in the object
  graph. The solution for this problem is to use our own utility
  function based on the "oslo_serialization.jsonutils" that is able
  to deal with at least part of the mentioned types, specifically
  FrozenDict and iterators. Generators are still a problem and this
  new function takes care of that separately, assuming that any
  generator is just a special iterator and hence represents a
  collection, i.e. a list in JSON terms. It works for all the cases
  we've encountered so far working with YAQL.
* Used the new function "utils.to_json_str()" everywhere for JSON
  serialization, including the action "std.http".
* Added necessary unit tests.

Closes-Bug: #1869168
Depends-On: I1081a44a6f305eb1dfe68a5bad30110385130725
Change-Id: I9e73ea7cbba215c3e1d174b5189be27c640c4d42
2020-03-31 18:42:11 +07:00
Eyal 8bdf341af7 Remove OpenStack actions from mistral
Depends-on: https://review.opendev.org/#/c/703296/
Depends-On: https://review.opendev.org/#/c/704280/
Change-Id: Id62fdabe7699e7c3b2977166e253cfc77779e467
2020-02-26 10:12:01 +02:00
Eyal eaf0916e31 Fix fake clients in actions
* Use inspector_url when creating a fake client for ironic inspector client
* Add a session and a url for designate fake client

Change-Id: I9cc78df13d0f0715538bbdb76c8ccad273bd2033
2020-01-27 17:35:06 +02:00
Zuul da93da4ac1 Merge "Add json param to HTTPAction" 2020-01-23 19:09:07 +00:00
Oleg Ovcharuk fb3db8ddb7 Add json param to HTTPAction
To simplify work with jsons and to avoid errors with json arrays
we should add support of request's json param alongside the data
param.

Change-Id: Id866ed13764b1d4db75cf1a819b53a7e8955b34a
Signed-off-by: Oleg Ovcharuk <vgvoleg@gmail.com>
2020-01-23 11:27:00 +03:00
Eyal 947a986a72 Gnocchi: fix client options
Based on https://review.opendev.org/#/c/488307/3

Change-Id: I367926727291f5f21b1849237ca29fdce7e926c0
Closes-Bug: 1707131
2020-01-19 14:26:26 +02:00
Eyal 7f92cc8f5b Fix typo
Change-Id: I8db642afbb637ac21dcd6526dd89039c6840d169
2020-01-19 14:13:52 +02:00
Zuul f1be1dd955 Merge "Update hacking and fix warnings" 2020-01-09 17:23:55 +00:00
Eyal d21cf4a7e7 Designate uses only v2
Was fixed in https://review.opendev.org/#/c/682785/
just fix the comment and the tools

Change-Id: I29acc5c0e50faed1456c8f46fddb835e01bcc0a8
2020-01-06 14:44:25 +02:00
Eyal a0663305e5 Update hacking and fix warnings
Change-Id: I47a17e140f1686e901c67c034105eeec1c421ae7
2020-01-02 17:18:38 +02:00
Dominic Schlegel f6ec559cac adjust doc string to correct key
Change-Id: I194d17b64a953ed0497da02b9ec079a536965668
2019-10-21 09:14:09 +02:00
Eyal b4a46fd1e6 Remove volumes.promote and volumes.reenable action from cinder
They were removed from cinder api see https://review.opendev.org/#/c/658318/
also move to cinder v3 (v2 is deprecated)

Change-Id: I35dd5927465152bb70822638bbaf7573db1220f1
2019-09-26 11:40:10 +03:00
Dmitry Tantsur 0de247948b Pass a real session to ironicclient in _get_fake_client
Using a dict is not guaranteed to work (and actually doesn't with
ironicclient 3.0.0, although a few other things are broken with it).

Change-Id: I59c113b22c60f04e89a631ade8039c4fa62933dc
2019-09-25 14:31:59 +02:00
Renat Akhmerov efc4cf078e Use v2 designate client instead of v1
* Module designateclient.v1 doesn't exist anymore after
  python-designateclient 3.0.0 is out. The new client
  requires a keystone session so all other parameters
  were dropped. Since this service now requires a
  a session the generator test now mocks the method
  _get_fake_client() for this action.
* Minor style changes.

Change-Id: Ida722828e3f1481e08f52257405ddfa2175733fa
2019-09-18 14:42:56 +07:00
Bo Tran 9585a63847 Fix don't work with senlin actions
We can't do run senlin actions because have an error when
init client senlin. We need an other way to init client to
run client with cron trigger and manual.

Change-Id: I294d18b341a3c7dd0df9c24588540f9c94dd4562
Closes-Bug: #1843178
2019-09-12 06:22:51 +00:00
Kien Nguyen 6dfab10e3d Support OpenStack services dynamic versions
Some OpenStack services have a discover_version method [1]
that returned a most recent version supported by API
and client. Mistral should use this method rather than
hardcode API version (manilaclient was done).

[1] https://github.com/openstack/python-novaclient/blob/master/novaclient/api_versions.py#L250

Change-Id: I0459206be5cc390853b9c69e8c5002568d1efa60
2019-09-03 01:25:34 +00:00
Brad P. Crochet b6ebcb3bd0 Use SessionClient for Ironic actions
The HTTPClient for Ironic is deprecated and will be removed in Stein.
Use the SessionClient for Ironic actions instead. Also uses
endpoint_override param instead of endpoint, as that is also
deprecated.

Change-Id: Ida3b502b25887ec9a7b51c4d6497699cc9466f05
2019-07-07 06:10:05 +00:00
apetrich dbc4c91150 Remove deprecated nova commands
novaclient.cert was removed 18 months ago
4bc4078fcb
this commit removes those calls.

Change-Id: Ie5159ba52b6a682e00027ce6bf6d3c5c3f4f1eb9
2019-05-16 16:25:37 +02:00
Zuul 6dcc048725 Merge "Adds private_key parameter in the standard ssh actions" 2019-05-16 06:40:47 +00:00
Jose Castro Leon eb59216281 Removes insecure parameter from barbican client
This removes the parameter insecure in the client creation as this
no longer exists in the client. It also changes the client class
to be called as other clients in openstack using sessions

Change-Id: I3cb7ed4255f8996b8bfd9a3e1edba6de50f4e492
Closes-Bug: #1800819
2019-05-13 06:54:39 +00:00
Jose Castro Leon 7e0f4eeed3 Add back the secrets_store action into mapping.json
This action is not included in the mapping.json and it is required
to retrieve secrets from barbican in the workflows

Change-Id: I68f2a75a30cbafba1dc5cc2ca222483c7b92dca1
Closes-Bug: #1800820
2019-05-13 02:28:51 +00:00
Jose Castro Leon b7107c848f Adds secrets_retrieve to the list of available actions in barbican
This method allows to retrieve the payloads of secrets in the
workflows.

Change-Id: I7d391a6b46ddd4b388c11a69b75f2a2cd7e40384
Closes-Bug: #1800821
2019-05-03 17:42:24 +00:00
Oleg Ovcharuk f9f994751a Add delay option to std.echo to emulate external lags.
Change-Id: Id177246996434d2ad1c111b0b7bf78664390045a
Signed-off-by: Oleg Ovcharuk <vgvoleg@gmail.com>
2019-04-24 07:25:19 +00:00
Zuul 7704797493 Merge "Don't use default mutable parameter" 2019-04-17 06:41:00 +00:00
Eyal 97b493ade6 Don't use default mutable parameter
Using default mutable parameter is bad.
Default parameters are evaluated only once
if you mutate it you will get unexpected results.
Since we don't mutate here the default paramter, make
sure it is unmutable.

Change-Id: Ib5c451a8c8cad7b6c9a009369c1c039563023368
2019-04-15 10:30:34 +03:00
Marc Gariepy 2cbf543103 Add reply-to to std.email
Reply to address is useful when sending email from an unmonitored email
address and to give user a place to respond in order to contact us.

Add Reply-to as described in section 3.6.2 of RFC5222
https://tools.ietf.org/html/rfc5322#section-3.6.2

Change-Id: Ib6b2bdc130e4f9e5170eb88760d69c3e08d2a1c7
2019-04-15 06:35:31 +00:00
Jose Castro Leon 9bbc1d41d0 Adds private_key parameter in the standard ssh actions
This method allows to specify a private key and avoids its storage
in the filesystem of the executors. This can be used later in
combination of a secrets_retrieve to use keys stored in barbican.

Change-Id: Ide438a7f6d24c8bdc9eb2c82e935fd39a6acc2c6
Closes-Bug: #1806703
2018-12-05 08:10:57 +01:00
Thomas Herve ec3d14112c Fix senlin fake client creation
The new openstacksdk mechanism forces a keystone request to find info
about endpoints. We don't need this for fake client, so skip the
__init__ of the class.

Change-Id: I5b0d89ac57c14f982a6afa638f088d365e0e4ab8
2018-11-06 11:52:32 +01:00
apetrich c93b45a61f Remove extra information from std.ssh action
The ssh error message can lead to information leak.
Removing the extra ssh message effects only the CLI call,
the full message is still being logged

Change-Id: I0b28e1cb17d4ce3ae711a25b6eaffb4ebf00ccd6
Closes-Bug: 1783708
2018-09-07 13:54:18 +00:00
Jose Castro Leon 6b4cc9a4a6 Removes non needed parameter passed in magnum client creation
Magnum client instantiation does not need the user_id parameter
coming from the context to do the operations.

Change-Id: I70070aee03671bf04ba4b933039b2c3fbf07c16f
Closes-Bug: #1786480
2018-08-10 15:59:26 +02:00
Zuul 952967a019 Merge "Remove hardcoded usage of v2 authentication in Barbican actions" 2018-08-03 11:03:26 +00:00
Zuul bef9aa5bc3 Merge "Improve std.email action" 2018-07-31 14:32:33 +00:00
Zuul 443cd6fc11 Merge "Support Manila actions in Mistral" 2018-07-31 11:30:40 +00:00
Jose Castro Leon 3c430ef0a2 Improve std.email action
Adds support for cc and bcc addresses to send mails as copy to
administrators and also html formatting. If the html body is specified
the mail will be sent as multipart.

Closes-Bug: #1783349

Change-Id: I2b90354c33052c4b7ae3a98a08e7df1055524a25
2018-07-31 08:43:03 +02:00
PrivateRookie 36050224ee remove invalid todo comment
remove invalid todo comment in std_actions.py, since there is no
need to implement this feature.

Change-Id: I500312bb039260853a4d96a54c3395992947b9d5
Related-Bug:#1676411
2018-07-30 22:37:16 +08:00
Jose Castro Leon a2756a34c2 Support Manila actions in Mistral
Adds manila actions into the available list of actions for mistral

Change-Id: Ic0a3c24f72d91a8a87ffcf81db763058bcbf8566
Closes-Bug: #1783291
2018-07-24 15:11:08 +02:00
Jose Castro Leon 36f28dec45 Remove hardcoded usage of v2 authentication in Barbican actions
There are still some hardcoded v2 authentication in barbican actions.
This api has been deprecated and removed, so we can change it to use
instead v3. It also removes the version number from some helper methods.

Change-Id: I0390daf841463d11cb7c61653897949989b6e6eb
Closes-bug: #1783316
2018-07-24 13:32:07 +02:00
Zuul e788284086 Merge "Return the result of the MistralHTTPAction" 2018-07-20 11:47:52 +00:00
Zuul 41e663411c Merge "modify grammar mistake" 2018-07-16 12:24:05 +00:00
Dougal Matthews 549ec1f3bf Return the result of the MistralHTTPAction
If the HTTP request fails, we need to fail the task. Returning the error
from the parent class will do this. While this means we also return the
success result it will be ignored by the Mistral engine.

Credit to @lijianying10 on GitHub for sending this fix via a pull
request. Tests were then added to verify the change.

Closes-Bug: #1779973
Change-Id: Ib8754c8de2d6677d71383b3793d0fa168be575f5
2018-07-16 11:43:26 +01:00
sunqingliang6 30e3062385 modify grammar mistake
Change-Id: Ibefc994787ddf009afbe685771923f5753731495
2018-07-16 07:47:52 +00:00