示例#1
0
 def produce_commands(self):
     collector = self._collector()
     if Facter.get(
             OperatingSystem) != OperatingSystem.Fedora and Facter.get(
                 OperatingSystemRelease).major() == '5':
         collector.collect_from_file('wget downloader', 'wget.sh')
     self._collect_repo(collector)
     self._collect_agent(collector)
     if self._installer.mode() == Mode.Server:
         self._collect_server(collector)
     return collector.lines()
示例#2
0
 def _collect_repo(self, collector):
     major = Facter.get(OperatingSystemRelease).major()
     os = Facter.get(OperatingSystem)
     if os == OperatingSystem.Fedora:
         abbr = 'fedora'
     else:
         abbr = 'el'
     mapping = dict(major=major, abbr=abbr)
     if ('%s-%s' % (abbr, major)) == 'el-5':
         script = 'pc3x-el5-repo.sh'
     else:
         script = 'pc3x-repo.sh'
     title = 'Puppet Package Repository setup (Puppet OSS 3.x)'
     collector.collect_from_template(title, script, mapping)
示例#3
0
 def process_fully_qualified_domain_name(self, fqdn):
     # type: (FqdnConfiguration) -> Sequence[Configurer]
     if Facter.get(Docker) == Docker.YES:
         raise NotImplementedError(
             'Can\'t set FQDN when running inside Docker!')
     osfamily = Facter.get(OsFamily)
     try:
         return {
             OsFamily.RedHat: [RedHatFQDNConfigurer(fqdn)],
             OsFamily.Debian: [DebianFQDNConfigurer(fqdn)]
         }[osfamily]
     except KeyError as ex:
         raise NotImplementedError(
             ex, 'Unsupported OS family %s for setting FQDN' % osfamily)
示例#4
0
 def _collect_repo(self, collector):
     major = Facter.get(OperatingSystemRelease).major()
     os = Facter.get(OperatingSystem)
     if os == OperatingSystem.Fedora:
         abbr = 'fedora'
     else:
         abbr = 'el'
     mapping = dict(major=major, abbr=abbr)
     if ('%s-%s' % (abbr, major)) == 'el-5':
         script = self._repo_script_path_el5()
     else:
         script = self._repo_script_path()
     collector.collect_from_template(self._repo_setup_title(), script,
                                     mapping)
示例#5
0
 def __produce_commands(self, install):
     # type: (After4xCollectionInstaller) -> Sequence[str]
     args = []  # type: MutableSequence[str]
     mem = install.puppetserver_jvm_memory()
     jvmargs = install.puppetserver_jvm_args()
     if mem.is_set():
         if mem.heap_minimum() is not None:
             args.append('-Xms{xms}'.format(xms=mem.heap_minimum()))
         if mem.heap_maximum() is not None:
             args.append('-Xmx{xmx}'.format(xmx=mem.heap_maximum()))
         java_version = Facter.get(JavaVersion)
         metaspace_arg = self.__get_metaspace_arg(java_version)
         if java_version.has_permgen_space(
         ) and mem.metaspace_maximum() is None:
             args.append(metaspace_arg.format(mspace='256m'))
         elif mem.metaspace_maximum() is not None:
             args.append(
                 metaspace_arg.format(mspace=mem.metaspace_maximum()))
     if jvmargs.are_set():
         args.extend(jvmargs)
     args_as_str = ' '.join(args)
     collector = self._collector()
     mapping = dict(jvmargs=args_as_str)
     collector.collect_from_template('Configuring PuppetServer JVM Args',
                                     'puppetserver-jvmargs.pp',
                                     mapping,
                                     format=ScriptFormat.PUPPET)
     return collector.lines()
示例#6
0
 def _collect_repo(self, collector):
     codename = Facter.get(OperatingSystemCodename)
     collector.collect_from_template(
         'Puppet Package Repository setup (Puppet OSS 3.x)',
         'pc3x-repo.sh',
         dict(codename=codename)
     )
示例#7
0
    def test_osrelrelease_minor(self):
        rel = Facter.get(OperatingSystemRelease)
        minor = rel.minor()

        assert minor is not None
        assert type(minor) is str
        assert re.compile('^\d+$').match(minor) is not None
示例#8
0
    def test_osrelease_major_oninvalid(self):
        MockFacter.set_fact(OperatingSystemRelease,
                            OperatingSystemRelease('alpha'))

        rel = Facter.get(OperatingSystemRelease)
        major = rel.major()

        assert major is not None
        assert major is 'alpha'
示例#9
0
 def __perform_installation(answers):
     # type: (Answers) -> Sequence[Configurer]
     configurers = []
     if answers.installer() is not None:
         osfamily = Facter.get(osfacts.OsFamily)
         gateway = container.get_named(InstallerGateway, osfamily.name.lower())
         configurers.extend(
             gateway.configurers(answers.installer())
         )
     return configurers
