Senlin是针对OpenStack云的集群服务。它创建并操作其他OpenStack服务公开的同类对象的集群。目的是使编排相似对象的过程更容易。

目录

  1. 组件
    1. senlinclient
    2. senlin-dashboard
    3. senlin-api
    4. senlin-engine
  2. 概念
    1. Profile Type
      1. 查看Profile Types
      2. 查看详细Profile Type
      3. 查看Profile Type操作
    2. Profile
      1. 创建Profile
      2. 查看Profiles
      3. 查看详细Profile
      4. 更新Profile
      5. 删除Profile
    3. Cluster
      1. 创建Cluster
        1. 集群容量
        2. 其他属性
      2. 查看Clusters
      3. 查看详细Cluster
      4. 更新Cluster
      5. 调整Cluster大小
        1. capacity
        2. adjustment
        3. percentage
        4. min-step
        5. strict
      6. Cluster伸缩
      7. 检查Cluster
      8. 恢复Cluster
      9. 删除Cluster
    4. Node
      1. 创建Node
      2. 查看Nodes
      3. 查看详细Node
      4. 检查Node
      5. 恢复Node
      6. 更新Node
      7. 生成Node
      8. 删除Node
    5. Cluster Membership
      1. 查看Cluster成员
      2. 增加Cluster成员
      3. 移除Cluster成员
      4. 替换Cluster成员
    6. Policy Type
      1. 查看Policy Types
      2. 查看详细Policy Type
    7. Policy
    8. 创建Policy
      1. 查看Policies
      2. 查看详细Policy
      3. 更新Policy
      4. 删除Policy
    9. Cluster-Policy Binding
      1. 集群绑定策略
      2. 查看集群策略
      3. 查看集群详细策略
      4. 更新集群的策略
      5. 集群解绑策略
    10. Receiver
      1. 创建Receiver
        1. Webhook Receiver
        2. Message Receiver
    11. Action
      1. 查看Actions
      2. 查看详细Action
    12. Event
      1. Event Dispatcher Configuration
      2. 查看Events
      3. 查看详细Event

Senlin与其他OpenStack服务进行交互,以便可以创建和操作这些服务公开的资源集群。这些交互主要通过配置文件插件完成。每个配置文件类型的实现都使Senlin能够创建,更新,删除特定类型的资源。

集群(Cluster)可以与不同的策略(Policy)对象相关联,可以在不同的实施级别上对其进行检查/实施。通过服务API,用户可以动态地将节点(Node)添加到集群中或从集群中删除节点,以及附加和分离策略,例如创建策略,删除策略,负载均衡策略,扩展策略,健康状况策略等。通过与其他OpenStack项目集成,可以使用户更轻松地管理大型资源池的部署和业务流程。

Senlin被设计为能够管理不同类型的对象。使用配置文件类型(Profile Type)实现管理对象的生命周期,这些实现是可以由服务引擎动态加载的插件。

组件

senlinclient

senlinclient软件包为openstackclient工具提供了一个插件,因此您具有命令行界面,可与senlin-api通信以管理集群,节点,配置文件,策略,操作(Action)和事件(Event)。

senlin-dashboard

senlin-dashboard是一个Horizo​​n插件,可为Senlin提供UI。

senlin-api

senlin-api组件提供了OpenStack本机REST API,该API通过RPC将API请求发送到senlin-engine来处理API请求。

senlin-engine

senlin-engine的主要职责是创建和编排集群,节点,配置文件和策略。

概念

Profile Type

配置文件类型(Profile Type)可以视为配置文件(Profile)对象的元类型。启动senlin-engine时,Profile Type的注册表会建立在内存中。未来,Senlin将允许用户提供其他配置文件类型的实现,作为可动态加载的插件。

Profile Type的实现指出需要哪些字段。通过引用此Profile Type创建Profile时,将为字段分配具体值。

查看Profile Types

查看Senlin服务器支持的Profile Type的列表。

1
openstack cluster profile type list
查看详细Profile Type

每个Profile Type都有一个用于其规范的架构,该架构描述了可以接受的名称和属性类型。要显示特定Profile Type的架构以及其他属性,可以使用下面的命令。

os.heat.stack

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
openstack cluster profile type show os.heat.stack-1.0

support_status:
'1.0':
- since: '2016.04'
status: SUPPORTED
id: os.heat.stack-1.0
location:
cloud: ''
project:
domain_id: null
domain_name: Default
id: f52380b8eb5345f0a568a186a5a832a5
name: admin
region_name: RegionOne
zone: null
name: os.heat.stack-1.0
schema:
context:
default: {}
description: A dictionary for specifying the customized context for stack operations.
required: false
type: Map
updatable: false
disable_rollback:
default: true
description: A boolean specifying whether a stack operation can be rolled back.
required: false
type: Boolean
updatable: true
environment:
default: {}
description: A map that specifies the environment used for stack operations.
required: false
type: Map
updatable: true
files:
default: {}
description: Contents of files referenced by the template, if any.
required: false
type: Map
updatable: true
parameters:
default: {}
description: Parameters to be passed to Heat for stack operations.
required: false
type: Map
updatable: true
template:
default: {}
description: Heat stack template.
required: false
type: Map
updatable: true
template_url:
default: ''
description: Heat stack template url.
required: false
type: String
updatable: true
timeout:
description: A integer that specifies the number of minutes that a stack operation
times out.
required: false
type: Integer
updatable: true

os.nova.server

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
openstack cluster profile type show os.nova.server-1.0

