Exemple #1
0
def main():
    """
    main method
    parses arguments and constructs Manager object and performs actions
    """
    logger = fancylogger.getLogger()
    options = get_options()
    logger.debug("arguments parsed, starting manager")
    manager = Manager(options)

    #print status
    if manager.status:
        print "Status:\n %s" % manager.status

    #actually do requested commands
    out = manager.doit()
    #parse and display the output
    errors = []
    if out:
        for i in out:  # this is an array of nodes and their  output,err
            if len(i[1]) > 0:  # only print if something to show
                print "%s:" % i[0]  # first element is the node
                for j in i[1]:  # second element is an array of [outputs of commands,errors]
                    print "    output: %s" % str(j[1][0])
                    if j[1][1]:
                        print "    error:  %s" % str(j[1][1])
                        errors.append(i[0])

    # print all nodes with errors out on the end
    if len(errors) > 0:
        print "ERRORS occured in: \n ", ",".join([str(x) for x in errors])
Exemple #2
0
#
'''
Created on Oct 18, 2011

@author: Jens Timmerman
'''
import os
import sys
import traceback
from vsc.install.testing import TestCase

# use the default shipped configfile
from vsc.manage import config
config.DEFAULT_CONFIGFILE = os.path.join(os.path.dirname(sys.argv[0]),'config/manage_defaults.cfg')
# get_options will initialize
config.get_options()


from vsc.manage.config import Options, get_config
from vsc.manage.manage import Manager
from vsc.manage.clusters import Cluster, NoSuchClusterException
from vsc.manage.managecommands import Command
from vsc.manage.nodes import NodeException, TestNode, CompositeNode


TEST_CLUSTER = 'shuppet'
TEST_NODE = 'node2201'

QUATTOR_PATH = os.path.join(os.path.dirname(sys.argv[0]),'test/profiles')
if not os.path.isdir(QUATTOR_PATH):
    raise Exception('Cannot find QUATTOR_PATH in %s (set VSC_MANAGE_QUATTOR_PATH envvar)' % QUATTOR_PATH)