def server_security_groups(request, instance_id):
 security_groups = []
 nclient = novaclient(request)
 (resp, body) = nclient.client.get(('/servers/%s/os-security-groups' % instance_id))
 if body:
  sg_objs = [NovaSecurityGroup(nclient.security_groups, sg, loaded=True) for sg in body.get('security_groups', [])]
  security_groups = [SecurityGroup(sg) for sg in sg_objs]
  for sg in security_groups:
   rule_objects = [SecurityGroupRule(rule) for rule in sg.rules]
   sg.rules = rule_objects
 return security_groups

def server_security_groups ( request , instance_id ) : security_groups = [ ] nclient = novaclient ( request ) ( resp , body ) = nclient . client . get ( ( '/servers/%s/os-security-groups' % instance_id ) ) if body : sg_objs = [ NovaSecurityGroup ( nclient . security_groups , sg , loaded = True ) for sg in body . get ( 'security_groups' , [ ] ) ] security_groups = [ SecurityGroup ( sg ) for sg in sg_objs ] for sg in security_groups : rule_objects = [ SecurityGroupRule ( rule ) for rule in sg . rules ] sg . rules = rule_objects return security_groups
gets security groups of an instance .