support_status:
'1.0':
- since: '2016.04'
status: SUPPORTED
id: os.nova.server-1.0
location:
cloud: ''
project:
domain_id: null
domain_name: Default
id: f52380b8eb5345f0a568a186a5a832a5
name: admin
region_name: RegionOne
zone: null
name: os.nova.server-1.0
schema:
admin_pass:
description: Password for the administrator account.
required: false
type: String
updatable: false
auto_disk_config:
default: true
description: Whether the disk partition is done automatically.
required: false
type: Boolean
updatable: false
availability_zone:
description: Name of availability zone for running the server.
required: false
type: String
updatable: false
block_device_mapping_v2:
description: A list specifying the properties of block devices to be used for
this server.
required: false
schema:
'*':
description: A map specifying the properties of a block device to be used
by the server.
required: false
schema:
boot_index:
description: Define the boot order of the device
required: false
type: Integer
updatable: false
delete_on_termination:
description: Whether to delete the volume when the server stops.
required: false
type: Boolean
updatable: false
destination_type:
description: Volume destination type, must be 'volume' or 'local'
required: true
type: String
updatable: false
device_name:
description: Name of the device(e.g. vda, xda, ....).
required: false
type: String
updatable: false
device_type:
description: Type of the device(e.g. disk, cdrom, ...).
required: false
type: String
updatable: false
disk_bus:
description: Bus of the device.
required: false
type: String
updatable: false
guest_format:
description: Specifies the disk file system format(e.g. swap, ephemeral,
...).
required: false
type: String
updatable: false
source_type:
description: Volume source type, must be one of 'image', 'snapshot', 'volume'
or 'blank'
required: true
type: String
updatable: false
uuid:
description: ID of the source image, snapshot or volume
required: false
type: String
updatable: false
volume_size:
description: Size of the block device in MB(for swap) and in GB(for other
formats)
required: true
type: Integer
updatable: false
type: Map
updatable: false
type: List
updatable: false
config_drive:
description: Whether config drive should be enabled for the server.
required: false
type: Boolean
updatable: false
context:
description: Customized security context for operating servers.
required: false
type: Map
updatable: false
flavor:
description: ID of flavor used for the server.
required: true
type: String
updatable: true
image:
description: ID of image to be used for the new server.
required: false
type: String
updatable: true
key_name:
description: Name of Nova keypair to be injected to server.
required: false
type: String
updatable: false
metadata:
description: A collection of key/value pairs to be associated with the server
created. Both key and value must be <=255 chars.
required: false
type: Map
updatable: true
name:
description: Name of the server. When omitted, the node name will be used.
required: false
type: String
updatable: true
networks:
description: List of networks for the server.
required: false
schema:
'*':
description: A map specifying the properties of a network for uses.
required: false
schema:
fixed_ip:
description: Fixed IP to be used by the network.
required: false
type: String
updatable: false
floating_ip:
description: The floating IP address to be associated with this port.
required: false
type: String
updatable: false
floating_network:
description: The network on which to create a floating IP
required: false
type: String
updatable: false
network:
description: Name or ID of network to create a port on.
required: false
type: String
updatable: false
port:
description: Port ID to be used by the network.
required: false
type: String
updatable: false
security_groups:
description: A list of security groups to be attached to this port.
required: false
schema:
'*':
description: Name of a security group
required: true
type: String
updatable: false
type: List
updatable: false
type: Map
updatable: false
type: List
updatable: true
personality:
description: List of files to be injected into the server, where each.
required: false
schema:
'*':
description: A map specifying the path & contents for an injected file.
required: false
schema:
contents:
description: Contents of the file to be injected.
required: true
type: String
updatable: false
path:
description: In-instance path for the file to be injected.
required: true
type: String
updatable: false
type: Map
updatable: false
type: List
updatable: false
scheduler_hints:
description: A collection of key/value pairs to be associated with the Scheduler
hints. Both key and value must be <=255 chars.
required: false
type: Map
updatable: false
security_groups:
description: List of security groups.
required: false
schema:
'*':
description: Name of a security group
required: true
type: String
updatable: false
type: List
updatable: false
user_data:
description: User data to be exposed by the metadata server.
required: false
type: String
updatable: false

container.dockerinc.docker

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
openstack cluster profile type show container.dockerinc.docker-1.0
support_status:
'1.0':
- since: '2017.02'
status: EXPERIMENTAL
id: container.dockerinc.docker-1.0
location:
cloud: ''
project:
domain_id: null
domain_name: Default
id: f52380b8eb5345f0a568a186a5a832a5
name: admin
region_name: RegionOne
zone: null
name: container.dockerinc.docker-1.0
schema:
command:
description: The command to run when container is started.
required: false
type: String
updatable: false
context:
description: Customized security context for operating containers.
required: false
type: Map
updatable: false
host_cluster:
description: The cluster on which container will be launched.
required: false
type: String
updatable: false
host_node:
description: The node on which container will be launched.
required: false
type: String
updatable: false
image:
description: The image used to create a container
required: true
type: String
updatable: false
name:
description: The name of the container.
required: false
type: String
updatable: true
port:
default: 2375
description: The port number used to connect to docker daemon.
required: false
type: Integer
updatable: false

  • default:未明确指定时属性的默认值。
  • description:属性的文字描述。
  • required:是否必须指定属性。这种属性通常没有默认值。
  • type:String, Integer, Boolean, Map或者List
  • updatable:属性是否可更新。
查看Profile Type操作

查看Profile Type支持的操作。

os.heat.stack

1
2
3
4
5
6
7
8
openstack cluster profile type ops os.heat.stack-1.0

operations:
abandon:
description: Abandon a heat stack node.
required: false
type: Map
updatable: false

os.nova.server

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
openstack cluster profile type ops os.nova.server-1.0                                                 

operations:
change_password:
description: Change the administrator password.
parameters:
admin_pass:
description: New password for the administrator.
required: false
type: String
evacuate:
description: Evacuate the server to a different host.
parameters:
force:
description: Whether the evacuation should be a forced one.
required: false
type: String
host:
description: The target host to evacuate the server.
required: false
type: String
lock:
description: Lock the server.
parameters: {}
pause:
description: Pause the server from running.
parameters: {}
reboot:
description: Reboot the nova server.
parameters:
type:
constraints:
- constraint:
- SOFT
- HARD
type: AllowedValues
default: SOFT
description: Type of reboot which can be 'SOFT' or 'HARD'.
required: false
type: String
rebuild:
description: Rebuild the server using current image and admin password.
parameters: {}
rescue:
description: Rescue the server.
parameters:
image_ref:
description: A string referencing the image to use.
required: false
type: String
resume:
description: Resume the running of the server.
parameters: {}
start:
description: Start the server.
parameters: {}
stop:
description: Stop the server.
parameters: {}
suspend:
description: Suspend the running of the server.
parameters: {}
unlock:
description: Unlock the server.
parameters: {}
unpause:
description: Unpause the server to running state.
parameters: {}
unrescue:
description: Unrescue the server.
parameters: {}

