def _load_env(self, name):
        if name is None:
            name = self._testMethodName

        storage = self.storage_cls(**self.storage_kwargs)

        return local.load_env(name=name, storage=storage)
예제 #2
0
def load_env(blueprint_id):
    if not os.path.isdir(storage_dir(blueprint_id)):
        error = exceptions.CloudifyCliError('Please initialize a blueprint')
        error.possible_solutions = ["Run `cfy init BLUEPRINT_PATH`"]
        raise error
    return local.load_env(name=blueprint_id or 'local',
                          storage=get_storage())
예제 #3
0
    def test_file_storage_payload(self):
        tempdir = tempfile.mkdtemp()
        storage = local.FileStorage(tempdir)
        try:
            self._test(storage)

            # update payload
            with storage.payload() as payload:
                payload['payload_key'] = 'payload_key_value'

            # read payload
            storage2 = local.FileStorage(tempdir)
            local.load_env(self.env.name, storage=storage2)
            with storage2.payload() as payload:
                self.assertEqual(payload['payload_key'], 'payload_key_value')
        finally:
            shutil.rmtree(tempdir)
    def test_file_storage_payload(self):
        tempdir = tempfile.mkdtemp()
        storage = local.FileStorage(tempdir)
        try:
            self._test(storage)

            # update payload
            with storage.payload() as payload:
                payload['payload_key'] = 'payload_key_value'

            # read payload
            storage2 = local.FileStorage(tempdir)
            local.load_env(self.env.name, storage=storage2)
            with storage2.payload() as payload:
                self.assertEqual(payload['payload_key'], 'payload_key_value')
        finally:
            shutil.rmtree(tempdir)
예제 #5
0
def _load_env():
    if not os.path.isdir(_storage_dir()):
        error = exceptions.CloudifyCliError(
            '{0} has not been initialized with a blueprint.'.format(
                utils.get_cwd()))

        # init was probably not executed.
        # suggest solution.

        error.possible_solutions = ["Run 'cfy local init' in this directory"]
        raise error
    return local.load_env(name=_NAME, storage=_storage())
예제 #6
0
def _load_env():
    if not os.path.isdir(_storage_dir()):
        error = exceptions.CloudifyCliError(
            '{0} has not been initialized with a blueprint.'
            .format(utils.get_cwd()))

        # init was probably not executed.
        # suggest solution.

        error.possible_solutions = [
            "Run 'cfy local init' in this directory"
        ]
        raise error
    return local.load_env(name=_NAME,
                          storage=_storage())
예제 #7
0
def load_env(name):
    storage = local.FileStorage(storage_dir=_workdir())
    return local.load_env(name=name, storage=storage)
예제 #8
0
def load_env(name='manager'):
    storage = local.FileStorage(storage_dir=_workdir())
    return local.load_env(name=name,
                          storage=storage)
예제 #9
0
def load_env(blueprint_id=None):
    if not os.path.isdir(storage_dir()):
        error = exceptions.CloudifyCliError('Please initialize a blueprint')
        error.possible_solutions = ["Run `cfy init BLUEPRINT_PATH`"]
        raise error
    return local.load_env(name=blueprint_id or 'local', storage=get_storage())
예제 #10
0
 def _load_env(self):
     return local.load_env(name=self._name, storage=self._storage())
예제 #11
0
파일: loader.py 프로젝트: dankilman/clash
 def _load_env(self):
     return local.load_env(name=self._name, storage=self._storage())
예제 #12
0
def load_env(name=_ENV_NAME):
    storage = local.FileStorage(storage_dir=_workdir())
    return local.load_env(name=name, storage=storage)
예제 #13
0
    arg_parser = argparse.ArgumentParser()
    arg_parser.add_argument('workflow')
    arg_parser.add_argument('blueprint_path')
    arg_parser.add_argument('--name', default='local')
    arg_parser.add_argument('--storage_dir', default='/tmp/cloudify-workflows')
    arg_parser.add_argument('--init', action='store_true')
    arg_parser.add_argument('--bootstrap', action='store_true')
    arg_parser.add_argument('--pool-size', type=int, default=1)
    args = arg_parser.parse_args()

    storage = local.FileStorage(args.storage_dir)
    name = args.name
    if args.init:
        env = local.init_env(args.blueprint_path, name=name, storage=storage)
    else:
        env = local.load_env(name=name, storage=storage)
        env.execute(args.workflow,
                    task_retries=3,
                    task_retry_interval=1,
                    task_thread_pool_size=args.pool_size)
        if args.bootstrap:
            outputs = env.outputs()
            provider = outputs['provider']['value']
            provider_context = provider['context'][0] or {}
            bootstrap_context = outputs['cloudify']['value']
            agent_key_path = bootstrap_context['cloudify_agent'][
                'agent_key_path'][0]
            bootstrap_context['cloudify_agent'][
                'agent_key_path'] = agent_key_path
            provider_context['cloudify'] = bootstrap_context
            management_endpoint = outputs['management_endpoint']['value'][0]
 def _bootstrap_local_env(self, workdir):
     storage = local.FileStorage(
         os.path.join(workdir, '.cloudify', 'bootstrap'))
     return local.load_env('manager', storage=storage)
예제 #15
0
 def env(self, name='main'):
     storage_dir = self.storage_dir(name)
     storage = local.FileStorage(storage_dir)
     return local.load_env('.local', storage)
예제 #16
0
 def env(self, name='main'):
     storage_dir = self.storage_dir(name)
     storage = local.FileStorage(storage_dir)
     return local.load_env('.local', storage)