Skip to content
This repository was archived by the owner on Nov 29, 2023. It is now read-only.

Commit ebae242

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "Support XML request format"
2 parents dad11b3 + 5117731 commit ebae242

File tree

9 files changed

+789
-176
lines changed

9 files changed

+789
-176
lines changed

openstack-common.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[DEFAULT]
22

33
# The list of modules to copy from openstack-common
4-
modules=setup
4+
modules=jsonutils,setup,timeutils
55

66
# The base module to hold the copy of openstack.common
77
base=quantumclient

quantum_test.sh

Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -14,114 +14,115 @@ else
1414
NOAUTH=
1515
fi
1616

17+
FORMAT=" --request-format xml"
1718

1819
# test the CRUD of network
1920
network=mynet1
20-
quantum net-create $NOAUTH $network || die "fail to create network $network"
21-
temp=`quantum net-list -- --name $network --fields id | wc -l`
21+
quantum net-create $FORMAT $NOAUTH $network || die "fail to create network $network"
22+
temp=`quantum net-list $FORMAT -- --name $network --fields id | wc -l`
2223
echo $temp
2324
if [ $temp -ne 5 ]; then
2425
die "networks with name $network is not unique or found"
2526
fi
2627
network_id=`quantum net-list -- --name $network --fields id | tail -n 2 | head -n 1 | cut -d' ' -f 2`
2728
echo "ID of network with name $network is $network_id"
2829

29-
quantum net-show $network || die "fail to show network $network"
30-
quantum net-show $network_id || die "fail to show network $network_id"
30+
quantum net-show $FORMAT $network || die "fail to show network $network"
31+
quantum net-show $FORMAT $network_id || die "fail to show network $network_id"
3132

32-
quantum net-update $network --admin_state_up False || die "fail to update network $network"
33-
quantum net-update $network_id --admin_state_up True || die "fail to update network $network_id"
33+
quantum net-update $FORMAT $network --admin_state_up False || die "fail to update network $network"
34+
quantum net-update $FORMAT $network_id --admin_state_up True || die "fail to update network $network_id"
3435

35-
quantum net-list -c id -- --id fakeid || die "fail to list networks with column selection on empty list"
36+
quantum net-list $FORMAT -c id -- --id fakeid || die "fail to list networks with column selection on empty list"
3637

3738
# test the CRUD of subnet
3839
subnet=mysubnet1
3940
cidr=10.0.1.3/24
40-
quantum subnet-create $NOAUTH $network $cidr --name $subnet || die "fail to create subnet $subnet"
41-
tempsubnet=`quantum subnet-list -- --name $subnet --fields id | wc -l`
41+
quantum subnet-create $FORMAT $NOAUTH $network $cidr --name $subnet || die "fail to create subnet $subnet"
42+
tempsubnet=`quantum subnet-list $FORMAT -- --name $subnet --fields id | wc -l`
4243
echo $tempsubnet
4344
if [ $tempsubnet -ne 5 ]; then
4445
die "subnets with name $subnet is not unique or found"
4546
fi
46-
subnet_id=`quantum subnet-list -- --name $subnet --fields id | tail -n 2 | head -n 1 | cut -d' ' -f 2`
47+
subnet_id=`quantum subnet-list $FORMAT -- --name $subnet --fields id | tail -n 2 | head -n 1 | cut -d' ' -f 2`
4748
echo "ID of subnet with name $subnet is $subnet_id"
48-
quantum subnet-show $subnet || die "fail to show subnet $subnet"
49-
quantum subnet-show $subnet_id || die "fail to show subnet $subnet_id"
49+
quantum subnet-show $FORMAT $subnet || die "fail to show subnet $subnet"
50+
quantum subnet-show $FORMAT $subnet_id || die "fail to show subnet $subnet_id"
5051