container.dockerinc.docker

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
openstack cluster profile type ops container.dockerinc.docker-1.0                                     

operations:
pause:
description: Pause a container.
parameters: {}
restart:
description: Restart a container.
parameters:
wait_time:
description: Number of seconds to wait before killing the container.
required: false
type: Integer
unpause:
description: Unpause a container.
parameters: {}
  • description:属性的文字描述。
  • required:是否必须指定属性。这种属性通常没有默认值。
  • type:String, Integer, Boolean, Map或者List
  • updatable:属性是否可更新。

Profile

配置文件(Profile)是用于创建节点(Node)的模型,可以将其视为具有唯一ID的Profile Type的实例。Profile在名为spec的属性中编码创建节点所需的信息。

Profile Type实现的主要工作是将用户提供的JSON数据结构转换为驱动程序可以使用的信息。驱动程序将根据提供的信息创建/删除/更新物理对象。

创建Profile

在使用集群(Cluster)或节点(Node)之前,您将需要使用配置文件类型(Profile Type)创建的配置文件(Profile)对象。要创建配置文件,您将需要YAML格式的spec文件。

1
2
3
4
5
6
7
8
# /examples/profiles/heat_stack/random_string/ heat_stack_random_string.yaml
type: os.heat.stack
version: 1.0
properties:
name: random_string_stack
template: random_string_template.yaml
context:
region_name: RegionOne

random_string_template.yaml

1
2
3
4
5
6
7
8
9
10
11
12
13
heat_template_version: 2014-10-16
parameters:
str_length:
type: number
default: 64
resources:
random:
type: OS::Heat::RandomString
properties:
length: {get_param: str_length}
outputs:
result:
value: {get_attr: [random, value]}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
openstack cluster profile create --spec heat_stack_random_string.yaml my_stack

+------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field | Value |
+------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| created_at | 2019-09-25T08:02:43Z |
| domain_id | None |
| id | ba4295d7-6800-4db4-8fe8-43ea978c91f9 |
| location | Munch({'project': Munch({'domain_id': None, 'id': u'f52380b8eb5345f0a568a186a5a832a5', 'name': 'admin', 'domain_name': 'Default'}), 'cloud': '', 'region_name': 'RegionOne', 'zone': None}) |
| metadata | {} |
| name | my_stack |
| project_id | f52380b8eb5345f0a568a186a5a832a5 |
| spec | +------------+---------------------------------------------+ |
| | | property | value | |
| | +------------+---------------------------------------------+ |
| | | properties | { | |
| | | | "files": {}, | |
| | | | "disable_rollback": true, | |
| | | | "template": { | |
| | | | "outputs": { | |
| | | | "result": { | |
| | | | "value": { | |
| | | | "get_attr": [ | |
| | | | "random", | |
| | | | "value" | |
| | | | ] | |
| | | | } | |
| | | | } | |
| | | | }, | |
| | | | "heat_template_version": "2014-10-16", | |
| | | | "resources": { | |
| | | | "random": { | |
| | | | "type": "OS::Heat::RandomString", | |
| | | | "properties": { | |
| | | | "length": { | |
| | | | "get_param": "str_length" | |
| | | | } | |
| | | | } | |
| | | | } | |
| | | | }, | |
| | | | "parameters": { | |
| | | | "str_length": { | |
| | | | "default": 64, | |
| | | | "type": "number" | |
| | | | } | |
| | | | } | |
| | | | }, | |
| | | | "parameters": {}, | |
| | | | "timeout": 60, | |
| | | | "environment": {}, | |
| | | | "context": { | |
| | | | "region_name": "RegionOne" | |
| | | | } | |
| | | | } | |
| | | type | os.heat.stack | |
| | | version | 1.0 | |
| | +------------+---------------------------------------------+ |
| type | os.heat.stack-1.0 |
| updated_at | None |
| user_id | c1bb613f1ece4654b488c65fc0f62df8 |
+------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

(可选)可以在创建新配置文件(Profile)时将一些键值对附加到新配置文件(Profile)。此数据称为配置文件的元数据(metadata)。

1
2
3
4
5
6
7
8
9
openstack cluster profile create \
--spec heat_stack_random_string.yaml \
--metadata "author=King;version=1.0" \
my_stack

openstack cluster profile create \
--spec heat_stack_random_string.yaml \
--metadata author=King --metadata version=1.0 \
my_stack
查看Profiles

查看创建的Profile列表。

1
openstack cluster profile list
查看详细Profile
1
openstack cluster profile show my_stack
更新Profile

更新Profile的名称。

1
openstack cluster profile update --name new_stack my_stack

更新或者创建元数据(metadata)。

1
openstack cluster profile update --metadata version=2.2 my_stack

不允许更改配置文件的spec
进行更改的唯一方法是使用profile create子命令来创建新的配置文件。

删除Profile
1
openstack cluster profile delete my_stack

Cluster

集群(Cluster)是一组逻辑对象,每个逻辑对象在Senlin的术语中称为节点(Node)。集群可以包含零个或多个节点。集群的profile_id属性,指定在创建/扩展新节点作为集群成员时使用的默认配置文件(Profile)。对于集群中的节点来说,拥有不同的配置文件对象是有效的,因为Senlin仅要求集群中的所有节点都具有相同的配置文件类型(Profile Type)。

创建Cluster
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
openstack cluster create --profile my_stack my_cluster                                                

+------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field | Value |
+------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| config | {} |
| created_at | None |
| data | {} |
| dependents | {} |
| desired_capacity | 0 |
| domain_id | None |
| id | eb5843d4-18c7-465f-bf65-76693f617f51 |
| init_at | 2019-09-25T09:20:40Z |
| location | Munch({'project': Munch({'domain_id': None, 'id': u'f52380b8eb5345f0a568a186a5a832a5', 'name': 'admin', 'domain_name': 'Default'}), 'cloud': '', 'region_name': 'RegionOne', 'zone': None}) |
| max_size | -1 |
| metadata | {} |
| min_size | 0 |
| name | my_cluster |
| node_ids | |
| profile_id | ba4295d7-6800-4db4-8fe8-43ea978c91f9 |
| profile_name | my_stack |
| project_id | f52380b8eb5345f0a568a186a5a832a5 |
| status | INIT |
| status_reason | Initializing |
| timeout | 3600 |
| updated_at | None |
| user_id | c1bb613f1ece4654b488c65fc0f62df8 |
+------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

