gs_phone 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGES.txt +12 -1
 - data/Rakefile +1 -1
 - data/TODO.txt +6 -4
 - data/bin/gs_phone +37 -1
 - data/lib/gs_phone/version.rb +1 -1
 - data/lib/gs_phone.rb +132 -119
 - data/test/gs_phone_test.rb +342 -1
 - metadata +2 -2
 
    
        data/CHANGES.txt
    CHANGED
    
    | 
         @@ -1,7 +1,18 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            Version 0.0.3
         
     | 
| 
      
 2 
     | 
    
         
            +
            (25 March 2007)
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            	* Added installation instructions
         
     | 
| 
      
 5 
     | 
    
         
            +
                    * Added unit tests to cover the majority of the current codebase
         
     | 
| 
      
 6 
     | 
    
         
            +
                    * Moved the control flow out of the class and into gs_phone
         
     | 
| 
      
 7 
     | 
    
         
            +
                    * Running gs_phone with no arguements will show the help
         
     | 
| 
      
 8 
     | 
    
         
            +
                    * Added a simple mock gsutil program for testing
         
     | 
| 
      
 9 
     | 
    
         
            +
                    * Cleaned up the message from the program
         
     | 
| 
      
 10 
     | 
    
         
            +
                    * Implemented a -v option to print out more status information
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
       1 
12 
     | 
    
         
             
            Version 0.0.2
         
     | 
| 
       2 
13 
     | 
    
         
             
            (23 March 2007)
         
     | 
| 
       3 
14 
     | 
    
         | 
| 
       4 
     | 
    
         
            -
            	* Changed the option parsing to use  
     | 
| 
      
 15 
     | 
    
         
            +
            	* Changed the option parsing to use Subversion style commands
         
     | 
| 
       5 
16 
     | 
    
         
             
            	* Added context based help to each command
         
     | 
| 
       6 
17 
     | 
    
         
             
            	* Setup a hidden folder in the HOME to store our configuration files
         
     | 
| 
       7 
18 
     | 
    
         
             
            	* Added a basic generated template file used by gsutil
         
     | 
    
        data/Rakefile
    CHANGED
    
    
    
        data/TODO.txt
    CHANGED
    
    | 
         @@ -4,12 +4,8 @@ This is the list of tasks that need to be done or have been completed. 
     | 
|
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
            = CURRENT
         
     | 
| 
       6 
6 
     | 
    
         | 
| 
       7 
     | 
    
         
            -
            * Add an INSTALL file
         
     | 
| 
       8 
     | 
    
         
            -
            * Add unit tests
         
     | 
| 
       9 
7 
     | 
    
         
             
            * Announce package
         
     | 
| 
       10 
8 
     | 
    
         
             
            * Get a list of the ip addresses currently assigned (Currently this works: grep -i '^ip' users.yml | awk '// {print $2}' | sort)
         
     | 
| 
       11 
     | 
    
         
            -
            * Cleanup the option parser
         
     | 
| 
       12 
     | 
    
         
            -
            * Cleanup the output from the program (e.g. remove "GS >")
         
     | 
| 
       13 
9 
     | 
    
         
             
            * Allow asterisk intregration
         
     | 
| 
       14 
10 
     | 
    
         
             
              * Read user list from extensions.conf and/or sip.conf
         
     | 
| 
       15 
11 
     | 
    
         | 
| 
         @@ -26,3 +22,9 @@ This is the list of tasks that need to be done or have been completed. 
     | 
|
| 
       26 
22 
     | 
    
         
             
            * Create a RubyForge Project
         
     | 
| 
       27 
23 
     | 
    
         
             
            * Rework commandline passing to be like Subversion (svn command options)
         
     | 
| 
       28 
24 
     | 
    
         
             
            * Make --help the default command if no option is given
         
     | 
| 
      
 25 
     | 
    
         
            +
            * Add an INSTALL file
         
     | 
| 
      
 26 
     | 
    
         
            +
            * BUG: help is still not the default command if no option is given
         
     | 
| 
      
 27 
     | 
    
         
            +
            * BUG: If gsutil is not found the program acts as if everything is ok.  It should error out.
         
     | 
| 
      
 28 
     | 
    
         
            +
            * Add unit tests
         
     | 
| 
      
 29 
     | 
    
         
            +
            * Cleanup the option parser
         
     | 
| 
      
 30 
     | 
    
         
            +
            * Cleanup the output from the program (e.g. remove "GS >")
         
     | 
    
        data/bin/gs_phone
    CHANGED
    
    | 
         @@ -8,5 +8,41 @@ require 'rubygems' 
     | 
|
| 
       8 
8 
     | 
    
         
             
            require_gem 'gs_phone'
         
     | 
| 
       9 
9 
     | 
    
         
             
            require 'gs_phone' 
         
     | 
| 
       10 
10 
     | 
    
         | 
| 
       11 
     | 
    
         
            -
            GrandStream.new(ARGV)
         
     | 
| 
       12 
11 
     | 
    
         | 
| 
      
 12 
     | 
    
         
            +
            gs = GrandStream.new
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            if not ARGV.nil? and ARGV.include?("-v")
         
     | 
| 
      
 15 
     | 
    
         
            +
              gs.verbose = true
         
     | 
| 
      
 16 
     | 
    
         
            +
              ARGV.delete_if { |a| a == "-v"}
         
     | 
| 
      
 17 
     | 
    
         
            +
            end
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
            @command = ARGV[0]
         
     | 
| 
      
 20 
     | 
    
         
            +
            @ip = ARGV[1]
         
     | 
| 
      
 21 
     | 
    
         
            +
            @current_ip = ARGV[2]
         
     | 
| 
      
 22 
     | 
    
         
            +
            @admin = ARGV[3]
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
            case @command
         
     | 
| 
      
 25 
     | 
    
         
            +
            when "help"
         
     | 
| 
      
 26 
     | 
    
         
            +
              response = gs.help(ARGV[1])
         
     | 
| 
      
 27 
     | 
    
         
            +
            when "new"
         
     | 
| 
      
 28 
     | 
    
         
            +
              # Don't use response because we want to give feeback throughout this process
         
     | 
| 
      
 29 
     | 
    
         
            +
              puts gs.add_user(@ip)
         
     | 
| 
      
 30 
     | 
    
         
            +
              puts gs.make(@ip)
         
     | 
| 
      
 31 
     | 
    
         
            +
              puts gs.update_config(@ip, @current_ip, @admin)
         
     | 
| 
      
 32 
     | 
    
         
            +
              puts gs.reboot_phone(@ip)
         
     | 
| 
      
 33 
     | 
    
         
            +
            when "add"
         
     | 
| 
      
 34 
     | 
    
         
            +
              response = gs.add_user(@ip)
         
     | 
| 
      
 35 
     | 
    
         
            +
            when "make"
         
     | 
| 
      
 36 
     | 
    
         
            +
              response = gs.make(@ip)
         
     | 
| 
      
 37 
     | 
    
         
            +
            when "update"
         
     | 
| 
      
 38 
     | 
    
         
            +
              response = gs.update_config(@ip, @current_ip, @admin)
         
     | 
| 
      
 39 
     | 
    
         
            +
            when "reboot"
         
     | 
| 
      
 40 
     | 
    
         
            +
              response = gs.reboot_phone(@ip)
         
     | 
| 
      
 41 
     | 
    
         
            +
            when "find"
         
     | 
| 
      
 42 
     | 
    
         
            +
              response = gs.find_ip
         
     | 
| 
      
 43 
     | 
    
         
            +
            else
         
     | 
| 
      
 44 
     | 
    
         
            +
              response = gs.help  
         
     | 
| 
      
 45 
     | 
    
         
            +
            end
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
            # Print out any responses, used for verbose options
         
     | 
| 
      
 48 
     | 
    
         
            +
            puts response unless response.nil?
         
     | 
    
        data/lib/gs_phone/version.rb
    CHANGED
    
    
    
        data/lib/gs_phone.rb
    CHANGED
    
    | 
         @@ -1,4 +1,4 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            #!/usr/bin/ruby 
     | 
| 
      
 1 
     | 
    
         
            +
            #!/usr/bin/ruby
         
     | 
| 
       2 
2 
     | 
    
         
             
            # This is used to manage the Grandstream phones.
         
     | 
| 
       3 
3 
     | 
    
         
             
            # It is a wrapper over Charles Howes (gsutil@ch.pkts.ca)'s gsutil
         
     | 
| 
       4 
4 
     | 
    
         
             
            # utility (http://www.pkts.ca/gsutil.shtml)
         
     | 
| 
         @@ -24,52 +24,43 @@ require 'yaml' 
     | 
|
| 
       24 
24 
     | 
    
         | 
| 
       25 
25 
     | 
    
         
             
            class GrandStream
         
     | 
| 
       26 
26 
     | 
    
         | 
| 
      
 27 
     | 
    
         
            +
              attr_reader :user_file
         
     | 
| 
      
 28 
     | 
    
         
            +
              attr_reader :admin_password
         
     | 
| 
      
 29 
     | 
    
         
            +
              attr_reader :gsutil
         
     | 
| 
      
 30 
     | 
    
         
            +
              attr_reader :template_files
         
     | 
| 
      
 31 
     | 
    
         
            +
              attr_reader :config_file
         
     | 
| 
      
 32 
     | 
    
         
            +
              attr_accessor :verbose
         
     | 
| 
      
 33 
     | 
    
         
            +
              
         
     | 
| 
       27 
34 
     | 
    
         
             
              # Default configurations
         
     | 
