Commit d309f564 authored by nazarf's avatar nazarf

add folder to from and to line get node info with google sheet

git-svn-id: https://svn.sp-service.com.ua/svnroot/svn/node-stats/trunk@8 320591d9-fe85-4a77-9bad-1a723db14d60
parent b32955f5
......@@ -127,7 +127,12 @@ class NodesController < AdminController
end
def sync_node
Node.sync_node
@params = {
from: params[:sync_to_sheet][:from],
to: params[:sync_to_sheet][:to]
}
p @params
Node.sync_node(@params[:from], @params[:to])
redirect_to nodes_path
end
......
......@@ -12,18 +12,24 @@ class Node < ActiveRecord::Base
AFTER_DOMAIN = 8
AFTER_IP = 9
STATE = 10
LINKED_PROXMOX_ID = 11
GATEWAY = 12
NETMASK = 13
IPV6 = 14
def self.sync_node
def self.sync_node(from, to)
session = GoogleDrive::Session.from_service_account_key("client_secret.json")
spreadsheet ||= session.spreadsheet_by_title("znode-instal-stats")
@worksheet = spreadsheet.worksheets.first
@worksheet.rows.each do |row|
@worksheet.rows.each_with_index do |row, index|
Node.create(name: row[AFTER_DOMAIN], domain: row[AFTER_DOMAIN], ipv4: row[AFTER_IP], start_balance_t: row[START_AMOUNT_T],
if index >= from.to_i && index <= to.to_i
Node.create(name: row[AFTER_DOMAIN], domain: row[AFTER_DOMAIN], ipv4: row[AFTER_IP], ipv6: row[IPV6], start_balance_t: row[START_AMOUNT_T],
start_balance_z: row[START_AMOUNT_Z], node_username: row[RPC_USER], node_password: row[RPC_PASS])
end
end
end
end
......@@ -3,7 +3,11 @@
%h1
= model_class.model_name.human(count: 2).mb_chars.titleize
= link_to 'refresh node', z_gettotalbalance_url, class: 'btn btn-success'
= link_to 'sync node', sync_node_url, class: 'btn btn-success'
= simple_form_for :sync_to_sheet, url: sync_node_path, method: :get, html: {class: 'form-inline'} do |f|
= f.button :submit, 'get node', class: 'btn btn-primary'
= f.input :from, required: false, label: 'from'
= f.input :to, required: false, label: 'to'
-#= link_to 'sync node', sync_node_url, class: 'btn btn-success'
%p=@command
Investment:
......
......@@ -4,7 +4,7 @@ lock '3.11.0'
# DEPLOY
set :application, 'node-statistic'
# set :deploy_to, '/var/www/amaox' # Default deploy_to directory is /var/www/my_app_name
set :repo_url, 'https://svn.sp-service.com.ua/svnroot/svn/node-stats/trunk'
set :repo_url, 'http://svn.sp-service.com.ua/svnroot/svn/node-stats/trunk'
# set :format, :pretty # Default value for :format is :pretty
# set :log_level, :debug # Default value for :log_level is :debug
# set :pty, true # Default value for :pty is false
......
server '194.44.41.195', user: 'deploy', roles: %w{app db web}
server '192.168.4.72', user: 'deploy', roles: %w{app db web}
# set :rvm_custom_path, '/usr/local/rvm' # only needed if not detected
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment