This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# example code that creates cloud server and try not to hit the cloud API climits | |
cs_count=13 # number of cs to build | |
build_nr=1 | |
delayed_10s=False | |
while build_nr <= cs_count : | |
if 0==build_nr % 11 and not delayed_10s: | |
time.sleep(60+10) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def cs_create(self, count, sample_nr): | |
name='test' + str(int(time.time())) | |
image=112 | |
flavor=1 | |
log("[%2d][%2d] creating image: " % (sample_nr, count) + pformat( {'name': name, 'image' : image, 'flavor' : flavor } ) ) | |
sm=self.cs.servers | |
server=sm.create(name, image, flavor) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Try to execute the script in two different modes to see the difference | |
# | |
# $ python log.py | tee log | |
# <noting for a long time> | |
# | |
# $ python -u log.py | tee log | |
# my log message 0 | |
# | |
import time |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import threading | |
import datetime | |
import time | |
from random import random | |
class ThreadClass(threading.Thread): | |
def set_id(self, id): | |
self.id=id | |
def dummy_delay(self): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Test1InstanceVariable: | |
mylist=[] | |
def __init__(self, number): | |
self.number= number | |
def add(self, i): | |
self.mylist.append(i) | |
def show(self): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class JavaExample { | |
// with the next line commented the code is erroring out when we try to compile it | |
//public int number; | |
public JavaExample (int _number) { | |
number=_number; | |
} | |
public void show() { | |
System.out.println("[test " + number + "] list=%s"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import paramiko | |
ssh = paramiko.SSHClient() | |
ssh.set_missing_host_key_policy( paramiko.AutoAddPolicy() ) | |
ssh.connect('5.79.4.10', username='root', password='7raW6nS6Krttest') | |
stdin, stdout, stderr = ssh.exec_command('echo text on stdout stream; echo text on stderror stream 1>&2') | |
print("reading outputs from the remote command") | |
for l in stdout : |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
iptables=$(iptables -nL) | |
ret=no | |
if echo $iptables | grep -q 'Chain INPUT .policy DROP.' ; then | |
if echo $iptables | grep -q 'Chain FORWARD .policy DROP.' ; then | |
if echo $iptables | grep -q 'Chain OUTPUT .policy ACCEPT.' ; then | |
if echo $iptables | grep -q 'Chain RS-RackConnect-INBOUND' ; then | |
ret=yes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import paramiko | |
bastion_ip='ip' # you have to edit and provide valid IP address | |
bastion_pass='pass' # you have to edit it and provide valid password | |
ssh = paramiko.SSHClient() | |
ssh.set_missing_host_key_policy( paramiko.AutoAddPolicy() ) | |
ssh.connect(bastion_ip, username='root', password=bastion_pass) | |
chan = ssh.invoke_shell() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import paramiko | |
import time | |
import re | |
bastion_ip='ip' | |
bastion_pass='pass' | |
ssh = paramiko.SSHClient() | |
ssh.set_missing_host_key_policy( paramiko.AutoAddPolicy() ) | |
ssh.connect(bastion_ip, username='root', password=bastion_pass) |
OlderNewer