404

[ Avaa Bypassed ]




Upload:

Command:

elspacio@18.191.223.30: ~ $
# Copyright (C) 2012 Canonical Ltd.
# Copyright (C) 2012 Hewlett-Packard Development Company, L.P.
# Copyright (C) 2012 Yahoo! Inc.
#
# This file is part of cloud-init. See LICENSE file for license information.

import copy
import logging
import os
from typing import Optional

from cloudinit.distros import Distro
from cloudinit.helpers import Paths, Runners
from cloudinit.reporting import events
from cloudinit.sources import DataSource

LOG = logging.getLogger(__name__)

# This class is the high level wrapper that provides
# access to cloud-init objects without exposing the stage objects
# to handler and or module manipulation. It allows for cloud
# init to restrict what those types of user facing code may see
# and or adjust (which helps avoid code messing with each other)
#
# It also provides util functions that avoid having to know
# how to get a certain member from this submembers as well
# as providing a backwards compatible object that can be maintained
# while the stages/other objects can be worked on independently...


class Cloud:
    def __init__(
        self,
        datasource: DataSource,
        paths: Paths,
        cfg: dict,
        distro: Distro,
        runners: Runners,
        reporter: Optional[events.ReportEventStack] = None,
    ):
        self.datasource = datasource
        self.paths = paths
        self.distro = distro
        self._cfg = cfg
        self._runners = runners
        if reporter is None:
            reporter = events.ReportEventStack(
                name="unnamed-cloud-reporter",
                description="unnamed-cloud-reporter",
                reporting_enabled=False,
            )
        self.reporter = reporter

    @property
    def cfg(self):
        # Ensure that cfg is not indirectly modified
        return copy.deepcopy(self._cfg)

    def run(self, name, functor, args, freq=None, clear_on_fail=False):
        return self._runners.run(name, functor, args, freq, clear_on_fail)

    def get_template_filename(self, name):
        fn = self.paths.template_tpl % (name)
        if not os.path.isfile(fn):
            LOG.warning(
                "No template found in %s for template named %s",
                os.path.dirname(fn),
                name,
            )
            return None
        return fn

    # The rest of these are just useful proxies
    def get_userdata(self, apply_filter=True):
        return self.datasource.get_userdata(apply_filter)

    def get_instance_id(self):
        return self.datasource.get_instance_id()

    @property
    def launch_index(self):
        return self.datasource.launch_index

    def get_public_ssh_keys(self):
        return self.datasource.get_public_ssh_keys()

    def get_locale(self):
        return self.datasource.get_locale()

    def get_hostname(self, fqdn=False, metadata_only=False):
        return self.datasource.get_hostname(
            fqdn=fqdn, metadata_only=metadata_only
        )

    def device_name_to_device(self, name):
        return self.datasource.device_name_to_device(name)

    def get_ipath_cur(self, name=None):
        return self.paths.get_ipath_cur(name)

    def get_cpath(self, name=None):
        return self.paths.get_cpath(name)

    def get_ipath(self, name=None):
        return self.paths.get_ipath(name)

Filemanager

Name Type Size Permission Actions
__pycache__ Folder 0755
analyze Folder 0755
cmd Folder 0755
config Folder 0755
distros Folder 0755
filters Folder 0755
handlers Folder 0755
mergers Folder 0755
net Folder 0755
reporting Folder 0755
sources Folder 0755
__init__.py File 0 B 0644
apport.py File 7.05 KB 0644
atomic_helper.py File 2.45 KB 0644
cloud.py File 3.22 KB 0644
dmi.py File 6.77 KB 0644
event.py File 2 KB 0644
features.py File 3.38 KB 0644
gpg.py File 4.28 KB 0644
helpers.py File 16.41 KB 0644
importer.py File 2.43 KB 0644
log.py File 5.47 KB 0644
netinfo.py File 22.97 KB 0644
persistence.py File 2.52 KB 0644
registry.py File 1022 B 0644
safeyaml.py File 10.28 KB 0644
settings.py File 2.02 KB 0644
signal_handler.py File 1.74 KB 0644
simpletable.py File 1.93 KB 0644
ssh_util.py File 22.28 KB 0644
stages.py File 38.88 KB 0644
subp.py File 13.23 KB 0644
temp_utils.py File 3.15 KB 0644
templater.py File 5.95 KB 0644
type_utils.py File 703 B 0644
url_helper.py File 27.32 KB 0644
user_data.py File 14.43 KB 0644
util.py File 96.43 KB 0644
version.py File 565 B 0644
warnings.py File 3.76 KB 0644