Method: CIMI::Model::NetworkCreate#create

Defined in:
lib/cimi/models/network_create.rb

#create(context) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/cimi/models/network_create.rb', line 20

def create(context)
  validate!
  if network_template.href?
    template = network_template.find(context)
    network_config = template.network_config.find(context)
    forwarding_group = template.forwarding_group.find(context)
  else
    network_config = CIMI::Model::NetworkConfiguration.find(context.href_id(network_template.network_config.href, :network_configurations), context)
    forwarding_group = CIMI::Model::ForwardingGroup.find(context.href_id(network_template.forwarding_group.href, :forwarding_groups), context)
  end
  params = {
    :network_config => network_config,
    :forwarding_group => forwarding_group,
    :name => name,
    :description => description,
    :env => context # FIXME: We should not pass the context to the driver (!)
  }
  network = context.driver.create_network(context.credentials, params)
  network.property = property if property
  network.save
  network
end