~ubuntu-branches/debian/stretch/fuel-agent/stretch

« back to all changes in this revision

Viewing changes to fuel_agent/manager.py

  • Committer: Package Import Robot
  • Author(s): Thomas Goirand
  • Date: 2016-03-16 17:12:17 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20160316171217-p5b360dfuxm5yidy
Tags: 9.0~0+2016.03.09.git.b1ba4b7747+dfsg1-1
* New upstream release based on commit b1ba4b7747.
* Uploading to unstable.
* Lots of tweaks to make Debian provisionning works.
* Standards-Version: 3.9.7 (no change).

Show diffs side-by-side

added added

removed removed

Lines of Context:
76
76
    ),
77
77
    cfg.IntOpt(
78
78
        'grub_timeout',
79
 
        default=5,
 
79
        default=10,
80
80
        help='Timeout in secs for GRUB'
81
81
    ),
82
82
    cfg.IntOpt(
140
140
        help='Allow to skip MD containers (fake raid leftovers) while '
141
141
             'cleaning the rest of MDs',
142
142
    ),
 
143
    cfg.IntOpt(
 
144
        'partition_udev_settle_attempts',
 
145
        default=10,
 
146
        help='How many times udev settle will be called after partitioning'
 
147
    ),
 
148
    cfg.ListOpt(
 
149
        'multipath_lvm_filter',
 
150
        default=['r|/dev/mapper/.*-part.*|',
 
151
                 'r|/dev/dm-.*|',
 
152
                 'r|/dev/disk/by-id/.*|'],
 
153
        help='Extra filters for lvm.conf to force lvm work with partions '
 
154
             'on multipath devices using /dev/mapper/<id>-part<n> links'
 
155
    ),
 
156
    cfg.StrOpt(
 
157
        'lvm_conf_path',
 
158
        default='/etc/lvm/lvm.conf',
 
159
        help='Path to LVM configuration file'
 
160
    )
143
161
]
144
162
 
145
163
cli_opts = [
179
197
            if not fs.keep_data and not found_images:
180
198
                fu.make_fs(fs.type, fs.options, fs.label, fs.device)
181
199
 
 
200
    @staticmethod
 
201
    def _make_partitions(parteds, wait_for_udev_settle=False):
 
202
        for parted in parteds:
 
203
            pu.make_label(parted.name, parted.label)
 
204
            for prt in parted.partitions:
 
205
                pu.make_partition(prt.device, prt.begin, prt.end, prt.type)
 
206
                if wait_for_udev_settle:
 
207
                    utils.wait_for_udev_settle(
 
208
                        attempts=CONF.partition_udev_settle_attempts)
 
209
                for flag in prt.flags:
 
210
                    pu.set_partition_flag(prt.device, prt.count, flag)
 
211
                if prt.guid:
 
212
                    pu.set_gpt_type(prt.device, prt.count, prt.guid)
 
213
                # If any partition to be created doesn't exist it's an error.
 
214
                # Probably it's again 'device or resource busy' issue.
 
215
                if not os.path.exists(prt.name):
 
216
                    raise errors.PartitionNotFoundError(
 
217
                        'Partition %s not found after creation' % prt.name)
 
218
 
182
219
    def do_partitioning(self):
183
220
        LOG.debug('--- Partitioning disks (do_partitioning) ---')
184
221
 
196
233
        lu.vgremove_all()
197
234
        lu.pvremove_all()
198
235
 
199
 
        LOG.debug("Enabling udev's rules blacklisting")
200
 
        utils.blacklist_udev_rules(udev_rules_dir=CONF.udev_rules_dir,
201
 
                                   udev_rules_lib_dir=CONF.udev_rules_lib_dir,
202
 
                                   udev_rename_substr=CONF.udev_rename_substr,
203
 
                                   udev_empty_rule=CONF.udev_empty_rule)
204
 
 
205
236
        for parted in self.driver.partition_scheme.parteds:
206
237
            for prt in parted.partitions:
207
238
                # We wipe out the beginning of every new partition
220
251
                              'seek=%s' % max(prt.end - 3, 0), 'count=5',
221
252
                              'of=%s' % prt.device, check_exit_code=[0, 1])
