Class: Openstack::QuantumMessager::Port

Inherits:
L2l3
  • Object
show all
Defined in:
lib/openstack-quantum-messager/l2l3/port.rb

Instance Attribute Summary

Attributes inherited from L2l3

#quantum_extension_url, #quantum_url

Instance Method Summary collapse

Methods inherited from L2l3

#attachment_detail, #dhcp, #dhcp_entry, #filter_rule, #filtered_range, #firewall, #network, #port

Constructor Details

#initialize(quantum_url) ⇒ Port

Returns a new instance of Port.



5
6
7
# File 'lib/openstack-quantum-messager/l2l3/port.rb', line 5

def initialize(quantum_url)
  @quantum_url = quantum_url
end

Instance Method Details

#create(network_id) ⇒ Object



9
10
11
12
# File 'lib/openstack-quantum-messager/l2l3/port.rb', line 9

def create(network_id)
  full_url = "#{@quantum_url}/networks/#{network_id}/ports.json"
  post_to_quantum(full_url, nil)
end

#delete(network_id, id) ⇒ Object



26
27
28
# File 'lib/openstack-quantum-messager/l2l3/port.rb', line 26

def delete(network_id, id)
  HTTParty.delete("#{@quantum_url}/networks/#{network_id}/ports/#{id}.json")
end

#list(network_id, filters = {}) ⇒ Object



30
31
32
# File 'lib/openstack-quantum-messager/l2l3/port.rb', line 30

def list(network_id, filters={})
  HTTParty.get("#{@quantum_url}/networks/#{network_id}/ports.json", :query => filters)
end

#plug(network_id, id, interface_id) ⇒ Object



14
15
16
17
18
# File 'lib/openstack-quantum-messager/l2l3/port.rb', line 14

def plug(network_id, id, interface_id)
  full_url = "#{@quantum_url}/networks/#{network_id}/ports/#{id}/attachment.json"
  response = put_to_quantum(full_url, {"attachment" => {"id" => interface_id}})
  response.code < 300
end

#unplug(network_id, id) ⇒ Object



20
21
22
23
24
# File 'lib/openstack-quantum-messager/l2l3/port.rb', line 20

def unplug(network_id, id)
  full_url = "#{@quantum_url}/networks/#{network_id}/ports/#{id}/attachment.json"
  response = HTTParty.delete(full_url)
  response.code < 300
end