components/openstack/nova/files/solariszones/driver.py
branchs11u3-sru
changeset 5412 8566c7ab4a73
parent 5411 27ae522d32d7
child 5413 bca6b9853ab7
equal deleted inserted replaced
5411:27ae522d32d7 5412:8566c7ab4a73
  1158             elif os.path.isdir(sc_profile):
  1158             elif os.path.isdir(sc_profile):
  1159                 shutil.copytree(sc_profile, os.path.join(sc_dir, 'sysconfig'))
  1159                 shutil.copytree(sc_profile, os.path.join(sc_dir, 'sysconfig'))
  1160 
  1160 
  1161         self._verify_sysconfig(sc_dir, instance)
  1161         self._verify_sysconfig(sc_dir, instance)
  1162 
  1162 
       
  1163         LOG.debug(_("Creating zone configuration for '%s' (%s)")
       
  1164                   % (name, instance['display_name']))
  1163         zonemanager = self.rad_connection.get_object(zonemgr.ZoneManager())
  1165         zonemanager = self.rad_connection.get_object(zonemgr.ZoneManager())
  1164         try:
  1166         try:
  1165             zonemanager.create(name, None, template)
  1167             zonemanager.create(name, None, template)
  1166             self._set_global_properties(name, extra_specs, brand)
  1168             self._set_global_properties(name, extra_specs, brand)
  1167             if connection_info:
  1169             if connection_info is not None:
  1168                 self._set_boot_device(name, connection_info, brand)
  1170                 self._set_boot_device(name, connection_info, brand)
  1169             self._set_num_cpu(name, instance['vcpus'], brand)
  1171             self._set_num_cpu(name, instance['vcpus'], brand)
  1170             self._set_memory_cap(name, instance['memory_mb'], brand)
  1172             self._set_memory_cap(name, instance['memory_mb'], brand)
  1171             self._set_network(context, name, instance, network_info, brand,
  1173             self._set_network(context, name, instance, network_info, brand,
  1172                               sc_dir)
  1174                               sc_dir)
  1457         volume = self._create_boot_volume(context, instance)
  1459         volume = self._create_boot_volume(context, instance)
  1458         volume_id = volume['id']
  1460         volume_id = volume['id']
  1459         # c1d0 is the standard dev for for default boot device.
  1461         # c1d0 is the standard dev for for default boot device.
  1460         # Irrelevant value for ZFS, but Cinder gets stroppy without it.
  1462         # Irrelevant value for ZFS, but Cinder gets stroppy without it.
  1461         mountpoint = "c1d0"
  1463         mountpoint = "c1d0"
       
  1464         name = instance['name']
  1462         try:
  1465         try:
  1463             connection_info = self._connect_boot_volume(volume, mountpoint,
  1466             connection_info = self._connect_boot_volume(volume, mountpoint,
  1464                                                         context, instance)
  1467                                                         context, instance)
  1465         except exception.InvalidVolume as badvol:
  1468         except exception.InvalidVolume as badvol:
  1466             # This Cinder volume is not usable for ZOSS so discard it.
  1469             # This Cinder volume is not usable for ZOSS so discard it.
  1471             self._volume_api.delete(context, volume_id)
  1474             self._volume_api.delete(context, volume_id)
  1472             connection_info = None
  1475             connection_info = None
  1473         except Exception as reason:
  1476         except Exception as reason:
  1474             # Something really bad happened. Don't pass Go.
  1477             # Something really bad happened. Don't pass Go.
  1475             LOG.error(_("Unable to attach root zpool volume '%s' to instance "
  1478             LOG.error(_("Unable to attach root zpool volume '%s' to instance "
  1476                         "%s: %s") % (volume['id'], instance['name'], reason))
  1479                         "%s: %s") % (volume['id'], name, reason))
  1477             self._volume_api.delete(context, volume_id)
  1480             self._volume_api.delete(context, volume_id)
  1478             # remove the sc_profile temp directory
  1481             # remove the sc_profile temp directory
  1479             shutil.rmtree(sc_dir)
  1482             shutil.rmtree(sc_dir)
  1480             raise
  1483             raise
  1481 
  1484 
  1482         name = instance['name']
  1485         configured = False
  1483 
  1486         installed = False
  1484         LOG.debug(_("creating zone configuration for '%s' (%s)") %
  1487         try:
  1485                   (name, instance['display_name']))
  1488             self._create_config(context, instance, network_info,
  1486         self._create_config(context, instance, network_info,
  1489                                 connection_info, sc_dir)
  1487                             connection_info, sc_dir)
  1490             configured = True
  1488         try:
       
  1489             self._install(instance, image, sc_dir)
  1491             self._install(instance, image, sc_dir)
       
  1492             installed = True
  1490             self._power_on(instance)
  1493             self._power_on(instance)
  1491         except Exception as reason:
  1494         except Exception as reason:
  1492             LOG.error(_("Unable to spawn instance '%s' via zonemgr(3RAD): %s")
  1495             LOG.error(_("Unable to spawn instance '%s' via zonemgr(3RAD): %s")
  1493                       % (name, reason))
  1496                       % (name, reason))
  1494             self._uninstall(instance)
  1497             if installed:
  1495             if connection_info:
  1498                 self._uninstall(instance)
       
  1499             if configured:
       
  1500                  self._delete_config(instance)
       
  1501             if connection_info is not None:
  1496                 self._volume_api.detach(context, volume_id)
  1502                 self._volume_api.detach(context, volume_id)
  1497                 self._volume_api.delete(context, volume_id)
  1503                 self._volume_api.delete(context, volume_id)
  1498             self._delete_config(instance)
       
  1499             raise
  1504             raise
  1500         finally:
  1505         finally:
  1501             # remove the sc_profile temp directory
  1506             # remove the sc_profile temp directory
  1502             shutil.rmtree(sc_dir)
  1507             shutil.rmtree(sc_dir)
  1503 
  1508 
  1504         if connection_info:
  1509         if connection_info is not None:
  1505             bdm = objects.BlockDeviceMapping(
  1510             bdm = objects.BlockDeviceMapping(
  1506                     source_type='volume', destination_type='volume',
  1511                     source_type='volume', destination_type='volume',
  1507                     instance_uuid=instance.uuid,
  1512                     instance_uuid=instance.uuid,
  1508                     volume_id=volume_id,
  1513                     volume_id=volume_id,
  1509                     connection_info=jsonutils.dumps(connection_info),
  1514                     connection_info=jsonutils.dumps(connection_info),
  2873                           instance=instance)
  2878                           instance=instance)
  2874 
  2879 
  2875         if not self._fc_wwpns:
  2880         if not self._fc_wwpns:
  2876             self._fc_wwpns = self._get_fc_wwpns()
  2881             self._fc_wwpns = self._get_fc_wwpns()
  2877             if not self._fc_wwpns or len(self._fc_wwpns) == 0:
  2882             if not self._fc_wwpns or len(self._fc_wwpns) == 0:
  2878                 LOG.debug(_('Could not determine Fibre channel '
  2883                 LOG.debug(_('Could not determine Fibre Channel '
  2879                           'World Wide Port Names'),
  2884                           'World Wide Port Names'),
  2880                           instance=instance)
  2885                           instance=instance)
  2881 
  2886 
  2882         if self._fc_wwnns and self._fc_wwpns:
  2887         if self._fc_wwnns and self._fc_wwpns:
  2883             connector["wwnns"] = self._fc_wwnns
  2888             connector["wwnns"] = self._fc_wwnns