Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion cloudstack_plugin/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,20 @@ def create(ctx, **kwargs):
acl_type = acl.get('type')

for port in acl_ports:
# Specifying port ranges "start_port:end_port"
ports = str(port).split(':')
start_port = int(ports[0])
if len(ports) == 1:
end_port = start_port
elif len(ports) == 2:
end_port = int(ports[1])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe add

else:
    raise NonRecoverableError(
        'port may be a single port or a port range '
        'in the format start_port:end_port')

In the scenario that a user puts a typo like "80:443:8080", instead of "80, 443, 8080" or even "80:443, 8080", this will raise an error instead of doing something unexpected.

else:
raise NonRecoverableError(
'Port may be a single port or a port range '
'in the format start_port:end_port.'
'Entered: {0}'.format(port))
create_acl(cloud_driver, acl_protocol, acl_list.id,
acl_cidr, port, port, acl_type)
acl_cidr, start_port, end_port, acl_type)

else:
ctx.logger.info('Creating network: {0}'.format(network_name))
Expand Down
2 changes: 1 addition & 1 deletion plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
plugins:
cloudstack:
executor: central_deployment_agent
source: https://github.com/cloudify-cosmo/cloudify-cloudstack-plugin/archive/1.2.1.zip
source: https://github.com/icclab/cloudify-cloudstack-plugin/archive/1.2.1-build.zip

node_types:
cloudify.cloudstack.nodes.VirtualMachine:
Expand Down