File: network.rb

package info (click to toggle)
ruby-fog-libvirt 0.15.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 512 kB
  • sloc: ruby: 2,595; makefile: 4
file content (44 lines) | stat: -rw-r--r-- 979 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
require 'fog/core/model'
require 'fog/libvirt/models/compute/util/util'

module Fog
  module Libvirt
    class Compute
      class Network < Fog::Model
        include Fog::Libvirt::Util

        identity :uuid
        attribute :name
        attribute :bridge_name
        attribute :xml

        def initialize(attributes = {})
          super
        end

        def dhcp_leases(mac, flags = 0)
          service.dhcp_leases(uuid, mac, flags)
        end

        def save
          raise Fog::Errors::Error.new('Creating a new network is not yet implemented. Contributions welcome!')
        end

        def shutdown
          service.destroy_network(uuid)
        end

        def to_xml
          builder = Nokogiri::XML::Builder.new do |xml|
            xml.network do
              xml.name(name)
              xml.bridge(:name => bridge_name, :stp => 'on', :delay => '0')
            end
          end

          builder.to_xml
        end
      end
    end
  end
end