func (cmd *showQuota) Run(context *cli.Context) { quotaName := context.Args()[0] cmd.ui.Say(T("Getting quota {{.QuotaName}} info as {{.Username}}...", map[string]interface{}{"QuotaName": quotaName, "Username": cmd.config.Username()})) quota, err := cmd.quotaRepo.FindByName(quotaName) if err != nil { cmd.ui.Failed(err.Error()) } cmd.ui.Ok() var megabytes string if quota.InstanceMemoryLimit == -1 { megabytes = T("unlimited") } else { megabytes = formatters.ByteSize(quota.InstanceMemoryLimit * formatters.MEGABYTE) } servicesLimit := strconv.Itoa(quota.ServicesLimit) if servicesLimit == "-1" { servicesLimit = T("unlimited") } table := terminal.NewTable(cmd.ui, []string{"", ""}) table.Add(T("Total Memory"), formatters.ByteSize(quota.MemoryLimit*formatters.MEGABYTE)) table.Add(T("Instance Memory"), megabytes) table.Add(T("Routes"), fmt.Sprintf("%d", quota.RoutesLimit)) table.Add(T("Services"), servicesLimit) table.Add(T("Paid service plans"), formatters.Allowed(quota.NonBasicServicesAllowed)) table.Print() }
func (cmd *ShowOrg) Run(c *cli.Context) { org := cmd.orgReq.GetOrganization() cmd.ui.Say(T("Getting info for org {{.OrgName}} as {{.Username}}...", map[string]interface{}{ "OrgName": terminal.EntityNameColor(org.Name), "Username": terminal.EntityNameColor(cmd.config.Username())})) cmd.ui.Ok() cmd.ui.Say("") table := terminal.NewTable(cmd.ui, []string{terminal.EntityNameColor(org.Name) + ":", "", ""}) domains := []string{} for _, domain := range org.Domains { domains = append(domains, domain.Name) } spaces := []string{} for _, space := range org.Spaces { spaces = append(spaces, space.Name) } spaceQuotas := []string{} for _, spaceQuota := range org.SpaceQuotas { spaceQuotas = append(spaceQuotas, spaceQuota.Name) } quota := org.QuotaDefinition orgQuota := fmt.Sprintf(T("{{.QuotaName}} ({{.MemoryLimit}}M memory limit, {{.RoutesLimit}} routes, {{.ServicesLimit}} services, paid services {{.NonBasicServicesAllowed}})", map[string]interface{}{ "QuotaName": quota.Name, "MemoryLimit": quota.MemoryLimit, "RoutesLimit": quota.RoutesLimit, "ServicesLimit": quota.ServicesLimit, "NonBasicServicesAllowed": formatters.Allowed(quota.NonBasicServicesAllowed)})) table.Add("", T("domains:"), terminal.EntityNameColor(strings.Join(domains, ", "))) table.Add("", T("quota:"), terminal.EntityNameColor(orgQuota)) table.Add("", T("spaces:"), terminal.EntityNameColor(strings.Join(spaces, ", "))) table.Add("", T("space quotas:"), terminal.EntityNameColor(strings.Join(spaceQuotas, ", "))) table.Print() }
func (cmd *ListSpaceQuotas) Run(c *cli.Context) { cmd.ui.Say(T("Getting space quotas as {{.Username}}...", map[string]interface{}{"Username": terminal.EntityNameColor(cmd.config.Username())})) quotas, apiErr := cmd.spaceQuotaRepo.FindByOrg(cmd.config.OrganizationFields().Guid) if apiErr != nil { cmd.ui.Failed(apiErr.Error()) return } cmd.ui.Ok() cmd.ui.Say("") table := terminal.NewTable(cmd.ui, []string{T("name"), T("total memory limit"), T("instance memory limit"), T("routes"), T("service instances"), T("paid service plans")}) var megabytes string for _, quota := range quotas { if quota.InstanceMemoryLimit == -1 { megabytes = T("unlimited") } else { megabytes = formatters.ByteSize(quota.InstanceMemoryLimit * formatters.MEGABYTE) } servicesLimit := strconv.Itoa(quota.ServicesLimit) if servicesLimit == "-1" { servicesLimit = T("unlimited") } table.Add( quota.Name, formatters.ByteSize(quota.MemoryLimit*formatters.MEGABYTE), megabytes, fmt.Sprintf("%d", quota.RoutesLimit), fmt.Sprintf(servicesLimit), formatters.Allowed(quota.NonBasicServicesAllowed), ) } table.Print() }
func (cmd *SpaceQuota) Run(c *cli.Context) { name := c.Args()[0] cmd.ui.Say(T("Getting space quota {{.Quota}} info as {{.Username}}...", map[string]interface{}{ "Quota": terminal.EntityNameColor(name), "Username": terminal.EntityNameColor(cmd.config.Username()), })) spaceQuota, apiErr := cmd.spaceQuotaRepo.FindByName(name) if apiErr != nil { cmd.ui.Failed(apiErr.Error()) return } cmd.ui.Ok() cmd.ui.Say("") var megabytes string table := terminal.NewTable(cmd.ui, []string{"", ""}) table.Add(T("total memory limit"), formatters.ByteSize(spaceQuota.MemoryLimit*formatters.MEGABYTE)) if spaceQuota.InstanceMemoryLimit == -1 { megabytes = T("unlimited") } else { megabytes = formatters.ByteSize(spaceQuota.InstanceMemoryLimit * formatters.MEGABYTE) } servicesLimit := strconv.Itoa(spaceQuota.ServicesLimit) if servicesLimit == "-1" { servicesLimit = T("unlimited") } table.Add(T("instance memory limit"), megabytes) table.Add(T("routes"), fmt.Sprintf("%d", spaceQuota.RoutesLimit)) table.Add(T("services"), servicesLimit) table.Add(T("non basic services"), formatters.Allowed(spaceQuota.NonBasicServicesAllowed)) table.Print() }
func (cmd *ShowSpace) quotaString(space models.Space) string { var instance_memory string if space.SpaceQuotaGuid == "" { return "" } quota, err := cmd.quotaRepo.FindByGuid(space.SpaceQuotaGuid) if err != nil { cmd.ui.Failed(err.Error()) return "" } if quota.InstanceMemoryLimit == -1 { instance_memory = "-1" } else { instance_memory = formatters.ByteSize(quota.InstanceMemoryLimit * formatters.MEGABYTE) } memory := formatters.ByteSize(quota.MemoryLimit * formatters.MEGABYTE) spaceQuota := fmt.Sprintf("%s (%s memory limit, %s instance memory limit, %d routes, %d services, paid services %s)", quota.Name, memory, instance_memory, quota.RoutesLimit, quota.ServicesLimit, formatters.Allowed(quota.NonBasicServicesAllowed)) // spaceQuota := fmt.Sprintf(T("{{.QuotaName}} ({{.MemoryLimit}} memory limit, {{.InstanceMemoryLimit}} instance memory limit, {{.RoutesLimit}} routes, {{.ServicesLimit}} services, paid services {{.NonBasicServicesAllowed}})", // map[string]interface{}{ // "QuotaName": quota.Name, // "MemoryLimit": memory, // "InstanceMemoryLimit": instance_memory, // "RoutesLimit": quota.RoutesLimit, // "ServicesLimit": quota.ServicesLimit, // "NonBasicServicesAllowed": formatters.Allowed(quota.NonBasicServicesAllowed)})) return spaceQuota }