예제 #1
0
    def parse_configdrive_scheme(self):
        LOG.debug('--- Preparing configdrive scheme ---')
        data = self.data
        configdrive_scheme = objects.ConfigDriveScheme()

        LOG.debug('Adding common parameters')

        interface_dicts = [
            dict(name=name, **spec)
            for name, spec in six.iteritems(data['interfaces'])
        ]

        admin_interface = next(x for x in interface_dicts
                               if (x['mac_address'] == data['kernel_options']
                                   ['netcfg/choose_interface']))

        ssh_auth_keys = data['ks_meta']['authorized_keys']
        if data['ks_meta']['auth_key']:
            ssh_auth_keys.append(data['ks_meta']['auth_key'])

        configdrive_scheme.set_common(
            ssh_auth_keys=ssh_auth_keys,
            hostname=data['hostname'],
            fqdn=data['hostname'],
            name_servers=data['name_servers'],
            search_domain=data['name_servers_search'],
            master_ip=data['ks_meta']['master_ip'],
            master_url='http://%s:8000/api' % data['ks_meta']['master_ip'],
            udevrules=data['kernel_options']['udevrules'],
            admin_mac=data['kernel_options']['netcfg/choose_interface'],
            admin_ip=admin_interface['ip_address'],
            admin_mask=admin_interface['netmask'],
            admin_iface_name=admin_interface['name'],
            timezone=data['ks_meta'].get('timezone', 'America/Los_Angeles'),
            gw=data['ks_meta']['gw'],
            ks_repos=data['ks_meta']['repo_setup']['repos'])

        LOG.debug('Adding puppet parameters')
        configdrive_scheme.set_puppet(master=data['ks_meta']['puppet_master'],
                                      enable=data['ks_meta']['puppet_enable'])

        LOG.debug('Adding mcollective parameters')
        configdrive_scheme.set_mcollective(
            pskey=data['ks_meta']['mco_pskey'],
            vhost=data['ks_meta']['mco_vhost'],
            host=data['ks_meta']['mco_host'],
            user=data['ks_meta']['mco_user'],
            password=data['ks_meta']['mco_password'],
            connector=data['ks_meta']['mco_connector'],
            enable=data['ks_meta']['mco_enable'])

        LOG.debug('Setting configdrive profile %s' % data['profile'])
        configdrive_scheme.set_profile(profile=data['profile'])
        configdrive_scheme.set_cloud_init_templates(
            templates=data['ks_meta'].get('cloud_init_templates', {}))
        return configdrive_scheme
예제 #2
0
    def configdrive_scheme(self):
        LOG.debug('--- Preparing configdrive scheme ---')
        data = self.data
        configdrive_scheme = objects.ConfigDriveScheme()

        LOG.debug('Adding common parameters')
        admin_interface = filter(
            lambda x: (x['mac_address'] == data['kernel_options'][
                'netcfg/choose_interface']), [
                    dict(name=name, **spec)
                    for name, spec in data['interfaces'].iteritems()
                ])[0]

        ssh_auth_keys = data['ks_meta']['authorized_keys']
        if data['ks_meta']['auth_key']:
            ssh_auth_keys.append(data['ks_meta']['auth_key'])

        configdrive_scheme.set_common(
            ssh_auth_keys=ssh_auth_keys,
            hostname=data['hostname'],
            fqdn=data['hostname'],
            name_servers=data['name_servers'],
            search_domain=data['name_servers_search'],
            master_ip=data['ks_meta']['master_ip'],
            master_url='http://%s:8000/api' % data['ks_meta']['master_ip'],
            udevrules=data['kernel_options']['udevrules'],
            admin_mac=data['kernel_options']['netcfg/choose_interface'],
            admin_ip=admin_interface['ip_address'],
            admin_mask=admin_interface['netmask'],
            admin_iface_name=admin_interface['name'],
            timezone=data['ks_meta'].get('timezone', 'America/Los_Angeles'),
            ks_repos=dict(
                map(lambda x: x.strip('"').strip("'"), item.split('='))
                for item in data['ks_meta']['repo_metadata'].split(',')))

        LOG.debug('Adding puppet parameters')
        configdrive_scheme.set_puppet(master=data['ks_meta']['puppet_master'],
                                      enable=data['ks_meta']['puppet_enable'])

        LOG.debug('Adding mcollective parameters')
        configdrive_scheme.set_mcollective(
            pskey=data['ks_meta']['mco_pskey'],
            vhost=data['ks_meta']['mco_vhost'],
            host=data['ks_meta']['mco_host'],
            user=data['ks_meta']['mco_user'],
            password=data['ks_meta']['mco_password'],
            connector=data['ks_meta']['mco_connector'],
            enable=data['ks_meta']['mco_enable'])

        LOG.debug('Setting configdrive profile %s' % data['profile'])
        configdrive_scheme.set_profile(profile=data['profile'])
        return configdrive_scheme
예제 #3
0
파일: nailgun.py 프로젝트: romcheg/fuel-web
    def configdrive_scheme(self):
        data = self.data
        configdrive_scheme = objects.ConfigDriveScheme()

        admin_interface = filter(
            lambda x: (x['mac_address'] ==
                       data['kernel_options']['netcfg/choose_interface']),
            [dict(name=name, **spec) for name, spec
             in data['interfaces'].iteritems()])[0]
        configdrive_scheme.set_common(
            ssh_auth_key=data['ks_meta']['auth_key'],
            hostname=data['hostname'],
            fqdn=data['hostname'],
            name_servers=data['name_servers'],
            search_domain=data['name_servers_search'],
            master_ip=data['ks_meta']['master_ip'],
            master_url='http://%s:8000/api' % data['ks_meta']['master_ip'],
            udevrules=data['kernel_options']['udevrules'],
            admin_mac=data['kernel_options']['netcfg/choose_interface'],
            admin_ip=admin_interface['ip_address'],
            admin_mask=admin_interface['netmask'],
            admin_iface_name=admin_interface['name'],
            timezone=data['ks_meta']['timezone'],
        )

        configdrive_scheme.set_puppet(
            master=data['ks_meta']['puppet_master']
        )

        configdrive_scheme.set_mcollective(
            pskey=data['ks_meta']['mco_pskey'],
            vhost=data['ks_meta']['mco_vhost'],
            host=data['ks_meta']['mco_host'],
            user=data['ks_meta']['mco_user'],
            password=data['ks_meta']['mco_password'],
            connector=data['ks_meta']['mco_connector']
        )

        configdrive_scheme.set_profile(profile=data['profile'])
        return configdrive_scheme
#    under the License.
import mock
import requests_mock
import unittest2

from fuel_agent.drivers import simple
from fuel_agent import objects
from fuel_agent.tests import base


@mock.patch.multiple(
    simple.NailgunSimpleDriver,
    parse_operating_system=lambda x: objects.OperatingSystem(None, None),
    parse_image_meta=lambda x: {},
    parse_grub=lambda x: objects.Grub(),
    parse_configdrive_scheme=lambda x: objects.ConfigDriveScheme(),
    parse_image_scheme=lambda x: objects.ImageScheme())
class TestObjectDeserialization(unittest2.TestCase):
    def test_driver_always_has_correct_objects(self):
        driver = simple.NailgunSimpleDriver({})
        assert isinstance(driver.partition_scheme, objects.PartitionScheme)

    def test_lv_data_is_loaded(self):
        lv_data = {
            'partitioning': {
                'lvs': [
                    {
                        'name': 'lv-name',
                        'size': 12345,
                        'vgname': 'vg-name',
                    },