示例#10
0
def calculate_osfamily():
    return {
        OperatingSystem.CentOS: OsFamily.RedHat,
        OperatingSystem.OracleLinux: OsFamily.RedHat,
        OperatingSystem.RedHat: OsFamily.RedHat,
        OperatingSystem.Scientific: OsFamily.RedHat,
        OperatingSystem.Debian: OsFamily.Debian,
        OperatingSystem.Ubuntu: OsFamily.Debian,
        OperatingSystem.OpenSuse: OsFamily.Suse,
        OperatingSystem.SLES: OsFamily.Suse,
        OperatingSystem.ArchLinux: OsFamily.Arch
    }.get(Facter.get(OperatingSystem), OsFamily.Unknown)
示例#11
0
def test_invalid_resolver():
    # noinspection PyUnresolvedReferences,PyProtectedMember
    resolvers = Facter._Facter__resolvers
    before_count = len(resolvers)
    try:
        Facter.set(TEST_KEY, lambda: None)
        value = Facter.get(TEST_KEY)

        assert value is None
        assert len(resolvers) == before_count + 1
    finally:
        resolvers.pop(TEST_KEY)
        assert len(resolvers) == before_count
示例#12
0
def calculate_java_version():
    # type: () -> JavaVersion
    osfamily = Facter.get(OsFamily)
    java_prog_name = 'java.exe' if osfamily is OsFamily.Windows else 'java'
    search_paths = environ['PATH'].split(path.pathsep)
    java_prog = None
    for search_path in search_paths:
        java_prog_candidate = path.join(search_path, java_prog_name)
        if __is_executable(java_prog_candidate):
            java_prog = java_prog_candidate
            break
    if java_prog is None:
        return JavaVersion.NOT_INSTALLED
    return __get_java_version(java_prog)
示例#13
0
 def produce_commands(self):
     if self.__installer.mode() == Mode.Agent:
         return []
     if self.__installer.is_after_4x():
         servicename = 'puppetserver'
     else:
         servicename = 'puppetmaster'
     enable = 'true' if Facter.get(Docker) is not Docker.YES else 'false'
     collector = self._collector()
     desc = 'Starting Puppet server service ({servicename})'.format(
         servicename=servicename)
     mapping = dict(servicename=servicename, enable=enable)
     collector.collect_from_template(desc, 'puppetserver.sh', mapping)
     return collector.lines()
示例#14
0
    def test_docker(self, tmpdir):
        old_chroot = puppeter.settings.chroot
        try:
            new_root = tmpdir.mkdir("docker-utest")
            puppeter.settings.chroot = str(new_root) + '/'
            p = new_root.mkdir('proc').mkdir('1').join('cgroup')
            p.write('11:blkio:/docker/885762619\n'
                    '10:pids:/docker/885762619'
                    '9:freezer:/docker/885762619\n'
                    '8:cpuset:/docker/885762619\n'
                    '7:perf_event:/docker/885762619\n'
                    '6:devices:/docker/885762619\n'
                    '5:hugetlb:/docker/885762619\n')
            docker = Facter.get(Docker)

            assert type(docker) is Docker
            assert docker is Docker.YES
            assert bool(docker) is True
        finally:
            puppeter.settings.chroot = old_chroot
示例#15
0
    def test_oscodename(self):
        codename = Facter.get(OperatingSystemCodename)

        assert codename == 'trusty'
        assert type(codename) is OperatingSystemCodename
示例#16
0
def test_facter_get_unknown():
    value = Facter.get(TEST_KEY)

    assert value is None
示例#17
0
    def test_oscodename(self):
        codename = Facter.get(OperatingSystemCodename)

        assert codename is not None
示例#18
0
    def test_operatingsystem(self):
        os = Facter.get(OperatingSystem)

        assert os is not None
示例#19
0
    def test_osfamily(self):
        osfamily = Facter.get(OsFamily)

        assert osfamily is not None
示例#20
0
 def _collect_repo(self, collector):
     codename = Facter.get(OperatingSystemCodename)
     collector.collect_from_template(
         'Puppet Labs Collection Repository (PC1) setup (Puppet OSS 4.x)',
         'pc4x-repo.sh', dict(codename=codename))
示例#21
0
    def test_osrelease(self):
        rel = Facter.get(OperatingSystemRelease)

        assert rel is not None
示例#22
0
    def test_osrelease(self):
        regex = OperatingSystemRelease.VERSION_RE
        rel = Facter.get(OperatingSystemRelease)

        assert rel is not None
        assert regex.match(rel) is not None
示例#23
0
 def _collect_repo(self, collector):
     rel = Facter.get(OperatingSystemRelease)
     collector.collect_from_file(
         'Ensure EPEL is active',
         'ensure-epel-{rel}.sh'.format(rel=rel.major()))