<s> import uuid <EOL> from openstack . network . v2 import network <EOL> from openstack . network . v2 import subnet <EOL> from openstack . tests . functional import base <EOL> class TestSubnet ( base . BaseFunctionalTest ) : <EOL> NET_NAME = uuid . uuid4 ( ) . hex <EOL> SUB_NAME = uuid . uuid4 ( ) . hex <EOL> UPDATE_NAME = uuid . uuid4 ( ) . hex <EOL> IPV4 = <NUM_LIT:4> <EOL> CIDR = "<STR_LIT>" <EOL> DNS_SERVERS = [ "<STR_LIT>" , "<STR_LIT>" ] <EOL> POOL = [ { "<STR_LIT:start>" : "<STR_LIT>" , "<STR_LIT:end>" : "<STR_LIT>" } ] <EOL> ROUTES = [ { "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" } ] <EOL> NET_ID = None <EOL> SUB_ID = None <EOL> @ classmethod <EOL> def setUpClass ( cls ) : <EOL> super ( TestSubnet , cls ) . setUpClass ( ) <EOL> net = cls . conn . network . create_network ( name = cls . NET_NAME ) <EOL> assert isinstance ( net , network . Network ) <EOL> cls . assertIs ( cls . NET_NAME , net . name ) <EOL> cls . NET_ID = net . id <EOL> sub = cls . conn . network . create_subnet ( name = cls . SUB_NAME , <EOL> ip_version = cls . IPV4 , <EOL> network_id = cls . NET_ID , <EOL> cidr = cls . CIDR , <EOL> dns_nameservers = cls . DNS_SERVERS , <EOL> allocation_pools = cls . POOL , <EOL> host_routes = cls . ROUTES ) <EOL> assert isinstance ( sub , subnet . Subnet ) <EOL> cls . assertIs ( cls . SUB_NAME , sub . name ) <EOL> cls . SUB_ID = sub . id <EOL> @ classmethod <EOL> def tearDownClass ( cls ) : <EOL> sot = cls . conn . network . delete_subnet ( cls . SUB_ID ) <EOL> cls . assertIs ( None , sot ) <EOL> sot = cls . conn . network . delete_network ( cls . NET_ID , ignore_missing = False ) <EOL> cls . assertIs ( None , sot ) <EOL> def test_find ( self ) : <EOL> sot = self . conn . network . find_subnet ( self . SUB_NAME ) <EOL> self . assertEqual ( self . SUB_ID , sot . id ) <EOL> def test_get ( self ) : <EOL> sot = self . conn . network . get_subnet ( self . SUB_ID ) <EOL> self . assertEqual ( self . SUB_NAME , sot . name ) <EOL> self . assertEqual ( self . SUB_ID , sot . id ) <EOL> self . assertEqual ( self . DNS_SERVERS , sot . dns_nameservers ) <EOL> self . assertEqual ( self . CIDR , sot . cidr ) <EOL> self . assertEqual ( self . POOL , sot . allocation_pools ) <EOL> self . assertEqual ( self . IPV4 , sot . ip_version ) <EOL> self . assertEqual ( self . ROUTES , sot . host_routes ) <EOL> self . assertEqual ( "<STR_LIT>" , sot . gateway_ip ) <EOL> self . assertTrue ( sot . is_dhcp_enabled ) <EOL> def test_list ( self ) : <EOL> names = [ o . name for o in self . conn . network . subnets ( ) ] <EOL> self . assertIn ( self . SUB_NAME , names ) <EOL> def test_update ( self ) : <EOL> sot = self . conn . network . update_subnet ( self . SUB_ID , <EOL> name = self . UPDATE_NAME ) <EOL> self . assertEqual ( self . UPDATE_NAME , sot . name ) </s>
