示例#1
0
    def guess_version(self):
        """
        :returns: (float) version of the config file or 0.9 if unrecognized
        """
        from kamaki.cli import logger
        # Ignore logs from "checker" logger
        logger.deactivate(__name__)
        checker = Config(self.path, with_defaults=False)
        logger.activate(__name__)

        sections = checker.sections()
        #  log.debug('Config file heuristic 1: old global section ?')
        if 'global' in sections:
            if checker.get('global', 'url') or checker.get('global', 'token'):
                log.debug('config file has an old global section')
                return 0.8
        #  log.debug('Config file heuristic 2: Any cloud sections ?')
        if CLOUD_PREFIX in sections:
            for r in self.keys(CLOUD_PREFIX):
                log.debug('found cloud "%s"' % r)
            ipv = self.get('global', 'ip_cli')
            if ipv in ('cyclades', ):
                    return 0.11
            netv = self.get('global', 'network_cli')
            if netv in ('cyclades', ):
                return 0.10
            return 0.12
        log.debug('All heuristics failed, cannot decide')
        return 0.12
示例#2
0
    def guess_version(self):
        """
        :returns: (float) version of the config file or 0.9 if unrecognized
        """
        from kamaki.cli import logger
        # Ignore logs from "checker" logger
        logger.deactivate(__name__)
        checker = Config(self.path, with_defaults=False)
        logger.activate(__name__)

        sections = checker.sections()
        #  log.debug('Config file heuristic 1: old global section ?')
        if 'global' in sections:
            if checker.get('global', 'url') or checker.get('global', 'token'):
                log.debug('config file has an old global section')
                return 0.8
        #  log.debug('Config file heuristic 2: Any cloud sections ?')
        if CLOUD_PREFIX in sections:
            for r in self.keys(CLOUD_PREFIX):
                log.debug('found cloud "%s"' % r)
            ipv = self.get('global', 'ip_cli')
            if ipv in ('cyclades', ):
                return 0.11
            netv = self.get('global', 'network_cli')
            if netv in ('cyclades', ):
                return 0.10
            return 0.12
        log.debug('All heuristics failed, cannot decide')
        return 0.12
示例#3
0
文件: test.py 项目: dimara/kamaki
 def test_deactivate(self, GL):
     from kamaki.cli.logger import deactivate, _blacklist
     self.assertEqual(_blacklist, {})
     deactivate('some logger')
     GL.assert_called_once_with('some logger')
     self.assertEqual(_blacklist.get('some logger', None),
                      self.PseudoLogger.level)
     from logging import CRITICAL
     self.assertEqual(self.PseudoLogger._setLevel_calls[-1], (CRITICAL, ))
示例#4
0
文件: test.py 项目: grnet/kamaki
 def test_deactivate(self, GL):
     from kamaki.cli.logger import deactivate, _blacklist
     self.assertEqual(_blacklist, {})
     deactivate('some logger')
     GL.assert_called_once_with('some logger')
     self.assertEqual(
         _blacklist.get('some logger', None), self.PseudoLogger.level)
     from logging import CRITICAL
     self.assertEqual(self.PseudoLogger._setLevel_calls[-1], (CRITICAL, ))
示例#5
0
#!/usr/bin/python
import sys
#from progress.bar import Bar
import json
from kamaki.clients import ClientError
from kamaki.clients.astakos import AstakosClient
from kamaki.clients.pithos import PithosClient
from kamaki.cli.logger import deactivate
deactivate('kamaki.clients.send')
deactivate('kamaki.clients.recv')

#AUTHENTICATION_URL = 'https://accounts.okeanos.grnet.gr/identity/v2.0'
#TOKEN = 'YOUR TOKEN'
AUTHENTICATION_URL = 'https://accounts.demo.synnefo.org/identity/v2.0'
TOKEN = 'YOUR TOKEN'
SMALLFILE = 'A NAME OF A SMALL FILE (in test folder)'
BIGFILE = 'A NAME OF A BIG FILE (in test folder)'
TMPFILE = 'A NAME OF A TMP FILE (in test folder)'
FILETOPUBLISH = 'THE NAME OF THE FILE YOU WANT TO PUBLISH (in test folder)'
YOUR_CONTAINER = 'THE NAME OF THE CONTAINER WITH FOLDERS'
YOUR_FOLDER_PATH = 'THE FOLDER(S) PATH IN A CONTAINER'

try:
    from progress.bar import Bar

    def create_pb(msg):
        def generator(n):
            bar = Bar(msg)
            for i in bar.iter(range(int(n))):
                yield
            yield