def update_ports_for_sg(self, context, portid, jobid):
port = db_api.port_find(context, id=portid, scope=db_api.ONE)<EOL>if not port:<EOL><INDENT>LOG.warning("<STR_LIT>")<EOL>return<EOL><DEDENT>net_driver = port_api._get_net_driver(port.network, port=port)<EOL>base_net_driver = port_api._get_net_driver(port.network)<EOL>sg_list = [sg for sg in port.security_groups]<EOL>success = False<EOL>error = None<EOL>retries = <NUM_LIT:3><EOL>retry_delay = <NUM_LIT:2><EOL>for retry in xrange(retries):<EOL><INDENT>try:<EOL><INDENT>net_driver.update_port(context, port_id=port["<STR_LIT>"],<EOL>mac_address=port["<STR_LIT>"],<EOL>device_id=port["<STR_LIT>"],<EOL>base_net_driver=base_net_driver,<EOL>security_groups=sg_list)<EOL>success = True<EOL>error = None<EOL>break<EOL><DEDENT>except Exception as error:<EOL><INDENT>LOG.warning("<STR_LIT>")<EOL>time.sleep(retry_delay)<EOL><DEDENT><DEDENT>status_str = "<STR_LIT>"<EOL>if not success:<EOL><INDENT>status_str = "<STR_LIT>" % (<EOL>portid, retries, error)<EOL><DEDENT>update_body = dict(completed=True, status=status_str)<EOL>update_body = dict(job=update_body)<EOL>job_api.update_job(context.elevated(), jobid, update_body)<EOL>
Updates the ports through redis.