Class: Occi::Infrastructure::Network

Inherits:
Core::Resource show all
Defined in:
lib/occi/infrastructure/network.rb,
lib/occi/infrastructure/network/ipnetwork.rb

Defined Under Namespace

Classes: Down, Ipnetwork, Up

Instance Attribute Summary

Attributes inherited from Core::Resource

#links

Attributes inherited from Core::Entity

#actions, #attributes, #id, #kind, #mixins, #model

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Core::Resource

#as_json, #initialize, #link, #model=, #summary, #summary=, #to_header, #to_text

Methods inherited from Core::Entity

#as_json, check, #check, #initialize, #inspect, #location, new, #title, #title=, #to_header, #to_s, #to_text, type_identifier

Constructor Details

This class inherits a constructor from Occi::Core::Resource

Class Method Details

.actionsObject



27
28
29
# File 'lib/occi/infrastructure/network.rb', line 27

def self.actions
  Occi::Core::Actions.new << Up.new << Down.new
end

.mixinsObject



7
8
9
# File 'lib/occi/infrastructure/network.rb', line 7

def self.mixins
  Occi::Core::Mixins.new << Occi::Infrastructure::Network::Ipnetwork.new
end

Instance Method Details

#addressObject

IPNetwork Mixin attributes



93
94
95
# File 'lib/occi/infrastructure/network.rb', line 93

def address
  @attributes.occi.network.address if @attributes.occi.network if @attributes.occi
end

#address=(address) ⇒ Object



97
98
99
100
101
102
103
# File 'lib/occi/infrastructure/network.rb', line 97

def address=(address)
  if @mixins.select { |mixin| mixin.kind_of? Occi::Infrastructure::Network::Ipnetwork }.empty?
    Occi::Log.info 'Adding mixin IPNetwork mixin'
    @mixins << Occi::Infrastructure::Network::Ipnetwork.new
  end
  @attributes.occi!.network!.address = address
end

#allocationObject



117
118
119
# File 'lib/occi/infrastructure/network.rb', line 117

def allocation
  @attributes.occi.network.allocation if @attributes.occi.network if @attributes.occi
end

#allocation=(allocation) ⇒ Object



121
122
123
124
125
126
127
# File 'lib/occi/infrastructure/network.rb', line 121

def allocation=(allocation)
  if @mixins.select { |mixin| mixin.kind_of? Occi::Infrastructure::Network::Ipnetwork }.empty?
    Occi::Log.info 'Adding mixin IPNetwork mixin'
    @mixins << Occi::Infrastructure::Network::Ipnetwork.new
  end
  @attributes.occi!.network!.allocation = allocation
end

#gatewayObject



105
106
107
# File 'lib/occi/infrastructure/network.rb', line 105

def gateway
  @attributes.occi.network.gateway if @attributes.occi.network if @attributes.occi
end

#gateway=(gateway) ⇒ Object



109
110
111
112
113
114
115
# File 'lib/occi/infrastructure/network.rb', line 109

def gateway=(gateway)
  if @mixins.select { |mixin| mixin.kind_of? Occi::Infrastructure::Network::Ipnetwork }.empty?
    Occi::Log.info 'Adding mixin IP network'
    @mixins << Occi::Infrastructure::Network::Ipnetwork.new
  end
  @attributes.occi!.network!.gateway = gateway
end

#ipnetwork(boolean = true) ⇒ Object



57
58
59
60
61
62
63
64
65
# File 'lib/occi/infrastructure/network.rb', line 57

def ipnetwork(boolean=true)
  if boolean
    require 'occi/infrastructure/network/ipnetwork'
    self.class.send(:include, Occi::Infrastructure::Network::Ipnetwork)
    mixins << Occi::Infrastructure::Network::Ipnetwork.mixin.type_identifier
  else
    mixins.delete Occi::Infrastructure::Network::Ipnetwork.mixin.type_identifier
  end
end

#labelObject



75
76
77
# File 'lib/occi/infrastructure/network.rb', line 75

def label
  @attributes.occi.nework.label if @attributes.occi.network if @attributes.occi
end

#label=(label) ⇒ Object



79
80
81
# File 'lib/occi/infrastructure/network.rb', line 79

def label=(label)
  @attributes.occi!.network!.label = label
end

#stateObject



83
84
85
# File 'lib/occi/infrastructure/network.rb', line 83

def state
  @attributes.occi.nework.state if @attributes.occi.network if @attributes.occi
end

#state=(state) ⇒ Object



87
88
89
# File 'lib/occi/infrastructure/network.rb', line 87

def state=(state)
  @attributes.occi!.network!.state = state
end

#vlanObject



67
68
69
# File 'lib/occi/infrastructure/network.rb', line 67

def vlan
  @attributes.occi.nework.vlan if @attributes.occi.network if @attributes.occi
end

#vlan=(vlan) ⇒ Object



71
72
73
# File 'lib/occi/infrastructure/network.rb', line 71

def vlan=(vlan)
  @attributes.occi!.network!.vlan = vlan
end