51-
quantum subnet-update $subnet --dns_namesevers host1 || die "fail to update subnet $subnet"
52-
quantum subnet-update $subnet_id --dns_namesevers host2 || die "fail to update subnet $subnet_id"
52+
quantum subnet-update $FORMAT $subnet --dns_namesevers host1 || die "fail to update subnet $subnet"
53+
quantum subnet-update $FORMAT $subnet_id --dns_namesevers host2 || die "fail to update subnet $subnet_id"
5354

5455
# test the crud of ports
5556
port=myport1
56-
quantum port-create $NOAUTH $network --name $port || die "fail to create port $port"
57-
tempport=`quantum port-list -- --name $port --fields id | wc -l`
57+
quantum port-create $FORMAT $NOAUTH $network --name $port || die "fail to create port $port"
58+
tempport=`quantum port-list $FORMAT -- --name $port --fields id | wc -l`
5859
echo $tempport
5960
if [ $tempport -ne 5 ]; then
6061
die "ports with name $port is not unique or found"
6162
fi
62-
port_id=`quantum port-list -- --name $port --fields id | tail -n 2 | head -n 1 | cut -d' ' -f 2`
63+
port_id=`quantum port-list $FORMAT -- --name $port --fields id | tail -n 2 | head -n 1 | cut -d' ' -f 2`
6364
echo "ID of port with name $port is $port_id"
64-
quantum port-show $port || die "fail to show port $port"
65-
quantum port-show $port_id || die "fail to show port $port_id"
65+
quantum port-show $FORMAT $port || die "fail to show port $port"
66+
quantum port-show $FORMAT $port_id || die "fail to show port $port_id"
6667

67-
quantum port-update $port --device_id deviceid1 || die "fail to update port $port"
68-
quantum port-update $port_id --device_id deviceid2 || die "fail to update port $port_id"
68+
quantum port-update $FORMAT $port --device_id deviceid1 || die "fail to update port $port"
69+
quantum port-update $FORMAT $port_id --device_id deviceid2 || die "fail to update port $port_id"
6970

7071
# test quota commands RUD
7172
DEFAULT_NETWORKS=10
7273
DEFAULT_PORTS=50
7374
tenant_id=tenant_a
7475
tenant_id_b=tenant_b
75-
quantum quota-update --tenant_id $tenant_id --network 30 || die "fail to update quota for tenant $tenant_id"
76-
quantum quota-update --tenant_id $tenant_id_b --network 20 || die "fail to update quota for tenant $tenant_id"
77-
networks=`quantum quota-list -c network -c tenant_id | grep $tenant_id | awk '{print $2}'`
76+
quantum quota-update $FORMAT --tenant_id $tenant_id --network 30 || die "fail to update quota for tenant $tenant_id"
77+
quantum quota-update $FORMAT --tenant_id $tenant_id_b --network 20 || die "fail to update quota for tenant $tenant_id"
78+
networks=`quantum quota-list $FORMAT -c network -c tenant_id | grep $tenant_id | awk '{print $2}'`
7879
if [ $networks -ne 30 ]; then
7980
die "networks quota should be 30"
8081
fi
81-
networks=`quantum quota-list -c network -c tenant_id | grep $tenant_id_b | awk '{print $2}'`
82+
networks=`quantum quota-list $FORMAT -c network -c tenant_id | grep $tenant_id_b | awk '{print $2}'`
8283
if [ $networks -ne 20 ]; then
8384
die "networks quota should be 20"
8485
fi
85-
networks=`quantum quota-show --tenant_id $tenant_id | grep network | awk -F'|' '{print $3}'`
86+
networks=`quantum quota-show $FORMAT --tenant_id $tenant_id | grep network | awk -F'|' '{print $3}'`
8687
if [ $networks -ne 30 ]; then
8788
die "networks quota should be 30"
8889
fi
89-
quantum quota-delete --tenant_id $tenant_id || die "fail to delete quota for tenant $tenant_id"
90-
networks=`quantum quota-show --tenant_id $tenant_id | grep network | awk -F'|' '{print $3}'`
90+
quantum quota-delete $FORMAT --tenant_id $tenant_id || die "fail to delete quota for tenant $tenant_id"
91+
networks=`quantum quota-show $FORMAT --tenant_id $tenant_id | grep network | awk -F'|' '{print $3}'`
9192
if [ $networks -ne $DEFAULT_NETWORKS ]; then
9293
die "networks quota should be $DEFAULT_NETWORKS"
9394
fi
9495
# update self
9596
if [ "t$NOAUTH" = "t" ]; then
9697
# with auth
97-
quantum quota-update --port 99 || die "fail to update quota for self"
98-
ports=`quantum quota-show | grep port | awk -F'|' '{print $3}'`
98+
quantum quota-update $FORMAT --port 99 || die "fail to update quota for self"
99+
ports=`quantum quota-show $FORMAT | grep port | awk -F'|' '{print $3}'`
99100
if [ $ports -ne 99 ]; then
100101
die "ports quota should be 99"
101102
fi
102103

