{"id":445,"date":"2014-01-17T14:43:51","date_gmt":"2014-01-17T14:43:51","guid":{"rendered":"http:\/\/corneliadavis.com\/blog\/?p=445"},"modified":"2014-01-17T14:43:51","modified_gmt":"2014-01-17T14:43:51","slug":"changing-quota-definitions","status":"publish","type":"post","link":"https:\/\/corneliadavis.com\/blog\/2014\/01\/17\/changing-quota-definitions\/","title":{"rendered":"Changing quota definitions"},"content":{"rendered":"<p dir=\"ltr\">Recently I\u2019ve had several customers ask about whether quota definitions can be changed, both in the OSS product and in PCF. \u00a0The short answer is \u201cyes\u201d. Here\u2019s the longer:<\/p>\n<p dir=\"ltr\">First, for those of you who might be unfamiliar with quotas, they are assigned to organizations and basically limit consumption within that organization. \u00a0A quota definition sets limits in certain areas, such as memory, number of service instances and so on. \u00a0The Cloud Foundry deployment has any number of named quota definitions defined, and an organization is assigned a single quota_definition.<\/p>\n<h1 dir=\"ltr\">Viewing the defined quota_definitions<\/h1>\n<p dir=\"ltr\">Currently the quota definitions for your elastic runtime deployment are only viewable through the command line client. \u00a0As you surely know, we currently have two clis, the old (v5), which I will henceforth refer to as \u201ccf\u201d or v5, and the new (v6), which I will henceforth refer to as \u201cgcf\u201d or v6. \u00a0To see the list of quota_defitions you can use the following commands:<\/p>\n<pre>cf -t set-quota<\/pre>\n<p dir=\"ltr\">That is, execute the command with no arguments and you will first be shown a list of the available quota definitions.<\/p>\n<p>Or with the new cli, first set the env variable CF_TRACE=true and execute:<\/p>\n<pre>gcf quotas<\/pre>\n<p dir=\"ltr\">In both of the above cases we\u2019ve run with tracing turned on so that you can see the details of the quota definitions. This will be key as you will need to know the format and key names when issuing curl commands described below.<\/p>\n<h1 dir=\"ltr\">Setting org quotas<\/h1>\n<p dir=\"ltr\">Given existing quota definitions, assigning one to an organization is done very simply with the following (v5 and v6) CLI commands:<\/p>\n<pre>cf set-quota --organization myorg --quota-definition trial<\/pre>\n<p dir=\"ltr\">or<\/p>\n<pre>gcf set-quota myorg trial<\/pre>\n<p dir=\"ltr\">The final argument in each of these is the name of an existing quota definition.<\/p>\n<h1 dir=\"ltr\">Creating, deleting or updating quota definitions<\/h1>\n<p dir=\"ltr\">Quota definitions themselves are created one of two ways; either at the time that you are deploying the elastic runtime, and\/or post deployment, using the api.<\/p>\n<h2 dir=\"ltr\">At deployment time<\/h2>\n<p dir=\"ltr\">This is done by simply including quota definitions in your deployment manifest properties, for example:<\/p>\n<pre>properties:\n  quota_definitions:\n    free:\n      memory_limit: 0\n      total_services: 0\n    paid:\n      memory_limit: 10240\n      total_services: -1\n    runaway:\n      memory_limit: 102400\n      total_services: -1<\/pre>\n<p dir=\"ltr\">PCF does not yet expose quota definitions in the Operations Manager (deployer), however, the good news is that regardless of how you deploy the Elastic Runtime, you may edit the quota definitions to your heart\u2019s content after deployment.<\/p>\n<h2 dir=\"ltr\">Post deployment<\/h2>\n<p dir=\"ltr\">To create a new quota definition using the API you simply need to issue a POST to the quota_definitions resource. \u00a0The simplest way to do this is with the (v5) <code>cf curl<\/code> command, as this will include your current token (obtained with a cf login) in the request; if you wish to use your favorite REST client you will have to futz with the auth token yourself. \u00a0Note that v6 does not <a href=\"https:\/\/www.pivotaltracker.com\/s\/projects\/892938\/stories\/57169686\">yet (!)<\/a> support <code>gcf curl<\/code>.<\/p>\n<p dir=\"ltr\">To craft the appropriate request you will need:<\/p>\n<ul>\n<li dir=\"ltr\">The method: POST<\/li>\n<li dir=\"ltr\">The relative path of the resource: <code>\/v2\/quota_definitions<\/code><\/li>\n<li dir=\"ltr\">The body which will contain the details of the new quota definition:\n<pre>{\"name\": \"default2\",\n \"non_basic_services_allowed\": true,\n \"total_services\": 100,\n \"total_routes\": 1000,\n \"memory_limit\": 10240,\n \"trial_db_allowed\": true}<\/pre>\n<\/li>\n<\/ul>\n<p dir=\"ltr\">Putting it all together, the request looks like this:<\/p>\n<pre>&gt; cf curl POST \/v2\/quota_definitions -b '{\"name\": \"default2\",\n                                          \"non_basic_services_allowed\": true,\n                                          \"total_services\": 100,\n                                          \"total_routes\": 1000,\n                                          \"memory_limit\": 10240,\n                                          \"trial_db_allowed\": true}'<\/pre>\n<p dir=\"ltr\">And, voila!, you have your new quota definition. \u00a0Go ahead and check.<\/p>\n<p dir=\"ltr\">Updating an existing quota definition is just as easy. \u00a0Recall from above that you can use v5 or v6 commands to get a list of the current quota definitions, with the details by having tracing turned on. \u00a0You need to find the relative path of the specific quota definition resource by looking at those details. \u00a0Then craft the appropriate request:<\/p>\n<ul>\n<li dir=\"ltr\">The method: PUT<\/li>\n<li dir=\"ltr\">That relative path: <code>\/v2\/quota_definitions\/286b4253-95de-442e-a2e8-d111c2adb2e2<\/code><\/li>\n<li dir=\"ltr\">The body; simply include the properties you wish to change:\n<pre>{\"memory_limit\": 20480}<\/pre>\n<\/li>\n<\/ul>\n<p dir=\"ltr\">Putting it all together, the request looks like this:<\/p>\n<pre>&gt; cf curl PUT \/v2\/quota_definitions\/286b4253-95de-442e-a2e8-d111c2adb2e2 -b '{\"memory_limit\": 20480}'<\/pre>\n<p dir=\"ltr\">In response you will get the updated quota definition:<\/p>\n<pre>{\n  \"metadata\": {\n    \"guid\": \"286b4253-95de-442e-a2e8-d111c2adb2e2\",\n    \"url\": \"\/v2\/quota_definitions\/286b4253-95de-442e-a2e8-d111c2adb2e2\",\n    \"created_at\": \"2014-01-14T19:26:43+00:00\",\n    \"updated_at\": \"2014-01-14T19:28:43+00:00\"\n  },\n  \"entity\": {\n    \"name\": \"default\",\n    \"non_basic_services_allowed\": true,\n    \"total_services\": 100,\n    \"total_routes\": 1000,\n    \"memory_limit\": 20480,\n    \"trial_db_allowed\": true\n  }\n}<\/pre>\n<p dir=\"ltr\">We are planning to add cli commands to facilitate this (stories: <a href=\"https:\/\/www.pivotaltracker.com\/s\/projects\/892938\/stories\/62681776\">here<\/a>, <a href=\"https:\/\/www.pivotaltracker.com\/s\/projects\/892938\/stories\/62681804\">here<\/a>, <a href=\"https:\/\/www.pivotaltracker.com\/s\/projects\/892938\/stories\/62681790\">here<\/a> and <a href=\"https:\/\/www.pivotaltracker.com\/s\/projects\/892938\/stories\/62681828\">here<\/a>), and are adding these capabilities to PCF Operations Manager, but in the mean time you have at least this level of control.<\/p>\n<p dir=\"ltr\">And one more note &#8211; we are just about to officially release the v6 cli (it\u2019s been in beta) at which point we will rename it to \u201ccf\u201d &#8211; so just to keep you on your toes, in my next post on the subject, the new will be v6 and called \u201ccf\u201d. \ud83d\ude09<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Recently I\u2019ve had several customers ask about whether quota definitions can be changed, both in the OSS product and in PCF. \u00a0The short answer is \u201cyes\u201d. Here\u2019s the longer: First, for those of you who might be unfamiliar with quotas, they are assigned to organizations and basically limit consumption within that organization. \u00a0A quota definition [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[13,19,23],"tags":[53],"class_list":["post-445","post","type-post","status-publish","format-standard","hentry","category-howto","category-opensource","category-pivotal","tag-cloudfoundry"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/corneliadavis.com\/blog\/wp-json\/wp\/v2\/posts\/445","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/corneliadavis.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/corneliadavis.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/corneliadavis.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/corneliadavis.com\/blog\/wp-json\/wp\/v2\/comments?post=445"}],"version-history":[{"count":0,"href":"https:\/\/corneliadavis.com\/blog\/wp-json\/wp\/v2\/posts\/445\/revisions"}],"wp:attachment":[{"href":"https:\/\/corneliadavis.com\/blog\/wp-json\/wp\/v2\/media?parent=445"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/corneliadavis.com\/blog\/wp-json\/wp\/v2\/categories?post=445"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/corneliadavis.com\/blog\/wp-json\/wp\/v2\/tags?post=445"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}