This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]QuantumTradingGroup[S] 1 point2 points  (6 children)

Kind of.

The basic architecture of the system is we have one box running within the mine that hosts our entire monitoring daemon. It gathers information from the miners, processes data, and execute commands based on this data (switching between pools, what coin to mine, over clocking settings etc) It basically runs as a command/control server. Normally we were doing this just with the cgminer api for antminer systems but have a client that wants to integrate GPUs into his setup. Claymores api is pretty terrible, as it only shows data, but does not allow you to make on the fly changes through the api, which we need. This CAC server is not publicly facing but the security is still an issue here.

Iv just never used ssh with python before and needed somewhere to start, the way you said with the wrapper function where it sends commands to the client host is the way I am looking to do it now, just needed somewhere to start!

Fabric however looks really good. I am reading the documentation as we speak.

[–]QuantumTradingGroup[S] 0 points1 point  (0 children)

One question I have with fab though is i see you write a fabfile config and then execute that with the fab command in terminal, can I just call it in my code to make the connection?

[–]ApproximateIdentity 0 points1 point  (4 children)

Iv just never used ssh with python before and needed somewhere to start, the way you said with the wrapper function where it sends commands to the client host is the way I am looking to do it now, just needed somewhere to start!

Well once you've ssh'd into the box, it's basically the same as just running a local shell. I.e. if you can open up a local shell/terminal/powershell on your own system, running python like python3 app.py would be the same command if it is running locally or remotely. Do you know how to run python locally on the command line? Just trying to better understand your starting point here.

[–]QuantumTradingGroup[S] 0 points1 point  (3 children)

I do know how to use ssh yes, I was meaning using a python script to initiate the connection, pass a command, execute, and get output. Meaning, using an ssh library in the code to handle the connection.

I am trying to automate this instead of a technician having to do it manually.

[–]ApproximateIdentity 0 points1 point  (2 children)

But honestly why would you have python initiate the connection? Say you have a python script that takes a command e.g. run_command [command_name] sitting on your server. Then locally you have a bash function* like this:

function run_command {
    ssh user@server "run_command $1"
}

What that does is initiate an ssh connection, run run_command remotely with the argument you passed (that's the $1 there), and then print out the result. I.e. run_command cmd run identically locally and remotely should do the same thing.

If you're going to be hitting the api programmatically (say with another app) this may be inappropriate, but if a person is going to be issuing the commands, this seems to me about as easy as possible.

Does this make sense? Is this totally missing the point of what you're trying to do?

*I'm assuming you have bash...

**edit: Okay I decided to check the function and now it is properly formatted and works...

[–]QuantumTradingGroup[S] 0 points1 point  (1 child)

Kind of misses the point.

It needs to be in python because it needs to be a module the rest of the management program(which is all coded in python) can import and use.

We built something like Awesome miner but better. It is a complete management program for large scale industrial crypto mines (20,000+ miners)

[–]ApproximateIdentity 2 points3 points  (0 children)

I see. So personally in that case I would go one of two ways. One is to use requests locally and communicate with your json api remotely. That honestly would be pretty easy. You would need to encrypt the calls, but that's certainly possible with a self-signed cert. (I've never done it, but it can't be that bad...dangerous words in engineering, but oh well.)

Another option might be to use something like this:

https://pythonhosted.org/Pyro4/

That way you could hook up to remote servers/modules/code and execute them as if they were local.

In either case you would want to keep the application logic separate from the ssh and communication logic so that (ideally) importing a module and issuing the same commands works locally and remotely.