def buildWithRemoteMapping(self): # TODO(jchaloup): read location of mappings from config file # TODO(jchaloup): change path to remote mappings to point to server ip2pp_location = "%s/data/import_path_to_provider_prefix_mapping.json" % getScriptDir(__file__) ip2pkg_location = "%s/data/import_path_to_package_name_mapping.json" % getScriptDir(__file__) raise NotImplementedError()
def buildWithRemoteMapping(self): # TODO(jchaloup): read location of mappings from config file # TODO(jchaloup): change path to remote mappings to point to server ip2pp_location = "%s/data/import_path_to_provider_prefix_mapping.json" % getScriptDir( __file__) ip2pkg_location = "%s/data/import_path_to_package_name_mapping.json" % getScriptDir( __file__) raise NotImplementedError()
def buildWithLocalMapping(self): # TODO(jchaloup): read location of mappings from config file ip2pp_location = "%s/data/import_path_to_provider_prefix_mapping.json" % getScriptDir(__file__) ip2pkg_location = "%s/data/import_path_to_package_name_mapping.json" % getScriptDir(__file__) native_packages_location = "%s/data/native_packages.json" % getScriptDir(__file__) # get mappings with open(ip2pp_location, "r") as f: ip2pp_mapping = json.load(f) with open(ip2pkg_location, "r") as f: ip2pkg_mapping = json.load(f) with open(native_packages_location, "r") as f: native_packages = json.load(f) return ImportPathParser(ip2pp_mapping, ip2pkg_mapping, native_packages["packages"])
def buildWithLocalMappingForIPPrefixDecomposer(self): # TODO(jchaloup): read location of mappings from config file ip2pp_location = "%s/data/import_path_to_provider_prefix_mapping.json" % getScriptDir(__file__) # get mappings with open(ip2pp_location, "r") as f: ip2pp_mapping = json.load(f) return ImportPathParser(ip2pp_mapping, {}, [])
def buildWithLocalMappingForIPPrefixDecomposer(self): # TODO(jchaloup): read location of mappings from config file ip2pp_location = "%s/data/import_path_to_provider_prefix_mapping.json" % getScriptDir( __file__) # get mappings with open(ip2pp_location, "r") as f: ip2pp_mapping = json.load(f) return ImportPathParser(ip2pp_mapping, {}, [])
def __init__(self): file_location = "%s/fakedata/nodes.json" % getScriptDir(__file__) self.data = {} with open(file_location, "r") as f: data = json.load(f) for line in data: parts = line["name"].split("-") name = "-".join(parts[:-2]) self.data[name] = line
def _getGoSymbols(self, path, imports_only=False): script_dir = getScriptDir(__file__) + "/." options = "" if imports_only: options = "-imports" so, se, rc = runCommand("%s/parseGo %s %s" % (script_dir, options, path)) if rc != 0: return (1, se) return (0, so)
def buildWithLocalMapping(self): # TODO(jchaloup): read location of mappings from config file ip2pp_location = "%s/data/import_path_to_provider_prefix_mapping.json" % getScriptDir( __file__) ip2pkg_location = "%s/data/import_path_to_package_name_mapping.json" % getScriptDir( __file__) native_packages_location = "%s/data/native_packages.json" % getScriptDir( __file__) # get mappings with open(ip2pp_location, "r") as f: ip2pp_mapping = json.load(f) with open(ip2pkg_location, "r") as f: ip2pkg_mapping = json.load(f) with open(native_packages_location, "r") as f: native_packages = json.load(f) return ImportPathParser(ip2pp_mapping, ip2pkg_mapping, native_packages["packages"])
def __init__(self, config=None, config_vars=None, dry_run=False): self._dry_run = dry_run if not config: config = "%s/../config.yaml" % getScriptDir(__file__) if config_vars: self._config_data = yaml.load( renderTemplate(os.path.dirname(config), os.path.basename(config), config_vars)) else: self._config_data = yaml.load(open(config, 'r'))
def __init__(self, ansible_dir, resource_file, cluster_os, kubeconfig_dest, private_key=None, log_file=None, dry=False): self._dry = dry self._class_dir = getScriptDir(__file__) self._ansible_dir = ansible_dir self._resource_file = resource_file self._kubeconfig_dest = kubeconfig_dest self._log_file = log_file self._private_key = private_key self._cluster_os = cluster_os inventory_dir = os.path.join(self._ansible_dir, "inventory") if "INVENTORY" in os.environ: self._inventory = os.environ["INVENTORY"] if "INVENTORY" not in os.environ: if os.path.exists(inventory_dir): self._inventory = os.path.join( self._ansible_dir, "inventory/central_ci_dynamic_hosts.py") else: self._inventory = os.path.join(self._class_dir, "central_ci_dynamic_hosts.py") self._playbooks_dir = os.path.join(self._class_dir, "playbook") data = json.load(open(resource_file)) nodes = [] masters = [] for node in data["resources"]: nodes.append(node["ip"]) if "masters" in node["metadata"]["ansible-group"]: masters.append(node["ip"]) assert len(masters) > 0 assert len(nodes) > 0 self._cluster_resources = {} self._cluster_resources["nodes"] = nodes self._cluster_resources["masters"] = masters data
def getPackages(self, distribution = "rawhide"): """ :param distribution: package distribution :type distribution: string :returns: [string] :raises KeyError: if distribution not found """ if self._packages == {}: file_location = "%s/data/distribution_packages.json" % getScriptDir(__file__) with open(file_location, "r") as f: packages = json.load(f) for pkg in packages: for distro in pkg["distributions"]: try: self._packages[distro].append(pkg["package"]) except KeyError: self._packages[distro] = [pkg["package"]] return self._packages[distribution]