103-
ports=`quantum quota-list -c port | grep 99 | awk '{print $2}'`
104+
ports=`quantum quota-list $FORMAT -c port | grep 99 | awk '{print $2}'`
104105
if [ $ports -ne 99 ]; then
105106
die "ports quota should be 99"
106107
fi
107-
quantum quota-delete || die "fail to delete quota for tenant self"
108-
ports=`quantum quota-show | grep port | awk -F'|' '{print $3}'`
108+
quantum quota-delete $FORMAT || die "fail to delete quota for tenant self"
109+
ports=`quantum quota-show $FORMAT | grep port | awk -F'|' '{print $3}'`
109110
if [ $ports -ne $DEFAULT_PORTS ]; then
110111
die "ports quota should be $DEFAULT_PORTS"
111112
fi
112113
else
113114
# without auth
114-
quantum quota-update --port 100
115+
quantum quota-update $FORMAT --port 100
115116
if [ $? -eq 0 ]; then
116117
die "without valid context on server, quota update command should fail."
117118
fi
118-
quantum quota-show
119+
quantum quota-show $FORMAT
119120
if [ $? -eq 0 ]; then
120121
die "without valid context on server, quota show command should fail."
121122
fi
122-
quantum quota-delete
123+
quantum quota-delete $FORMAT
123124
if [ $? -eq 0 ]; then
124125
die "without valid context on server, quota delete command should fail."
125126
fi
126-
quantum quota-list || die "fail to update quota for self"
127+
quantum quota-list $FORMAT || die "fail to update quota for self"
127128
fi

quantumclient/common/constants.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Copyright (c) 2012 OpenStack, LLC.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12+
# implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
17+
EXT_NS = '_extension_ns'
18+
XML_NS_V20 = 'http://openstack.org/quantum/api/v2.0'
19+
XSI_NAMESPACE = "http://www.w3.org/2001/XMLSchema-instance"
20+
XSI_ATTR = "xsi:nil"
21+
XSI_NIL_ATTR = "xmlns:xsi"
22+
TYPE_XMLNS = "xmlns:quantum"
23+
TYPE_ATTR = "quantum:type"
24+
VIRTUAL_ROOT_KEY = "_v_root"
25+
26+
TYPE_BOOL = "bool"
27+
TYPE_INT = "int"
28+
TYPE_LONG = "long"
29+
TYPE_FLOAT = "float"
30+
TYPE_LIST = "list"
31+
TYPE_DICT = "dict"
32+
33+
PLURALS = {'networks': 'network',
34+
'ports': 'port',
35+
'subnets': 'subnet',
36+
'dns_nameservers': 'dns_nameserver',
37+
'host_routes': 'host_route',
38+
'allocation_pools': 'allocation_pool',
39+
'fixed_ips': 'fixed_ip',
40+
'extensions': 'extension'}

0 commit comments

Comments
 (0)