1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
#!/usr/bin/python
#
# Test creation of a consumer and consumption of an entitlement.
#
import httplib, urllib
import sys
import simplejson as json
import base64
# POST new user
print("create consumer")
info = {
"type": "system",
}
# "parent": "",
# "type":"system",
# "metadata": {
# "entry":[
# {
# "key":"arch",
# "value":"i386"
# },
# {
# "key":"cpu",
# "value": "Intel"
# }]
# }
#}
params = {"type_label": 'system'}
print params
headers = {"Content-type": "application/json",
"Accept": "application/json"}
print "JSON: %s" % json.dumps(params)
print "JSON: %s" % type(json.dumps(params))
conn = httplib.HTTPConnection("localhost", 8080)
conn.request("POST", '/candlepin/consumer/', urllib.urlencode(params), headers)
response = conn.getresponse()
print("Status: %d Response: %s" % (response.status, response.reason))
rsp = response.read()
print("created consumer: %s" % rsp)
conn.close()
## GET list of consumers
#response = urllib.urlopen('http://localhost:8080/candlepin/consumer/')
#rsp = response.read()
#print("list of consumers: %s" % rsp)
## GET candlepin user
#response = urllib.urlopen('http://localhost:8080/candlepin/consumer/candlepin')
#rsp = response.read()
#print("get: %s" % rsp)
## GET candlepin user
#response = urllib.urlopen('http://localhost:8080/candlepin/consumer/info')
#rsp = response.read()
#print("get info: %s" % rsp)
##print("delete consumer")
##conn = httplib.HTTPConnection("localhost", 8080)
##conn.request("DELETE", '/candlepin/consumer/')
##response = conn.getresponse()
##
##print("Status: %d Response: %s" % (response.status, response.reason))
##conn.close()
##print("delete product from consumer")
##conn.request("DELETE", '/candlepin/consumer/%s/product/%s' % ())
|