2012-04-02 07:25:03 -04:00
|
|
|
require 'fog/core/model'
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module Compute
|
|
|
|
class XenServer
|
2012-12-22 18:21:33 -05:00
|
|
|
|
2012-04-02 07:25:03 -04:00
|
|
|
class VIF < Fog::Model
|
|
|
|
# API Reference here:
|
|
|
|
# http://docs.vmd.citrix.com/XenServer/5.6.0/1.0/en_gb/api/?c=VIF
|
2012-12-22 18:21:33 -05:00
|
|
|
|
2012-04-02 07:25:03 -04:00
|
|
|
identity :reference
|
2012-12-22 18:21:33 -05:00
|
|
|
|
2012-04-02 07:25:03 -04:00
|
|
|
attribute :mac, :aliases => :MAC
|
|
|
|
attribute :uuid
|
|
|
|
attribute :allowed_operations
|
|
|
|
attribute :currently_attached
|
|
|
|
attribute :device
|
|
|
|
attribute :mac_autogenerated, :aliases => :MAC_autogenerated
|
|
|
|
attribute :metrics
|
|
|
|
attribute :mtu, :aliases => :MTU
|
2012-04-02 07:35:49 -04:00
|
|
|
attribute :__network, :aliases => :network
|
2012-04-02 07:25:03 -04:00
|
|
|
attribute :status_code
|
|
|
|
attribute :status_detail
|
2012-04-02 07:35:49 -04:00
|
|
|
attribute :__vm, :aliases => :VM
|
2012-12-22 18:21:33 -05:00
|
|
|
|
2012-04-02 07:35:49 -04:00
|
|
|
|
2012-04-09 13:29:17 -04:00
|
|
|
def destroy
|
2012-12-22 18:21:33 -05:00
|
|
|
service.destroy_vif reference
|
2012-04-09 13:29:17 -04:00
|
|
|
end
|
|
|
|
|
2012-04-02 07:35:49 -04:00
|
|
|
def network
|
2012-12-22 18:21:33 -05:00
|
|
|
service.networks.get __network
|
2012-04-02 07:25:03 -04:00
|
|
|
end
|
2012-04-02 07:35:49 -04:00
|
|
|
|
|
|
|
def server
|
2012-12-22 18:21:33 -05:00
|
|
|
service.servers.get __vm
|
2012-04-02 07:35:49 -04:00
|
|
|
end
|
|
|
|
|
2012-04-13 06:44:49 -04:00
|
|
|
def save
|
|
|
|
requires :server
|
|
|
|
raise ArgumentError.new('network is required for this operation') \
|
|
|
|
unless attributes[:__network]
|
2012-12-22 18:21:33 -05:00
|
|
|
ref = service.create_vif attributes[:server], attributes[:__network]
|
|
|
|
merge_attributes service.vifs.get(ref).attributes
|
2012-04-13 06:44:49 -04:00
|
|
|
end
|
|
|
|
|
2012-04-02 07:25:03 -04:00
|
|
|
end
|
2012-12-22 18:21:33 -05:00
|
|
|
|
2012-04-02 07:25:03 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|