Skip to content
This repository has been archived by the owner on Aug 29, 2018. It is now read-only.

Commit

Permalink
Bug 999884 - Check if 'tc' already exists in oo-admin-ctl-tc
Browse files Browse the repository at this point in the history
  • Loading branch information
mfojtik committed Oct 14, 2013
1 parent b8374f8 commit e4ceb5d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions node/lib/openshift-origin-node/utils/tc.rb
Expand Up @@ -148,6 +148,7 @@ def with_tc_batch
end

def startuser_impl(uuid, pwent, netclass, f)
return false if tc_exists?(netclass)
# Select what type of user. Note that a user can high bandwidth
# normally but throttled for a specific and temporary reason.
if File.exists?("#{@tc_user_dir}/#{uuid}_throttle")
Expand Down Expand Up @@ -178,6 +179,11 @@ def stopuser_impl(uuid, pwent, netclass, f)
f.puts("class del dev #{@tc_if} parent 1:1 classid 1:#{netclass}")
end

def tc_exists?(netclass)
out, _, _ = ::OpenShift::Runtime::Utils.oo_spawn("tc -s class show dev #{@tc_if} classid 1:#{netclass}", :chdir=>"/")
!out.empty?
end

def with_tc_loaded
out, err, rc = ::OpenShift::Runtime::Utils.oo_spawn("tc qdisc show dev #{@tc_if}", :chdir=>"/")
if out.include?("qdisc htb 1:")
Expand All @@ -190,8 +196,7 @@ def with_tc_loaded
end

def statususer(uuid, pwent, netclass)
out, err, rc = ::OpenShift::Runtime::Utils.oo_spawn("tc -s class show dev #{@tc_if} classid 1:#{netclass}", :chdir=>"/")
if out.empty?
if !tc_exists?(netclass)
raise ArgumentError, "tc not configured for user #{uuid}"
else
@output << out
Expand Down

0 comments on commit e4ceb5d

Please sign in to comment.