    # File lib/chef/client.rb, line 318
        def register(client_name=node_name, config=Chef::Config)
          if File.exists?(config[:client_key])
            @events.skipping_registration(client_name, config)
            Chef::Log.debug("Client key #{config[:client_key]} is present - skipping registration")
          else
            @events.registration_start(node_name, config)
            Chef::Log.info("Client key #{config[:client_key]} is not present - registering")
            Chef::REST.new(config[:client_url], config[:validation_client_name], config[:validation_key]).register(client_name, config[:client_key])
            @events.registration_completed
          end
          # We now have the client key, and should use it from now on.
          @rest = Chef::REST.new(config[:chef_server_url], client_name, config[:client_key])
          @resource_reporter = Chef::ResourceReporter.new(@rest)
          @events.register(@resource_reporter)
        rescue Exception => e
          # TODO: munge exception so a semantic failure message can be given to the
          # user
          @events.registration_failed(node_name, e, config)
          raise
        end