Skip to content

Commit cad3dd2

Browse files
Merge pull request #931 from rlrossiter/sg-rule-doc
Update documentation for security group rule add
2 parents 1584ce0 + bf44e5f commit cad3dd2

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

SoftLayer/CLI/securitygroup/rule.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,35 @@ def rule_list(env, securitygroup_id, sortby):
6767
@click.option('--ethertype', '-e',
6868
help='The ethertype (IPv4 or IPv6) to enforce')
6969
@click.option('--port-max', '-M', type=click.INT,
70-
help='The upper port bound to enforce')
70+
help=('The upper port bound to enforce. When the protocol is ICMP, '
71+
'this specifies the ICMP code to permit'))
7172
@click.option('--port-min', '-m', type=click.INT,
72-
help='The lower port bound to enforce')
73+
help=('The lower port bound to enforce. When the protocol is ICMP, '
74+
'this specifies the ICMP type to permit'))
7375
@click.option('--protocol', '-p',
7476
help='The protocol (icmp, tcp, udp) to enforce')
7577
@environment.pass_env
7678
def add(env, securitygroup_id, remote_ip, remote_group,
7779
direction, ethertype, port_max, port_min, protocol):
78-
"""Add a security group rule to a security group."""
80+
"""Add a security group rule to a security group.
81+
82+
\b
83+
Examples:
84+
# Add an SSH rule (TCP port 22) to a security group
85+
slcli sg rule-add 384727 \\
86+
--direction ingress \\
87+
--protocol tcp \\
88+
--port-min 22 \\
89+
--port-max 22
90+
91+
\b
92+
# Add a ping rule (ICMP type 8 code 0) to a security group
93+
slcli sg rule-add 384727 \\
94+
--direction ingress \\
95+
--protocol icmp \\
96+
--port-min 8 \\
97+
--port-max 0
98+
"""
7999
mgr = SoftLayer.NetworkManager(env.client)
80100

81101
ret = mgr.add_securitygroup_rule(securitygroup_id, remote_ip, remote_group,

SoftLayer/managers/network.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ def add_securitygroup_rule(self, group_id, remote_ip=None,
7676
:param str direction: The direction to enforce (egress or ingress)
7777
:param str ethertype: The ethertype to enforce (IPv4 or IPv6)
7878
:param int port_max: The upper port bound to enforce
79+
(icmp code if the protocol is icmp)
7980
:param int port_min: The lower port bound to enforce
81+
(icmp type if the protocol is icmp)
8082
:param str protocol: The protocol to enforce (icmp, udp, tcp)
8183
"""
8284
rule = {'direction': direction}

0 commit comments

Comments
 (0)