Method: VMC::Cli::Command::Apps#mem

Defined in:
lib/cli/commands/apps.rb

#mem(appname, memsize = nil) ⇒ Object



139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# File 'lib/cli/commands/apps.rb', line 139

def mem(appname, memsize=nil)
  app = client.app_info(appname)
  mem = current_mem = mem_quota_to_choice(app[:resources][:memory])
  memsize = normalize_mem(memsize) if memsize

  memsize ||= ask(
    "Update Memory Reservation?",
    :default => current_mem,
    :choices => mem_choices
  )

  mem         = mem_choice_to_quota(mem)
  memsize     = mem_choice_to_quota(memsize)
  current_mem = mem_choice_to_quota(current_mem)

  display "Updating Memory Reservation to #{mem_quota_to_choice(memsize)}: ", false

  # check memsize here for capacity
  check_has_capacity_for((memsize - mem) * app[:instances])

  mem = memsize

  if (mem != current_mem)
    app[:resources][:memory] = mem
    client.update_app(appname, app)
    display 'OK'.green
    restart appname if app[:state] == 'STARTED'
  else
    display 'OK'.green
  end
end