def upload_security_groups(self, security_groups):
        existing = {sg.name for sg in self.get_security_groups()}
        for security_group in security_groups:
            if security_group.name not in existing:
                sg = self.nova_client.security_groups.create(
                    name=security_group.name,
                    description=security_group.description)
                for rule in security_group.rules:
                    self.nova_client.security_group_rules.create(
                        parent_group_id=sg.id,
                        ip_protocol=rule['ip_protocol'],
                        from_port=rule['from_port'],
                        to_port=rule['to_port'],
                        cidr=rule['ip_range']['cidr'])
dataset/ETHPy150Open MirantisWorkloadMobility/CloudFerry/cloudferry/lib/os/network/nova_network.py/NovaNetwork.upload_security_groups/original