Пример #1
0
def init(reset_config, skip_logging=False):
    if os.path.exists(os.path.join(
            os.getcwd(),
            constants.ARIA_WD_SETTINGS_DIRECTORY_NAME,
            constants.ARIA_WD_SETTINGS_FILE_NAME)):
        if not reset_config:
            msg = 'Current directory is already initialized'
            error = exceptions.AriaError(msg)
            error.possible_solutions = [
                "Run 'aria init -b [blueprint-id] -p [path-to-a-blueprint]' "
                "to force re-initialization "
                "(might overwrite existing "
                "configuration files if exist)"
            ]
            raise error
        else:
            shutil.rmtree(os.path.join(
                os.getcwd(),
                constants.ARIA_WD_SETTINGS_DIRECTORY_NAME))

    settings = utils.AriaWorkingDirectorySettings()
    utils.dump_aria_working_dir_settings(settings)
    utils.dump_configuration_file()
    logger.configure_loggers('aria_cli.cli.main')
    if not skip_logging:
        logger.get_logger().info('Initialization completed successfully')
Пример #2
0
def _set_cli_except_hook():

    from aria_core import logger
    LOG = logger.get_logger('aria_cli.cli.main')

    def recommend(possible_solutions):

        LOG.info('Possible solutions:')
        for solution in possible_solutions:
            LOG.info('  - {0}'.format(solution))

    def new_excepthook(tpe, value, tb):

        prefix = None
        server_traceback = None
        output_message = True
        if issubclass(tpe, exceptions.SuppressedAriaError):
            output_message = False
        if verbose_output:
            # print traceback if verbose
            s_traceback = StringIO.StringIO()
            traceback.print_exception(
                etype=tpe,
                value=value,
                tb=tb,
                file=s_traceback)
            LOG.error(s_traceback.getvalue())
            if server_traceback:
                LOG.error('Server Traceback (most recent call last):')

                # No need for print_tb since this exception
                # is already formatted by the server
                LOG.error(server_traceback)
        if output_message and not verbose_output:

            # if we output the traceback
            # we output the message too.
            # print_exception does that.
            # here we just want the message (non verbose)
            if prefix:
                LOG.error('{0}: {1}'.format(prefix, value))
            else:
                LOG.error(value)
        if hasattr(value, 'possible_solutions'):
            recommend(getattr(value, 'possible_solutions'))

    sys.excepthook = new_excepthook
Пример #3
0
import os
import sys

from virtualenvapi import manage
from virtualenvapi import exceptions

from aria_core import constants
from aria_core import exceptions as aria_exceptions
from aria_core import logger
from aria_core import logger_config
from aria_core import utils

from aria_core.dependencies import futures
from aria_core.processor import blueprint_processor

LOG = logger.get_logger("aria_cli.cli.main")


def initialize_blueprint(blueprint_path, blueprint_id, storage, install_plugins=False, inputs=None, storage_path=None):

    venv_path = install_blueprint_plugins(
        blueprint_id, blueprint_path, install_plugins=install_plugins, storage_path=storage_path
    )
    provider_context = logger_config.AriaConfig().local_provider_context
    inputs = utils.inputs_to_dict(inputs, "inputs")
    sys.path.append(venv_path)
    env = futures.aria_local.init_env(
        blueprint_path=blueprint_path,
        name=blueprint_id,
        inputs=inputs,
        storage=storage,
Пример #4
0
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.

import shutil
import warnings

from aria_core import blueprints
from aria_core import logger
from aria_core import utils
from aria_core import workflows


LOG = logger.get_logger(__name__)


class BlueprintsAPI(object):

    def __init__(self, storage_path):
        self._storage_path = storage_path

    def validate(self, blueprint_path):
        """
        Validates a blueprint using Aria DSL parser API
        :param blueprint_path: path to a blueprint
        :type blueprint_path: str
        :return: None
        """
        return blueprints.validate(blueprint_path)
Пример #5
0
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.

import shutil
import warnings

from aria_core import blueprints
from aria_core import logger
from aria_core import utils
from aria_core import workflows


LOG = logger.get_logger(__name__)


class BlueprintsAPI(object):

    def __init__(self, storage_path=None):
        self._storage_path = storage_path

    def validate(self, blueprint_path):
        """
        Validate blueprint in order to be a valid TOSCA template
        Parameters
        ----------
        blueprint_path: str

        Returns
Пример #6
0
import os
import sys

from virtualenvapi import manage
from virtualenvapi import exceptions

from aria_core import constants
from aria_core import exceptions as aria_exceptions
from aria_core import logger
from aria_core import logger_config
from aria_core import utils

from aria_core.dependencies import futures
from aria_core.processor import blueprint_processor

LOG = logger.get_logger('aria_cli.cli.main')


def initialize_blueprint(blueprint_path,
                         blueprint_id,
                         storage,
                         install_plugins=False,
                         inputs=None,
                         storage_path=None):

    venv_path = install_blueprint_plugins(blueprint_id,
                                          blueprint_path,
                                          install_plugins=install_plugins,
                                          storage_path=storage_path)
    provider_context = (logger_config.AriaConfig().local_provider_context)
    inputs = utils.inputs_to_dict(inputs, 'inputs')