Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

enable billing and paid quota in yeti setup

Change-Id: I40185a37d81d0798cc21d6a31006d6e1aba12d1f
  • Loading branch information...
commit 030fdbbad3986cdf19f3c3ef01f30638cda2b933 1 parent 756e9c3
Patrick Bozeman pbozeman authored
Showing with 21 additions and 3 deletions.
  1. +21 −3 bin/setup_yeti
24 bin/setup_yeti
View
@@ -1,6 +1,7 @@
#! /usr/bin/env ruby
require "yaml"
+require "yajl"
module YetiSetup
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
with_uaa_target(uaa_url) do
user_guid = create_uaa_user(uaa_cc_secret, email, password)
token = auth_token(cc_admin_email, cc_admin_password)
+ quota_guid = get_paid_quota_guid(cc_url, token)
create_cc_user(cc_url, token, user_guid)
- org_guid = create_cc_org(cc_url, token, org_name, user_guid)
+ org_guid = create_cc_org(cc_url, token, org_name, user_guid, quota_guid)
space_guid = create_cc_space(cc_url, token, space_name, org_guid, user_guid)
end
puts "SUCCESS"
@@ -53,14 +55,30 @@ module YetiSetup
guid
end
- def self.create_cc_org(cc_url, token, name, user_guid)
+ def self.get_paid_quota_guid(cc_url, token)
+ puts "# fetching paid quota guid"
+ cmd = "curl -H 'Content-Type: application/json' " +
+ " -H 'Authorization: #{token}' " +
+ " #{cc_url}/v2/quota_definitions"
+ output = run cmd
+ output_hash = Yajl::Parser.parse(output)
+ resource = output_hash["resources"].select do |r|
+ r["entity"]["name"] == "paid"
+ end
+ error "could not find paid quota" unless resource
+ resource.first["metadata"]["guid"]
+ end
+
+ def self.create_cc_org(cc_url, token, name, user_guid, quota_guid)
puts "# creating cc org"
cmd = "curl -v -X POST -H 'Content-Type: application/json' " +
" -H 'Authorization: #{token}' " +
" -d '{" +
"\"name\":\"#{name}\", " +
"\"user_guids\": [\"#{user_guid}\"], " +
- "\"manager_guids\": [\"#{user_guid}\"] " +
+ "\"manager_guids\": [\"#{user_guid}\"], " +
+ "\"billing_enabled\": true, " +
+ "\"quota_definition_guid\": \"#{quota_guid}\" " +
"}'" +
" #{cc_url}/v2/organizations"
output = run cmd
Please sign in to comment.
Something went wrong with that request. Please try again.