diff options
| author | Soren Hansen <soren@linux2go.dk> | 2011-09-17 18:00:25 +0000 |
|---|---|---|
| committer | Tarmac <> | 2011-09-17 18:00:25 +0000 |
| commit | 7f80909f4818a5a8d9b61816a3ce23792cdba8a0 (patch) | |
| tree | 58ab299c7998aaa2536d80aa816f17e031e76743 /nova/api | |
| parent | 830a85815cc6b53395a91efb93466692dc33fc83 (diff) | |
| parent | 2d3027da762cdac0c5a12adee15d1bb28fb7bf10 (diff) | |
| download | nova-7f80909f4818a5a8d9b61816a3ce23792cdba8a0.tar.gz nova-7f80909f4818a5a8d9b61816a3ce23792cdba8a0.tar.xz nova-7f80909f4818a5a8d9b61816a3ce23792cdba8a0.zip | |
Fix a bug that would make spawning new instances fail if no port/protocol is given (for rules granting access for other security groups).
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/ec2/cloud.py | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py index fb1afa43a..23ac30494 100644 --- a/nova/api/ec2/cloud.py +++ b/nova/api/ec2/cloud.py @@ -594,18 +594,31 @@ class CloudController(object): g['ipPermissions'] = [] for rule in group.rules: r = {} - r['ipProtocol'] = rule.protocol - r['fromPort'] = rule.from_port - r['toPort'] = rule.to_port r['groups'] = [] r['ipRanges'] = [] if rule.group_id: source_group = db.security_group_get(context, rule.group_id) r['groups'] += [{'groupName': source_group.name, 'userId': source_group.project_id}] + if rule.protocol: + r['ipProtocol'] = rule.protocol + r['fromPort'] = rule.from_port + r['toPort'] = rule.to_port + g['ipPermissions'] += [dict(r)] + else: + for protocol, min_port, max_port in (('icmp', -1, -1), + ('tcp', 1, 65535), + ('udp', 1, 65536)): + r['ipProtocol'] = protocol + r['fromPort'] = min_port + r['toPort'] = max_port + g['ipPermissions'] += [dict(r)] else: + r['ipProtocol'] = rule.protocol + r['fromPort'] = rule.from_port + r['toPort'] = rule.to_port r['ipRanges'] += [{'cidrIp': rule.cidr}] - g['ipPermissions'] += [r] + g['ipPermissions'] += [r] return g def _rule_args_to_dict(self, context, kwargs): |
