~ntt-pf-lab/nova/lp703037

« back to all changes in this revision

Viewing changes to nova/virt/libvirt_conn.py

  • Committer: Hisaharu Ishii
  • Date: 2011-01-21 11:04:02 UTC
  • mfrom: (572.1.25 nova)
  • Revision ID: ishii.hisaharu@lab.ntt.co.jp-20110121110402-29ict0qj0qvdl4dm
Merged with rev597

Show diffs side-by-side

added added

removed removed

Lines of Context:
350
350
        rescue_images = {'image_id': FLAGS.rescue_image_id,
351
351
                         'kernel_id': FLAGS.rescue_kernel_id,
352
352
                         'ramdisk_id': FLAGS.rescue_ramdisk_id}
353
 
        self._create_image(instance, xml, 'rescue-', rescue_images)
 
353
        self._create_image(instance, xml, '.rescue', rescue_images)
354
354
        self._conn.createXML(xml, 0)
355
355
 
356
356
        timer = utils.LoopingCall(f=None)
532
532
        utils.execute('truncate %s -s %dG' % (target, local_gb))
533
533
        # TODO(vish): should we format disk by default?
534
534
 
535
 
    def _create_image(self, inst, libvirt_xml, prefix='', disk_images=None):
 
535
    def _create_image(self, inst, libvirt_xml, suffix='', disk_images=None):
536
536
        # syntactic nicety
537
 
        def basepath(fname='', prefix=prefix):
 
537
        def basepath(fname='', suffix=suffix):
538
538
            return os.path.join(FLAGS.instances_path,
539
539
                                inst['name'],
540
 
                                prefix + fname)
 
540
                                fname + suffix)
541
541
 
542
542
        # ensure directories exist and are writable
543
 
        utils.execute('mkdir -p %s' % basepath(prefix=''))
544
 
        utils.execute('chmod 0777 %s' % basepath(prefix=''))
 
543
        utils.execute('mkdir -p %s' % basepath(suffix=''))
 
544
        utils.execute('chmod 0777 %s' % basepath(suffix=''))
545
545
 
546
546
        LOG.info(_('instance %s: Creating image'), inst['name'])
547
547
        f = open(basepath('libvirt.xml'), 'w')
548
548
        f.write(libvirt_xml)
549
549
        f.close()
550
550
 
551
 
        # NOTE(vish): No need add the prefix to console.log
 
551
        # NOTE(vish): No need add the suffix to console.log
552
552
        os.close(os.open(basepath('console.log', ''),
553
553
                         os.O_CREAT | os.O_WRONLY, 0660))
554
554
 
577
577
 
578
578
        root_fname = disk_images['image_id']
579
579
        size = FLAGS.minimum_root_size
580
 
        if inst['instance_type'] == 'm1.tiny' or prefix == 'rescue-':
 
580
        if inst['instance_type'] == 'm1.tiny' or suffix == '.rescue':
581
581
            size = None
582
582
            root_fname += "_sm"
583
583
 
593
593
 
594
594
        if type_data['local_gb']:
595
595
            self._cache_image(fn=self._create_local,
596
 
                              target=basepath('local'),
 
596
                              target=basepath('disk.local'),
597
597
                              fname="local_%s" % type_data['local_gb'],
598
598
                              cow=FLAGS.use_cow_images,
599
599
                              local_gb=type_data['local_gb'])
733
733
                'cpu_time': cpu_time}
734
734
 
735
735
    def get_diagnostics(self, instance_name):
736
 
        raise exception.APIError("diagnostics are not supported for libvirt")
 
736
        raise exception.APIError(_("diagnostics are not supported "
 
737
                                   "for libvirt"))
737
738
 
738
739
    def get_disks(self, instance_name):
739
740
        """
1133
1134
 
1134
1135
        return
1135
1136
 
 
1137
    def apply_instance_filter(self, instance):
 
1138
        """No-op. Everything is done in prepare_instance_filter"""
 
1139
        pass
 
1140
 
1136
1141
    def refresh_security_group_rules(self, security_group_id):
1137
1142
        return self._define_filter(
1138
1143
                   self.security_group_to_nwfilter_xml(security_group_id))