[PRD-1728] Add state for node network interfaces(agent, nailgun, web UI)

Related-Bug #1247022

Change-Id: If8358938aa67ff0d90eeaec0923b7cffe523bf33
This commit is contained in:
Vladimir Sharshov 2013-11-11 12:56:10 +04:00
parent d90504004b
commit 0e60ff862d
6 changed files with 13 additions and 7 deletions

View File

@ -176,6 +176,7 @@ class NodeAgent
# Exception: eth0.0(example) have "type" => "eth" but it is not physical interface
next if int =~ /\d+\.\d+$/
int_meta = {:name => int}
int_meta[:state] = intinfo[:state]
(intinfo[:addresses] or {} rescue {}).each do |addr, addrinfo|
if (addrinfo[:family] rescue nil) =~ /lladdr/
int_meta[:mac] = addr

View File

@ -468,6 +468,7 @@ class NodeNICsHandler(JSONHandler):
'name',
'current_speed',
'max_speed',
'state',
('assigned_networks', 'id', 'name'),
('allowed_networks', 'id', 'name')
)

View File

@ -257,3 +257,4 @@ class NodeNICInterface(Base):
order_by="NetworkGroup.id")
ip_addr = Column(String(25))
netmask = Column(String(25))
state = Column(String(25))

View File

@ -860,6 +860,7 @@ class NetworkManager(object):
interface.max_speed = interface_attrs.get('max_speed')
interface.ip_addr = interface_attrs.get('ip')
interface.netmask = interface_attrs.get('netmask')
interface.state = interface_attrs.get('state')
def __delete_not_found_interfaces(self, node, interfaces):
interfaces_mac_addresses = map(

View File

@ -168,12 +168,13 @@ class TestHandlers(BaseIntegrationTest):
def test_NIC_updates_by_agent(self):
meta = self.env.default_metadata()
self.env.set_interfaces_in_meta(meta, [
{'name': 'eth0', 'mac': '12345', 'current_speed': 1}])
{'name': 'eth0', 'mac': '12345', 'current_speed': 1,
'state': 'up'}])
node = self.env.create_node(api=True, meta=meta)
new_meta = self.env.default_metadata()
self.env.set_interfaces_in_meta(new_meta, [
{'name': 'new_nic', 'mac': '12345', 'current_speed': 10,
'max_speed': 10}])
'max_speed': 10, 'state': 'down'}])
node_data = {'mac': node['mac'], 'is_agent': True,
'meta': new_meta}
resp = self.app.put(
@ -193,13 +194,15 @@ class TestHandlers(BaseIntegrationTest):
self.assertEquals(resp_nic['mac'], nic['mac'])
self.assertEquals(resp_nic['current_speed'], nic['current_speed'])
self.assertEquals(resp_nic['max_speed'], nic['max_speed'])
self.assertEquals(resp_nic['state'], nic['state'])
for conn in ('assigned_networks', 'allowed_networks'):
self.assertEquals(resp_nic[conn], [])
def test_NIC_adds_by_agent(self):
meta = self.env.default_metadata()
self.env.set_interfaces_in_meta(meta, [
{'name': 'eth0', 'mac': '12345', 'current_speed': 1}])
{'name': 'eth0', 'mac': '12345', 'current_speed': 1,
'state': 'up'}])
node = self.env.create_node(api=True, meta=meta)
meta['interfaces'].append({'name': 'new_nic', 'mac': '643'})
@ -227,6 +230,7 @@ class TestHandlers(BaseIntegrationTest):
self.assertEquals(resp_nic['current_speed'],
nic.get('current_speed'))
self.assertEquals(resp_nic['max_speed'], nic.get('max_speed'))
self.assertEquals(resp_nic['state'], nic.get('state'))
for conn in ('assigned_networks', 'allowed_networks'):
self.assertEquals(resp_nic[conn], [])

View File

@ -2,12 +2,10 @@
<div class="physical-network-box" data-name="<%- ifc.get('name') %>">
<div class="network-box-name"><%- ifc.get('name') %></div>
<div class="network-box-item">
<% var currentSpeed = showBandwidth(ifc.get('current_speed')); %>
<div class="network-info-box enable-selection">
<div class="network-interfaces-status"><div class="interface-<%= currentSpeed !== 'N/A' ? 'online' : 'offline' %>"></div></div>
<div class="network-interfaces-status"><div class="interface-<%= ifc.get('state') !== 'down' ? 'online' : 'offline'%>"></div></div>
<div>MAC: <%- ifc.get('mac') %></div>
<div><%- $.t('cluster_page.nodes_tab.configure_interfaces.speed') %>: <%- currentSpeed %></div>
<div><%- $.t('cluster_page.nodes_tab.configure_interfaces.speed') %>: <%- showBandwidth(ifc.get('current_speed')) %></div>
</div>
<div class="logical-network-box">