- def create_security_group(self, group_name, fw_rules=[]):
- security_group = SecurityGroup(self.driver)
- security_group.create_security_group(group_name)
- if not fw_rules:
- # open port 22 by default
- security_group.add_rule_to_group(group_name,
- protocol='tcp',
- cidr_ip = '0.0.0.0/0',
- port_range='22',
- icmp_type_code="-1")
- elif isinstance(fw_rules, list):
+ def create_security_group(self, slicename, fw_rules=[]):
+ # use default group by default
+ group_name = 'default'
+ if isinstance(fw_rules, list) and fw_rules:
+ # Each sliver get's its own security group.
+ # Keep security group names unique by appending some random
+ # characters on end.
+ random_name = "".join([random.choice(string.letters+string.digits)
+ for i in xrange(6)])
+ group_name = slicename + random_name
+ security_group = SecurityGroup(self.driver)
+ security_group.create_security_group(group_name)