从输出中,可以看到一个新的集群对象已创建并处于INIT状态。Senlin将验证使用--profile选项指定的配置文件是否存在。服务器允许值是配置文件名称,配置文件ID或配置文件对象的短ID。

集群容量

创建集群时,默认情况下senlin将创建一个没有节点的集群,即desired_capacity将设置为0。但是,可以指定集群的所需容量,集群的最大和最小。min_size的默认值为0,max_size的默认值为**-1**,这意味着集群大小没有上限。

创建一个集群,其所需容量设置为2,最小大小设置为1,最大大小设置为3。

1
2
3
4
openstack cluster create --desired-capacity 2 \
--min-size 1 --max-size 3 \
--profile my_stack \
my_cluster

当未指定desired_capacity并且未指定min_size时,senlin-engine将创建一个空集群。
当指定了required_capacity集群容量或min_size时,Senlin将在创建集群对象后立即开始创建节点的过程。

其他属性

可以使用--metadata(或-M)选项将某些键值对与要创建的集群相关联。这些数据称为集群的元数据(metadata)。

由于集群操作在执行时可能需要一些时间才能完成,并且Senlin与后端服务进行交互才能实现,因此需要一种方法来验证操作是否超时。创建集群时,可以使用--timeout选项,以秒为单位指定默认超时时间。该值将是集群的全局设置。

可以使用选项--config将键值对传递给要创建的集群。支持以下配置属性:

  • node.name.format:指定如何自动命名集群节点。该值可以包含占位符,例如**$nI用于在节点索引的左边填充n个零,或$nR**用于长度为n的随机字符串。
  • cluster.stop_node_before_delete:如果设置为True,则导致节点删除的集群操作(调整大小等)将首先请求节点停止。成功关闭节点后,将删除该节点。默认设置为False,集群将在不停止该节点的情况下执行节点删除。
查看Clusters

查看创建的集群列表。

1
openstack cluster list
查看详细Cluster
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
openstack cluster show my_cluster

+------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field | Value |
+------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| config | {} |
| created_at | 2019-09-25T09:20:40Z |
| data | {} |
| dependents | {} |
| desired_capacity | 0 |
| domain_id | None |
| id | eb5843d4-18c7-465f-bf65-76693f617f51 |
| init_at | 2019-09-25T09:20:40Z |
| location | Munch({'project': Munch({'domain_id': None, 'id': u'f52380b8eb5345f0a568a186a5a832a5', 'name': 'admin', 'domain_name': 'Default'}), 'cloud': '', 'region_name': 'RegionOne', 'zone': None}) |
| max_size | -1 |
| metadata | {} |
| min_size | 0 |
| name | my_cluster |
| node_ids | |
| profile_id | ba4295d7-6800-4db4-8fe8-43ea978c91f9 |
| profile_name | my_stack |
| project_id | f52380b8eb5345f0a568a186a5a832a5 |
| status | ACTIVE |
| status_reason | CLUSTER_CREATE: number of active nodes is equal or above desired_capacity (0). |
| timeout | 3600 |
| updated_at | 2019-09-25T09:20:40Z |
| user_id | c1bb613f1ece4654b488c65fc0f62df8 |
+------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

从结果中,可以检查属于该集群的节点的列表。

更新Cluster

修改集群的名称。

1
openstack cluster update --name test_cluster my_cluster

使用选项--timeout更改timeout属性。您可以使用选项--metadata更改与集群关联的元数据。

更改集群及其成员节点使用的配置文件。

1
openstack cluster update --profile fedora21_server web_cluster

假设集群web_cluster现在使用的是os.nova.server类型的配置文件,其中使用了Fedora 20的镜像,则上述命令将启动全局升级到使用Fedora 21的镜像的新配置文件。

调整Cluster大小
capacity

--capacity,将集群调整为指定的大小。
将集群test_cluster的大小调整为2个节点,前提是min_size不大于2,并且max_size不小于2或等于-1(指示集群大小没有上限)。

1
openstack cluster resize --capacity 2 my_cluster
adjustment

--adjustment,向集群添加指定数量的节点,或者从集群中删除指定数量的节点。(正数表示增加,负数表示删除)
将两个节点添加到指定的集群:

1
openstack cluster resize --adjustment 2 my_cluster

从指定的集群中删除2个节点:

1
openstack cluster resize --adjustment 2 my_cluster
percentage

--percentage,以指定百分比调整集群的大小。(正数表示扩大,负数表示缩小)

senlin-engine会根据集群的当前大小,指定的百分比值,约束条件(即min_sizemax_size属性)计算要添加或删除的实际节点数。

将集群大小增加30%:

1
openstack cluster resize --percentage 30 my_cluster

将集群大小减少25%:

1
openstack cluster resize --percentage 25 my_cluster
min-step

如果因某些限制而无法完全实现调整大小操作,则可以请求根据最大努力进行大小更改,**-–min-step**告诉senlin-engine是否仍然希望部分实现调整大小操作。

strict

如果指定了--strict选项,Senlin将严格遵守集群大小限制。如果容量值超出范围,则该请求将被拒绝。当--strict设置为False时(默认为False),senlin-engine将尽力调整大小。

假设有一个集群A,其min_size设置为5,当前大小为7。如果新的容量值为4,选项--strict设置为True,则该请求将被拒绝,并显示一条错误消息。如果新的容量值为4,并且未设置选项--strict,Senlin将尝试将群集的大小调整为5个节点。

调整大小时,可以同时调整集群的min_sizemax_size属性。

在计算集群的新容量时,senlin-engine将根据以下规则确定值:

  • 如果新容量的值大于1.0或小于-1.0,则将四舍五入为值的整数部分。例如,将3.4舍入为3,-1.9将舍入为-1;
  • 如果新容量的值在0到1之间,Senlin会将其向上舍入为1。
  • 如果新容量的值在0到-1之间,Senlin会将其舍入到-1;
  • 除非指定了--strict选项,否则新容量应在min_sizemax_size范围内(包括两端)。
  • 如果未给出min_sizemax_size的新值,则将根据当前大小约束执行范围检查,否则,Senlin将首先验证新大小约束并针对新约束执行范围检查;
  • 如果指定了选项--min-step,则当新容量值的绝对值小于<**MIN_STEP**>时,将使用<**MIN_STEP**>值。
Cluster伸缩

向集群添加两个节点:

1
openstack cluster expand --count 2 my_cluster

从集群中删除两个节点:

1
openstack cluster shrink --count 2 my_cluster

参数<COUNT>,是一个正整数,表示要添加或删除的节点数。
选项--count是可选的。如果指定此选项,即使有附加的扩展策略,Senlin仍将使用它来更改群集大小。但是,如果忽略此选项,Senlin会将其视为隐式设置为值1。

检查Cluster

属于指定集群的所有节点将执行检查操作。如果节点的物理资源不是ACTIVE,则节点状态将作为检查操作的一部分进行更改。

1
openstack cluster check my_cluster
恢复Cluster

恢复集群。

1
openstack cluster recover my_cluster --check true

选项--check是可选的。如果设置此选项,群集将在执行恢复之前执行检查操作。
还原操作将从指定的群集中删除节点并重新创建它。

删除Cluster

删除集群。

1
openstack cluster delete my_cluster

当集群中有节点时,senlin-engine将启动一个进程,以从集群中删除所有节点并销毁它们,然后再删除集群对象本身。

Node

节点(Node)是由Senlin服务管理的逻辑对象。一个节点在任何时候最多只能是一个集群的成员。一个节点可以是孤立节点,这意味着它不属于任何群集。

创建Node

创建节点时,该节点具有profile_id属性,该属性指定在创建支持该节点的物理对象时要使用哪个Profile。所以在创建节点时,需要指定要使用的Profile的ID或名称。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
openstack cluster node create --profile my_stack my_node

+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field | Value |
+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| cluster_id | |
| created_at | None |
| data | {} |
| dependents | {} |
| details | None |
| domain_id | None |
| id | 21b3e7dd-9f7f-4dea-93a0-9d03eb7b1236 |
| index | -1 |
| init_at | 2019-09-26T03:58:12Z |
| location | Munch({'project': Munch({'domain_id': None, 'id': u'f52380b8eb5345f0a568a186a5a832a5', 'name': 'admin', 'domain_name': 'Default'}), 'cloud': '', 'region_name': 'RegionOne', 'zone': None}) |
| metadata | {} |
| name | my_node |
| physical_id | None |
| profile_id | ba4295d7-6800-4db4-8fe8-43ea978c91f9 |
| profile_name | my_stack |
| project_id | f52380b8eb5345f0a568a186a5a832a5 |
| role | |
| status | INIT |
| status_reason | Initializing |
| updated_at | None |
| user_id | c1bb613f1ece4654b488c65fc0f62df8 |
+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

新节点的索引属性为-1。这是因为为节点指定所属集群。
可以使用命令openstack cluster member add在节点创建后,为集群添加成员
当节点成为集群的成员时,它将为其索引属性获取一个值,该值可在所属集群中唯一标识其自身。

在创建节点时指定拥有的集群:

1
openstack cluster node create --profile my_stack --cluster my_cluster my_node

当指定拥有的群集时,senlin-engine将验证指定的群集Profile Type与新节点的Profile Type是否相同。如果配置文件类型不匹配,将会收到一个错误信息。

创建新节点时,可能会用到的另一个参数是--role选项。
创建一个主节点:

1
openstack cluster node create --profile my_stack --cluster my_cluster --role master master_node

创建新节点时,可以指定的最后一个参数是--metadata选项。此选项的值是由分号(’;’)分隔的键值对的列表。这些键值对附加到节点,并且可以用于任何目的。

1
openstack cluster node create --profile my_stack --metadata owner=King my_node
查看Nodes

查看节点列表。

查看详细Node

查看节点详细信息。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
openstack cluster node show node-TDqkLXqv                                                            

+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field | Value |
+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| cluster_id | eb5843d4-18c7-465f-bf65-76693f617f51 |
| created_at | 2019-09-26T06:19:55Z |
| data | {} |
| dependents | {} |
| details | None |
| domain_id | None |
| id | 2549b4ad-d29d-4a67-8bf3-c803538241d5 |
| index | 4 |
| init_at | 2019-09-26T06:19:49Z |
| location | Munch({'project': Munch({'domain_id': None, 'id': u'f52380b8eb5345f0a568a186a5a832a5', 'name': 'admin', 'domain_name': 'Default'}), 'cloud': '', 'region_name': 'RegionOne', 'zone': None}) |
| metadata | {} |
| name | node-TDqkLXqv |
| physical_id | 7ceed7f7-84d3-44da-a767-95651602c5a3 |
| profile_id | ba4295d7-6800-4db4-8fe8-43ea978c91f9 |
| profile_name | my_stack |
| project_id | f52380b8eb5345f0a568a186a5a832a5 |
| role | master |
| status | ACTIVE |
| status_reason | Creation succeeded |
| updated_at | 2019-09-26T06:19:55Z |
| user_id | c1bb613f1ece4654b488c65fc0f62df8 |
+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

+---------------+------------------------------------------------+
| Field | Value |
+---------------+------------------------------------------------+
| cluster_id | |
| created_at | None |
| data | {} |
| dependents | {} |
| details | None |
| domain_id | None |
| id | 21b3e7dd-9f7f-4dea-93a0-9d03eb7b1236 |
| index | -1 |
| init_at | 2019-09-26T03:58:12Z |
| location | None |
| metadata | {} |
| name | my_node |
| physical_id | None |
| profile_id | ba4295d7-6800-4db4-8fe8-43ea978c91f9 |
| profile_name | my_stack |
| project_id | f52380b8eb5345f0a568a186a5a832a5 |
| role | |
| status | INIT |
| status_reason | Initializing |
| updated_at | None |
| user_id | c1bb613f1ece4654b488c65fc0f62df8 |
+---------------+------------------------------------------------+

从输出中,可以看到节点的physical_id(如果已成功创建)。对于不同的配置文件类型,此值可以是某种类型的对象的ID。例如,如果使用的配置文件类型为os.heat.stack,则表示Heat Stack ID;如果使用的配置文件类型是os.nova.server,则将给出Nova虚机ID。

选项--details指定后,将得到有关支持该节点的物理对象的详细信息。

1
openstack cluster node show --details node-TDqkLXqv
检查Node

senlin-engine执行特定于配置文件的检查操作,以获取物理资源(例如虚拟机)的最新状态。如果虚拟机状态不是ACTIVE,则该节点将设置为ERROR状态。

1
openstack cluster node check my_node
恢复Node

创建节点并运行一段时间后,如果该节点进入ERROR状态,则可以使用命令尝试将其恢复为ACTIVE状态。恢复操作将删除指定的节点并重新创建它。

1
openstack cluster node recover my_node
更新Node

更新节点名称。

1
openstack cluster node update --name new_node_name old_node_name

更改节点角色。

1
openstack cluster node update --role slave master_node

更新元数据。

1
openstack cluster node update --metadata version=2.1 my_node

更改节点的Profile。

1
openstack cluster node update --profile fedora21_server fedora20_server

假设节点fedora20_server现在使用的是os.nova.server类型的配置文件,其中使用了Fedora 20镜像,经过上述命令,该节点将使用新的配置文件和Fedora 21镜像。

生成Node

在Senlin服务中,我们可以采用现有资源作为节点,并为此节点创建配置文件。要生成节点,您需要通过设置--identity来指定物理资源ID和设置–type来指定配置文件类型(Profile Type)。

1
2
3
4
openstack cluster node adopt 
--identity 1177c8e8-8472-4e9d-8f15-1d4866b85b8b \
--type os.nova.server-1.0 \
--name test_adopt_node

--name是可选的,如果省略,senlin-engine将为该节点生成一个以node-开头的随机名称。
--role--metadata和创建节点时使用一致。

--overrides支持用户可以覆盖节点的配置文件(Profile)的属性。

1
2
3
4
openstack cluster node adopt 
--identity 1177c8e8-8472-4e9d-8f15-1d4866b85b8b \
--type os.nova.server-1.0 \
--override '{"networks":[{"network": "public"}]}'

--snapshot选项是布尔类型。如果设置,senlin-engine将在接受资源作为节点之前为资源创建快照。

预览要生成的节点。要预览节点,您需要通过设置--identity来指定资源物理ID,并通过设置--type来指定资源Profile Type名称。

1
2
3
4
openstack cluster node adopt 
--identity 1177c8e8-8472-4e9d-8f15-1d4866b85b8b \
--type os.nova.server-1.0 \
--preview
删除Node

删除节点。

1
openstack cluster node delete my_node

Cluster Membership

一个节点在任何时候最多可以属于一个集群。一个节点不属于任何群集时,称为孤立节点。创建节点时,可以使其成为集群的成员,也可以在创建集群和节点之后更改集群成员资格。

查看Cluster成员
1
openstack cluster members list my_cluster
增加Cluster成员
1
openstack cluster members add --nodes node3,node4 my_cluster
移除Cluster成员
1
openstack cluster members del --nodes node21,node22 my_cluster

从集群中删除节点后,它们的索引属性将重置为-1。

替换Cluster成员

用node22替换node21。

1
openstack cluster members replace --nodes node21=node22 my_cluster

执行此操作时,senlin-engine将检查替换的节点是否是指定集群的成员。如果指定节点列表中的任何节点都不属于目标群集,则将收到错误消息,命令将失败。

Policy Type

策略类型(Policy Type)是在包含特定配置文件类型(Profile Type)的节点的集群上,执行特定操作时要检查和执行的规则的规范。

启动senlin-engine时,策略类型的注册表会建立在内存中。未来,Senlin将允许用户提供其他策略类型的实现,作为可动态加载的插件。

策略类型的实现指明哪些字段是必需的,哪些字段是可选的,有时还会限制字段值。通过引用此策略类型创建策略时,将为这些字段分配具体值。例如,策略类型senlin.policy.deletion所需的属性:

1
2
3
4
criteria: String # valid values - OLDEST_FIRST, YOUNGEST_FIRST, RANDOM
destroy_after_deletion: Boolean
grace_period: Integer
reduce_desired_capacity: Boolean

此策略类型的策略对象的规范可能如下所示:

1
2
3
4
5
6
7
type: senlin.policy.deletion
version: 1.0
properties:
criteria: OLDEST_FIRST
destroy_after_deletion: True
grace_period: 120
reduce_desired_capacity: True
查看Policy Types
1
openstack cluster policy type list
查看详细Policy Type

查看Policy Type详细信息。

1
openstack cluster policy type show senlin.policy.health-1.0

Policy

策略(Policy)是从策略类型(Policy Type)实例化的对象。创建之后,就可以将其动态附加到集群或从集群分离。策略通常包含要执行或已经执行某些动作时要检查和强制实施的规则。

一个策略可以附加到许多集群,而一个集群可以附加许多策略。除此之外,还可以动态启用或禁用集群上的策略。

创建Policy

创建新的策略对象时,需要YAML格式的spec文件。还可能需要查看策略类型(Policy Type)中的属性名称和特定的策略类型。

examples/policies/deletion_policy.yaml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# Sample deletion policy that can be attached to a cluster.
type: senlin.policy.deletion
version: 1.0
description: A policy for choosing victim node(s) from a cluster for deletion.
properties:
# The valid values include:
# OLDEST_FIRST, OLDEST_PROFILE_FIRST, YOUNGEST_FIRST, RANDOM
criteria: OLDEST_FIRST

# Whether deleted node should be destroyed
destroy_after_deletion: True

# Length in number of seconds before the actual deletion happens
# This param buys an instance some time before deletion
grace_period: 60

# Whether the deletion will reduce the desired capacity of
# the cluster as well
reduce_desired_capacity: False

创建Policy

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
openstack cluster policy create --spec deletion_policy.yaml my_policy

+------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field | Value |
+------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| created_at | 2019-09-27T02:17:12.000000 |
| data | {} |
| domain_id | None |
| id | 53d08309-236e-4e49-87b1-a913077b6c79 |
| location | Munch({'project': Munch({'domain_id': None, 'id': u'f52380b8eb5345f0a568a186a5a832a5', 'name': 'admin', 'domain_name': 'Default'}), 'cloud': '', 'region_name': 'RegionOne', 'zone': None}) |
| name | delete_policy |
| project_id | f52380b8eb5345f0a568a186a5a832a5 |
| spec | { |
| | "version": 1.0, |
| | "type": "senlin.policy.deletion", |
| | "description": "A policy for choosing victim node(s) from a cluster for deletion.", |
| | "properties": { |
| | "destroy_after_deletion": true, |
| | "grace_period": 60, |
| | "reduce_desired_capacity": false, |
| | "criteria": "OLDEST_FIRST" |
| | } |
| | } |
| type | senlin.policy.deletion-1.0 |
| updated_at | None |
| user_id | c1bb613f1ece4654b488c65fc0f62df8 |
+------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
查看Policies

查看Policy列表。

1
openstack cluster policy list
查看详细Policy

查看Policy的详细信息。

1
openstack cluster policy show delete_policy
更新Policy

更改Policy的名称。

1
openstack cluster policy update --name my_policy delete_policy
删除Policy
1
openstack cluster policy delete delete_policy

Cluster-Policy Binding

可以同时将策略对象(Policy)附加到至少一个集群(Cluster)。集群在任何时候都可以连接多个策略对象。将策略对象附加到群集后,仍然可以启用或禁用它,或更新策略对象的某些属性。

集群绑定策略

Senlin允许将策略对象附加到集群,并动态地将其与集群分离。将策略对象附加到集群时,可以自定义特定集群的策略属性。

1
openstack cluster policy attach --policy delete_policy --enabled False my_cluster

--enabled:布尔值,指示绑定的策略是否要启用。

请注意,在大多数情况下,Senlin不允许将多个相同类型的策略附加到同一群集。对于某些策略类型,此限制已放宽。例如,在使用有关扩展的策略时,实际上可以将多个策略实例附加到同一群集,每个实例都与特定场景有关。

查看集群策略

查看指定集群的策略列表。

1
openstack cluster policy binding list my_cluster
查看集群详细策略

查看指定集群的指定策略的详细信息。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
openstack cluster policy binding show  --policy delete_policy my_cluster

+--------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field | Value |
+--------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| cluster_name | my_cluster |
| data | None |
| id | fbeef144-dae1-48c1-a78a-1d839fbccff9 |
| is_enabled | False |
| location | Munch({'project': Munch({'domain_id': None, 'id': u'f52380b8eb5345f0a568a186a5a832a5', 'name': 'admin', 'domain_name': 'Default'}), 'cloud': '', 'region_name': 'RegionOne', 'zone': None}) |
| name | None |
| policy_id | 53d08309-236e-4e49-87b1-a913077b6c79 |
| policy_name | delete_policy |
| policy_type | senlin.policy.deletion-1.0 |
+--------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
更新集群的策略

更新指定集群的策略信息。

1
2
3
openstack cluster policy binding update \
--enabled True \
--policy my_delete my_cluster
集群解绑策略
1
openstack cluster policy detach --policy my_delete mycluster

Receiver

接收器(Receiver)用于使senlin-engine准备好对外部警报或事件做出反应,以便可以在集群上自动启动特定的操作。例如,当集群上的负载上升时,Receiver可以更改指定集群的大小。

创建Receiver

目前,Senlin支持两种接收器类型:webhookmessage。前者,将生成一个永久的Webhook网址,供用户通过发送HTTP POST请求在给定集群上触发特定操作。对于后者,将创建Zaqar消息队列,以供用户发布消息,此类消息用于通知Senlin服务以针对特定集群启动操作。

Webhook Receiver

创建类型为Webhook的Receiver。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
openstack cluster receiver create --cluster my_cluster --action CLUSTER_SCALE_OUT --type webhook webhook_receiver

+------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field | Value |
+------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| action | CLUSTER_SCALE_OUT |
| actor | { |
| | "trust_id": "267bd0d37750422a92715b36257f1e85" |
| | } |
| channel | { |
| | "alarm_url": "http://192.168.10.20:8778/v1/webhooks/e00915bc-51ca-4a88-ade1-491327fb604c/trigger?V=1" |
| | } |
| cluster_id | eb5843d4-18c7-465f-bf65-76693f617f51 |
| created_at | 2019-09-27T02:48:42Z |
| domain_id | None |
| id | e00915bc-51ca-4a88-ade1-491327fb604c |
| location | Munch({'project': Munch({'domain_id': None, 'id': u'f52380b8eb5345f0a568a186a5a832a5', 'name': 'admin', 'domain_name': 'Default'}), 'cloud': '', 'region_name': 'RegionOne', 'zone': None}) |
| name | webhook_receiver |
| params | {} |
| project_id | f52380b8eb5345f0a568a186a5a832a5 |
| type | webhook |
| updated_at | None |
| user_id | c1bb613f1ece4654b488c65fc0f62df8 |
+------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

对于Webhook接收器,可以检查channel属性的alarm_url字段。可以使用此URL触发指定的操作。

以下命令通过将POST请求发送到alarm_url来触发Receiver。

1
curl -X POST <alarm_url>
Message Receiver

Message Receiver与Webhook Receiver的不同之处在于,它可以在不同的集群上触发不同的操作。因此,在创建Message Receiver时,可以省略选项--cluster和选项--action。Senlin将检查传入的消息是否包含此类属性。

1
openstack cluster receiver create --type message message-receiver

创建消息接收器后,可以将以下格式的消息发送到命名的Zaqar队列,触发Receiver。

1
2
3
4
5
6
7
8
9
10
11
12
{
"messages": [
{
"ttl": 300,
"body": {
"cluster": "my-cluster",
"action": "CLUSTER_SCALE_IN",
"params": {"count": 2}
}
}
]
}

Action

Action是可以在集群或节点上执行的操作。每个Action在创建后都由工作线程异步执行。除某些对象检索或对象列表API外,大多数Senlin API在senlin-engine内异步执行。

