Class: Dcmgr::Cli::Vlan

Inherits:
Base
  • Object
show all
Defined in:
lib/dcmgr/cli/vlan.rb

Constant Summary collapse

M =
Dcmgr::Models

Instance Method Summary collapse

Instance Method Details

#addObject



12
13
14
15
16
17
# File 'lib/dcmgr/cli/vlan.rb', line 12

def add
  UnknownUUIDError.raise(options[:account_id]) if M::[options[:account_id]].nil?
  Error.raise("Tag_id already exists",100) unless M::VlanLease.find(:tag_id => options[:tag_id]).nil?
  
  puts super(M::VlanLease,options)
end

#del(uuid) ⇒ Object



20
21
22
# File 'lib/dcmgr/cli/vlan.rb', line 20

def del(uuid)
  super(M::VlanLease,uuid)
end

#modify(uuid) ⇒ Object



27
28
29
30
# File 'lib/dcmgr/cli/vlan.rb', line 27

def modify(uuid)
  UnknownUUIDError.raise(options[:account_id]) if options[:account_id] && M::[options[:account_id]].nil?
  super(M::VlanLease,uuid,options)
end

#show(uuid = nil) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/dcmgr/cli/vlan.rb', line 33

def show(uuid=nil)
  if uuid
    lease = M::VlanLease[uuid] || UnknownUUIDError.raise(uuid)
    puts ERB.new("Vlan Lease UUID:\n  <%= lease.canonical_uuid %>\nAccount id:\n  <%= lease.account_id %>\nTag id:\n  <%= lease.tag_id %>\n", nil, '-').result(binding)
  else
    puts ERB.new("<%- M::VlanLease.each { |row| -%>\n<%= row.canonical_uuid %>\\t<%= row.account_id %>\\t<%= row.tag_id %>\n<%- } -%>\n", nil, '-').result(binding)
  end
end