lib/dcmgr/models/host_pool.rb in wakame-vdc-dcmgr-10.11.0 vs lib/dcmgr/models/host_pool.rb in wakame-vdc-dcmgr-10.12.0
- old
+ new
@@ -17,20 +17,19 @@
inheritable_schema do
String :node_id, :size=>80, :null=>true
String :arch, :size=>10, :null=>false # :x86, :x86_64
String :hypervisor, :size=>30, :null=>false
- Fixnum :network_id, :null=>false
Fixnum :offering_cpu_cores, :null=>false, :unsigned=>true
Fixnum :offering_memory_size, :null=>false, :unsigned=>true
- Fixnum :allow_memory_overcommit, :null=>false, :default=>1
+
+ index :node_id
end
one_to_many :instances
many_to_one :node, :class=>Isono::Models::NodeState, :key=>:node_id, :primary_key=>:node_id
- many_to_one :network
def after_initialize
super
end
@@ -64,23 +63,24 @@
# Factory method for Instance model to run on this HostPool.
# @param [Models::Account] account
# @param [Models::Image] image
# @param [Models::InstanceSpec] spec
+ # @param [Models::Network] network
# @return [Models::Instance] created new Instance object.
- def create_instance(account, image, spec, &blk)
+ def create_instance(account, image, spec, network, &blk)
raise ArgumentError unless image.is_a?(Image)
raise ArgumentError unless spec.is_a?(InstanceSpec)
+ raise ArgumentError unless network.is_a?(Network)
i = Instance.new &blk
i.account_id = account.canonical_uuid
i.image = image
i.instance_spec = spec
i.host_pool = self
i.save
- # TODO: set vnic spec from InstanceSpec
- vnic = i.add_nic
- IpLease.lease(vnic)
+ vnic = i.add_nic(network)
+ IpLease.lease(vnic, network)
i
end
def status
node.nil? ? :offline : node.state