712 |
712 |
"""
|
713 |
713 |
inst_os = OSFromDisk(instance.os)
|
714 |
714 |
|
715 |
|
create_env = OSEnvironment(instance)
|
|
715 |
create_env = OSEnvironment(instance, inst_os)
|
716 |
716 |
if reinstall:
|
717 |
717 |
create_env['INSTANCE_REINSTALL'] = "1"
|
718 |
718 |
|
... | ... | |
744 |
744 |
"""
|
745 |
745 |
inst_os = OSFromDisk(instance.os)
|
746 |
746 |
|
747 |
|
rename_env = OSEnvironment(instance)
|
|
747 |
rename_env = OSEnvironment(instance, inst_os)
|
748 |
748 |
rename_env['OLD_INSTANCE_NAME'] = old_name
|
749 |
749 |
|
750 |
750 |
logfile = "%s/rename-%s-%s-%s-%d.log" % (constants.LOG_OS_DIR, instance.os,
|
... | ... | |
1569 |
1569 |
# push the error up
|
1570 |
1570 |
return status, api_versions
|
1571 |
1571 |
|
1572 |
|
if constants.OS_API_VERSION not in api_versions:
|
|
1572 |
if not constants.OS_API_VERSIONS.intersection(api_versions):
|
1573 |
1573 |
return False, ("API version mismatch for path '%s': found %s, want %s." %
|
1574 |
|
(os_dir, api_versions, constants.OS_API_VERSION))
|
|
1574 |
(os_dir, api_versions, constants.OS_API_VERSIONS))
|
1575 |
1575 |
|
1576 |
1576 |
# OS Scripts dictionary, we will populate it with the actual script names
|
1577 |
1577 |
os_scripts = dict.fromkeys(constants.OS_SCRIPTS)
|
... | ... | |
1628 |
1628 |
return payload
|
1629 |
1629 |
|
1630 |
1630 |
|
1631 |
|
def OSEnvironment(instance, debug=0):
|
|
1631 |
def OSEnvironment(instance, os, debug=0):
|
1632 |
1632 |
"""Calculate the environment for an os script.
|
1633 |
1633 |
|
1634 |
1634 |
@type instance: L{objects.Instance}
|
1635 |
1635 |
@param instance: target instance for the os script run
|
|
1636 |
@type os: L{objects.OS}
|
|
1637 |
@param os: operating system for which the environment is being built
|
1636 |
1638 |
@type debug: integer
|
1637 |
1639 |
@param debug: debug level (0 or 1, for OS Api 10)
|
1638 |
1640 |
@rtype: dict
|
... | ... | |
1642 |
1644 |
|
1643 |
1645 |
"""
|
1644 |
1646 |
result = {}
|
1645 |
|
result['OS_API_VERSION'] = '%d' % constants.OS_API_VERSION
|
|
1647 |
api_version = max(constants.OS_API_VERSIONS.intersection(os.api_versions))
|
|
1648 |
result['OS_API_VERSION'] = '%d' % api_version
|
1646 |
1649 |
result['INSTANCE_NAME'] = instance.name
|
1647 |
1650 |
result['INSTANCE_OS'] = instance.os
|
1648 |
1651 |
result['HYPERVISOR'] = instance.hypervisor
|
... | ... | |
1759 |
1762 |
@rtype: None
|
1760 |
1763 |
|
1761 |
1764 |
"""
|
1762 |
|
export_env = OSEnvironment(instance)
|
1763 |
|
|
1764 |
1765 |
inst_os = OSFromDisk(instance.os)
|
|
1766 |
export_env = OSEnvironment(instance, inst_os)
|
|
1767 |
|
1765 |
1768 |
export_script = inst_os.export_script
|
1766 |
1769 |
|
1767 |
1770 |
logfile = "%s/exp-%s-%s-%s.log" % (constants.LOG_OS_DIR, inst_os.name,
|
... | ... | |
1903 |
1906 |
@return: each boolean represent the success of importing the n-th disk
|
1904 |
1907 |
|
1905 |
1908 |
"""
|
1906 |
|
import_env = OSEnvironment(instance)
|
1907 |
1909 |
inst_os = OSFromDisk(instance.os)
|
|
1910 |
import_env = OSEnvironment(instance, inst_os)
|
1908 |
1911 |
import_script = inst_os.import_script
|
1909 |
1912 |
|
1910 |
1913 |
logfile = "%s/import-%s-%s-%s.log" % (constants.LOG_OS_DIR, instance.os,
|