222
253
 
 
254
        parteds = []
 
255
        parteds_with_rules = []
223
256
        for parted in self.driver.partition_scheme.parteds:
224
 
            pu.make_label(parted.name, parted.label)
225
 
            for prt in parted.partitions:
226
 
                pu.make_partition(prt.device, prt.begin, prt.end, prt.type)
227
 
                for flag in prt.flags:
228
 
                    pu.set_partition_flag(prt.device, prt.count, flag)
229
 
                if prt.guid:
230
 
                    pu.set_gpt_type(prt.device, prt.count, prt.guid)
231
 
                # If any partition to be created doesn't exist it's an error.
232
 
                # Probably it's again 'device or resource busy' issue.
233
 
                if not os.path.exists(prt.name):
234
 
                    raise errors.PartitionNotFoundError(
235
 
                        'Partition %s not found after creation' % prt.name)
236
 
 
237
 
        LOG.debug("Disabling udev's rules blacklisting")
 
257
            if hw.is_multipath_device(parted.name):
 
258
                parteds_with_rules.append(parted)
 
259
            else:
 
260
                parteds.append(parted)
 
261
 
 
262
        utils.blacklist_udev_rules(udev_rules_dir=CONF.udev_rules_dir,
 
263
                                   udev_rules_lib_dir=CONF.udev_rules_lib_dir,
 
264
                                   udev_rename_substr=CONF.udev_rename_substr,
 
265
                                   udev_empty_rule=CONF.udev_empty_rule)
 
266
 
 
267
        self._make_partitions(parteds)
 
268
 
238
269
        utils.unblacklist_udev_rules(
239
270
            udev_rules_dir=CONF.udev_rules_dir,
240
271
            udev_rename_substr=CONF.udev_rename_substr)
241
272
 
 
273
        self._make_partitions(parteds_with_rules, wait_for_udev_settle=True)
 
274
 
242
275
        # If one creates partitions with the same boundaries as last time,
243
276
        # there might be md and lvm metadata on those partitions. To prevent
244
277
        # failing of creating md and lvm devices we need to make sure
658
691
        mount2uuid = {}
659
692
        for fs in self.driver.partition_scheme.fss:
660
693
            mount2uuid[fs.mount] = utils.execute(
661
 
                'blkid', '-o', 'value', '-s', 'UUID', fs.device,
 
694
                'blkid', '-c', '/dev/null', '-o', 'value',
 
695
                '-s', 'UUID', fs.device,
662
696
                check_exit_code=[0])[0].strip()
663
697
 
664
698
        if '/' not in mount2uuid:
677
711
        install_devices = [d.name for d in self.driver.partition_scheme.parteds
678
712
                           if d.install_bootloader]
679
713
 
680
 
        grub.append_kernel_params('root=UUID=%s ' % mount2uuid['/'])
 
714
#       Zigo: This failed in Debian... :/
 
715
#        grub.append_kernel_params('root=UUID=%s ' % mount2uuid['/'])
681
716
 
682
717
        kernel = grub.kernel_name or gu.guess_kernel(chroot=chroot,
683
718
                                                     regexp=grub.kernel_regexp)
851
886
            bu.dump_runtime_uuid(bs_scheme.uuid,
852
887
                                 os.path.join(chroot,
853
888
                                              'etc/nailgun-agent/config.yaml'))
 
889
            bu.append_lvm_devices_filter(chroot, CONF.multipath_lvm_filter,
 
890
                                         CONF.lvm_conf_path)
854
891
            bu.do_post_inst(chroot,
855
892
                            allow_unsigned_file=CONF.allow_unsigned_file,
856
893
                            force_ipv4_file=CONF.force_ipv4_file)