def create_openstack_network(self, subnet, network, tenant_id,<EOL>tenant_name, direction):
try:<EOL><INDENT>gw = str(netaddr.IPAddress(subnet['<STR_LIT>'].split('<STR_LIT:/>')[<NUM_LIT:0>]) + <NUM_LIT:2>)<EOL>net_id, subnet_id = self.os_helper.create_network(<EOL>network['<STR_LIT:name>'], tenant_id, subnet['<STR_LIT>'], gw=gw)<EOL>if net_id is None or subnet_id is None:<EOL><INDENT>self.release_subnet(subnet['<STR_LIT>'], direction)<EOL><DEDENT>return net_id, subnet_id<EOL><DEDENT>except Exception as exc:<EOL><INDENT>self.release_subnet(subnet['<STR_LIT>'], direction)<EOL>LOG.error("<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>",<EOL>{'<STR_LIT>': tenant_name, '<STR_LIT:name>': network['<STR_LIT:name>'],<EOL>'<STR_LIT>': direction, '<STR_LIT>': str(exc)})<EOL>return None, None<EOL><DEDENT>
Helper function to create openstack network.

        The net_id and subnet_id is returned. Upon failure, the subnet is
        deallocated.