| 
       28 
35 
     | 
    
         
             
              @user_file = "#{ENV["HOME"]}/.gs_phone/users.yml"
         
     | 
| 
       29 
36 
     | 
    
         
             
              @admin_password = "admin"
         
     | 
| 
       30 
37 
     | 
    
         
             
              @gsutil = "#{ENV["HOME"]}/.gs_phone/gsutil"
         
     | 
| 
       31 
     | 
    
         
            -
              @config_file = "#{ENV["HOME"]}/.gs_phone/settings.yml"
         
     | 
| 
       32 
38 
     | 
    
         
             
              @template_files = "#{ENV["HOME"]}/.gs_phone/templates/"
         
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
     | 
    
         
            -
               
     | 
| 
       35 
     | 
    
         
            -
              def initialize 
     | 
| 
       36 
     | 
    
         
            -
                 
     | 
| 
       37 
     | 
    
         
            -
                 
     | 
| 
       38 
     | 
    
         
            -
                 
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
       40 
     | 
    
         
            -
                @admin = args[3]
         
     | 
| 
       41 
     | 
    
         
            -
             
     | 
| 
       42 
     | 
    
         
            -
                case @command
         
     | 
| 
       43 
     | 
    
         
            -
                when "help"
         
     | 
| 
       44 
     | 
    
         
            -
                  help_command = args[1]
         
     | 
| 
       45 
     | 
    
         
            -
                  puts usage_summary(help_command)
         
     | 
| 
       46 
     | 
    
         
            -
                when "new"
         
     | 
| 
       47 
     | 
    
         
            -
                  self.add_user(@ip)
         
     | 
| 
       48 
     | 
    
         
            -
                  self.make(@ip)
         
     | 
| 
       49 
     | 
    
         
            -
                  self.update_config(@ip, @current_ip, @admin)
         
     | 
| 
       50 
     | 
    
         
            -
                  self.reboot_phone(@ip)
         
     | 
| 
       51 
     | 
    
         
            -
                when "add"
         
     | 
| 
       52 
     | 
    
         
            -
                  self.add_user(@ip)
         
     | 
| 
       53 
     | 
    
         
            -
                when "make"
         
     | 
| 
       54 
     | 
    
         
            -
                  self.make(@ip)
         
     | 
| 
       55 
     | 
    
         
            -
                when "update"
         
     | 
| 
       56 
     | 
    
         
            -
                  self.update_config(@ip, @current_ip, @admin)
         
     | 
| 
       57 
     | 
    
         
            -
                when "reboot"
         
     | 
| 
       58 
     | 
    
         
            -
                  self.reboot_phone(@ip)
         
     | 
| 
       59 
     | 
    
         
            -
                when "find"
         
     | 
| 
       60 
     | 
    
         
            -
                  self.find_ip
         
     | 
| 
      
 39 
     | 
    
         
            +
              @new_config_created = ""
         
     | 
| 
      
 40 
     | 
    
         
            +
              
         
     | 
| 
      
 41 
     | 
    
         
            +
              def initialize
         
     | 
| 
      
 42 
     | 
    
         
            +
                @verbose = false
         
     | 
| 
      
 43 
     | 
    
         
            +
                # Use the GS_PHONE_CONFIG environnment to set the data directory
         
     | 
| 
      
 44 
     | 
    
         
            +
                if not ENV["GS_PHONE_CONFIG"].nil?
         
     | 
| 
      
 45 
     | 
    
         
            +
                  @config_file = ENV["GS_PHONE_CONFIG"]
         
     | 
| 
       61 
46 
     | 
    
         
             
                else
         
     | 
| 
       62 
     | 
    
         
            -
                  
         
     | 
| 
      
 47 
     | 
    
         
            +
                  @config_file = "#{ENV["HOME"]}/.gs_phone/"
         
     | 
| 
       63 
48 
     | 
    
         
             
                end
         
     | 
| 
      
 49 
     | 
    
         
            +
                read_configuration
         
     | 
| 
      
 50 
     | 
    
         
            +
                # TODO: need to find a way to stop printing this in TEST
         
     | 
| 
      
 51 
     | 
    
         
            +
                # puts @new_config_created unless @new_config_created.nil?
         
     | 
| 
       64 
52 
     | 
    
         
             
              end
         
     | 
| 
       65 
53 
     | 
    
         | 
| 
      
 54 
     | 
    
         
            +
              def help(command=nil)
         
     | 
| 
      
 55 
     | 
    
         
            +
                usage_summary(command)
         
     | 
| 
      
 56 
     | 
    
         
            +
              end
         
     | 
| 
       66 
57 
     | 
    
         | 
| 
       67 
58 
     | 
    
         
             
              # Read the gs_phone configuration file to get the settings
         
     | 
| 
       68 
59 
     | 
    
         
             
              def read_configuration
         
     | 
| 
       69 
     | 
    
         
            -
             
     | 
