-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathNSX Security Group.cat.rb
More file actions
100 lines (85 loc) · 1.95 KB
/
NSX Security Group.cat.rb
File metadata and controls
100 lines (85 loc) · 1.95 KB
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
name 'NSX Security Group'
short_description " \n
An NSX Security Group."
long_description " \n
Create and manage an NSX Security Group (experimental)."
type 'application'
rs_ca_ver 20161221
import 'sys_log'
import 'plugins/nsx'
###
# User Inputs
###
parameter 'nsx_security_group_name' do
label 'Name'
description 'A name for the security group.'
category 'NSX Security Group'
type 'string'
min_length 1
default "nsx-plugin-sg-"
end
# parameter 'nsx_wstunnel' do
# like $nsx.nsx_wstunnel
# end
#parameter 'nsx_user' do
# label 'Username'
# description 'The NSX user name.'
# category 'NSX Endpoint'
# type 'string'
# min_length
# MUST REMOVE!
# default 'admin'
#end
#parameter 'nsx_password' do
# label 'Password'
# description "The NSX user's password."
# category 'NSX Endpoint'
# type 'string'
# min_length 1
# # MUST REMOVE!
# default 'P@ssw0rdP@ssw0rd'
#end
resource 'nsx_security_group', type: 'nsx.security_group' do
name $nsx_security_group_name
description 'My security group description.'
end
###
# Outputs
###
output "list_sg" do
label "sg count"
end
###
# Operations
###
operation 'list_secgroups' do
definition 'list_sgs'
output_mappings do{
$list_sg => $count
}end
end
###
# Definitions
###
define list_sgs() return $count do
call sys_log.set_task_target(@@deployment)
call sys_log.summary("List")
call start_debugging()
@sgs = nsx.security_group.list()
call stop_debugging()
call sys_log.detail(to_object(@sgs))
$count = to_s(size(@sgs))
end
define start_debugging() do
if $$debugging == false || logic_and($$debugging != false, $$debugging != true)
initiate_debug_report()
$$debugging = true
end
end
define stop_debugging() do
if $$debugging == true
$debug_report = complete_debug_report()
call sys_log.detail($debug_report)
$$debugging = false
end
end