Class: Dcmgr::Cli::Network::PhyOps
- Defined in:
- lib/dcmgr/cli/network.rb
Constant Summary collapse
Instance Method Summary collapse
Instance Method Details
#add(name) ⇒ Object
222 223 224 225 226 227 228 229 230 231 232 |
# File 'lib/dcmgr/cli/network.rb', line 222 def add(name) M::PhysicalNetwork.find(:name=>name) && Error.raise("Duplicate physical network name: #{name}", 100) phy = [:null] ? nil : ([:interface] || name) fields={ :name=>name, :interface=>phy, :description=>[:description], } M::PhysicalNetwork.create(fields) end |
#del(name) ⇒ Object
249 250 251 252 |
# File 'lib/dcmgr/cli/network.rb', line 249 def del(name) phy = M::PhysicalNetwork.find(:name=>name) || Error.raise("Unknown physical network: #{name}", 100) phy.destroy end |
#modify(name) ⇒ Object
238 239 240 241 242 243 244 245 246 |
# File 'lib/dcmgr/cli/network.rb', line 238 def modify(name) phy = M::PhysicalNetwork.find(:name=>name) || Error.raise("Unknown physical network: #{name}", 100) phy = [:null] ? nil : [:interface] phy.update({ :interface=>phy, :description=>[:description], }) end |
#show(name = nil) ⇒ Object
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 |
# File 'lib/dcmgr/cli/network.rb', line 255 def show(name=nil) if name phy = M::PhysicalNetwork.find(:name=>name) || Error.raise("Unknown physical network: #{name}", 100) print ERB.new(<<__END, nil, '-').result(binding) Physical Network: <%= phy.name %> Forwarding Interface: <%= phy.interface.nil? ? 'none': phy.interface %> <%- if phy.description -%> Description: <%= phy.description %> <%- end -%> __END else print ERB.new(<<__END, nil, '-').result(binding) <%- M::PhysicalNetwork.order(:id).all.each { |l| -%> <%= "%-20s %-15s" % [l.name, l.interface] %> <%- } -%> __END end end |