39
39
gateway = 'gatewayvalue'
40
40
args = ['--gateway', gateway, netid, cidr]
41
41
position_names = ['ip_version', 'network_id', 'cidr', 'gateway_ip']
42
position_values = [4, ]
43
position_values.extend([netid, cidr, gateway])
42
position_values = [4, netid, cidr, gateway]
44
43
_str = self._test_create_resource(resource, cmd, name, myid, args,
45
44
position_names, position_values)
47
46
def test_create_subnet_tenant(self):
48
"""create_subnet --tenant-id tenantid netid cidr"""
47
"""Create subnet: --tenant_id tenantid netid cidr."""
49
48
resource = 'subnet'
50
49
cmd = CreateSubnet(MyApp(sys.stdout), None)
54
53
cidr = 'prefixvalue'
55
args = ['--tenant-id', 'tenantid', netid, cidr]
54
args = ['--tenant_id', 'tenantid', netid, cidr]
56
55
position_names = ['ip_version', 'network_id', 'cidr']
57
position_values = [4, ]
58
position_values.extend([netid, cidr])
56
position_values = [4, netid, cidr]
59
57
_str = self._test_create_resource(resource, cmd, name, myid, args,
60
58
position_names, position_values,
61
59
tenant_id='tenantid')
63
61
def test_create_subnet_tags(self):
64
""" create_subnet netid cidr --tags a b"""
62
"""Create subnet: netid cidr --tags a b."""
65
63
resource = 'subnet'
66
64
cmd = CreateSubnet(MyApp(sys.stdout), None)
70
68
cidr = 'prefixvalue'
71
69
args = [netid, cidr, '--tags', 'a', 'b']
72
70
position_names = ['ip_version', 'network_id', 'cidr']
73
position_values = [4, ]
74
position_values.extend([netid, cidr])
71
position_values = [4, netid, cidr]
75
72
_str = self._test_create_resource(resource, cmd, name, myid, args,
76
73
position_names, position_values,
76
def test_create_subnet_allocation_pool(self):
77
"""Create subnet: --tenant_id tenantid <allocation_pool> netid cidr.
78
The <allocation_pool> is --allocation_pool start=1.1.1.10,end=1.1.1.20
81
cmd = CreateSubnet(MyApp(sys.stdout), None)
86
args = ['--tenant_id', 'tenantid',
87
'--allocation_pool', 'start=1.1.1.10,end=1.1.1.20',
89
position_names = ['ip_version', 'allocation_pools', 'network_id',
91
pool = [{'start': '1.1.1.10', 'end': '1.1.1.20'}]
92
position_values = [4, pool, netid, cidr]
93
_str = self._test_create_resource(resource, cmd, name, myid, args,
94
position_names, position_values,
97
def test_create_subnet_allocation_pools(self):
98
"""Create subnet: --tenant-id tenantid <pools> netid cidr.
99
The <pools> are --allocation_pool start=1.1.1.10,end=1.1.1.20 and
100
--allocation_pool start=1.1.1.30,end=1.1.1.40
103
cmd = CreateSubnet(MyApp(sys.stdout), None)
108
args = ['--tenant_id', 'tenantid',
109
'--allocation_pool', 'start=1.1.1.10,end=1.1.1.20',
110
'--allocation_pool', 'start=1.1.1.30,end=1.1.1.40',
112
position_names = ['ip_version', 'allocation_pools', 'network_id',
114
pools = [{'start': '1.1.1.10', 'end': '1.1.1.20'},
115
{'start': '1.1.1.30', 'end': '1.1.1.40'}]
116
position_values = [4, pools, netid, cidr]
117
_str = self._test_create_resource(resource, cmd, name, myid, args,
118
position_names, position_values,
119
tenant_id='tenantid')
79
121
def test_list_subnets_detail(self):
122
"""List subnets: -D."""
81
123
resources = "subnets"
82
124
cmd = ListSubnet(MyApp(sys.stdout), None)
83
125
self._test_list_resources(resources, cmd, True)
85
127
def test_list_subnets_tags(self):
86
"""list_subnets -- --tags a b"""
128
"""List subnets: -- --tags a b."""
87
129
resources = "subnets"
88
130
cmd = ListSubnet(MyApp(sys.stdout), None)
89
131
self._test_list_resources(resources, cmd, tags=['a', 'b'])
91
133
def test_list_subnets_detail_tags(self):
92
"""list_subnets -D -- --tags a b"""
134
"""List subnets: -D -- --tags a b."""
93
135
resources = "subnets"
94
136
cmd = ListSubnet(MyApp(sys.stdout), None)
95
137
self._test_list_resources(resources, cmd, detail=True, tags=['a', 'b'])
97
139
def test_list_subnets_fields(self):
98
"""list_subnets --fields a --fields b -- --fields c d"""
140
"""List subnets: --fields a --fields b -- --fields c d."""
99
141
resources = "subnets"
100
142
cmd = ListSubnet(MyApp(sys.stdout), None)
101
143
self._test_list_resources(resources, cmd,
102
144
fields_1=['a', 'b'], fields_2=['c', 'd'])
104
146
def test_update_subnet(self):
105
""" update_subnet myid --name myname --tags a b"""
147
"""Update subnet: myid --name myname --tags a b."""
106
148
resource = 'subnet'
107
149
cmd = UpdateSubnet(MyApp(sys.stdout), None)
108
150
self._test_update_resource(resource, cmd, 'myid',
114
156
def test_show_subnet(self):
115
""" show_subnet --fields id --fields name myid """
157
"""Show subnet: --fields id --fields name myid."""
116
158
resource = 'subnet'
117
159
cmd = ShowSubnet(MyApp(sys.stdout), None)
119
args = ['--fields', 'id', '--fields', 'name', myid]
120
self._test_show_resource(resource, cmd, myid, args, ['id', 'name'])
160
args = ['--fields', 'id', '--fields', 'name', self.test_id]
161
self._test_show_resource(resource, cmd, self.test_id,
162
args, ['id', 'name'])
122
164
def test_delete_subnet(self):
165
"""Delete subnet: subnetid."""
126
166
resource = 'subnet'
127
167
cmd = DeleteSubnet(MyApp(sys.stdout), None)