Project

General

Profile

Download (1.21 KB) Statistics
| Branch: | Tag: | Revision:
132a991c Ohad Levy
module FogExtensions
module Openstack
module Server
ca8e438b Ohad Levy
extend ActiveSupport::Concern

included do
alias_method_chain :security_groups, :no_id
end

a490a1a4 Ohad Levy
def to_s
name
end

a6ce3c99 Daniel Lobato
def start
if state.downcase == 'paused'
service.unpause_server(id)
else
service.resume_server(id)
end
end

def stop
service.suspend_server(id)
end

def pause
service.pause_server(id)
end

132a991c Ohad Levy
def tenant
ca8e438b Ohad Levy
service.tenants.detect{|t| t.id == tenant_id }
132a991c Ohad Levy
end

def flavor_with_object
ca8e438b Ohad Levy
service.flavors.get attributes[:flavor]['id']
132a991c Ohad Levy
end

def created_at
Time.parse attributes['created']
end

ca8e438b Ohad Levy
# the original method requires a server ID, however we want to be able to call this method on new instances too
def security_groups_with_no_id
return [] if id.nil?

security_groups_without_no_id
end

# dummy place holder for passing down the floating ip network
def network
132a991c Ohad Levy
end

40df7dfb Daniel Lobato
def reset
reboot('HARD')
end

c6e02bd3 Joseph Magen
def vm_description
service.flavors.get(flavor_ref).try(:name)
end

132a991c Ohad Levy
end
end
a6ce3c99 Daniel Lobato
end