示例#1
0
    def parse_operating_system(self):
        if self.data.get('codename').lower() != 'trusty':
            raise errors.WrongInputDataError(
                'Currently, only Ubuntu Trusty is supported, given '
                'codename is {0}'.format(self.data.get('codename')))

        packages = self.data.get('packages', self.DEFAULT_TRUSTY_PACKAGES)

        repos = []
        for repo in self.data['repos']:
            repos.append(objects.DEBRepo(
                name=repo['name'],
                uri=repo['uri'],
                suite=repo['suite'],
                section=repo['section'],
                priority=repo['priority']))

        proxies = objects.RepoProxies()

        proxy_dict = self.data.get('proxies', {})
        for protocol, uri in six.iteritems(proxy_dict.get('protocols', {})):
            proxies.add_proxy(protocol, uri)
        proxies.add_direct_repo_addrs(proxy_dict.get(
            'direct_repo_addr_list', []))

        os = objects.Ubuntu(repos=repos, packages=packages, major=14, minor=4,
                            proxies=proxies)

        # add root account
        root_password = self.data.get('root_password')
        hashed_root_password = self.data.get('hashed_root_password')

        # for backward compatibily set default password is no password provided
        if root_password is None and hashed_root_password is None:
            root_password = CONF.default_root_password

        os.add_user_account(
            name='root',
            password=root_password,
            homedir='/root',
            hashed_password=hashed_root_password,
        )
        return os
示例#2
0
    def parse_operating_system(self):
        LOG.debug('--- Preparing operating system data ---')
        os_release = self._image_meta.get('os', None)

        os = self.get_os_by_image_meta(os_release) or \
            self.get_os_by_profile(self.data['profile'].lower())

        # FIXME(dnikishov): until fuel-agent-versioning BP
        # will have been implemented, we need to deal with the case when
        # 9.0 fuel-agent will be managing 6.1 to 8.0 environments, whose
        # provisioning serializers on Nailgun side will not have
        # user_accounts in the ks_meta dict
        try:
            user_accounts = self.data['ks_meta']['user_accounts']
        except KeyError:
            LOG.warn(('This environment does not support non-root accounts '
                      'on the target nodes. Non-root user accounts will not '
                      'be created'))
            user_accounts = []

        for account in user_accounts:
            os.add_user_account(**account)

        return os