Commit 8238b175 authored by Hugo Roenick's avatar Hugo Roenick
Browse files

[OPENBUS-2306]: [busadmin] Necessário realizar chamadas non_existent em modo protegido

 - realizando chamadas de non_existent em modo protegido
 - incluindo descrição de ofertas que falharam durante a verificação de responsividade

git-svn-id: https://subversion.tecgraf.puc-rio.br/engdist/openbus/core/branches/02_00_00@142247 ae0415b3-e90b-0410-900d-d0be9363c56b
parent c3daccbb
......@@ -1244,11 +1244,18 @@ handlers["report"] = function(cmd)
msg = " - Barramento (versão 2.0.x): %s"
local ref = "corbaloc::"..host..":"..port.."/"..BusObjectKey
local bus = orb:newproxy(ref, nil, "scs::core::IComponent")
if bus:_non_existent() then
printf(msg, "[INACESSÍVEL]")
return
local ok, status = pcall(bus._non_existent, bus)
if ok then
if status then
printf(msg, "[INACESSÍVEL]")
return
else
printf(msg, "[ACESSÍVEL]")
end
else
printf(msg, "[ACESSÍVEL]")
local errmsg = string.format("[ERRO] %s", status._repid)
printf(msg, errmsg)
return
end
bus = nil
ref = nil
......@@ -1256,10 +1263,16 @@ handlers["report"] = function(cmd)
msg = " - Suporte legado (versão 1.5.x): %s"
local legacyref = "corbaloc::"..host..":"..port.."/openbus_v1_05"
local legacy = orb:newproxy(legacyref, nil, "scs::core::IComponent")
if legacy:_non_existent() then
printf(msg, "[DESABILITADO]")
ok, status = pcall(legacy._non_existent, legacy)
if ok then
if status then
printf(msg, "[DESABILITADO]")
else
printf(msg, "[HABILITADO]")
end
else
printf(msg, "[HABILITADO]")
local errmsg = string.format("[ERRO] %s", status._repid)
printf(msg, errmsg)
end
legacyref = nil
legacy = nil
......@@ -1328,14 +1341,14 @@ handlers["report"] = function(cmd)
msg = " - Autorizações concedidas: %s"
local ok, ents = pcall(conn.entities.getAuthorizedEntities, conn.entities)
if not ok then
local errormsg = string.format("[ERRO]\n%s", tostring(interfaces))
local errormsg = string.format("[ERRO]\n%s", tostring(ents))
printf(msg, errormsg)
else
local authorizations = 0
for _, entitydesc in ipairs(ents) do
local ok, ifaces = pcall(entitydesc.ref.getGrantedInterfaces, entitydesc.ref)
if not ok then
local errormsg = string.format("[ERRO]\n%s", tostring(interfaces))
local errormsg = string.format("[ERRO]\n%s", tostring(ifaces))
printf(msg, errormsg)
break
else
......@@ -1357,11 +1370,22 @@ handlers["report"] = function(cmd)
-- ofertas não responsivas
if #offers > 0 then
local invalid = {}
local failed = {}
for _, offer in ipairs(offers) do
if offer.service_ref:_non_existent() then
invalid[#invalid+1] = offer
local ok, nonexists = pcall(offer.service_ref._non_existent, offer.service_ref)
if ok then
if nonexists then
invalid[#invalid+1] = offer
end
else
offer.error = nonexists._repid
failed[#failed+1] = offer
end
end
if #failed > 0 then
printf(" - '%d' Falha(s) inesperada(s) na tentativa de contactar oferta(s):", #failed)
printer.showFailedOffer(failed)
end
if #invalid > 0 then
printf(" - Existe(m) '%d' Oferta(s) que no momento não estão responsivas:", #invalid)
printer.showOffer(invalid)
......
......@@ -245,9 +245,15 @@ end
-- Exibe a tabela com as interfaces oferecidas no barramento.
--
-- @param offers Estrutura definida na IDL.
-- @param failed Parmetro opcional que indica se informa o erro associado.
---
function module.showOffer(offers)
local titles = { "", "ID ENTIDADE", "INTERFACES", "DATA", "HORA"}
function module.showOffer(offers, failed)
local titles
if not failed then
titles = { "", "ID ENTIDADE", "INTERFACES", "DATA", "HORA"}
else
titles = { "", "ID ENTIDADE", "INTERFACES", "ERROR", "DATA", "HORA"}
end
if #offers == 0 then
showEmptyTable(titles)
return {}
......@@ -260,6 +266,9 @@ function module.showOffer(offers)
desc.offer = offer.ref
desc.properties = offer.properties
desc.interfaces = {}
if failed then
desc.error = offer.error
end
for j, prop in ipairs(offer.properties) do
if prop.name == "openbus.offer.entity" then
desc.entity = prop.value
......@@ -290,10 +299,17 @@ function module.showOffer(offers)
end)
for i, desc in ipairs(offerList) do
desc.id = i
table.insert(tableList, { {string.format("%.3d", i)}, {desc.entity},
desc.interfaces, {string.format("%.2d/%.2d/%d", desc.day, desc.month,
desc.year)}, {string.format("%.2d:%.2d:%.2d", desc.hour, desc.minute,
desc.second)} })
if not failed then
table.insert(tableList, { {string.format("%.3d", i)}, {desc.entity},
desc.interfaces, {string.format("%.2d/%.2d/%d", desc.day, desc.month,
desc.year)}, {string.format("%.2d:%.2d:%.2d", desc.hour, desc.minute,
desc.second)} })
else
table.insert(tableList, { {string.format("%.3d", i)}, {desc.entity},
desc.interfaces, {desc.error}, {string.format("%.2d/%.2d/%d",
desc.day, desc.month, desc.year)}, {string.format("%.2d:%.2d:%.2d",
desc.hour, desc.minute, desc.second)} })
end
end
local sizes = adjustColumnWidth(titles, tableList)
......@@ -301,6 +317,14 @@ function module.showOffer(offers)
return offerList
end
---
-- Exibe a tabela com as interfaces oferecidas no barramento.
--
-- @param offers Estrutura definida na IDL.
---
function module.showFailedOffer(offers)
module.showOffer(offers, true)
end
---
-- Exibe a tabela com as propriedades da oferta.
--
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment