Esempio n. 1
0
class MothershipPlugin(AbsPlugin):
    """ Mothership plugin """
    def __init__(self):
        self.__config = ConfigLoader().load("mothership.conf",
                "config/mothership.conf")
        self.__scriptdir = "kahuna/plugins/mothership"

    # Override the endpoint address and credentials to create the
    # context
    def _config_overrides(self):
        overrides = {}
        overrides['address'] = self.__config.get("mothership", "host")
        overrides['user'] = self.__config.get("mothership", "user")
        overrides['password'] = self.__config.get("mothership", "password")
        return overrides

    # Override the commands factory method because the command names we want
    # can not be used as valid python class method names
    def _commands(self):
        """ Returns the provided commands, mapped to handler methods """
        commands = {}
        commands['deploy-abiquo'] = self.deploy_abiquo
        commands['deploy-chef'] = self.deploy_chef
        commands['deploy-kvm'] = self.deploy_kvm
        commands['deploy-vbox'] = self.deploy_vbox
        commands['list-templates'] = self.list_templates
        return commands

    def list_templates(self, args):
        """ List all available templates """
        try:
            admin = self._context.getAdministrationService()
            user = admin.getCurrentUser()
            enterprise = user.getEnterprise()
            templates = enterprise.listTemplates()
            pprint_templates(templates)
        except (AbiquoException, AuthorizationException), ex:
            print "Error: %s" % ex.getMessage()
Esempio n. 2
0
class MothershipPlugin(AbsPlugin):
    """ Mothership plugin """
    def __init__(self):
        self.__config = ConfigLoader().load("mothership.conf",
                "config/mothership.conf")
        self.__scriptdir = "kahuna/plugins/mothership"

    # Override the endpoint address and credentials to create the
    # context
    def _config_overrides(self):
        overrides = {}
        overrides['address'] = self.__config.get("mothership", "host")
        overrides['user'] = self.__config.get("mothership", "user")
        overrides['password'] = self.__config.get("mothership", "password")
        return overrides

    # Override the commands factory method because the command names we want
    # can not be used as valid python class method names
    def _commands(self):
        """ Returns the provided commands, mapped to handler methods """
        commands = {}
        commands['deploy-abiquo'] = self.deploy_abiquo
        commands['deploy-chef'] = self.deploy_chef
        commands['deploy-kvm'] = self.deploy_kvm
        commands['deploy-vbox'] = self.deploy_vbox
        commands['list-templates'] = self.list_templates
        return commands

    def list_templates(self, args):
        """ List all available templates """
        try:
            admin = self._context.getAdministrationService()
            enterprise = admin.getCurrentEnterprise()
            templates = enterprise.listTemplates()
            pprint_templates(templates)
        except (AbiquoException, AuthorizationException), ex:
            print "Error: %s" % ex.getMessage()
Esempio n. 3
0
 def __init__(self):
     self.__config = ConfigLoader().load("scalability.conf",
             "config/scalability.conf")
Esempio n. 4
0
class ScalabilityPlugin(AbsPlugin):
    """ Scalability plugin """
    def __init__(self):
        self.__config = ConfigLoader().load("scalability.conf",
                "config/scalability.conf")

    # Override the endpoint address and credentials to create the
    # context
    def _config_overrides(self):
        overrides = {}
        overrides['address'] = self.__config.get("scalability", "host")
        overrides['user'] = self.__config.get("scalability", "user")
        overrides['password'] = self.__config.get("scalability", "password")
        return overrides

    # Override the commands factory method because the command names we want
    # can not be used as valid python class method names
    def _commands(self):
        """ Returns the provided commands, mapped to handler methods """
        commands = {}
        commands['reset-datanode'] = self.reset_datanode
        commands['deploy-api'] = self.deploy_api
        commands['deploy-rs'] = self.deploy_rs
        return commands

    def reset_datanode(self, args):
        """ Resets the datanode (database, redis and rabbitmq) """
        parser = OptionParser(usage="scalability reset-datanode <options>")
        parser.add_option('-j', '--jenkins-version',
                help='Download the database from the given version '
                'from Jenkins', action='store', dest='jenkins')
        parser.add_option('-d', '--datanode',
                help='Ip address of the data node (with rabbit, '
                'redis and zookeper)', action='store', dest='datanode')
        parser.add_option('-u', '--login-user',
                help='Username used to access the datanode',
                action='store', dest='user')
        parser.add_option('-p', '--login-password',
                help='Password used to access the datanode',
                action='store', dest='password')

        (options, args) = parser.parse_args(args)

        if not options.datanode or not options.jenkins \
                or not options.user or not options.password:
            parser.print_help()
            return

        compute = self._context.getComputeService()
        license = self.__config.get("reset-datanode", "license")
        predicate = NodeHasIp(options.datanode)

        try:
            script = []
            script.append(jenkins._download_database(options.jenkins))
            script.append(Statements.exec(
                "mysql -u %s kinton </tmp/kinton-schema-%s.sql" %
                (options.user, options.jenkins)))
            script.append(Statements.exec(
                'mysql -u %s kinton -e "'
                'insert into license (data, version_c) values (\'%s\', 1)"' %
                (options.user, license)))
            script.append(redis.run("flushall"))
            script.extend(rabbitmq.reset())
            print "Cleaning database for datanode at: %s" % options.datanode
            options = RunScriptOptions.Builder \
                .overrideLoginUser(options.user) \
                .overrideLoginPassword(options.password)
            compute.runScriptOnNodesMatching(predicate,
                StatementList(script), options)
        except RunNodesException, ex:
            self._print_node_errors(ex)
Esempio n. 5
0
 def __init__(self):
     self.__config = ConfigLoader().load("mothership.conf",
             "config/mothership.conf")
     self.__scriptdir = "kahuna/plugins/mothership"
Esempio n. 6
0
 def __init__(self):
     self.__config = ConfigLoader().load("env.conf", "config/env.conf")
 def __init__(self):
     self.__config = ConfigLoader().load("machine.conf",
                                         "config/machine.conf")