Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
4cd41c4
arup cuurent prod state
Nov 25, 2018
8b72e72
(panasonic:he50 camera) add support for basic auth
viv-4 Nov 26, 2018
5be4d53
[Exchange Bookings] Add sensitivity check
Nov 30, 2018
5332eac
[Exchange Bookings] Dont spell like an idiot
Nov 30, 2018
79d672b
(cisco:ce) Add in_call status to sx80, roomkit
w-le Dec 3, 2018
e2fa635
(cisoc:ce) fix missing in_call when calls={}
w-le Dec 3, 2018
1b2facd
(lutron) trigger alias from scene to button_press
w-le Dec 4, 2018
4aab63c
[Google Driver] Fix syntax errors
Dec 7, 2018
655566a
[Exchange Driver] Add name to panel bookings and filter sensitive boo…
Dec 7, 2018
59b8617
(panasonic:lcd) add polling enable setting
viv-4 Dec 10, 2018
e0e6c90
[EWS Lib] Access fields in current user by symbol
Dec 11, 2018
c248e8e
Merge branch 'tracking-stats' into arup
stakach Jan 30, 2019
8ed741d
[EWS Panel] Add new setting
Feb 11, 2019
2d122cd
Merge branch 'arup' of https://github.com/acaprojects/aca-device-modu…
Feb 11, 2019
8a5ea29
panasonic:lcd control updates
Feb 25, 2019
c1fe7ed
Merge branch 'arup' of https://github.com/acaprojects/aca-device-modu…
Feb 25, 2019
8055218
add booking removal toggle setting
viv-4 Feb 25, 2019
fcb7869
Merge branch 'arup' of github.com:acaprojects/aca-device-modules into…
viv-4 Feb 25, 2019
e3fd537
fix instance variable
viv-4 Feb 25, 2019
0425f0e
[aca:exchange] remove booking remove toggle
viv-4 Feb 25, 2019
cac1cf3
[aca:exchange] remove training comma
viv-4 Feb 25, 2019
6e73f05
(excahnge bookings) add reason for meeting cancel_meeting
stakach Feb 25, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/microsoft/exchange.rb
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,8 @@ def create_booking(room_email:, start_param:, end_param:, subject:, description:
booking[:end] = end_object.utc.iso8601.chop

# Add the current user passed in as an attendee
mailbox = { email_address: current_user.email }
mailbox[:name] = current_user.name if current_user.name
mailbox = { email_address: current_user[:email] }
mailbox[:name] = current_user[:name] if current_user[:name]
booking[:required_attendees] = [{
attendee: { mailbox: mailbox }
}]
Expand All @@ -323,7 +323,7 @@ def create_booking(room_email:, start_param:, end_param:, subject:, description:
STDERR.flush

if mailbox_location == 'user'
mailbox = current_user.email
mailbox = current_user[:email]
elsif mailbox_location == 'room'
mailbox = room_email
end
Expand Down Expand Up @@ -378,7 +378,7 @@ def update_booking(booking_id:, room_email:nil, start_param:nil, end_param:nil,
booking[:end] = Time.at(end_param.to_i / 1000).utc.iso8601.chop if end_param

if mailbox_location == 'user'
mailbox = current_user.email
mailbox = current_user[:email]
elsif mailbox_location == 'room'
mailbox = room_email
end
Expand Down
68 changes: 68 additions & 0 deletions lib/tasks/offload.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# encoding: ASCII-8BIT
# frozen_string_literal: true

# rake offload:catalyst_snmp['port_number']

namespace :offload do
desc 'provides a process for offloading SNMP workloads'
task(:catalyst_snmp, [:tcp_port]) do |_, args|
require 'uv-rays'
require File.join(__dir__, '../../modules/cisco/catalyst_snmp_client.rb')
require File.join(__dir__, '../../modules/cisco/catalyst_offloader.rb')

port = args[:tcp_port].to_i
connected = 0
puts "offload catalyst snmp binding to port #{port}"

Libuv.reactor.run do |reactor|
tcp = reactor.tcp
tcp.bind('0.0.0.0', port) do |client|
tokeniser = ::UV::AbstractTokenizer.new(::Cisco::CatalystOffloader::Proxy::ParserSettings)
snmp_client = nil
client_host = nil
connected += 1
STDOUT.puts "total connections: #{connected}"

client.progress do |data|
tokeniser.extract(data).each do |response|
begin
args = Marshal.load(response[4..-1])
if args[0] == :client
STDOUT.puts "reloading client with #{args[1]}"
client_host = args[1][:host]
snmp_client&.close
snmp_client = ::Cisco::Switch::CatalystSNMPClient.new(reactor, args[1])
else
STDOUT.puts "received request #{client_host} #{args[0]}"
retval = nil
begin
retval = snmp_client.__send__(*args)
rescue => e
retval = e
end
if args[0].to_s.start_with? 'query'
msg = Marshal.dump(retval)
client.write("#{[msg.length].pack('V')}#{msg}")
end
end
rescue => e
STDOUT.puts "failed to marshal request\n#{e.message}\n#{e.backtrace&.join("\n")}"
end
end
end
client.enable_nodelay
client.start_read
client.finally do
connected -= 1
STDOUT.puts "total connections: #{connected}"
end
end
tcp.catch do |e|
STDOUT.puts "failed to bind port\n#{e.message}\n#{e.backtrace&.join("\n")}"
end
tcp.listen(1024)
end

puts "offload catalyst snmp closed..."
end
end
102 changes: 57 additions & 45 deletions modules/aca/exchange_booking.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ def on_update
self[:last_meeting_started] = setting(:last_meeting_started)
self[:cancel_meeting_after] = setting(:cancel_meeting_after)
self[:booking_min_duration] = setting(:booking_min_duration)
self[:booking_cancel_timeout] = setting(:booking_cancel_timeout)
self[:booking_disable_future] = setting(:booking_disable_future)
self[:booking_max_duration] = setting(:booking_max_duration)
self[:hide_all_day_bookings] = setting(:hide_all_day_bookings)
Expand Down Expand Up @@ -383,7 +384,7 @@ def start_meeting(meeting_ref)
define_setting(:last_meeting_started, meeting_ref)
end

def cancel_meeting(start_time)
def cancel_meeting(start_time, reason = "timeout")
task {
if start_time.class == Integer
delete_ews_booking (start_time / 1000).to_i
Expand All @@ -393,7 +394,7 @@ def cancel_meeting(start_time)
delete_ews_booking start_time.to_i
end
}.then(proc { |count|
logger.debug { "successfully removed #{count} bookings" }
logger.warn { "successfully removed #{count} bookings due to #{reason}" }

self[:last_meeting_started] = 0
self[:meeting_pending] = 0
Expand Down Expand Up @@ -614,10 +615,15 @@ def get_attr(entry, attr_name)
def make_ews_booking(user_email: nil, subject: 'On the spot booking', room_email:, start_time:, end_time:)
user_email ||= self[:email] # if swipe card used

if subject.empty?
subject = "Quick Book by Display Panel On #{system.name}"
end

booking = {
subject: subject,
start: start_time,
end: end_time
end: end_time,
location: system.name
}

if user_email
Expand All @@ -643,47 +649,47 @@ def make_ews_booking(user_email: nil, subject: 'On the spot booking', room_email
end

def delete_ews_booking(delete_at)
now = Time.now
if @timezone
start = now.in_time_zone(@timezone).midnight
ending = now.in_time_zone(@timezone).tomorrow.midnight
else
start = now.midnight
ending = now.tomorrow.midnight
end

count = 0

cli = Viewpoint::EWSClient.new(*@ews_creds)

if @use_act_as
# TODO:: think this line can be removed??
# delete_at = Time.parse(delete_at.to_s).to_i

opts = {}
opts[:act_as] = @ews_room if @ews_room

folder = cli.get_folder(:calendar, opts)
items = folder.items({:calendar_view => {:start_date => start.utc.iso8601, :end_date => ending.utc.iso8601}})
else
cli.set_impersonation(Viewpoint::EWS::ConnectingSID[@ews_connect_type], @ews_room) if @ews_room
items = cli.find_items({:folder_id => :calendar, :calendar_view => {:start_date => start.utc.iso8601, :end_date => ending.utc.iso8601}})
end

items.each do |meeting|
meeting_time = Time.parse(meeting.ews_item[:start][:text])

# Remove any meetings that match the start time provided
if meeting_time.to_i == delete_at
# new_booking = meeting.update_item!({ end: Time.now.utc.iso8601.chop })

meeting.delete!(:recycle, send_meeting_cancellations: 'SendOnlyToAll')
count += 1
end
end

# Return the number of meetings removed
count
now = Time.now
if @timezone
start = now.in_time_zone(@timezone).midnight
ending = now.in_time_zone(@timezone).tomorrow.midnight
else
start = now.midnight
ending = now.tomorrow.midnight
end

count = 0

cli = Viewpoint::EWSClient.new(*@ews_creds)

if @use_act_as
# TODO:: think this line can be removed??
# delete_at = Time.parse(delete_at.to_s).to_i

opts = {}
opts[:act_as] = @ews_room if @ews_room

folder = cli.get_folder(:calendar, opts)
items = folder.items({:calendar_view => {:start_date => start.utc.iso8601, :end_date => ending.utc.iso8601}})
else
cli.set_impersonation(Viewpoint::EWS::ConnectingSID[@ews_connect_type], @ews_room) if @ews_room
items = cli.find_items({:folder_id => :calendar, :calendar_view => {:start_date => start.utc.iso8601, :end_date => ending.utc.iso8601}})
end

items.each do |meeting|
meeting_time = Time.parse(meeting.ews_item[:start][:text])

# any meetings that match the start time provided
if meeting_time.to_i == delete_at
# new_booking = meeting.update_item!({ end: Time.now.utc.iso8601.chop })

meeting.delete!(:recycle, send_meeting_cancellations: 'SendOnlyToAll')
count += 1
end
end

# Return the number of meetings removed
count
end

def todays_bookings(first=false, skype_exists=false)
Expand Down Expand Up @@ -760,6 +766,7 @@ def todays_bookings(first=false, skype_exists=false)
self[:skype_meeting_pending] = true
end
set_skype_url = false
self[:skype_meeting_address] = links[0]
system[:Skype].set_uri(links[0]) if skype_exists
end
end
Expand All @@ -784,7 +791,12 @@ def todays_bookings(first=false, skype_exists=false)
# Prevent connections handing with TIME_WAIT
# cli.ews.connection.httpcli.reset_all

subject = item[:subject][:text]
if ["Private", "Confidential"].include?(meeting.sensitivity)
subject = meeting.sensitivity
else
subject = item[:subject][:text]
end

{
:Start => start,
:End => ending,
Expand Down
4 changes: 2 additions & 2 deletions modules/aca/google_refresh_booking.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class Aca::GoogleRefreshBooking
ews_room: 'room@email.address',

# Optional EWS for creating and removing bookings
google_organiser_location: 'attendees'
google_organiser_location: 'attendees',
google_client_id: '',
google_secret: '',
google_redirect_uri: '',
Expand Down Expand Up @@ -334,7 +334,7 @@ def fetch_bookings(*args)

authorization = Google::Auth::UserRefreshCredentials.new options

Calendar = Google::Apis::CalendarV3
# Calendar = Google::Apis::CalendarV3
calendar = Calendar::CalendarService.new
calendar.authorization = authorization
events = calendar.list_events(system.email)
Expand Down
40 changes: 40 additions & 0 deletions modules/aca/ping.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# frozen_string_literal: true
# encoding: ASCII-8BIT

module Aca; end
class Aca::Ping
include ::Orchestrator::Constants

# Discovery Information
udp_port 9
descriptive_name 'Ping Device (ICMP)'
generic_name :Ping

default_settings({
ping_every: '2m',
ping_count: 2
})

def on_load
on_update
end

def on_update
@ping_count = setting(:ping_count) || 2
schedule.clear
schedule.every(setting(:ping_every) || '2m') { ping_device }
end

def ping_device
ping = ::UV::Ping.new(remote_address, count: @ping_count)
ping.ping
set_connected_state(ping.pingable)
logger.debug { {
host: ping.ip,
pingable: ping.pingable,
warning: ping.warning,
exception: ping.exception
}.inspect }
ping.pingable
end
end
8 changes: 8 additions & 0 deletions modules/aca/ping_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# frozen_string_literal: true
# encoding: ASCII-8BIT

Orchestrator::Testing.mock_device 'Aca::Ping', ip: 'localhost' do
exec(:ping_device)
expect(result).to be(true)
expect(status[:connected]).to be(true)
end
9 changes: 8 additions & 1 deletion modules/aca/tracking/desk_management.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,17 @@ def desk_usage(level)
#
# @param desk_id [String] the unique id that represents a desk
def desk_details(*desk_ids)
bucket = ::Aca::Tracking::SwitchPort.bucket
desk_ids.map do |desk_id|
switch_ip, port = @desk_mappings[desk_id]
if switch_ip
::Aca::Tracking::SwitchPort.find_by_id("swport-#{switch_ip}-#{port}")&.details
details = ::Aca::Tracking::SwitchPort.find_by_id("swport-#{switch_ip}-#{port}")&.details

# We do this as the mac ownership can change without a disconnect / reconnect event
mac = details.mac
details.username = bucket.get("macuser-#{mac}", quiet: true) if mac

details
else # Check for manual checkin
username = @manual_usage[desk_id]
if username
Expand Down
Loading