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)
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?
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,
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=''))
546
546
LOG.info(_('instance %s: Creating image'), inst['name'])
547
547
f = open(basepath('libvirt.xml'), 'w')
548
548
f.write(libvirt_xml)
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))
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}
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 "
738
739
def get_disks(self, instance_name):
1137
def apply_instance_filter(self, instance):
1138
"""No-op. Everything is done in prepare_instance_filter"""
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))