Class: F5::Cli::VLAN

Inherits:
Subcommand show all
Defined in:
lib/f5/cli/application.rb

Instance Method Summary collapse

Instance Method Details

#create(vid, name, *members) ⇒ Object



193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# File 'lib/f5/cli/application.rb', line 193

def create(vid, name, *members)
  if members.empty?
    puts "I need at least one member interface"
    exit
  end

  memberdata = members.map do |m|
    (mtype, mname) = m.split /:/
    if mname.nil?
      puts "Each member must be in the form of interface/trunk:id"
      exit
    end
    { member_name: mname,
      member_type: (mtype == 'trunk' ? 'MEMBER_TRUNK' : 'MEMBER_INTERFACE'),
      tag_state: 'MEMBER_TAGGED' }
  end

  response = client.Networking.VLAN.create_v2(
    vlans: { item: [ name ] },
    vlan_ids: { item: [ vid ] },
    members: { item: [ item: memberdata ] },
    failsafe_states: { item: [ 'STATE_DISABLED' ] },
    timeouts: { item: [ 100 ] } #???
  )
  puts response

end

#listObject



165
166
167
168
169
170
171
172
173
174
175
176
# File 'lib/f5/cli/application.rb', line 165

def list
  response = client.Networking.VLAN.get_list

  vlans = extract_items(response, :as_array)
  if vlans.empty?
    puts "No VLANs found"
  else
    vlans.each do |vlan|
      puts vlan
    end
  end
end

#show(name) ⇒ Object



179
180
181
182
183
184
185
186
187
188
189
190
# File 'lib/f5/cli/application.rb', line 179

def show(name)
  members = extract_items client.Networking.VLAN.get_member(vlans: { item: [ name ] } ), :as_array

  vid = extract_items client.Networking.VLAN.get_vlan_id(vlans: { item: [ name ] } )

  failsafe_state = extract_items client.Networking.VLAN.get_failsafe_state(vlans: { item: [ name ] } )

  puts "VLAN id #{vid} and failsafe is #{failsafe_state}"
  members.each do |member|
    puts "Interface %s is a %s and tag state is %s" % [ member[:member_name], member[:member_type], member[:tag_state] ]
  end
end