Module: OCCI::Backend::OpenNebula::Network

Included in:
OpenNebula
Defined in:
lib/occi/backend/opennebula/network.rb

Overview


Constant Summary

TEMPLATENETWORKRAWFILE =
'network.erb'

Instance Method Summary (collapse)

Instance Method Details

- (Object) network_action_dummy(network, parameters)




124
125
# File 'lib/occi/backend/opennebula/network.rb', line 124

def network_action_dummy(network, parameters)
end

- (Object) network_delete(network)




105
106
107
108
109
# File 'lib/occi/backend/opennebula/network.rb', line 105

def network_delete(network)
  backend_object = VirtualNetwork.new(VirtualNetwork.build_xml(network.backend[:id]), @one_client)
  rc = backend_object.delete
  check_rc(rc)
end

- (Object) network_deploy(network)




80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/occi/backend/opennebula/network.rb', line 80

def network_deploy(network)

  backend_object = VirtualNetwork.new(VirtualNetwork.build_xml(), @one_client)

  template_location = OCCI::Server.config["TEMPLATE_LOCATION"] + TEMPLATENETWORKRAWFILE
  template = Erubis::Eruby.new(File.read(template_raw)).evaluate(network)

  OCCI::Log.debug("Parsed template #{template}")
  rc = backend_object.allocate(template)
  check_rc(rc)

  backend_object.info
  network.id = self.generate_occi_id(OCCI::Registry.get_by_id(network.kind), backend_object['ID'].to_s)

  network_set_state(backend_object, network)

  OCCI::Log.debug("OpenNebula ID of virtual network: #{network.backend[:id]}")
end

- (Object) network_down(network, parameters)




134
135
136
137
# File 'lib/occi/backend/opennebula/network.rb', line 134

def network_down(network, parameters)
  backend_object = VirtualNetwork.new(VirtualNetwork.build_xml(network.backend[:id]), @one_client)
  # not implemented in OpenNebula
end

- (Object) network_parse_backend_object(backend_object)




40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/occi/backend/opennebula/network.rb', line 40

def network_parse_backend_object(backend_object)

  # get information on storage object from OpenNebula backend
  backend_object.info

  network_kind = OCCI::Registry.get_by_id("http://schemas.ogf.org/occi/infrastructure#network")

  network = Hashie::Mash.new

  network.kind = storage_kind.type_identifier
  network.mixins = %w|http://opennebula.org/occi/infrastructure#network http://schemas.ogf.org/occi/infrastructure#ipnetwork|
  network.id = self.generate_occi_id(network_kind, backend_object.id.to_s)
  network.title = backend_object['NAME']
  network.summary = backend_object['TEMPLATE/DESCRIPTION'] if backend_object['TEMPLATE/DESCRIPTION']

  network.attributes!.occi!.network!.address = backend_object['TEMPLATE/NETWORK_ADDRESS'] if backend_object['TEMPLATE/NETWORK_ADDRESS']
  network.attributes!.occi!.network!.gateway = backend_object['TEMPLATE/GATEWAY'] if backend_object['TEMPLATE/GATEWAY']
  network.attributes!.occi!.network!.vlan = backend_object['TEMPLATE/VLAN_ID'] if backend_object['TEMPLATE/VLAN_ID']
  network.attributes!.occi!.network!.allocation = "static" if backend_object['TEMPLATE/TYPE'].downcase == "fixed"
  network.attributes!.occi!.network!.allocation = "dynamic" if backend_object['TEMPLATE/TYPE'].downcase == "ranged"

  network.attributes!.org!.opennebula!.network!.vlan = backend_object['TEMPLATE/VLAN'] if backend_object['TEMPLATE/VLAN']
  network.attributes!.org!.opennebula!.network!.phydev = backend_object['TEMPLATE/PHYDEV'] if backend_object['TEMPLATE/PHYDEV']
  network.attributes!.org!.opennebula!.network!.bridge = backend_object['TEMPLATE/BRIDGE'] if backend_object['TEMPLATE/BRIDGE']

  network.attributes!.org!.opennebula!.network!.ip_start = backend_object['TEMPLATE/IP_START'] if backend_object['TEMPLATE/IP_START']
  network.attributes!.org!.opennebula!.network!.ip_end = backend_object['TEMPLATE/IP_END'] if backend_object['TEMPLATE/IP_END']

  network = OCCI::Core::Resource.new(network)

  network_set_state(backend_object, network)

  network_kind.entities << network
end

- (Object) network_register_all_instances




112
113
114
115
116
117
# File 'lib/occi/backend/opennebula/network.rb', line 112

def network_register_all_instances
  occi_objects = []
  backend_object_pool=VirtualNetworkPool.new(@one_client, OCCI::Backend::OpenNebula::OpenNebula::INFO_ACL)
  backend_object_pool.info
  backend_object_pool.each { |backend_object| network_parse_backend_object(backend_object) }
end

- (Object) network_set_state(backend_object, network)




100
101
102
# File 'lib/occi/backend/opennebula/network.rb', line 100

def network_set_state(backend_object, network)
  network.attributes!.occi!.network!.state = "active"
end

- (Object) network_up(network, parameters)




128
129
130
131
# File 'lib/occi/backend/opennebula/network.rb', line 128

def network_up(network, parameters)
  backend_object = VirtualNetwork.new(VirtualNetwork.build_xml(network.backend[:id]), @one_client)
  # not implemented in OpenNebula
end