コード例 #1
0
    def execute(self, context):
        """Execute the main code for this operator.

        Create a ConfigMap with the deployment status of this dag's action
        """
        LOG.info("Running deployment status operator")

        self.xcom_puller = XcomPuller(self.main_dag_name, context['ti'])

        # Required for the get_deployment_status helper to function properly
        config.parse_args(args=[], default_config_files=[self.shipyard_conf])

        # First we need to check if the concurrency check was successful as
        # this operator is expected to run even if upstream steps fail
        if not self.xcom_puller.get_concurrency_status():
            msg = "Concurrency check did not pass, so the deployment status " \
                  "will not be updated"
            LOG.error(msg)
            raise AirflowException(msg)

        deployment_status_doc, revision_id = self._get_status_and_revision()
        deployment_version_doc = self._get_version_doc(revision_id)

        full_data = {
            'deployment': deployment_status_doc,
            **deployment_version_doc
        }
        config_map_data = {'release': yaml.safe_dump(full_data)}

        self._store_as_config_map(config_map_data)
コード例 #2
0
def shipyard_upgrade_db(default_config_files=None):
    """
    Starts database upgrade
    """
    # Trigger configuration resolution.
    config.parse_args(args=[], default_config_files=default_config_files)

    db.SHIPYARD_DB.update_db()
コード例 #3
0
def start_shipyard(default_config_files=None):
    # Trigger configuration resolution.
    config.parse_args(args=[], default_config_files=default_config_files)

    ucp_logging.setup_logging(CONF.logging.log_level)

    # Setup the RBAC policy enforcer
    policy.policy_engine = policy.ShipyardPolicy()
    policy.policy_engine.register_policy()

    # Start the API
    return api.start_api()
コード例 #4
0
def start_shipyard(default_config_files=None):
    # Trigger configuration resolution.
    config.parse_args(args=[], default_config_files=default_config_files)

    LoggingConfig(level=CONF.logging.log_level,
                  named_levels=CONF.logging.named_log_levels).setup_logging()

    # Setup the RBAC policy enforcer
    policy.policy_engine = policy.ShipyardPolicy()
    policy.policy_engine.register_policy()

    # Start the API
    if CONF.base.profiler:
        LOG.warning("Profiler ENABLED. Expect significant "
                    "performance overhead.")
        return ProfilerMiddleware(api.start_api(),
                                  profile_dir="/tmp/profiles")  # nosec
    else:
        return api.start_api()
コード例 #5
0
ファイル: shipyard.py プロジェクト: sblanco1/shipyard
def start_shipyard():
    # Trigger configuration resolution.
    config.parse_args()

    # Setup root logger
    base_console_handler = logging.StreamHandler()

    logging.basicConfig(level=logging.INFO,
                        format='%(asctime)s - %(levelname)s - %(message)s',
                        handlers=[base_console_handler])
    logging.getLogger().info("Setting logging level to: %s",
                             logging.getLevelName(CONF.logging.log_level))

    logging.basicConfig(level=CONF.logging.log_level,
                        format='%(asctime)s - %(levelname)s - %(message)s',
                        handlers=[base_console_handler])

    # Specalized format for API logging
    logger = logging.getLogger('shipyard.control')
    logger.propagate = False
    formatter = logging.Formatter(
        ('%(asctime)s - %(levelname)s - %(user)s - %(req_id)s - '
         '%(external_ctx)s - %(message)s'))

    console_handler = logging.StreamHandler()
    console_handler.setFormatter(formatter)
    logger.addHandler(console_handler)

    # Setup the RBAC policy enforcer
    policy.policy_engine = policy.ShipyardPolicy()
    policy.policy_engine.register_policy()

    # Upgrade database
    if CONF.base.upgrade_db:
        # this is a reasonable place to put any online alembic upgrades
        # desired. Currently only shipyard db is under shipyard control.
        db.SHIPYARD_DB.update_db()

    # Start the API
    return api.start_api()
コード例 #6
0
def setup_config():
    """
    Initialize shipyard config - this is needed so that CONF resolves.
    """
    config.parse_args()