Permalink
Browse files

old version support

  • Loading branch information...
1 parent 8899377 commit 5bc115b0782845f850fc1b8dbc25bea9256386b8 pyw committed Jul 16, 2012
Showing with 20 additions and 10 deletions.
  1. +7 −6 dough/api.py
  2. +5 −3 dough/billing/api.py
  3. +2 −0 dough/billing/driver/load_balancer.py
  4. +0 −1 dough/db/sqlalchemy/api.py
  5. +6 −0 etc/dough/dough.conf.sample
View
@@ -69,12 +69,13 @@ def subscribe_item(context, region=None, item=None, item_type=None,
# TODO(lzyeval): check if products size is not 1
values['product_id'] = products[0]['id']
values['status'] = "verified"
- print "subscription_create", values
+ print "subscription_create", item, payment_type, values
app = context.app
- app.info("subscribe_item:proj_id=" + \
- str(context.project_id) + \
- str(resource_name) + \
- str(resource_uuid))
+ app.info("subscribe_item:proj_id=" + str(context.project_id) + \
+ " name:" + str(resource_name) + \
+ "/" + str(item) + \
+ "/" + str(payment_type) + \
+ "/" + str(resource_uuid))
subscription_ref = db.subscription_create(context, values)
db.subscription_extend(context,
subscription_ref['id'],
@@ -117,7 +118,7 @@ def unsubscribe_item(context, region=None, item=None,
print "subscription_get_by_resource_uuid", resource_uuid, "item=", item, "region=", region
raise exception.SubscriptionNotFoundByRegionOrItem(region=region,
item=item)
- app.info("unsubscribe_item:subs_id=" + str(subscription_id))
+ app.info("\tsubs_id=" + str(subscription_id))
db.subscription_destroy(context, subscription_id)
except Exception, e:
# TODO(lzyeval): report
View
@@ -30,6 +30,7 @@ def creating(context, subscription_id, tenant_id, resource_uuid,
app = context.app
conn = driver.get_connection(item_name)
if not conn.is_running(resource_uuid):
+ print "creating wait running", tenant_id, subscription_id
if created_at + relativedelta(minutes=10) < utils.utcnow():
db.subscription_error(context, subscription_id)
# TODO(lzyeval): report
@@ -42,7 +43,7 @@ def creating(context, subscription_id, tenant_id, resource_uuid,
quantity = conn.get_usage(resource_uuid,
expires_at - relativedelta(**interval_info),
expires_at, order_size)
- print "creating", tenant_id, subscription_id, \
+ print "creating and is running", tenant_id, subscription_id, \
quantity, order_size, "\033[1;33m", price, "\033[0m"
app.info("creating %s:subid=%s,tid=%s,price=%s" % (item_name, subscription_id, tenant_id, str(price)))
charge(context, tenant_id, subscription_id, quantity,
@@ -116,6 +117,7 @@ def charge(context, tenant_id, subscription_id, quantity, order_size, price):
'quantity': quantity,
'line_total': line_total,
}
- print "purchase_create, subid=", subscription_id, values
- context.app.info("purchase_create:subid=%s, line_total=%s" % (subscription_id, str(line_total)))
+ print "purchase_create, tenant_id=%s, subid=%s" % (tenant_id, subscription_id)
+ print values
+ context.app.info("purchase_create:tenant_id=%s, subid=%s, line_total=%s" % (tenant_id, subscription_id, str(line_total)))
db.purchase_create(context, values)
@@ -48,6 +48,8 @@ def send(self, msg_body):
#result = utils.loads(r_msg_body)['msg']
#if result['code'] == 500:
result = utils.loads(r_msg_body)
+ if "msg" in result: # FIXME: old version support
+ result = result["msg"]
if result['code'] == 500:
return None
else:
@@ -298,7 +298,6 @@ def subscription_get(context, subscription_id):
def subscription_create(context, values):
- print "subscription_create", values
subscriptions = subscription_get_all(context, values)
if subscriptions:
raise Exception()
@@ -1,3 +1,9 @@
+[dough-api]
+log: /var/log/dough-api.log
+
+[farmer]
+log: /var/log/dough-farmer.log
+
[DEFAULT]
sql_connection=mysql://someuser:somepasswd@localhost/dough
api_listen=localhost

0 comments on commit 5bc115b

Please sign in to comment.