Skip to content
This repository
Browse code

enable billing and paid quota in yeti setup

Change-Id: I40185a37d81d0798cc21d6a31006d6e1aba12d1f
  • Loading branch information...
commit 030fdbbad3986cdf19f3c3ef01f30638cda2b933 1 parent 756e9c3
Patrick Bozeman pbozeman authored

Showing 1 changed file with 21 additions and 3 deletions. Show diff stats Hide diff stats

  1. +21 3 bin/setup_yeti
24 bin/setup_yeti
... ... @@ -1,6 +1,7 @@
1 1 #! /usr/bin/env ruby
2 2
3 3 require "yaml"
  4 +require "yajl"
4 5
5 6 module YetiSetup
6 7 def self.setup(uaa_url, uaa_cc_secret, cc_url, cc_admin_email, cc_admin_password, num_users, email, password, org_name, space_name)
@@ -25,8 +26,9 @@ module YetiSetup
25 26 with_uaa_target(uaa_url) do
26 27 user_guid = create_uaa_user(uaa_cc_secret, email, password)
27 28 token = auth_token(cc_admin_email, cc_admin_password)
  29 + quota_guid = get_paid_quota_guid(cc_url, token)
28 30 create_cc_user(cc_url, token, user_guid)
29   - org_guid = create_cc_org(cc_url, token, org_name, user_guid)
  31 + org_guid = create_cc_org(cc_url, token, org_name, user_guid, quota_guid)
30 32 space_guid = create_cc_space(cc_url, token, space_name, org_guid, user_guid)
31 33 end
32 34 puts "SUCCESS"
@@ -53,14 +55,30 @@ module YetiSetup
53 55 guid
54 56 end
55 57
56   - def self.create_cc_org(cc_url, token, name, user_guid)
  58 + def self.get_paid_quota_guid(cc_url, token)
  59 + puts "# fetching paid quota guid"
  60 + cmd = "curl -H 'Content-Type: application/json' " +
  61 + " -H 'Authorization: #{token}' " +
  62 + " #{cc_url}/v2/quota_definitions"
  63 + output = run cmd
  64 + output_hash = Yajl::Parser.parse(output)
  65 + resource = output_hash["resources"].select do |r|
  66 + r["entity"]["name"] == "paid"
  67 + end
  68 + error "could not find paid quota" unless resource
  69 + resource.first["metadata"]["guid"]
  70 + end
  71 +
  72 + def self.create_cc_org(cc_url, token, name, user_guid, quota_guid)
57 73 puts "# creating cc org"
58 74 cmd = "curl -v -X POST -H 'Content-Type: application/json' " +
59 75 " -H 'Authorization: #{token}' " +
60 76 " -d '{" +
61 77 "\"name\":\"#{name}\", " +
62 78 "\"user_guids\": [\"#{user_guid}\"], " +
63   - "\"manager_guids\": [\"#{user_guid}\"] " +
  79 + "\"manager_guids\": [\"#{user_guid}\"], " +
  80 + "\"billing_enabled\": true, " +
  81 + "\"quota_definition_guid\": \"#{quota_guid}\" " +
64 82 "}'" +
65 83 " #{cc_url}/v2/organizations"
66 84 output = run cmd

Git Notes

review

Verified+1: CI Master <cf-ci@rbcon.com>
Code-Review+2: Kowshik Prakasam <kprakasam@rbcon.com>
Submitted-by: Patrick Bozeman <pbozeman@vmware.com>
Submitted-at: Wed, 02 Jan 2013 23:48:32 +0000
Reviewed-on: http://reviews.cloudfoundry.org/12938
Project: cloud_controller_ng
Branch: refs/heads/master

0 comments on commit 030fdbb

Please sign in to comment.
Something went wrong with that request. Please try again.