Add clustering guides file, Examples code.
Clustering guides add action/eventfile. Clustering examples add action/event example code. Change-Id: I47164b1539d53e51ac915817398ebf85fd8ddb24 Signed-off-by: Yuanbin.Chen <cybing4@gmail.com>
This commit is contained in:
parent
5add422b34
commit
c0b2d084d2
|
@ -15,4 +15,33 @@
|
||||||
Working with Actions
|
Working with Actions
|
||||||
====================
|
====================
|
||||||
|
|
||||||
.. TODO(Qiming): Implement this guide
|
An action is an abstraction of some logic that can be executed by a worker
|
||||||
|
thread. Most of the operations supported by Senlin are executed asynchronously,
|
||||||
|
which means they are queued into database and then picked up by certain worker
|
||||||
|
thread for execution.
|
||||||
|
|
||||||
|
|
||||||
|
List Actions
|
||||||
|
~~~~~~~~~~~~
|
||||||
|
|
||||||
|
To examine the list of actions:
|
||||||
|
|
||||||
|
.. literalinclude:: ../../examples/clustering/action.py
|
||||||
|
:pyobject: list_actions
|
||||||
|
|
||||||
|
When listing actions, you can specify the sorting option using the ``sort``
|
||||||
|
parameter and you can do pagination using the ``limit`` and ``marker``
|
||||||
|
parameters.
|
||||||
|
|
||||||
|
Full example: `manage action`_
|
||||||
|
|
||||||
|
|
||||||
|
Get Action
|
||||||
|
~~~~~~~~~~
|
||||||
|
|
||||||
|
To get a action based on its name or ID:
|
||||||
|
|
||||||
|
.. literalinclude:: ../../examples/clustering/action.py
|
||||||
|
:pyobject: get_action
|
||||||
|
|
||||||
|
.. _manage action: http://git.openstack.org/cgit/openstack/python-openstacksdk/tree/examples/clustering/action.py
|
||||||
|
|
|
@ -15,4 +15,33 @@
|
||||||
Working with Events
|
Working with Events
|
||||||
===================
|
===================
|
||||||
|
|
||||||
.. TODO(Qiming): Implement this guide
|
An event is a record generated during engine execution. Such an event
|
||||||
|
captures what has happened inside the senlin-engine. The senlin-engine service
|
||||||
|
generates event records when it is performing some actions or checking
|
||||||
|
policies.
|
||||||
|
|
||||||
|
|
||||||
|
List Events
|
||||||
|
~~~~~~~~~~~~
|
||||||
|
|
||||||
|
To examine the list of events:
|
||||||
|
|
||||||
|
.. literalinclude:: ../../examples/clustering/event.py
|
||||||
|
:pyobject: list_events
|
||||||
|
|
||||||
|
When listing events, you can specify the sorting option using the ``sort``
|
||||||
|
parameter and you can do pagination using the ``limit`` and ``marker``
|
||||||
|
parameters.
|
||||||
|
|
||||||
|
Full example: `manage event`_
|
||||||
|
|
||||||
|
|
||||||
|
Get Event
|
||||||
|
~~~~~~~~~
|
||||||
|
|
||||||
|
To get a event based on its name or ID:
|
||||||
|
|
||||||
|
.. literalinclude:: ../../examples/clustering/event.py
|
||||||
|
:pyobject: get_event
|
||||||
|
|
||||||
|
.. _manage event: http://git.openstack.org/cgit/openstack/python-openstacksdk/tree/examples/clustering/event.py
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
|
"""
|
||||||
|
Managing policies in the Cluster service.
|
||||||
|
|
||||||
|
For a full guide see
|
||||||
|
https://developer.openstack.org/sdks/python/openstacksdk/user/guides/cluster.html
|
||||||
|
"""
|
||||||
|
|
||||||
|
ACTION_ID = "06ad259b-d6ab-4eb2-a0fa-fb144437eab1"
|
||||||
|
|
||||||
|
|
||||||
|
def list_actions(conn):
|
||||||
|
print("List Actions:")
|
||||||
|
|
||||||
|
for actions in conn.clustering.actions():
|
||||||
|
print(actions.to_dict())
|
||||||
|
|
||||||
|
for actions in conn.clustering.actions(sort='name:asc'):
|
||||||
|
print(actions.to_dict())
|
||||||
|
|
||||||
|
|
||||||
|
def get_action(conn):
|
||||||
|
print("Get Action:")
|
||||||
|
|
||||||
|
action = conn.clustering.get_action(ACTION_ID)
|
||||||
|
print(action.to_dict())
|
|
@ -0,0 +1,37 @@
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
|
"""
|
||||||
|
Managing policies in the Cluster service.
|
||||||
|
|
||||||
|
For a full guide see
|
||||||
|
https://developer.openstack.org/sdks/python/openstacksdk/user/guides/cluster.html
|
||||||
|
"""
|
||||||
|
|
||||||
|
EVENT_ID = "5d982071-76c5-4733-bf35-b9e38a563c99"
|
||||||
|
|
||||||
|
|
||||||
|
def list_events(conn):
|
||||||
|
print("List Events:")
|
||||||
|
|
||||||
|
for events in conn.clustering.events():
|
||||||
|
print(events.to_dict())
|
||||||
|
|
||||||
|
for events in conn.clustering.events(sort='name:asc'):
|
||||||
|
print(events.to_dict())
|
||||||
|
|
||||||
|
|
||||||
|
def get_event(conn):
|
||||||
|
print("Get Event:")
|
||||||
|
|
||||||
|
event = conn.clustering.get_event(EVENT_ID)
|
||||||
|
print(event.to_dict())
|
Loading…
Reference in New Issue