예제 #1
0
def add_ssh_host(*, name, host, port, login, password):
    storm_ = Storm()

    try:
        storm_.delete_entry(name)
    except ValueError:
        pass

    storm_.add_entry(
        name,
        host,
        login,
        port,
        id_file='',
        # With these options there will be no stupid interactive
        # questions on ssh key uploading.
        custom_options=[
            'StrictHostKeyChecking=no',
            'UserKnownHostsFile=/dev/null',
        ],
    )

    # TODO can be insecure. Copy the password to a local file
    # with 0600 permissions and use the file with `-f` option.
    local(f'sshpass -p {password} ssh-copy-id {name}')
예제 #2
0
    def run_fufu(self):
        os.system("cls")
        self.result_table = []
        ''' get ssh connection and reset eth0 ip address '''
        self.utils = Utils(self)
        if self.utils.ssh is None:
            self.result_table.append(['Connection to the system', 'FAIL'])
            print("Can't established ssh connection")
            raw_input('Press Enter for continue...')
            self.menu()
        else:
            self.result_table.append(['Connection to the system', 'PASS'])

        tests = Tests(self, self.utils)

        if not tests.check_bands():
            self.menu()

        print('Enable Remote and Modem Communication: {}'.format(
            self.utils.set_remote_communication(1)))
        ''' save set files '''
        self.utils.send_command('udp_bridge1', 'start')
        storm = Storm(self)
        for place, band in enumerate(self.utils.get_bands()):
            storm.save_setfile(place=place, band=band)
        self.result_table.append(['Save set file for IDOBR', 'PASS'])
        self.utils.send_command('udp_bridge1', 'stop')

        self.utils.set_filters(1)

        tests.verify_connections()
        ''' test power '''
        tests.test_composite_power()
        ''' test bands status '''
        tests.test_band_status()
        ''' test sw and patch version '''
        tests.test_swv()
        ''' Set date and time'''
        tests.set_dateTime()
        ''' TTF calibration '''
        tests.ttf_calibrate()
        ''' Band mute test '''
        tests.mute_test()
        ''' test alarm '''
        tests.test_ext_alarm()
        ''' gps/gpr test '''
        tests.gpr_gps_test()
        ''' clear log '''
        tests.clear_log()
        self.utils.print_table(['Description', 'Status'], self.result_table)
        self.utils.ssh.close()
        raw_input('Press Enter for continue...')
        self.menu()
예제 #3
0
    def setUp(self):
        FAKE_SSH_CONFIG = """Host *
            IdentitiesOnly yes

        Host netscaler
            hostname 1.1.1.1
            port 3367

        """

        with open('/tmp/ssh_config', 'w+') as f:
            f.write(FAKE_SSH_CONFIG)

        self.storm = Storm('/tmp/ssh_config')
예제 #4
0
    def setUp(self):
        fake_ssh_config = """Host *
            IdentitiesOnly yes

        Host netscaler
            hostname 1.1.1.1
            port 3367

        """

        with open('/tmp/ssh_config', 'w+') as f:
            f.write(fake_ssh_config)

        self.storm = Storm('/tmp/ssh_config')
예제 #5
0
    def __init__(self) -> None:
        """Initialization method.

        Raises:
            NoRuntimeDetectedError: If no `Runtime` could be automatically detected.
        """
        # Create the Logger
        self.log = logging.getLogger(__name__)

        runtimes = {}
        self.inactive_hosts = []

        # Iterate over ssh configuration entries and look for valid RemoteRuntimes
        ssh_util = Storm()
        self.log.debug(
            "RuntimeManager starts looking for Runtimes based on ssh configuration."
        )

        for ssh_entry in ssh_util.list_entries(only_servers=True):
            if ssh_entry["host"] in runtimes:
                continue
            if (ssh_entry["host"] == "localhost" and "127.0.0.1"
                    in runtimes) or (ssh_entry["host"] == "127.0.0.1"
                                     and "localhost" in runtimes):
                continue
            try:
                self.log.debug(
                    f'RuntimeManager tries to instantiate host {ssh_entry["host"]} as Runtime.'
                )
                runtime = Runtime(ssh_entry["host"])
            except InvalidRuntimeError:
                self.inactive_hosts.append(ssh_entry["host"])
                self.log.debug(
                    f'RuntimeManager detected host config for {ssh_entry["host"]}, that could NOT be '
                    f"instantiated  as a valid Runtime.")
                continue
            runtimes.update({runtime.host: runtime})
            self.log.info(runtime.host +
                          " detected as valid Runtime by the RuntimeManager.")

        try:
            self._group = RuntimeGroup(list(runtimes.values()))
            self.log.info(
                f"RuntimeManager detected {len(runtimes)} valid Runtime(s).")
        except ValueError as err:
            raise NoRuntimesDetectedError(err)

        self.log.debug("RuntimeManager initialized.")
예제 #6
0
def execute_host(args):
    if not args.subcommand == 'list' and not args.host:
        puts(red('--host is required'))
        return
    ssh_config = Storm()
    if args.subcommand == 'list':
        for entry in ssh_config.list_entries():
            puts(green(entry['host']))
    elif args.subcommand == 'add':
        result = parse(args.connection_url)
        puts(result)
        ssh_config.add_entry(args.host,
                             host=result[1],
                             user=result[0],
                             port=result[2],
                             id_file=args.id_file)
        for entry in ssh_config.list_entries():
            puts(green(entry['host']))
    elif args.subcommand == 'delete':
        ssh_config.delete_entry(args.host)
        for entry in ssh_config.list_entries():
            puts(green(entry['host']))
예제 #7
0
def get_storm_instance(config_file=None):
    return Storm(config_file)
예제 #8
0
 def get_storm():
     return Storm(ssh_config)
예제 #9
0
import getpass
import collections

import six

from storm import Storm, __version__
from storm.exceptions import StormValueError
from storm.ssh_uri_parser import parse
from storm import web as _web

from storm.kommandr import *

from termcolor import colored

storm_ = Storm()

default_user = getpass.getuser()


def fixed_width(text, size):
    text_width = len(text)
    if size > text_width:
        for _ in range(text_width, size):
            text += " "

    return text


def get_formatted_message(message, format_type):
    format_typed = fixed_width(format_type, 8)
예제 #10
0
파일: web.py 프로젝트: silky/storm
def get_storm():
    return Storm()
예제 #11
0
import math
import numpy as np
import pandas as pd
import matplotlib as plt
from shapely.geometry import Point, Polygon
from sklearn.metrics import confusion_matrix
from scipy import stats
import geopandas as gpd
import h5py

from storm import Storm
from readData import ReadEMData

print(Storm(1, [[4, 0, 6, 7, 8, 9]]))

print("hello world")


#get EM data
def extractDataEM():
    databaseEM = ReadEMData("data/disastersStats.xlsx", "Feuil2")
    databaseEM.reformatDates()
    databaseEM.changeDatesToTimeStep()
    databaseEM.addYearColumn()
    return databaseEM, databaseEM.aggregateByDisasterNo()


def addYear(year, df, world, databaseEM, dataEM):
    realDisasters = dataEM[dataEM["year"] == year]
    path = "./climo_" + str(year) + ".h5"
    simulatedDisasters = creatStormObjectList(path)