Skip to content

Commit

Permalink
Merge pull request #25 from redBorder/development
Browse files Browse the repository at this point in the history
Release 1.0.0
  • Loading branch information
manegron authored May 29, 2024
2 parents 99fc27d + bf731e9 commit f87db64
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 22 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.1
1.0.0
15 changes: 10 additions & 5 deletions packaging/rpm/redborder-cli.spec
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ Requires: bash redborder-common redborder-rubyrvm bash-completion

%install
mkdir -p %{buildroot}/usr/lib/redborder/scripts
mkdir -p %{buildroot}/usr/lib/redborder/lib/red
mkdir -p %{buildroot}/usr/lib/redborder/lib/rbcli
mkdir -p %{buildroot}/etc/bash_completion.d
cp resources/lib/* %{buildroot}/usr/lib/redborder/lib/red
cp resources/lib/* %{buildroot}/usr/lib/redborder/lib/rbcli
cp resources/scripts/* %{buildroot}/usr/lib/redborder/scripts
cp resources/red_bash_completion %{buildroot}/etc/bash_completion.d/red
chmod 0644 %{buildroot}/usr/lib/redborder/lib/red/*
cp resources/rbcli_bash_completion %{buildroot}/etc/bash_completion.d/rbcli
chmod 0644 %{buildroot}/usr/lib/redborder/lib/rbcli/*
chmod 0755 %{buildroot}/usr/lib/redborder/scripts/*
chmod 0644 %{buildroot}/etc/bash_completion.d/*

Expand All @@ -40,16 +40,21 @@ chmod 0644 %{buildroot}/etc/bash_completion.d/*
%defattr(0755,root,root)
/usr/lib/redborder/scripts
%defattr(0644,root,root)
/usr/lib/redborder/lib/red/*
/usr/lib/redborder/lib/rbcli/*
/etc/bash_completion.d/*

%doc

%changelog
* Thu May 23 2024 Miguel Negrón <manegron@redborder.com>
- Rename red to rbcli

* Wed Feb 01 2023 Luis Blanco <ljblanco@redborder.com> -
- unliked reference for the IPS and Proxy for the red command

* Tue Jan 21 2022 David Vanhoucke <dvanhoucke@redborder.com> - 0.0.8-1
- adding extra functionality

* Tue Jan 17 2017 Juan J. Prieto <jjprieto@redborder.com> - 0.0.1-1
- first spec version

6 changes: 3 additions & 3 deletions resources/lib/memcached.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def initialize
def execute(*pattern)
# Credit to Graham King at http://www.darkcoding.net/software/memcached-list-all-keys/ for the original article on how to get the data from memcache in the first place.
# Adapted by Pablo Nebrera (pablonebrera@eneotecnologia.com) --> rb_memcache_keys
# Adapted by Eduardo Reyes (eareyes@redborder.com) --> red command
# Adapted by Eduardo Reyes (eareyes@redborder.com) --> rbcli command

config = YAML.load_file('/var/www/rb-rails/config/memcached_config.yml')
memcachservers=[config["production"]["servers"].sample]
Expand Down Expand Up @@ -220,9 +220,9 @@ def execute(*keys)
keys = "#{keys.join("' '")}"

if $parser.data[:invert]
list_of_keys = `red memcached keys -v '#{keys}' | awk -F"|" '{print $4}' | tr -d '\n'`.gsub(/\s+/, " ").split
list_of_keys = `rbcli memcached keys -v '#{keys}' | awk -F"|" '{print $4}' | tr -d '\n'`.gsub(/\s+/, " ").split
else
list_of_keys = `red memcached keys '#{keys}' | awk -F"|" '{print $4}' | tr -d '\n'`.gsub(/\s+/, " ").split
list_of_keys = `rbcli memcached keys '#{keys}' | awk -F"|" '{print $4}' | tr -d '\n'`.gsub(/\s+/, " ").split
end

@memcached = Dalli::Client.new("memcached.service:11211", {:expires_in => 0})
Expand Down
21 changes: 15 additions & 6 deletions resources/lib/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ class ServiceListCmd < CmdParse::Command

def initialize
$parser.data[:show_runtime] = false
$parser.data[:no_color] = false
super('list', takes_commands: false)
short_desc('List services from node')
options.on('-r', '--runtime', 'Show runtime') { $parser.data[:show_runtime] = true }
options.on('-n', '--no-color', 'Print without colors') { $parser.data[:no_color] = true }
end

def execute()
Expand All @@ -35,6 +37,13 @@ def execute()
return
end

# Set colors
if $parser.data[:no_color]
red, green, yellow, reset = ''
else
red, green, yellow, reset = RED, GREEN, YELLOW, RESET
end

services = node.attributes['redborder']['services'] || []
systemd_services = node.attributes['redborder']['systemdservices'] || []
systemctl_services = []
Expand Down Expand Up @@ -72,27 +81,27 @@ def execute()
running = running + 1
runtime = `systemctl status #{systemd_service} | grep 'Active:' | awk '{for(i=9;i<=NF;i++) printf $i " "; print ""}'`.strip
if $parser.data[:show_runtime]
printf("%-33s #{GREEN}%-33s#{RESET}%-10s\n", "#{systemd_service}:", ret, runtime)
printf("%-33s #{green}%-33s#{reset}%-10s\n", "#{systemd_service}:", ret, runtime)
else
printf("%-33s #{GREEN}%-10s#{RESET}\n", "#{systemd_service}:", ret)
printf("%-33s #{green}%-10s#{reset}\n", "#{systemd_service}:", ret)
end
elsif not_enable_services.include?systemd_service
ret = "not running"
stopped = stopped + 1
runtime = "N/A"
if $parser.data[:show_runtime]
printf("%-33s #{YELLOW}%-33s#{RESET}%-10s\n", "#{systemd_service}:", ret, runtime)
printf("%-33s #{yellow}%-33s#{reset}%-10s\n", "#{systemd_service}:", ret, runtime)
else
printf("%-33s #{YELLOW}%-10s#{RESET}\n", "#{systemd_service}:", ret)
printf("%-33s #{yellow}%-10s#{reset}\n", "#{systemd_service}:", ret)
end
else
ret = "not running!!"
errors = errors + 1
runtime = "N/A"
if $parser.data[:show_runtime]
printf("%-33s #{RED}%-33s#{RESET}%-10s\n", "#{systemd_service}:", ret, runtime)
printf("%-33s #{red}%-33s#{reset}%-10s\n", "#{systemd_service}:", ret, runtime)
else
printf("%-33s #{RED}%-10s#{RESET}\n", "#{systemd_service}:", ret)
printf("%-33s #{red}%-10s#{reset}\n", "#{systemd_service}:", ret)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion resources/lib/zookeeper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def execute()
sleep(10)
service_start_cmd.execute("all", "kafka")
sleep(10)
# TODO : create topics via red command
# TODO : create topics via rbcli command
utils.remote_cmd(Socket.gethostname.split(".").first,"/usr/lib/redborder/bin/rb_create_topics")

else
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Completion for red:
# Completion for rbcli:
#
#
_red()
_rbcli()
{
local cur prev opts
COMPREPLY=()
Expand Down Expand Up @@ -42,4 +42,4 @@ _red()
fi

}
complete -F _red red
complete -F _rbcli rbcli
6 changes: 3 additions & 3 deletions resources/scripts/red.rb → resources/scripts/rbcli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@

$parser = CmdParse::CommandParser.new(handle_exceptions: :no_help)

Dir["#{ENV['RBLIB']}/red/*.rb"].each { |file| require file }
Dir["#{ENV['RBLIB']}/rbcli/*.rb"].each { |file| require file }

$parser.global_options do |opt|
opt.on("-V","--verbose","Enable verbosity") do
$parser.data[:verbose] = true
end
end

$parser.main_options.program_name = "red"
$parser.main_options.version = "0.0.1"
$parser.main_options.program_name = "rbcli"
$parser.main_options.version = "1.0.0"
$parser.main_options.banner = "This is the redborder CLI program"

#$parser.main_options do |opt|
Expand Down

0 comments on commit f87db64

Please sign in to comment.