diff --git a/SoftLayer/CLI/securitygroup/rule.py b/SoftLayer/CLI/securitygroup/rule.py index dfbc93ed9..4f624308c 100644 --- a/SoftLayer/CLI/securitygroup/rule.py +++ b/SoftLayer/CLI/securitygroup/rule.py @@ -67,15 +67,35 @@ def rule_list(env, securitygroup_id, sortby): @click.option('--ethertype', '-e', help='The ethertype (IPv4 or IPv6) to enforce') @click.option('--port-max', '-M', type=click.INT, - help='The upper port bound to enforce') + help=('The upper port bound to enforce. When the protocol is ICMP, ' + 'this specifies the ICMP code to permit')) @click.option('--port-min', '-m', type=click.INT, - help='The lower port bound to enforce') + help=('The lower port bound to enforce. When the protocol is ICMP, ' + 'this specifies the ICMP type to permit')) @click.option('--protocol', '-p', help='The protocol (icmp, tcp, udp) to enforce') @environment.pass_env def add(env, securitygroup_id, remote_ip, remote_group, direction, ethertype, port_max, port_min, protocol): - """Add a security group rule to a security group.""" + """Add a security group rule to a security group. + + \b + Examples: + # Add an SSH rule (TCP port 22) to a security group + slcli sg rule-add 384727 \\ + --direction ingress \\ + --protocol tcp \\ + --port-min 22 \\ + --port-max 22 + + \b + # Add a ping rule (ICMP type 8 code 0) to a security group + slcli sg rule-add 384727 \\ + --direction ingress \\ + --protocol icmp \\ + --port-min 8 \\ + --port-max 0 + """ mgr = SoftLayer.NetworkManager(env.client) ret = mgr.add_securitygroup_rule(securitygroup_id, remote_ip, remote_group, diff --git a/SoftLayer/managers/network.py b/SoftLayer/managers/network.py index 2513a912f..8a49edad8 100644 --- a/SoftLayer/managers/network.py +++ b/SoftLayer/managers/network.py @@ -76,7 +76,9 @@ def add_securitygroup_rule(self, group_id, remote_ip=None, :param str direction: The direction to enforce (egress or ingress) :param str ethertype: The ethertype to enforce (IPv4 or IPv6) :param int port_max: The upper port bound to enforce + (icmp code if the protocol is icmp) :param int port_min: The lower port bound to enforce + (icmp type if the protocol is icmp) :param str protocol: The protocol to enforce (icmp, udp, tcp) """ rule = {'direction': direction}