Example #1
0
    def __init__(self, bucket_name):
        ec = EnjoliverConfig(importer=__file__)
        aws_id = ec.aws_id
        aws_secret = ec.aws_secret
        self.bucket_name = bucket_name

        if not bucket_name:
            logger.error("bucket_name=%s" % bucket_name)
            raise AttributeError("bucket_name is not defined: %s" %
                                 bucket_name)

        if aws_id is None or aws_secret is None:
            logger.error(
                "Missing the couple AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY")
            raise EnvironmentError(
                "Missing the couple AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY")
        logger.info("connect to bucket name: %s" % bucket_name)

        self.s3 = boto3.resource('s3')
        self.bucket = self.s3.Bucket(bucket_name)
Example #2
0
"""
import json
import os
import re

import ipaddr
import requests
import time
from werkzeug.contrib.cache import SimpleCache, NullCache

import generator
import logging
import schedulerv2
from configs import EnjoliverConfig

EC = EnjoliverConfig(importer=__file__)

logger = logging.getLogger(__name__)


class ConfigSyncSchedules(object):
    __name__ = "ConfigSyncSchedules"
    sub_ips = EC.sub_ips
    range_nb_ips = EC.range_nb_ips
    skip_ips = EC.skip_ips

    def __init__(self, api_uri: str, matchbox_path: str, ignition_dict: dict, extra_selector_dict=None):
        """
        :param api_uri: http://1.1.1.1:5000
        :param matchbox_path: /var/lib/matchbox
        :param ignition_dict: ignition.yaml
Example #3
0
import logging
import socket

from configs import EnjoliverConfig

logger = logging.getLogger(__file__)
EC = EnjoliverConfig()


def get_mac_from_raw_query(request_raw_query: str):
    """
    Get MAC address inside a matchbox "request raw query"
    /path?<request_raw_query>
    :param request_raw_query:
    :return: mac address
    """
    mac = ""
    raw_query_list = request_raw_query.split("&")
    for param in raw_query_list:
        if "mac=" in param:
            mac = param.replace("mac=", "")
    if not mac:
        raise AttributeError("%s is not parsable" % request_raw_query)
    return mac.replace("-", ":")


def get_verified_dns_query(interface: dict):
    """
    A discovery machine give a FQDN. This method will do the resolution before insert in the db
    :param interface:
    :return: