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::Account[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::Account[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(<<__END, nil, '-').result(binding)
Vlan Lease UUID:
  <%= lease.canonical_uuid %>
Account id:
  <%= lease.account_id %>
Tag id:
  <%= lease.tag_id %>
__END
  else
    puts ERB.new(<<__END, nil, '-').result(binding)
<%- M::VlanLease.each { |row| -%>
<%= row.canonical_uuid %>\t<%= row.account_id %>\t<%= row.tag_id %>
<%- } -%>
__END
  end
end