lib/dcmgr/models/instance_nic.rb in wakame-vdc-dcmgr-10.12.0 vs lib/dcmgr/models/instance_nic.rb in wakame-vdc-dcmgr-11.06.0
- old
+ new
@@ -6,19 +6,29 @@
taggable 'vif'
inheritable_schema do
Fixnum :instance_id, :null=>false
Fixnum :network_id, :null=>false
+ Fixnum :nat_network_id
+ Fixnum :bandwidth_group_id
String :mac_addr, :null=>false, :size=>12
index :mac_addr
end
with_timestamps
+ many_to_one :bandwidth_group
many_to_one :instance
+ many_to_one :nat_network, :key => :nat_network_id, :class => Network
many_to_one :network
- one_to_one :ip, :class=>IpLease
+ one_to_many :ip, :class=>IpLease
+ one_to_many(:direct_ip_lease, :class=>IpLease, :read_only=>true) do |ds|
+ ds.where(:network_id=>self.network_id)
+ end
+ one_to_many(:nat_ip_lease, :class=>IpLease, :read_only=>true) do |ds|
+ ds.where(:network_id=>self.nat_network_id)
+ end
def to_hash
h = values.dup.merge(super)
h.delete(:instance_id)
h
@@ -41,10 +51,10 @@
super
end
def before_destroy
MacLease.find(:mac_addr=>self.mac_addr).destroy
- ip && ip.destroy
+ ip_dataset.destroy
super
end
def validate
super