components/openstack/nova/files/solariszones/driver.py
changeset 5194 e5ea1fd7704a
parent 5193 3120ba36a435
child 5195 694672bf3c17
equal deleted inserted replaced
5193:3120ba36a435 5194:e5ea1fd7704a
  1311                     shutil.copytree(sc_profile, os.path.join(sc_dir,
  1311                     shutil.copytree(sc_profile, os.path.join(sc_dir,
  1312                                     'sysconfig'))
  1312                                     'sysconfig'))
  1313 
  1313 
  1314             self._verify_sysconfig(sc_dir, instance, admin_password)
  1314             self._verify_sysconfig(sc_dir, instance, admin_password)
  1315 
  1315 
       
  1316         LOG.debug(_("Creating zone configuration for '%s' (%s)")
       
  1317                   % (name, instance['display_name']))
  1316         zonemanager = self.rad_connection.get_object(zonemgr.ZoneManager())
  1318         zonemanager = self.rad_connection.get_object(zonemgr.ZoneManager())
  1317         try:
  1319         try:
  1318             zonemanager.create(name, None, template)
  1320             zonemanager.create(name, None, template)
  1319             self._set_global_properties(name, extra_specs, brand)
  1321             self._set_global_properties(name, extra_specs, brand)
  1320             if connection_info:
  1322             if connection_info is not None:
  1321                 self._set_boot_device(name, connection_info, brand)
  1323                 self._set_boot_device(name, connection_info, brand)
  1322             self._set_num_cpu(name, instance['vcpus'], brand)
  1324             self._set_num_cpu(name, instance['vcpus'], brand)
  1323             self._set_memory_cap(name, instance['memory_mb'], brand)
  1325             self._set_memory_cap(name, instance['memory_mb'], brand)
  1324             self._set_network(context, name, instance, network_info, brand,
  1326             self._set_network(context, name, instance, network_info, brand,
  1325                               sc_dir)
  1327                               sc_dir)
  1609         volume = self._create_boot_volume(context, instance)
  1611         volume = self._create_boot_volume(context, instance)
  1610         volume_id = volume['id']
  1612         volume_id = volume['id']
  1611         # c1d0 is the standard dev for for default boot device.
  1613         # c1d0 is the standard dev for for default boot device.
  1612         # Irrelevant value for ZFS, but Cinder gets stroppy without it.
  1614         # Irrelevant value for ZFS, but Cinder gets stroppy without it.
  1613         mountpoint = "c1d0"
  1615         mountpoint = "c1d0"
       
  1616         name = instance['name']
  1614         try:
  1617         try:
  1615             connection_info = self._connect_boot_volume(volume, mountpoint,
  1618             connection_info = self._connect_boot_volume(volume, mountpoint,
  1616                                                         context, instance)
  1619                                                         context, instance)
  1617         except exception.InvalidVolume as badvol:
  1620         except exception.InvalidVolume as badvol:
  1618             # This Cinder volume is not usable for ZOSS so discard it.
  1621             # This Cinder volume is not usable for ZOSS so discard it.
  1623             self._volume_api.delete(context, volume_id)
  1626             self._volume_api.delete(context, volume_id)
  1624             connection_info = None
  1627             connection_info = None
  1625         except Exception as reason:
  1628         except Exception as reason:
  1626             # Something really bad happened. Don't pass Go.
  1629             # Something really bad happened. Don't pass Go.
  1627             LOG.error(_("Unable to attach root zpool volume '%s' to instance "
  1630             LOG.error(_("Unable to attach root zpool volume '%s' to instance "
  1628                         "%s: %s") % (volume['id'], instance['name'], reason))
  1631                         "%s: %s") % (volume['id'], name, reason))
  1629             self._volume_api.delete(context, volume_id)
  1632             self._volume_api.delete(context, volume_id)
  1630             # remove the sc_profile temp directory
  1633             # remove the sc_profile temp directory
  1631             shutil.rmtree(sc_dir)
  1634             shutil.rmtree(sc_dir)
  1632             raise
  1635             raise
  1633 
  1636 
  1634         name = instance['name']
  1637         configured = False
  1635 
  1638         installed = False
  1636         LOG.debug(_("creating zone configuration for '%s' (%s)") %
  1639         try:
  1637                   (name, instance['display_name']))
  1640             self._create_config(context, instance, network_info,
  1638 
  1641                                 connection_info, sc_dir, admin_password)
  1639         self._create_config(context, instance, network_info, connection_info,
  1642             configured = True
  1640                             sc_dir, admin_password)
       
  1641         try:
       
  1642             self._install(instance, image, sc_dir)
  1643             self._install(instance, image, sc_dir)
       
  1644             installed = True
  1643             self._power_on(instance)
  1645             self._power_on(instance)
  1644         except Exception as reason:
  1646         except Exception as reason:
  1645             LOG.error(_("Unable to spawn instance '%s' via zonemgr(3RAD): %s")
  1647             LOG.error(_("Unable to spawn instance '%s' via zonemgr(3RAD): %s")
  1646                       % (name, reason))
  1648                       % (name, reason))
  1647             self._uninstall(instance)
  1649             if installed:
  1648             if connection_info:
  1650                 self._uninstall(instance)
       
  1651             if configured:
       
  1652                 self._delete_config(instance)
       
  1653             if connection_info is not None:
  1649                 self._volume_api.detach(context, volume_id)
  1654                 self._volume_api.detach(context, volume_id)
  1650                 self._volume_api.delete(context, volume_id)
  1655                 self._volume_api.delete(context, volume_id)
  1651             self._delete_config(instance)
       
  1652             raise
  1656             raise
  1653         finally:
  1657         finally:
  1654             # remove the sc_profile temp directory
  1658             # remove the sc_profile temp directory
  1655             shutil.rmtree(sc_dir)
  1659             shutil.rmtree(sc_dir)
  1656 
  1660 
  1657         if connection_info:
  1661         if connection_info is not None:
  1658             bdm = objects.BlockDeviceMapping(
  1662             bdm = objects.BlockDeviceMapping(
  1659                     source_type='volume',
  1663                     source_type='volume',
  1660                     destination_type='volume',
  1664                     destination_type='volume',
  1661                     instance_uuid=instance.uuid,
  1665                     instance_uuid=instance.uuid,
  1662                     volume_id=volume_id,
  1666                     volume_id=volume_id,
  3488                           instance=instance)
  3492                           instance=instance)
  3489 
  3493 
  3490         if not self._fc_wwpns:
  3494         if not self._fc_wwpns:
  3491             self._fc_wwpns = self._get_fc_wwpns()
  3495             self._fc_wwpns = self._get_fc_wwpns()
  3492             if not self._fc_wwpns or len(self._fc_wwpns) == 0:
  3496             if not self._fc_wwpns or len(self._fc_wwpns) == 0:
  3493                 LOG.debug(_('Could not determine Fibre channel '
  3497                 LOG.debug(_('Could not determine Fibre Channel '
  3494                           'World Wide Port Names'),
  3498                           'World Wide Port Names'),
  3495                           instance=instance)
  3499                           instance=instance)
  3496 
  3500 
  3497         if self._fc_wwnns and self._fc_wwpns:
  3501         if self._fc_wwnns and self._fc_wwpns:
  3498             connector["wwnns"] = self._fc_wwnns
  3502             connector["wwnns"] = self._fc_wwnns
  3578         """Delete any lingering instance files for an instance.
  3582         """Delete any lingering instance files for an instance.
  3579 
  3583 
  3580         :param instance: nova.objects.instance.Instance
  3584         :param instance: nova.objects.instance.Instance
  3581         :returns: True if the instance was deleted from disk, False otherwise.
  3585         :returns: True if the instance was deleted from disk, False otherwise.
  3582         """
  3586         """
  3583         LOG.debug(_("Cleaning up for instance %s"), instance['name'])
       
  3584         # Delete the zone configuration for the instance using destroy, because
  3587         # Delete the zone configuration for the instance using destroy, because
  3585         # it will simply take care of the work, and we don't need to duplicate
  3588         # it will simply take care of the work, and we don't need to duplicate
  3586         # the code here.
  3589         # the code here.
       
  3590         LOG.debug(_("Cleaning up for instance %s"), instance['name'])
  3587         try:
  3591         try:
  3588             self.destroy(None, instance, None)
  3592             self.destroy(None, instance, None)
  3589         except Exception:
  3593         except Exception:
  3590             return False
  3594             return False
  3591         return True
  3595         return True