示例#1
0
    def bootstrap(self):
        with LogTask('Bootstrapping %s' % self.vm.name()):
            if self.vm._spec['disks'][0]['type'] != 'empty' and self.vm._spec[
                    'disks'][0]['format'] != 'iso':
                sysprep_cmd = [
                    sysprep.set_hostname(self.vm.name()),
                    sysprep.set_root_password(self.vm.root_password()),
                    sysprep.add_ssh_key(
                        self.vm.virt_env.prefix.paths.ssh_id_rsa_pub(), ),
                    sysprep.set_iscsi_initiator_name(self.vm.iscsi_name())
                ]

                if self.vm.distro() in ('fc24', 'fc25', 'debian', 'el7'):
                    path = '/boot/grub2/grub.cfg'
                    if self.vm.distro() == 'debian':
                        path = '/boot/grub/grub.cfg'
                    sysprep_cmd.append(
                        sysprep.edit(path, 's/set timeout=5/set timeout=0/s'))

                # In fc25 NetworkManager configures the interfaces successfuly
                # on boot.
                if self.vm.distro() not in ('fc25', 'fc26'):
                    ifaces = [('eth{0}'.format(idx),
                               utils.ipv4_to_mac(nic['ip']))
                              for idx, nic in enumerate(self.vm.spec['nics'])]
                    sysprep_cmd.extend(
                        sysprep.config_net_ifaces_dhcp(self.vm.distro(),
                                                       ifaces))

                sysprep.sysprep(self.vm._spec['disks'][0]['path'], sysprep_cmd)
示例#2
0
文件: vm.py 项目: bellle/lago
    def bootstrap(self):
        with LogTask('Bootstrapping %s' % self.vm.name()):
            if self.vm._spec['disks'][0]['type'] != 'empty' and self.vm._spec[
                    'disks'][0]['format'] != 'iso':
                root_disk = self.vm._spec['disks'][0]['path']
                mappings = {
                    'eth{0}'.format(idx): utils.ipv4_to_mac(nic['ip'])
                    for idx, nic in enumerate(self.vm.spec['nics'])
                }
                public_ssh_key = self.vm.virt_env.prefix.paths.ssh_id_rsa_pub()

                sysprep.sysprep(
                    disk=root_disk,
                    mappings=mappings,
                    distro=self.vm.distro(),
                    root_password=self.vm.root_password(),
                    public_key=public_ssh_key,
                    iscsi_name=self.vm.iscsi_name(),
                    hostname=self.vm.name(),
                )
示例#3
0
文件: vm.py 项目: nirs/lago
    def bootstrap(self):
        with LogTask('Bootstrapping %s' % self.vm.name()):
            if self.vm._spec['disks'][0]['type'] != 'empty' and self.vm._spec[
                'disks'
            ][0]['format'] != 'iso':
                root_disk = self.vm._spec['disks'][0]['path']
                mappings = {
                    'eth{0}'.format(idx): utils.ipv4_to_mac(nic['ip'])
                    for idx, nic in enumerate(self.vm.spec['nics'])
                }
                public_ssh_key = self.vm.virt_env.prefix.paths.ssh_id_rsa_pub()

                sysprep.sysprep(
                    disk=root_disk,
                    mappings=mappings,
                    distro=self.vm.distro(),
                    root_password=self.vm.root_password(),
                    public_key=public_ssh_key,
                    iscsi_name=self.vm.iscsi_name(),
                    hostname=self.vm.name(),
                )
示例#4
0
文件: vm.py 项目: gbenhaim/lago
 def bootstrap(self):
     with LogTask('Bootstrapping %s' % self.vm.name()):
         if self.vm._spec['disks'][0]['type'] != 'empty' and self.vm._spec[
                 'disks'][0]['format'] != 'iso':
             sysprep.sysprep(
                 self.vm._spec['disks'][0]['path'],
                 [
                     sysprep.set_hostname(self.vm.name()),
                     sysprep.set_root_password(self.vm.root_password()),
                     sysprep.add_ssh_key(
                         self.vm.virt_env.prefix.paths.ssh_id_rsa_pub(), ),
                     sysprep.set_iscsi_initiator_name(self.vm.iscsi_name()),
                     sysprep.edit("/boot/grub2/grub.cfg",
                                  "s/set timeout=5/set timeout=0/g") if
                     (self.vm.distro() == 'el7'
                      or self.vm.distro() == 'fc24') else '',
                 ] + [
                     sysprep.config_net_interface_dhcp(
                         'eth%d' % index,
                         utils.ipv4_to_mac(nic['ip']),
                     ) for index, nic in enumerate(self.vm._spec['nics'])
                     if 'ip' in nic
                 ],
             )