| 
       70 
     | 
    
         
            -
                if File.exists?(" 
     | 
| 
      
 60 
     | 
    
         
            +
                
         
     | 
| 
      
 61 
     | 
    
         
            +
                if File.exists?(@config_file + "/settings.yml")
         
     | 
| 
       71 
62 
     | 
    
         
             
                  settings = Hash.new
         
     | 
| 
       72 
     | 
    
         
            -
                  settings = YAML::load(File.open(" 
     | 
| 
      
 63 
     | 
    
         
            +
                  settings = YAML::load(File.open(@config_file + "/settings.yml"))
         
     | 
| 
       73 
64 
     | 
    
         | 
| 
       74 
65 
     | 
    
         
             
                  @user_file = settings["user_file"] if settings.include?("user_file")
         
     | 
| 
       75 
66 
     | 
    
         
             
                  @admin_password = settings["admin_password"]
         
     | 
| 
         @@ -77,46 +68,57 @@ class GrandStream 
     | 
|
| 
       77 
68 
     | 
    
         
             
                  @config_file = settings["config_file"]
         
     | 
| 
       78 
69 
     | 
    
         
             
                  @template_files = settings["template_files"]
         
     | 
| 
       79 
70 
     | 
    
         
             
                else
         
     | 
| 
       80 
     | 
    
         
            -
                   
     | 
| 
      
 71 
     | 
    
         
            +
                  # No settings found so we need to follow a differnt logic path
         
     | 
| 
      
 72 
     | 
    
         
            +
                  # using the @new_config_created to hold our info messages
         
     | 
| 
      
 73 
     | 
    
         
            +
                  @new_config_created = "You have no default configuration file.  We will create one for you\n"
         
     | 
| 
       81 
74 
     | 
    
         
             
                  settings = {
         
     | 
| 
       82 
75 
     | 
    
         
             
                    "admin_password" => "admin",
         
     | 
| 
       83 
     | 
    
         
            -
                    "user_file" => "#{ 
     | 
| 
       84 
     | 
    
         
            -
                    "gsutil" => "#{ 
     | 
| 
       85 
     | 
    
         
            -
                    "config_file" => "#{ 
     | 
| 
       86 
     | 
    
         
            -
                    "template_files" => "#{ 
     | 
| 
      
 76 
     | 
    
         
            +
                    "user_file" => "#{@config_file}/users.yml",
         
     | 
| 
      
 77 
     | 
    
         
            +
                    "gsutil" => "#{@config_file}/gsutil",
         
     | 
| 
      
 78 
     | 
    
         
            +
                    "config_file" => "#{@config_file}/settings.yml",
         
     | 
| 
      
 79 
     | 
    
         
            +
                    "template_files" => "#{@config_file}/templates/"
         
     | 
| 
       87 
80 
     | 
    
         
             
                  }
         
     | 
| 
       88 
81 
     | 
    
         | 
| 
       89 
     | 
    
         
            -
                  Dir.mkdir( 
     | 
| 
       90 
     | 
    
         
            -
                  Dir.mkdir("#{ 
     | 
| 
       91 
     | 
    
         
            -
                  cfg_template = File.new("#{ 
     | 
| 
      
 82 
     | 
    
         
            +
                  Dir.mkdir(@config_file)
         
     | 
| 
      
 83 
     | 
    
         
            +
                  Dir.mkdir("#{@config_file}/templates")
         
     | 
| 
      
 84 
     | 
    
         
            +
                  cfg_template = File.new("#{@config_file}/templates/template.cfg", "w")
         
     | 
| 
       92 
85 
     | 
    
         
             
                  cfg_template.puts add_template
         
     | 
| 
       93 
86 
     | 
    
         
             
                  cfg_template.close
         
     | 
| 
       94 
87 
     | 
    
         | 
| 
       95 
     | 
    
         
            -
                  file = File.new("#{ 
     | 
| 
      
 88 
     | 
    
         
            +
                  file = File.new("#{@config_file}/settings.yml","w")
         
     | 
| 
       96 
89 
     | 
    
         
             
                  file.puts settings.to_yaml
         
     | 
| 
       97 
90 
     | 
    
         
             
                  file.close
         
     | 
| 
       98 
91 
     | 
    
         | 
| 
       99 
     | 
    
         
            -
                   
     | 
| 
       100 
     | 
    
         
            -
                   
     | 
| 
       101 
     | 
    
         
            -
                  exit
         
     | 
| 
      
 92 
     | 
    
         
            +
                  @new_config_created << "File #{@config_file}/ has been created.  Please make sure the\n"
         
     | 
| 
      
 93 
     | 
    
         
            +
                  @new_config_created << " settings are correct."
         
     | 
| 
       102 
94 
     | 
    
         | 
| 
       103 
95 
     | 
    
         
             
                end
         
     | 
| 
       104 
96 
     | 
    
         
             
              end
         
     | 
| 
       105 
97 
     | 
    
         | 
| 
       106 
98 
     | 
    
         
             
              # Add a user to the configuration file
         
     | 
| 
       107 
     | 
    
         
            -
              def add_user(ip_addr=nil)
         
     | 
| 
      
 99 
     | 
    
         
            +
              def add_user(ip_addr=nil,username=nil,password=nil,mac_addy=nil)
         
     | 
| 
       108 
100 
     | 
    
         
             
                # Lets get some details for the new user
         
     | 
| 
       109 
     | 
    
         
            -
                 
     | 
| 
       110 
     | 
    
         
            -
             
     | 
| 
       111 
     | 
    
         
            -
             
     | 
| 
       112 
     | 
    
         
            -
                 
     | 
| 
      
 101 
     | 
    
         
            +
                if username.nil?
         
     | 
| 
      
 102 
     | 
    
         
            +
                  puts "Username?"
         
     | 
| 
      
 103 
     | 
    
         
            +
                  username = STDIN.gets.chomp
         
     | 
| 
      
 104 
     | 
    
         
            +
                end
         
     | 
| 
      
 105 
     | 
    
         
            +
                
         
     | 
| 
      
 106 
     | 
    
         
            +
                # TODO: assuming password and extensions are the same.
         
     | 
| 
      
 107 
     | 
    
         
            +
                if password.nil?
         
     | 
| 
      
 108 
     | 
    
         
            +
                  puts "Extension Number?"
         
     | 
| 
      
 109 
     | 
    
         
            +
                  password = STDIN.gets.chomp
         
     | 
| 
      
 110 
     | 
    
         
            +
                end
         
     | 
| 
      
 111 
     | 
    
         
            +
             
     | 
| 
       113 
112 
     | 
    
         
             
                # Skip the ip address if they already passed it in.
         
     | 
| 
       114 
113 
     | 
    
         
             
                if ip_addr.nil?
         
     | 
| 
       115 
     | 
    
         
            -
                  puts " 
     | 
| 
      
 114 
     | 
    
         
            +
                  puts "Phone IP Address (i.e. 192.168.1.1)"
         
     | 
| 
       116 
115 
     | 
    
         
             
                  ip_addr = STDIN.gets.chomp
         
     | 
| 
       117 
116 
     | 
    
         
             
                end
         
     | 
| 
       118 
     | 
    
         
            -
             
     | 
| 
       119 
     | 
    
         
            -
                mac_addy 
     | 
| 
      
 117 
     | 
    
         
            +
             
     | 
| 
      
 118 
     | 
    
         
            +
                if mac_addy.nil?
         
     | 
| 
      
 119 
     | 
    
         
            +
                  puts "MAC Address?"
         
     | 
| 
      
 120 
     | 
    
         
            +
                  mac_addy = STDIN.gets.chomp
         
     | 
| 
      
 121 
     | 
    
         
            +
                end
         
     | 
| 
       120 
122 
     | 
    
         | 
| 
       121 
123 
     | 
    
         
             
                # Open the user file and enter the data
         
     | 
| 
       122 
124 
     | 
    
         
             
                users = File.open(@user_file, 'a')
         
     | 
| 
         @@ -127,54 +129,54 @@ class GrandStream 
     | 
|
| 
       127 
129 
     | 
    
         
             
                users.puts "mac: " + mac_addy
         
     | 
| 
       128 
130 
     | 
    
         
             
                users.close
         
     | 
| 
       129 
131 
     | 
    
         | 
| 
       130 
     | 
    
         
            -
                # Set this so we can use it in other parts of the script if " 
     | 
| 
       131 
     | 
    
         
            -
                @ip = ip_addr 
     | 
| 
      
 132 
     | 
    
         
            +
                # Set this so we can use it in other parts of the script if "new" was called
         
     | 
| 
      
 133 
     | 
    
         
            +
                @ip = ip_addr
         
     | 
| 
       132 
134 
     | 
    
         
             
              end
         
     | 
| 
       133 
135 
     | 
    
         | 
| 
       134 
136 
     | 
    
         
             
              # Generate a config file from the template
         
     | 
| 
       135 
137 
     | 
    
         
             
              def make(ip_address=@ip)
         
     | 
| 
       136 
138 
     | 
    
         
             
                # Skip the ip address if they already passed it in.
         
     | 
| 
       137 
139 
     | 
    
         
             
                if ip_address.nil?
         
     | 
| 
       138 
     | 
    
         
            -
                  puts " 
     | 
| 
      
 140 
     | 
    
         
            +
                  puts "What ip address?  "
         
     | 
| 
       139 
141 
     | 
    
         
             
                  ip_address = STDIN.gets.chomp
         
     | 
| 
       140 
142 
     | 
    
         
             
                end
         
     | 
| 
       141 
143 
     | 
    
         | 
| 
       142 
     | 
    
         
            -
                 
     | 
| 
       143 
     | 
    
         
            -
                 
     | 
| 
       144 
     | 
    
         
            -
             
     | 
| 
      
 144 
     | 
    
         
            +
                exten = ""
         
     | 
| 
      
 145 
     | 
    
         
            +
                
         
     | 
| 
       145 
146 
     | 
    
         
             
                # Open the user file and find the user who has the ip address that matches
         
     | 
| 
       146 
147 
     | 
    
         
             
                # the one we are looking for
         
     | 
| 
       147 
     | 
    
         
            -
                 
     | 
| 
       148 
     | 
    
         
            -
             
     | 
| 
       149 
     | 
    
         
            -
             
     | 
| 
       150 
     | 
    
         
            -
             
     | 
| 
       151 
     | 
    
         
            -
             
     | 
| 
       152 
     | 
    
         
            -
             
     | 
| 
       153 
     | 
    
         
            -
             
     | 
| 
       154 
     | 
    
         
            -
             
     | 
| 
       155 
     | 
    
         
            -
             
     | 
| 
       156 
     | 
    
         
            -
             
     | 
| 
       157 
     | 
    
         
            -
             
     | 
| 
       158 
     | 
    
         
            -
             
     | 
| 
       159 
     | 
    
         
            -
             
     | 
| 
       160 
     | 
    
         
            -
             
     | 
| 
       161 
     | 
    
         
            -
             
     | 
| 
       162 
     | 
    
         
            -
             
     | 
| 
       163 
     | 
    
         
            -
             
     | 
| 
       164 
     | 
    
         
            -
             
     | 
| 
       165 
     | 
    
         
            -
             
     | 
| 
       166 
     | 
    
         
            -
             
     | 
| 
       167 
     | 
    
         
            -
             
     | 
| 
       168 
     | 
    
         
            -
             
     | 
| 
       169 
     | 
    
         
            -
             
     | 
| 
       170 
     | 
    
         
            -
             
     | 
| 
       171 
     | 
    
         
            -
                     
     | 
| 
       172 
     | 
    
         
            -
                  end #  
     | 
| 
       173 
     | 
    
         
            -
                end #  
     | 
| 
      
 148 
     | 
    
         
            +
                File.open(@user_file) do |users|
         
     | 
| 
      
 149 
     | 
    
         
            +
                  data = YAML::load_documents(users) do |element|
         
     | 
| 
      
 150 
     | 
    
         
            +
                    if element['ip'] == ip_address and not element['skip'] == 'y'
         
     | 
| 
      
 151 
     | 
    
         
            +
                      name = element['name']
         
     | 
| 
      
 152 
     | 
    
         
            +
                      password = element['ext'].to_s
         
     | 
| 
      
 153 
     | 
    
         
            +
                      exten = element['ext'].to_s
         
     | 
| 
      
 154 
     | 
    
         
            +
                      ip = element['ip']
         
     | 
| 
      
 155 
     | 
    
         
            +
                      
         
     | 
| 
      
 156 
     | 
    
         
            +
                      # Split the ip address into each octal, the Grandstream config files
         
     | 
| 
      
 157 
     | 
    
         
            +
                      # needs it this way
         
     | 
| 
      
 158 
     | 
    
         
            +
                      ip1, ip2, ip3, ip4 = ip.split('.')
         
     | 
| 
      
 159 
     | 
    
         
            +
                      
         
     | 
| 
      
 160 
     | 
    
         
            +
                      templated = IO.readlines(@template_files + "template.cfg")
         
     | 
| 
      
 161 
     | 
    
         
            +
                      phone_config = ""
         
     | 
| 
      
 162 
     | 
    
         
            +
             
     | 
| 
      
 163 
     | 
    
         
            +
                      # Substitue in the user fields into their config 
         
     | 
| 
      
 164 
     | 
    
         
            +
                      # a.k.a. Magic REGEX section
         
     | 
| 
      
 165 
     | 
    
         
            +
                      templated.each do |line|
         
     | 
| 
      
 166 
     | 
    
         
            +
                        phone_config << line.gsub(/<<ext>>/, exten).gsub(/<<name>>/, name).gsub(/<<password>>/, password).gsub(/<<ip1>>/, ip1).gsub(/<<ip2>>/, ip2).gsub(/<<ip3>>/, ip3).gsub(/<<ip4>>/, ip4)
         
     | 
| 
      
 167 
     | 
    
         
            +
                      end
         
     | 
| 
      
 168 
     | 
    
         
            +
                      # Write out the string to a file now
         
     | 
| 
      
 169 
     | 
    
         
            +
                      File.open("#{@template_files}#{ip}.cfg", "w+") do |file|
         
     | 
| 
      
 170 
     | 
    
         
            +
                        file.puts phone_config
         
     | 
| 
      
 171 
     | 
    
         
            +
                      end
         
     | 
| 
      
 172 
     | 
    
         
            +
                    end # IF
         
     | 
| 
      
 173 
     | 
    
         
            +
                  end # DO
         
     | 
| 
      
 174 
     | 
    
         
            +
                end # File
         
     | 
| 
      
 175 
     | 
    
         
            +
                return "Made config for extension #{exten.to_s}"
         
     | 
| 
       174 
176 
     | 
    
         
             
              end
         
     | 
| 
       175 
177 
     | 
    
         | 
| 
       176 
178 
     | 
    
         
             
              def make_all
         
     | 
| 
       177 
     | 
    
         
            -
                puts " 
     | 
| 
      
 179 
     | 
    
         
            +
                puts "Making all configs" if @verbose
         
     | 
| 
       178 
180 
     | 
    
         
             
                @user_list = Hash.new
         
     | 
| 
       179 
181 
     | 
    
         | 
| 
       180 
182 
     | 
    
         
             
                users = File.open(@user_file)
         
     | 
| 
         @@ -183,7 +185,6 @@ class GrandStream 
     | 
|
| 
       183 
185 
     | 
    
         
             
                  @user_list[element['ext']] = element['ip']
         
     | 
| 
       184 
186 
     | 
    
         
             
                end
         
     | 
| 
       185 
187 
     | 
    
         
             
                @user_list.each do |ext,ip|
         
     | 
| 
       186 
     | 
    
         
            -
                  puts "GS< Making config for #{ext} (#{ip})"
         
     | 
| 
       187 
188 
     | 
    
         
             
                  make(ip)
         
     | 
| 
       188 
189 
     | 
    
         
             
                end
         
     | 
| 
       189 
190 
     | 
    
         
             
              end
         
     | 
| 
         @@ -193,7 +194,7 @@ class GrandStream 
     | 
|
| 
       193 
194 
     | 
    
         
             
              def update_config(ip_address=@ip, current_ip=nil, admin=nil)
         
     | 
| 
       194 
195 
     | 
    
         
             
                # Skip the ip address if they already passed it in.
         
     | 
| 
       195 
196 
     | 
    
         
             
                if ip_address.nil?
         
     | 
| 
       196 
     | 
    
         
            -
                  puts " 
     | 
| 
      
 197 
     | 
    
         
            +
                  puts "What ip address?  "
         
     | 
| 
       197 
198 
     | 
    
         
             
                  ip_address = STDIN.gets.chomp
         
     | 
| 
       198 
199 
     | 
    
         
             
                end
         
     | 
| 
       199 
200 
     | 
    
         
             
                if admin.nil?
         
     | 
| 
         @@ -202,15 +203,19 @@ class GrandStream 
     | 
|
| 
       202 
203 
     | 
    
         
             
                if current_ip.nil?
         
     | 
| 
       203 
204 
     | 
    
         
             
                  current_ip = ip_address
         
     | 
| 
       204 
205 
     | 
    
         
             
                end
         
     | 
| 
       205 
     | 
    
         
            -
             
     | 
| 
       206 
     | 
    
         
            -
                 
     | 
| 
       207 
     | 
    
         
            -
                 
     | 
| 
       208 
     | 
    
         
            -
             
     | 
| 
      
 206 
     | 
    
         
            +
             
     | 
| 
      
 207 
     | 
    
         
            +
                # Shell out to the gsutil script to scrape the webforms
         
     | 
| 
      
 208 
     | 
    
         
            +
                if system("#{@gsutil} -p '#{admin}' -r '#{current_ip}' < #{@template_files}#{ip_address}.cfg")
         
     | 
| 
      
 209 
     | 
    
         
            +
                  return "Config sent to phone" if @verbose
         
     | 
| 
      
 210 
     | 
    
         
            +
                else
         
     | 
| 
      
 211 
     | 
    
         
            +
                  # TODO: This path is never reached, even if gsutil has an error.
         
     | 
| 
      
 212 
     | 
    
         
            +
                  return "ERROR: Failed to send config"
         
     | 
| 
      
 213 
     | 
    
         
            +
                end
         
     | 
| 
       209 
214 
     | 
    
         
             
              end
         
     | 
| 
       210 
215 
     | 
    
         | 
| 
       211 
216 
     | 
    
         
             
              # Make a config file for each phone and push it to the phone
         
     | 
| 
       212 
217 
     | 
    
         
             
              def update_all
         
     | 
| 
       213 
     | 
    
         
            -
                puts " 
     | 
| 
      
 218 
     | 
    
         
            +
                puts "Updating all phones" if @verbose
         
     | 
| 
       214 
219 
     | 
    
         
             
                @user_list = Hash.new
         
     | 
| 
       215 
220 
     | 
    
         | 
| 
       216 
221 
     | 
    
         
             
                users = File.open(@user_file)
         
     | 
| 
         @@ -220,10 +225,15 @@ class GrandStream 
     | 
|
| 
       220 
225 
     | 
    
         
             
                    @user_list[element['ext']] = element['ip']
         
     | 
| 
       221 
226 
     | 
    
         
             
                  end
         
     | 
| 
       222 
227 
     | 
    
         
             
                end
         
     | 
| 
      
 228 
     | 
    
         
            +
             
     | 
| 
      
 229 
     | 
    
         
            +
                responses = String.new
         
     | 
| 
       223 
230 
     | 
    
         
             
                @user_list.each do |ext,ip|
         
     | 
| 
       224 
     | 
    
         
            -
                   
     | 
| 
       225 
     | 
    
         
            -
                   
     | 
| 
      
 231 
     | 
    
         
            +
                  response = update_config(ip)
         
     | 
| 
      
 232 
     | 
    
         
            +
                  if response
         
     | 
| 
      
 233 
     | 
    
         
            +
                    responses << response
         
     | 
| 
      
 234 
     | 
    
         
            +
                  end
         
     | 
| 
       226 
235 
     | 
    
         
             
                end
         
     | 
| 
      
 236 
     | 
    
         
            +
                return responses if @verbose
         
     | 
| 
       227 
237 
     | 
    
         
             
              end
         
     | 
| 
       228 
238 
     | 
    
         | 
| 
       229 
239 
     | 
    
         | 
| 
         @@ -231,21 +241,23 @@ class GrandStream 
     | 
|
| 
       231 
241 
     | 
    
         
             
              def reboot_phone(ip_address=@ip)
         
     | 
| 
       232 
242 
     | 
    
         
             
                # Skip the ip address if they already passed it in.
         
     | 
| 
       233 
243 
     | 
    
         
             
                if ip_address.nil?
         
     | 
| 
       234 
     | 
    
         
            -
                  puts " 
     | 
| 
      
 244 
     | 
    
         
            +
                  puts "What ip address?  "
         
     | 
| 
       235 
245 
     | 
    
         
             
                  ip_address = STDIN.gets.chomp
         
     | 
| 
       236 
246 
     | 
    
         
             
                end
         
     | 
| 
       237 
247 
     | 
    
         
             
                # Need a delay, if we just uploaded the new config then the phone will give a 500 
         
     | 
| 
       238 
248 
     | 
    
         
             
                # error if we try to reboot it too soon
         
     | 
| 
       239 
249 
     | 
    
         
             
                sleep(3) 
         
     | 
| 
       240 
250 
     | 
    
         
             
                # Setup the string to shell out to the gsutil script to scrape the webforms
         
     | 
| 
       241 
     | 
    
         
            -
                 
     | 
| 
       242 
     | 
    
         
            -
             
     | 
| 
       243 
     | 
    
         
            -
                 
     | 
| 
      
 251 
     | 
    
         
            +
                if system("#{@gsutil} -p '#{@admin_password}' -b '#{ip_address}'")
         
     | 
| 
      
 252 
     | 
    
         
            +
                  return "Phone rebooted" if @verbose
         
     | 
| 
      
 253 
     | 
    
         
            +
                else
         
     | 
| 
      
 254 
     | 
    
         
            +
                  return "ERROR: Failed to reboot phone"
         
     | 
| 
      
 255 
     | 
    
         
            +
                end
         
     | 
| 
       244 
256 
     | 
    
         
             
              end
         
     | 
| 
       245 
257 
     | 
    
         | 
| 
       246 
258 
     | 
    
         
             
              # Reboot all phones
         
     | 
| 
       247 
259 
     | 
    
         
             
              def reboot_all_phones
         
     | 
| 
       248 
     | 
    
         
            -
                puts " 
     | 
| 
      
 260 
     | 
    
         
            +
                puts "Rebooting all phones" if @verbose
         
     | 
| 
       249 
261 
     | 
    
         
             
                @user_list = Hash.new
         
     | 
| 
       250 
262 
     | 
    
         | 
| 
       251 
263 
     | 
    
         
             
                users = File.open(@user_file)
         
     | 
| 
         @@ -255,32 +267,36 @@ class GrandStream 
     | 
|
| 
       255 
267 
     | 
    
         
             
                    @user_list[element['ext']] = element['ip']
         
     | 
| 
       256 
268 
     | 
    
         
             
                  end
         
     | 
| 
       257 
269 
     | 
    
         
             
                end
         
     | 
| 
       258 
     | 
    
         
            -
                 
     | 
| 
       259 
     | 
    
         
            -
                 
     | 
| 
       260 
     | 
    
         
            -
                sleep(3) 
         
     | 
| 
       261 
     | 
    
         
            -
                # Go-go BOFH method, this will reboot every phone in the user list.
         
     | 
| 
      
 270 
     | 
    
         
            +
                
         
     | 
| 
      
 271 
     | 
    
         
            +
                responses = String.new
         
     | 
| 
       262 
272 
     | 
    
         
             
                @user_list.each do |ext,ip|
         
     | 
| 
       263 
     | 
    
         
            -
                   
     | 
| 
       264 
     | 
    
         
            -
                   
     | 
| 
       265 
     | 
    
         
            -
             
     | 
| 
      
 273 
     | 
    
         
            +
                  response = reboot_phone(ip)
         
     | 
| 
      
 274 
     | 
    
         
            +
                  if response
         
     | 
| 
      
 275 
     | 
    
         
            +
                    responses << response
         
     | 
| 
      
 276 
     | 
    
         
            +
                  end
         
     | 
| 
       266 
277 
     | 
    
         
             
                end
         
     | 
| 
      
 278 
     | 
    
         
            +
             
     | 
| 
      
 279 
     | 
    
         
            +
                return responses if @verbose
         
     | 
| 
       267 
280 
     | 
    
         
             
              end
         
     | 
| 
       268 
281 
     | 
    
         | 
| 
       269 
282 
     | 
    
         
             
              # Finds the ip address of the phone if you know the extension.
         
     | 
| 
       270 
     | 
    
         
            -
              def find_ip
         
     | 
| 
       271 
     | 
    
         
            -
                 
     | 
| 
       272 
     | 
    
         
            -
             
     | 
| 
      
 283 
     | 
    
         
            +
              def find_ip(extension=nil)
         
     | 
| 
      
 284 
     | 
    
         
            +
                if extension.nil?
         
     | 
| 
      
 285 
     | 
    
         
            +
                  print "What extension?  "
         
     | 
| 
      
 286 
     | 
    
         
            +
                  extension = STDIN.gets.chomp
         
     | 
| 
      
 287 
     | 
    
         
            +
                end
         
     | 
| 
       273 
288 
     | 
    
         | 
| 
       274 
289 
     | 
    
         
             
                # Go thorugh config file loking for the extension
         
     | 
| 
       275 
290 
     | 
    
         
             
                data = YAML::load_documents(File.open(@user_file)) do |element|
         
     | 
| 
       276 
     | 
    
         
            -
                  if element['ext'] ==  
     | 
| 
      
 291 
     | 
    
         
            +
                  if element['ext'] == extension.to_i
         
     | 
| 
       277 
292 
     | 
    
         
             
                    @ip = element['ip']
         
     | 
| 
       278 
     | 
    
         
            -
                    puts " 
     | 
| 
      
 293 
     | 
    
         
            +
                    puts "#{element['ip']}" if @verbose
         
     | 
| 
      
 294 
     | 
    
         
            +
                    return element['ip']
         
     | 
| 
       279 
295 
     | 
    
         
             
                  end        
         
     | 
| 
       280 
296 
     | 
    
         
             
                end
         
     | 
| 
       281 
297 
     | 
    
         
             
              end
         
     | 
| 
       282 
298 
     | 
    
         | 
| 
       283 
     | 
    
         
            -
             
     | 
| 
      
 299 
     | 
    
         
            +
              def usage_summary(command)
         
     | 
| 
       284 
300 
     | 
    
         
             
                usage = ""
         
     | 
| 
       285 
301 
     | 
    
         
             
                case command
         
     | 
| 
       286 
302 
     | 
    
         
             
                when "new"
         
     | 
| 
         @@ -320,7 +336,7 @@ Usage: update IP_ADDRESS [CURRENT_ADDRESS] [ADMIN_PASSWORD] 
     | 
|
| 
       320 
336 
     | 
    
         | 
| 
       321 
337 
     | 
    
         
             
            Sends the updated configuration file for IP_ADDRESS to the phone.
         
     | 
| 
       322 
338 
     | 
    
         | 
| 
       323 
     | 
    
         
            -
             
     | 
| 
      
 339 
     | 
    
         
            +
            Optionally, a phone configuration can be sent to a phone that currently has
         
     | 
| 
       324 
340 
     | 
    
         
             
            a different ip address by using CURRENT_ADDRESS
         
     | 
| 
       325 
341 
     | 
    
         | 
| 
       326 
342 
     | 
    
         
             
            The admin password from the configuration file can also be overridden
         
     | 
| 
         @@ -358,9 +374,6 @@ EOFIND 
     | 
|
| 
       358 
374 
     | 
    
         
             
                  usage =<<EOHELP
         
     | 
| 
       359 
375 
     | 
    
         
             
            Usage: COMMAND [options]
         
     | 
| 
       360 
376 
     | 
    
         | 
| 
       361 
     | 
    
         
            -
            IP is the ip address you want the phone to use crtIP is the ip address
         
     | 
| 
       362 
     | 
    
         
            -
            the phone currently has pass is the current phone password
         
     | 
| 
       363 
     | 
    
         
            -
             
     | 
| 
       364 
377 
     | 
    
         
             
            COMMANDS       DESCRIPTION
         
     | 
| 
       365 
378 
     | 
    
         
             
            new            Add new user and setup their phone 
         
     | 
| 
       366 
379 
     | 
    
         
             
            add            Adds a user to the phone database
         
     | 
    
        data/test/gs_phone_test.rb
    CHANGED
    
    | 
         @@ -1,11 +1,352 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require File.dirname(__FILE__) + '/test_helper.rb'
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
            class  
     | 
| 
      
 3 
     | 
    
         
            +
            class GrandstreamTest < Test::Unit::TestCase
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
              def setup
         
     | 
| 
      
 6 
     | 
    
         
            +
                # Recreate the base config files
         
     | 
| 
      
 7 
     | 
    
         
            +
                ENV["GS_PHONE_CONFIG"] = "tmp"
         
     | 
| 
      
 8 
     | 
    
         
            +
              end
         
     | 
| 
      
 9 
     | 
    
         
            +
              
         
     | 
| 
      
 10 
     | 
    
         
            +
              def teardown
         
     | 
| 
      
 11 
     | 
    
         
            +
                # Remove the base config files
         
     | 
| 
      
 12 
     | 
    
         
            +
                system("rm -Rf tmp")
         
     | 
| 
       6 
13 
     | 
    
         
             
              end
         
     | 
| 
       7 
14 
     | 
    
         | 
| 
       8 
15 
     | 
    
         
             
              def test_truth
         
     | 
| 
       9 
16 
     | 
    
         
             
                assert true
         
     | 
| 
       10 
17 
     | 
    
         
             
              end
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
              def create_new_settings
         
     | 
| 
      
 20 
     | 
    
         
            +
                GrandStream.new()    
         
     | 
| 
      
 21 
     | 
    
         
            +
                # Copy in my ruby gsutil script so it can be used as a mock of the real gsutil.
         
     | 
| 
      
 22 
     | 
    
         
            +
                system("cp test/mock_gsutil.rb tmp/gsutil")
         
     | 
| 
      
 23 
     | 
    
         
            +
              end
         
     | 
| 
      
 24 
     | 
    
         
            +
              
         
     | 
| 
      
 25 
     | 
    
         
            +
              def change_admin_password
         
     | 
| 
      
 26 
     | 
    
         
            +
                settings = ""
         
     | 
| 
      
 27 
     | 
    
         
            +
                File.open("tmp/settings.yml", "r") do |file|
         
     | 
| 
      
 28 
     | 
    
         
            +
                  settings = file.readlines
         
     | 
| 
      
 29 
     | 
    
         
            +
                end
         
     | 
| 
      
 30 
     | 
    
         
            +
                
         
     | 
| 
      
 31 
     | 
    
         
            +
                settings.each do |line|
         
     | 
| 
      
 32 
     | 
    
         
            +
                  line.gsub!(": admin",": gs_phone")
         
     | 
| 
      
 33 
     | 
    
         
            +
                end
         
     | 
| 
      
 34 
     | 
    
         
            +
                
         
     | 
| 
      
 35 
     | 
    
         
            +
                File.open("tmp/settings.yml", "w") do |file|
         
     | 
| 
      
 36 
     | 
    
         
            +
                  file.puts settings
         
     | 
| 
      
 37 
     | 
    
         
            +
                end
         
     | 
| 
      
 38 
     | 
    
         
            +
              end
         
     | 
| 
      
 39 
     | 
    
         
            +
              
         
     | 
| 
      
 40 
     | 
    
         
            +
              def test_new_config
         
     | 
| 
      
 41 
     | 
    
         
            +
                create_new_settings
         
     | 
| 
      
 42 
     | 
    
         
            +
                
         
     | 
| 
      
 43 
     | 
    
         
            +
                # Make sure the files are there
         
     | 
| 
      
 44 
     | 
    
         
            +
                assert File.exists?( "tmp/settings.yml")
         
     | 
| 
      
 45 
     | 
    
         
            +
                assert File.exists?( "tmp/templates")
         
     | 
| 
      
 46 
     | 
    
         
            +
                assert File.exists?( "tmp/templates/template.cfg") 
         
     | 
| 
      
 47 
     | 
    
         
            +
                
         
     | 
| 
      
 48 
     | 
    
         
            +
                # Make sure the settings file is correct
         
     | 
| 
      
 49 
     | 
    
         
            +
                settings = YAML::load(File.open("tmp/settings.yml"))
         
     | 
| 
      
 50 
     | 
    
         
            +
                assert_equal "admin",              settings["admin_password"]
         
     | 
| 
      
 51 
     | 
    
         
            +
                assert_equal "tmp/users.yml",      settings["user_file"]
         
     | 
| 
      
 52 
     | 
    
         
            +
                assert_equal "tmp/gsutil",         settings["gsutil"]
         
     | 
| 
      
 53 
     | 
    
         
            +
                assert_equal "tmp/settings.yml",   settings["config_file"]
         
     | 
| 
      
 54 
     | 
    
         
            +
                assert_equal "tmp/templates/",     settings["template_files"]
         
     | 
| 
      
 55 
     | 
    
         
            +
                
         
     | 
| 
      
 56 
     | 
    
         
            +
              end
         
     | 
| 
      
 57 
     | 
    
         
            +
              
         
     | 
| 
      
 58 
     | 
    
         
            +
              # Reading an existing settings file
         
     | 
| 
      
 59 
     | 
    
         
            +
              def test_read_settings
         
     | 
| 
      
 60 
     | 
    
         
            +
                create_new_settings
         
     | 
| 
      
 61 
     | 
    
         
            +
                gs = GrandStream.new()
         
     | 
| 
      
 62 
     | 
    
         
            +
                assert_equal "admin",              gs.admin_password
         
     | 
| 
      
 63 
     | 
    
         
            +
                assert_equal "tmp/users.yml",      gs.user_file
         
     | 
| 
      
 64 
     | 
    
         
            +
                assert_equal "tmp/gsutil",         gs.gsutil
         
     | 
| 
      
 65 
     | 
    
         
            +
                assert_equal "tmp/settings.yml",   gs.config_file
         
     | 
| 
      
 66 
     | 
    
         
            +
                assert_equal "tmp/templates/",     gs.template_files
         
     | 
| 
      
 67 
     | 
    
         
            +
              end
         
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
      
 69 
     | 
    
         
            +
              # Adding a new user
         
     | 
| 
      
 70 
     | 
    
         
            +
              def test_add_user
         
     | 
| 
      
 71 
     | 
    
         
            +
                create_new_settings
         
     | 
| 
      
 72 
     | 
    
         
            +
                gs = GrandStream.new
         
     | 
| 
      
 73 
     | 
    
         
            +
                gs.add_user("192.168.100.23","John Doe","200","000B820B0A7C")
         
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
      
 75 
     | 
    
         
            +
                assert File.exists?("tmp/users.yml")
         
     | 
| 
      
 76 
     | 
    
         
            +
                users = YAML::load(File.open("tmp/users.yml"))
         
     | 
| 
      
 77 
     | 
    
         
            +
                assert_equal "John Doe", users["name"]
         
     | 
| 
      
 78 
     | 
    
         
            +
                assert_equal 200, users["ext"]
         
     | 
| 
      
 79 
     | 
    
         
            +
                assert_equal "192.168.100.23", users["ip"]
         
     | 
| 
      
 80 
     | 
    
         
            +
                assert_equal "000B820B0A7C", users["mac"]
         
     | 
| 
      
 81 
     | 
    
         
            +
                
         
     | 
| 
      
 82 
     | 
    
         
            +
              end
         
     | 
| 
      
 83 
     | 
    
         
            +
             
     | 
| 
      
 84 
     | 
    
         
            +
              # Making a configuration file
         
     | 
| 
      
 85 
     | 
    
         
            +
              def test_make
         
     | 
| 
      
 86 
     | 
    
         
            +
                create_new_settings
         
     | 
| 
      
 87 
     | 
    
         
            +
                gs = GrandStream.new
         
     | 
| 
      
 88 
     | 
    
         
            +
                gs.add_user("192.168.100.23","John Doe","200","000B820B0A7C")
         
     | 
| 
      
 89 
     | 
    
         
            +
                
         
     | 
| 
      
 90 
     | 
    
         
            +
                # Make the file and check that it is correct
         
     | 
| 
      
 91 
     | 
    
         
            +
                gs.make("192.168.100.23")
         
     | 
| 
      
 92 
     | 
    
         
            +
                assert File.exists?("tmp/templates/192.168.100.23.cfg")
         
     | 
| 
      
 93 
     | 
    
         
            +
                
         
     | 
| 
      
 94 
     | 
    
         
            +
                config = File.read("tmp/templates/192.168.100.23.cfg")
         
     | 
| 
      
 95 
     | 
    
         
            +
                
         
     | 
| 
      
 96 
     | 
    
         
            +
                assert config.match("name = John Doe"), "Could not find the name in the file"
         
     | 
| 
      
 97 
     | 
    
         
            +
                assert config.match("end_user_password = 200"), "Could not find the password in the file"
         
     | 
| 
      
 98 
     | 
    
         
            +
                assert config.match("sip_userid = 200"), "Could not find the extension in the file"
         
     | 
| 
      
 99 
     | 
    
         
            +
                assert config.match("authenticate_id = 200"), "Could not find the extension in the file"
         
     | 
| 
      
 100 
     | 
    
         
            +
                assert config.match("static_ipaddress_1 = 192"), "Could not find the ip address in the file"
         
     | 
| 
      
 101 
     | 
    
         
            +
                assert config.match("static_ipaddress_2 = 168"), "Could not find the ip address in the file"
         
     | 
| 
      
 102 
     | 
    
         
            +
                assert config.match("static_ipaddress_3 = 100"), "Could not find the ip address in the file"
         
     | 
| 
      
 103 
     | 
    
         
            +
                assert config.match("static_ipaddress_4 = 23"), "Could not find the ip address in the file"
         
     | 
| 
      
 104 
     | 
    
         
            +
                
         
     | 
| 
      
 105 
     | 
    
         
            +
             
     | 
| 
      
 106 
     | 
    
         
            +
              end
         
     | 
| 
      
 107 
     | 
    
         
            +
             
     | 
| 
      
 108 
     | 
    
         
            +
              # Making all of the configuration files
         
     | 
| 
      
 109 
     | 
    
         
            +
              def test_make_all
         
     | 
| 
      
 110 
     | 
    
         
            +
                create_new_settings
         
     | 
| 
      
 111 
     | 
    
         
            +
                gs = GrandStream.new
         
     | 
| 
      
 112 
     | 
    
         
            +
             
     | 
| 
      
 113 
     | 
    
         
            +
                # Users
         
     | 
| 
      
 114 
     | 
    
         
            +
                userlist = { 
         
     | 
| 
      
 115 
     | 
    
         
            +
                  "192.168.100.23" => "John Doe1",
         
     | 
| 
      
 116 
     | 
    
         
            +
                  "192.168.100.24" => "John Doe2",
         
     | 
| 
      
 117 
     | 
    
         
            +
                  "192.168.100.25" => "John Doe3",
         
     | 
| 
      
 118 
     | 
    
         
            +
                  "192.168.100.26" => "John Doe4",
         
     | 
| 
      
 119 
     | 
    
         
            +
                  "192.168.100.27" => "John Doe5",
         
     | 
| 
      
 120 
     | 
    
         
            +
                  "192.168.100.28" => "John Doe6"
         
     | 
| 
      
 121 
     | 
    
         
            +
                }
         
     | 
| 
      
 122 
     | 
    
         
            +
             
     | 
| 
      
 123 
     | 
    
         
            +
                # Create some users
         
     | 
| 
      
 124 
     | 
    
         
            +
                userlist.each do |ip,user|
         
     | 
| 
      
 125 
     | 
    
         
            +
                  gs.add_user(ip,user,rand(300).to_s,"000B820B0A7C")
         
     | 
| 
      
 126 
     | 
    
         
            +
                end
         
     | 
| 
      
 127 
     | 
    
         
            +
             
     | 
| 
      
 128 
     | 
    
         
            +
                # Make all of the files
         
     | 
| 
      
 129 
     | 
    
         
            +
                gs.make_all
         
     | 
| 
      
 130 
     | 
    
         
            +
             
     | 
| 
      
 131 
     | 
    
         
            +
                # Check that they are all there and correct
         
     | 
| 
      
 132 
     | 
    
         
            +
                userlist.each do |ip, user|
         
     | 
| 
      
 133 
     | 
    
         
            +
                  assert File.exists?("tmp/templates/#{ip}.cfg")
         
     | 
| 
      
 134 
     | 
    
         
            +
                  config = File.read("tmp/templates/#{ip}.cfg")
         
     | 
| 
      
 135 
     | 
    
         
            +
                  assert config.match("name = #{user}"), "Could not find the name in the file"
         
     | 
| 
      
 136 
     | 
    
         
            +
                end
         
     | 
| 
      
 137 
     | 
    
         
            +
              end
         
     | 
| 
      
 138 
     | 
    
         
            +
             
     | 
| 
      
 139 
     | 
    
         
            +
              # Finding the ip address of one phone
         
     | 
| 
      
 140 
     | 
    
         
            +
              def test_find_ip
         
     | 
| 
      
 141 
     | 
    
         
            +
                create_new_settings
         
     | 
| 
      
 142 
     | 
    
         
            +
                gs = GrandStream.new
         
     | 
| 
      
 143 
     | 
    
         
            +
                gs.add_user("192.168.100.23","John Doe","200","000B820B0A7C")
         
     | 
| 
      
 144 
     | 
    
         
            +
             
     | 
| 
      
 145 
     | 
    
         
            +
                assert_equal "192.168.100.23", gs.find_ip("200")
         
     | 
| 
      
 146 
     | 
    
         
            +
              end
         
     | 
| 
      
 147 
     | 
    
         
            +
             
     | 
| 
      
 148 
     | 
    
         
            +
              # Reboot the phone
         
     | 
| 
      
 149 
     | 
    
         
            +
              def test_reboot
         
     | 
| 
      
 150 
     | 
    
         
            +
                create_new_settings
         
     | 
| 
      
 151 
     | 
    
         
            +
                # Change the admin password so the mock will work
         
     | 
| 
      
 152 
     | 
    
         
            +
                change_admin_password
         
     | 
| 
      
 153 
     | 
    
         
            +
                gs = GrandStream.new
         
     | 
| 
      
 154 
     | 
    
         
            +
                assert_nil gs.reboot_phone("192.168.1.25") # a nil return means no error
         
     | 
| 
      
 155 
     | 
    
         
            +
             
     | 
| 
      
 156 
     | 
    
         
            +
              end
         
     | 
| 
      
 157 
     | 
    
         
            +
             
     | 
| 
      
 158 
     | 
    
         
            +
              # Reboot the phone with an incorrect password
         
     | 
| 
      
 159 
     | 
    
         
            +
              def test_reboot_incorrect_password
         
     | 
| 
      
 160 
     | 
    
         
            +
                create_new_settings
         
     | 
| 
      
 161 
     | 
    
         
            +
                gs = GrandStream.new
         
     | 
| 
      
 162 
     | 
    
         
            +
                assert_equal "ERROR: Failed to reboot phone", gs.reboot_phone("192.168.1.25")
         
     | 
| 
      
 163 
     | 
    
         
            +
             
     | 
| 
      
 164 
     | 
    
         
            +
              end
         
     | 
| 
      
 165 
     | 
    
         
            +
             
     | 
| 
      
 166 
     | 
    
         
            +
              
         
     | 
| 
      
 167 
     | 
    
         
            +
              # Rebooting all of the phones
         
     | 
| 
      
 168 
     | 
    
         
            +
              def test_reboot_all
         
     | 
| 
      
 169 
     | 
    
         
            +
                create_new_settings
         
     | 
| 
      
 170 
     | 
    
         
            +
                # Change the admin password so the mock will work
         
     | 
| 
      
 171 
     | 
    
         
            +
                change_admin_password
         
     | 
| 
      
 172 
     | 
    
         
            +
                gs = GrandStream.new
         
     | 
| 
      
 173 
     | 
    
         
            +
                gs.add_user("192.168.1.25","John Doe1","200","000B820B0A7C")
         
     | 
| 
      
 174 
     | 
    
         
            +
                gs.add_user("192.168.1.25","John Doe2","201","000B820B0A7C")
         
     | 
| 
      
 175 
     | 
    
         
            +
                
         
     | 
| 
      
 176 
     | 
    
         
            +
                assert_nil gs.reboot_all_phones # a nil return means no error
         
     | 
| 
      
 177 
     | 
    
         
            +
             
     | 
| 
      
 178 
     | 
    
         
            +
              end
         
     | 
| 
      
 179 
     | 
    
         
            +
             
     | 
| 
      
 180 
     | 
    
         
            +
              # Sending the update
         
     | 
| 
      
 181 
     | 
    
         
            +
              def test_update
         
     | 
| 
      
 182 
     | 
    
         
            +
                create_new_settings
         
     | 
| 
      
 183 
     | 
    
         
            +
                # Change the admin password so the mock will work
         
     | 
| 
      
 184 
     | 
    
         
            +
                change_admin_password
         
     | 
| 
      
 185 
     | 
    
         
            +
                gs = GrandStream.new
         
     | 
| 
      
 186 
     | 
    
         
            +
                gs.add_user("192.168.1.25","John Doe","200","000B820B0A7C")
         
     | 
| 
      
 187 
     | 
    
         
            +
                gs.make("192.168.1.25")
         
     | 
| 
      
 188 
     | 
    
         
            +
                
         
     | 
| 
      
 189 
     | 
    
         
            +
                assert_nil gs.update_config("192.168.1.25") # nil means no error
         
     | 
| 
      
 190 
     | 
    
         
            +
                
         
     | 
| 
      
 191 
     | 
    
         
            +
              end
         
     | 
| 
      
 192 
     | 
    
         
            +
             
     | 
| 
      
 193 
     | 
    
         
            +
              # Send the update with an incorrect password
         
     | 
| 
      
 194 
     | 
    
         
            +
              def test_update_incorrect_password
         
     | 
| 
      
 195 
     | 
    
         
            +
                create_new_settings
         
     | 
| 
      
 196 
     | 
    
         
            +
                gs = GrandStream.new
         
     | 
| 
      
 197 
     | 
    
         
            +
                gs.add_user("192.168.1.25","John Doe","200","000B820B0A7C")
         
     | 
| 
      
 198 
     | 
    
         
            +
                gs.make("192.168.1.25")
         
     | 
| 
      
 199 
     | 
    
         
            +
                
         
     | 
| 
      
 200 
     | 
    
         
            +
                assert_equal "ERROR: Failed to send config", gs.update_config("192.168.1.25")
         
     | 
| 
      
 201 
     | 
    
         
            +
                
         
     | 
| 
      
 202 
     | 
    
         
            +
              end
         
     | 
| 
      
 203 
     | 
    
         
            +
             
     | 
| 
      
 204 
     | 
    
         
            +
              # Sending all of the updates
         
     | 
| 
      
 205 
     | 
    
         
            +
              def test_update_all
         
     | 
| 
      
 206 
     | 
    
         
            +
                create_new_settings
         
     | 
| 
      
 207 
     | 
    
         
            +
                # Change the admin password so the mock will work
         
     | 
| 
      
 208 
     | 
    
         
            +
                change_admin_password
         
     | 
| 
      
 209 
     | 
    
         
            +
                gs = GrandStream.new
         
     | 
| 
      
 210 
     | 
    
         
            +
                
         
     | 
| 
      
 211 
     | 
    
         
            +
                userlist = { 
         
     | 
| 
      
 212 
     | 
    
         
            +
                  "192.168.1.25" => "John Doe1",
         
     | 
| 
      
 213 
     | 
    
         
            +
                  "192.168.1.26" => "John Doe2"
         
     | 
| 
      
 214 
     | 
    
         
            +
                }
         
     | 
| 
      
 215 
     | 
    
         
            +
             
     | 
| 
      
 216 
     | 
    
         
            +
                # Create some users
         
     | 
| 
      
 217 
     | 
    
         
            +
                userlist.each do |ip,user|
         
     | 
| 
      
 218 
     | 
    
         
            +
                  gs.add_user(ip,user,rand(300).to_s,"000B820B0A7C")
         
     | 
| 
      
 219 
     | 
    
         
            +
                end
         
     | 
| 
      
 220 
     | 
    
         
            +
             
     | 
| 
      
 221 
     | 
    
         
            +
                # Make all of the files
         
     | 
| 
      
 222 
     | 
    
         
            +
                gs.make_all
         
     | 
| 
      
 223 
     | 
    
         
            +
                
         
     | 
| 
      
 224 
     | 
    
         
            +
                assert_nil gs.update_all # nil means no error
         
     | 
| 
      
 225 
     | 
    
         
            +
                
         
     | 
| 
      
 226 
     | 
    
         
            +
              end
         
     | 
| 
      
 227 
     | 
    
         
            +
             
     | 
| 
      
 228 
     | 
    
         
            +
              
         
     | 
| 
      
 229 
     | 
    
         
            +
              #####
         
     | 
| 
      
 230 
     | 
    
         
            +
              # Help sections
         
     | 
| 
      
 231 
     | 
    
         
            +
              #####
         
     | 
| 
      
 232 
     | 
    
         
            +
              def test_help
         
     | 
| 
      
 233 
     | 
    
         
            +
                create_new_settings
         
     | 
| 
      
 234 
     | 
    
         
            +
                gs = GrandStream.new
         
     | 
| 
      
 235 
     | 
    
         
            +
                help =<<EOHELP
         
     | 
| 
      
 236 
     | 
    
         
            +
            Usage: COMMAND [options]
         
     | 
| 
      
 237 
     | 
    
         
            +
                  
         
     | 
| 
      
 238 
     | 
    
         
            +
            COMMANDS       DESCRIPTION
         
     | 
| 
      
 239 
     | 
    
         
            +
            new            Add new user and setup their phone 
         
     | 
| 
      
 240 
     | 
    
         
            +
            add            Adds a user to the phone database
         
     | 
| 
      
 241 
     | 
    
         
            +
            make           Generates a config file from the template
         
     | 
| 
      
 242 
     | 
    
         
            +
            update         Uploads the configuration file to the phone
         
     | 
| 
      
 243 
     | 
    
         
            +
            reboot         Reboots a phone 
         
     | 
| 
      
 244 
     | 
    
         
            +
            find           Find the ip address in the configuration file
         
     | 
| 
      
 245 
     | 
    
         
            +
             
     | 
| 
      
 246 
     | 
    
         
            +
            EOHELP
         
     | 
| 
      
 247 
     | 
    
         
            +
                
         
     | 
| 
      
 248 
     | 
    
         
            +
                assert_equal help, gs.help
         
     | 
| 
      
 249 
     | 
    
         
            +
              end
         
     | 
| 
      
 250 
     | 
    
         
            +
             
     | 
| 
      
 251 
     | 
    
         
            +
                def test_help_new
         
     | 
| 
      
 252 
     | 
    
         
            +
                create_new_settings
         
     | 
| 
      
 253 
     | 
    
         
            +
                gs = GrandStream.new
         
     | 
| 
      
 254 
     | 
    
         
            +
                help =<<EONEW
         
     | 
| 
      
 255 
     | 
    
         
            +
            Usage: new
         
     | 
| 
      
 256 
     | 
    
         
            +
                  
         
     | 
| 
      
 257 
     | 
    
         
            +
            Goes through all the steps to setup a new phone:
         
     | 
| 
      
 258 
     | 
    
         
            +
              "add", "make", "update", "reboot"
         
     | 
| 
      
 259 
     | 
    
         
            +
             
     | 
| 
      
 260 
     | 
    
         
            +
            EONEW
         
     | 
| 
      
 261 
     | 
    
         
            +
                
         
     | 
| 
      
 262 
     | 
    
         
            +
                assert_equal help, gs.help("new")
         
     | 
| 
      
 263 
     | 
    
         
            +
              end
         
     | 
| 
      
 264 
     | 
    
         
            +
             
     | 
| 
      
 265 
     | 
    
         
            +
              def test_help_add
         
     | 
| 
      
 266 
     | 
    
         
            +
                create_new_settings
         
     | 
| 
      
 267 
     | 
    
         
            +
                gs = GrandStream.new
         
     | 
| 
      
 268 
     | 
    
         
            +
                help =<<EOADD
         
     | 
| 
      
 269 
     | 
    
         
            +
            Usage: add IP_ADDRESS
         
     | 
| 
      
 270 
     | 
    
         
            +
                  
         
     | 
| 
      
 271 
     | 
    
         
            +
            Adds a user who has a phone at IP_ADDRESS
         
     | 
| 
      
 272 
     | 
    
         
            +
             
     | 
| 
      
 273 
     | 
    
         
            +
            Ex:
         
     | 
| 
      
 274 
     | 
    
         
            +
              add 192.168.1.200
         
     | 
| 
      
 275 
     | 
    
         
            +
             
     | 
| 
      
 276 
     | 
    
         
            +
            EOADD
         
     | 
| 
      
 277 
     | 
    
         
            +
             
     | 
| 
      
 278 
     | 
    
         
            +
                assert_equal help, gs.help("add")
         
     | 
| 
      
 279 
     | 
    
         
            +
              end
         
     | 
| 
      
 280 
     | 
    
         
            +
             
     | 
| 
      
 281 
     | 
    
         
            +
              def test_help_make
         
     | 
| 
      
 282 
     | 
    
         
            +
                create_new_settings
         
     | 
| 
      
 283 
     | 
    
         
            +
                gs = GrandStream.new
         
     | 
| 
      
 284 
     | 
    
         
            +
                help =<<EOMAKE
         
     | 
| 
      
 285 
     | 
    
         
            +
            Usage: make IP_ADDRESS
         
     | 
| 
      
 286 
     | 
    
         
            +
                  
         
     | 
| 
      
 287 
     | 
    
         
            +
            Creates the configuration file for the phone at IP_ADDRESS
         
     | 
| 
      
 288 
     | 
    
         
            +
             
     | 
| 
      
 289 
     | 
    
         
            +
            Ex:
         
     | 
| 
      
 290 
     | 
    
         
            +
              make 192.168.1.200
         
     | 
| 
      
 291 
     | 
    
         
            +
             
     | 
| 
      
 292 
     | 
    
         
            +
            EOMAKE
         
     | 
| 
      
 293 
     | 
    
         
            +
             
     | 
| 
      
 294 
     | 
    
         
            +
                assert_equal help, gs.help("make")
         
     | 
| 
      
 295 
     | 
    
         
            +
              end
         
     | 
| 
      
 296 
     | 
    
         
            +
                
         
     | 
| 
      
 297 
     | 
    
         
            +
              def test_help_update
         
     | 
| 
      
 298 
     | 
    
         
            +
                create_new_settings
         
     | 
| 
      
 299 
     | 
    
         
            +
                gs = GrandStream.new
         
     | 
| 
      
 300 
     | 
    
         
            +
                help =<<EOUPDATE
         
     | 
| 
      
 301 
     | 
    
         
            +
            Usage: update IP_ADDRESS [CURRENT_ADDRESS] [ADMIN_PASSWORD]
         
     | 
| 
      
 302 
     | 
    
         
            +
                  
         
     | 
| 
      
 303 
     | 
    
         
            +
            Sends the updated configuration file for IP_ADDRESS to the phone.
         
     | 
| 
      
 304 
     | 
    
         
            +
             
     | 
| 
      
 305 
     | 
    
         
            +
            Optionally, a phone configuration can be sent to a phone that currently has
         
     | 
| 
      
 306 
     | 
    
         
            +
            a different ip address by using CURRENT_ADDRESS
         
     | 
| 
      
 307 
     | 
    
         
            +
             
     | 
| 
      
 308 
     | 
    
         
            +
            The admin password from the configuration file can also be overridden
         
     | 
| 
      
 309 
     | 
    
         
            +
             
     | 
| 
      
 310 
     | 
    
         
            +
            Ex:
         
     | 
| 
      
 311 
     | 
    
         
            +
              update 192.168.1.200
         
     | 
| 
      
 312 
     | 
    
         
            +
              update 192.168.1.200 192.168.1.10  <= Send '200's update to the phone at '10'
         
     | 
| 
      
 313 
     | 
    
         
            +
              update 192.168.1.200 192.168.1.10 admin <= Also uses the factory password
         
     | 
| 
      
 314 
     | 
    
         
            +
             
     | 
| 
      
 315 
     | 
    
         
            +
             
     | 
| 
      
 316 
     | 
    
         
            +
            EOUPDATE
         
     | 
| 
      
 317 
     | 
    
         
            +
                
         
     | 
| 
      
 318 
     | 
    
         
            +
                assert_equal help, gs.help("update")
         
     | 
| 
      
 319 
     | 
    
         
            +
              end
         
     | 
| 
      
 320 
     | 
    
         
            +
              
         
     | 
| 
      
 321 
     | 
    
         
            +
              def test_help_reboot
         
     | 
| 
      
 322 
     | 
    
         
            +
                create_new_settings
         
     | 
| 
      
 323 
     | 
    
         
            +
                gs = GrandStream.new
         
     | 
| 
      
 324 
     | 
    
         
            +
                help =<<EOREBOOT
         
     | 
| 
      
 325 
     | 
    
         
            +
            Usage: reboot COMMAND IP_ADDRESS
         
     | 
| 
      
 326 
     | 
    
         
            +
                  
         
     | 
| 
      
 327 
     | 
    
         
            +
            Reboots the phone at IP_ADDRESS.
         
     | 
| 
      
 328 
     | 
    
         
            +
             
     | 
| 
      
 329 
     | 
    
         
            +
            CAUTION: Some firmware will allow the phone to be rebooted while it is in use!
         
     | 
| 
      
 330 
     | 
    
         
            +
             
     | 
| 
      
 331 
     | 
    
         
            +
            Ex:
         
     | 
| 
      
 332 
     | 
    
         
            +
              reboot 192.168.1.200
         
     | 
| 
      
 333 
     | 
    
         
            +
             
     | 
| 
      
 334 
     | 
    
         
            +
            EOREBOOT
         
     | 
| 
      
 335 
     | 
    
         
            +
             
     | 
| 
      
 336 
     | 
    
         
            +
                assert_equal help, gs.help("reboot")
         
     | 
| 
      
 337 
     | 
    
         
            +
              end
         
     | 
| 
      
 338 
     | 
    
         
            +
             
     | 
| 
      
 339 
     | 
    
         
            +
              def test_help_find
         
     | 
| 
      
 340 
     | 
    
         
            +
                create_new_settings
         
     | 
| 
      
 341 
     | 
    
         
            +
                gs = GrandStream.new
         
     | 
| 
      
 342 
     | 
    
         
            +
                help =<<EOFIND
         
     | 
| 
      
 343 
     | 
    
         
            +
            Usage: find
         
     | 
| 
      
 344 
     | 
    
         
            +
                  
         
     | 
| 
      
 345 
     | 
    
         
            +
            Searches the user.yml file to get the ipaddress of an extension.
         
     | 
| 
      
 346 
     | 
    
         
            +
             
     | 
| 
      
 347 
     | 
    
         
            +
            EOFIND
         
     | 
| 
      
 348 
     | 
    
         
            +
             
     | 
| 
      
 349 
     | 
    
         
            +
                assert_equal help, gs.help("find")
         
     | 
| 
      
 350 
     | 
    
         
            +
              end
         
     | 
| 
      
 351 
     | 
    
         
            +
             
     | 
| 
       11 
352 
     | 
    
         
             
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -3,8 +3,8 @@ rubygems_version: 0.9.0 
     | 
|
| 
       3 
3 
     | 
    
         
             
            specification_version: 1
         
     | 
| 
       4 
4 
     | 
    
         
             
            name: gs_phone
         
     | 
| 
       5 
5 
     | 
    
         
             
            version: !ruby/object:Gem::Version 
         
     | 
| 
       6 
     | 
    
         
            -
              version: 0.0. 
     | 
| 
       7 
     | 
    
         
            -
            date: 2007-03- 
     | 
| 
      
 6 
     | 
    
         
            +
              version: 0.0.3
         
     | 
| 
      
 7 
     | 
    
         
            +
            date: 2007-03-25 00:00:00 -07:00
         
     | 
| 
       8 
8 
     | 
    
         
             
            summary: Application to mange and configure a group of Grandstream Voip phones
         
     | 
| 
       9 
9 
     | 
    
         
             
            require_paths: 
         
     | 
| 
       10 
10 
     | 
    
         
             
            - lib
         
     |