Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Commit

Permalink
Merge "Fixes bug: GET and LIST return some empty fields"
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins authored and openstack-gerrit committed Jan 14, 2015
2 parents 2337641 + 576c5ec commit cd5787f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 17 deletions.
40 changes: 24 additions & 16 deletions poppy/storage/cassandra/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,25 +539,33 @@ def format_result(result):
domains = [domain.Domain(d['domain'], d.get('protocol', 'http'))
for d in domains]

restrictions = [restriction.Restriction(
r.get('name'),
[rule.Rule(r_rule.get('name'),
referrer=r_rule.get('referrer'))
for r_rule in r['rules']])
for r in restrictions]

caching_rules = [cachingrule.CachingRule(
caching_rule.get('name'),
caching_rule.get('ttl'),
[rule.Rule(rule_i.get('name'),
request_url=rule_i.get('request_url'))
for rule_i in caching_rule['rules']])
for caching_rule in caching_rules]
restriction_objects = []
for r in restrictions:
restriction_object = restriction.Restriction(r.get('name'))
restriction_object.rules = []
for r_rule in r['rules']:
rule_object = rule.Rule(r_rule.get('name'))
del r_rule['name']
rule_object.from_dict(r_rule)
restriction_object.rules.append(rule_object)
restriction_objects.append(restriction_object)

caching_objects = []
for caching_rule in caching_rules:
caching_object = cachingrule.CachingRule(caching_rule.get('name'),
caching_rule.get('ttl'))
caching_object.rules = []
for cr_rule in caching_rule['rules']:
rule_object = rule.Rule(cr_rule.get('name'))
del cr_rule['name']
rule_object.from_dict(cr_rule)
caching_object.rules.append(rule_object)
caching_objects.append(caching_object)

# create the service object
s = service.Service(service_id, name, domains, origins, flavor_id,
caching=caching_rules,
restrictions=restrictions)
caching=caching_objects,
restrictions=restriction_objects)

# format the provider details
provider_detail_results = result.get('provider_details') or {}
Expand Down
3 changes: 2 additions & 1 deletion tests/api/services/test_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,8 @@ def setUp(self):
u"ttl": 1200,
u"rules": [{
u"name": u"index",
u"request_url": u"/index.htm"
u"request_url": u"/index.htm",
u"http_method": u"GET"
}]
}
]
Expand Down

0 comments on commit cd5787f

Please sign in to comment.