不同类型的对象支持不同的动作集。例如,集群(Cluster)支持以下操作:

  • CREATE: creates a cluster;
  • DELETE: deletes a cluster;
  • UPDATE: update the properties and/or the profile used by a cluster;
  • ADD_NODES: add existing nodes to a cluster;
  • DEL_NODES: remove nodes from a cluster;
  • ATTACH_POLICY: attach the specified policy to a cluster;
  • DETACH_POLICY: detach the specified policy from a cluster;
  • UPDATE_POLICY: update the specified policy on a cluster;
  • SCALE_IN: shrink the size of a cluster;
  • SCALE_OUT: inflate the size of a cluster;
  • RESIZE: resize a cluster;
  • CHECK: check a cluster;
  • RECOVER: recover a cluster;
  • REPLACE_NODES: replace the nodes in cluster with specified nodes;
  • OPERATION: perform an operation on the specified cluster;

节点(Node)支持以下操作:

  • CREATE: creates a node;
  • DELETE: deletes a node;
  • UPDATE: updates the properties and/or the profile used by a node;
  • CHECK: check a node;
  • RECOVER: recover a node;
  • OPERATION: perform an operation on the specified node;
查看Actions

查看Action列表。

1
openstack cluster action list 
查看详细Action

查看Action的详细信息。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
openstack cluster action show c3bee157

+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field | Value |
+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| action | CLUSTER_CREATE |
| cause | RPC Request |
| created_at | 2019-09-25T09:20:40Z |
| depended_by | |
| depends_on | |
| domain_id | None |
| end_at | 1569403240.87 |
| id | c3bee157-00fd-4330-a049-3a3feb0cd593 |
| inputs | {} |
| interval | -1 |
| location | Munch({'project': Munch({'domain_id': None, 'id': u'f52380b8eb5345f0a568a186a5a832a5', 'name': 'admin', 'domain_name': 'Default'}), 'cloud': '', 'region_name': 'RegionOne', 'zone': None}) |
| name | cluster_create_eb5843d4 |
| outputs | {} |
| owner_id | None |
| project_id | f52380b8eb5345f0a568a186a5a832a5 |
| start_at | 1569403240.47 |
| status | SUCCEEDED |
| status_reason | Action completed successfully. |
| target_id | eb5843d4-18c7-465f-bf65-76693f617f51 |
| timeout | 3600 |
| updated_at | None |
| user_id | c1bb613f1ece4654b488c65fc0f62df8 |
+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

Event

事件(Event)是senlin-engine执行期间生成的记录。senlin-engine服务在执行某些操作或检查策略时会生成事件记录。

事件(Event)具有级别属性,可以将其解释为事件的严重性级别值:

  • 10: interpreted as DEBUG level. Events at this level can be ignored safely by users. For developers they may provide some useful information for debugging the code.
  • 20: interpreted as INFO level. Events at this level are mostly about notifying that some operations have been successfully performed.
  • 30: interpreted as WARNING level. Events at this level are used to signal some unhealthy status or anomalies detected by the engine. These events should be monitored and checked when operating a cluster.
  • 40: interpreted as ERROR level. Events at this level signifies some failures in engine operations. These event should be monitored and checked when operating a cluster. Usually some user intervention is expected to recover a cluster from this status.
  • 50: interpreted as CRITICAL level. Events at this level are about serious problems encountered by the engine. The engine service may have run into some bugs. User intervention is required to do a recovery.
Event Dispatcher Configuration

Senlin提供了用于事件调度的开放式体系结构。内置调度程序中的两个是数据库和消息。

  1. 数据库调度程序将事件转储到数据库表中,并且默认情况下启用。

  2. 消息调度程序将事件对象转换为版本化的事件通知,并发布在全局消息队列中。默认情况下,禁用此调度程序。要启用它,可以将以下行添加到senlin.conf文件的[DEFAULT]部分,然后重新启动senlin-engine:

    1
    2
    [default]
    event_dispatchers = message

    根据部署设置,使用消息分发程序时,还必须将以下行添加到senlin.conf文件中。这些行将消息传递设置为oslo.messaging软件包使用的默认驱动程序:

    1
    2
    [oslo_messaging_notifications]
    driver = messaging

    使用此配置,数据库分发程序将被禁用,这意味着您只能通过消息队列访问事件。

  3. event_dispatchers字段为MultiString时,如果需要,可以同时启用数据库分发程序和消息分发程序:

    1
    2
    3
    4
    5
    6
    [default]
    event_dispatchers = database
    event_dispatchers = message

    [oslo_messaging_notifications]
    driver = messaging

请注意,默认情况下,与TTL(生存时间)值不相关的未处理事件通知将保留在消息总线上,在启用消息分派器之前,请确保Senlin事件通知将被某些服务订阅并处理。

By default, we use the senlin exchange which type is TOPIC to route the notifications to queues with different routing_key. The queues name could be versioned_notifications.debug, versioned_notifications.info, versioned_notifications.warn and versioned_notifications.error that depends on the log level you are using in senlin.conf. The corresponding routing_key are the same as the queues’ name.

There are two options to consume the notifications:

  • Consume the notifications from the default queues directlly.
  • Declare your own queues, then bind them to senlin exchange with corresponding routing_key to customize the flow.
查看Events

查看Event列表。

1
openstack cluster event list
查看详细Event

查看Event的详细信息。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
openstack cluster event show 932d0009                                                                

+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field | Value |
+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| action | CLUSTER_CREATE |
| cluster_id | eb5843d4-18c7-465f-bf65-76693f617f51 |
| generated_at | 2019-09-25T09:20:40+00:00 |
| id | 932d0009-286f-40e1-81e0-3b44a41657da |
| level | INFO |
| location | Munch({'project': Munch({'domain_id': None, 'id': u'f52380b8eb5345f0a568a186a5a832a5', 'name': 'admin', 'domain_name': 'Default'}), 'cloud': '', 'region_name': 'RegionOne', 'zone': None}) |
| name | None |
| obj_id | eb5843d4-18c7-465f-bf65-76693f617f51 |
| obj_name | my_cluster |
| obj_type | CLUSTER |
| project_id | f52380b8eb5345f0a568a186a5a832a5 |
| status | start |
| status_reason | c3bee157 |
| user_id | c1bb613f1ece4654b488c65fc0f62df8 |
+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+