def create_subnet(self, snet):
snet_id = snet.get('<STR_LIT:id>')<EOL>if self.fw_api.is_subnet_source_fw(snet.get('<STR_LIT>'),<EOL>snet.get('<STR_LIT>')):<EOL><INDENT>LOG.info("<STR_LIT>", snet.get('<STR_LIT>'))<EOL>return<EOL><DEDENT>if snet_id not in self.subnet:<EOL><INDENT>self.subnet[snet_id] = {}<EOL>self.subnet[snet_id].update(snet)<EOL><DEDENT>net = self.network.get(self.subnet[snet_id].get('<STR_LIT>'))<EOL>if not net:<EOL><INDENT>LOG.error('<STR_LIT>',<EOL>{'<STR_LIT>': self.subnet[snet_id].get('<STR_LIT>')})<EOL>return<EOL><DEDENT>query_net = self.get_network(net.get('<STR_LIT:id>'))<EOL>if query_net.result != constants.SUBNET_PENDING:<EOL><INDENT>LOG.info("<STR_LIT>")<EOL>return<EOL><DEDENT>if query_net and query_net.source.lower() == '<STR_LIT>':<EOL><INDENT>LOG.info('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>', {'<STR_LIT:name>': query_net.name})<EOL>return<EOL><DEDENT>tenant_name = self.get_project_name(snet['<STR_LIT>'])<EOL>subnet = utils.Dict2Obj(snet)<EOL>dcnm_net = utils.Dict2Obj(net)<EOL>if not tenant_name:<EOL><INDENT>LOG.error('<STR_LIT>',<EOL>{'<STR_LIT>': subnet.tenant_id})<EOL>self.update_network_db(dcnm_net.id, constants.CREATE_FAIL)<EOL>return<EOL><DEDENT>try:<EOL><INDENT>self.dcnm_client.create_network(tenant_name, dcnm_net, subnet,<EOL>self.dcnm_dhcp)<EOL>self.update_network_db(net.get('<STR_LIT:id>'), constants.RESULT_SUCCESS)<EOL><DEDENT>except dexc.DfaClientRequestFailed:<EOL><INDENT>LOG.exception('<STR_LIT>',<EOL>{'<STR_LIT>': dcnm_net.name})<EOL>self.update_network_db(dcnm_net.id, constants.CREATE_FAIL)<EOL><DEDENT>self.network_sub_create_notif(snet.get('<STR_LIT>'), tenant_name,<EOL>snet.get('<STR_LIT>'))<EOL>
Create subnet.