~ubuntu-branches/ubuntu/raring/nova/raring-proposed

« back to all changes in this revision

Viewing changes to nova/virt/hyperv/vmutils.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Adam Gandelman, Chuck Short
  • Date: 2012-11-23 09:04:58 UTC
  • mfrom: (1.1.66)
  • Revision ID: package-import@ubuntu.com-20121123090458-91565o7aev1i1h71
Tags: 2013.1~g1-0ubuntu1
[ Adam Gandelman ]
* debian/control: Ensure novaclient is upgraded with nova,
  require python-keystoneclient >= 1:2.9.0. (LP: #1073289)
* debian/patches/{ubuntu/*, rbd-security.patch}: Dropped, applied
  upstream.
* debian/control: Add python-testtools to Build-Depends.

[ Chuck Short ]
* New upstream version.
* Refreshed debian/patches/avoid_setuptools_git_dependency.patch.
* debian/rules: FTBFS if missing binaries.
* debian/nova-scheudler.install: Add missing rabbit-queues and
  nova-rpc-zmq-receiver.
* Remove nova-volume since it doesnt exist anymore, transition to cinder-*.
* debian/rules: install apport hook in the right place.
* debian/patches/ubuntu-show-tests.patch: Display test failures.
* debian/control: Add depends on genisoimage
* debian/control: Suggest guestmount.
* debian/control: Suggest websockify. (LP: #1076442)
* debian/nova.conf: Disable nova-volume service.
* debian/control: Depend on xen-system-* rather than the hypervisor.
* debian/control, debian/mans/nova-conductor.8, debian/nova-conductor.init,
  debian/nova-conductor.install, debian/nova-conductor.logrotate
  debian/nova-conductor.manpages, debian/nova-conductor.postrm
  debian/nova-conductor.upstart.in: Add nova-conductor service.
* debian/control: Add python-fixtures as a build deps.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
import uuid
27
27
 
28
28
from nova import exception
29
 
from nova import flags
 
29
from nova.openstack.common import cfg
30
30
from nova.openstack.common import log as logging
31
31
from nova.virt.hyperv import constants
32
32
from nova.virt import images
35
35
if sys.platform == 'win32':
36
36
    import wmi
37
37
 
38
 
FLAGS = flags.FLAGS
 
38
CONF = cfg.CONF
39
39
LOG = logging.getLogger(__name__)
40
40
 
41
41
 
55
55
        else:
56
56
            return vms[0].ElementName
57
57
 
58
 
    #TODO(alexpilotti): use the reactor to poll instead of sleep
59
58
    def check_job_status(self, jobpath):
60
59
        """Poll WMI job state for completion"""
61
60
        job_wmi_path = jobpath.replace('\\', '/')
65
64
            time.sleep(0.1)
66
65
            job = wmi.WMI(moniker=job_wmi_path)
67
66
        if job.JobState != constants.WMI_JOB_STATE_COMPLETED:
68
 
            LOG.debug(_("WMI job failed: %(ErrorSummaryDescription)s - "
69
 
                "%(ErrorDescription)s - %(ErrorCode)s") % job)
 
67
            job_state = job.JobState
 
68
            if job.path().Class == "Msvm_ConcreteJob":
 
69
                err_sum_desc = job.ErrorSummaryDescription
 
70
                err_desc = job.ErrorDescription
 
71
                err_code = job.ErrorCode
 
72
                LOG.debug(_("WMI job failed with status %(job_state)d. "
 
73
                    "Error details: %(err_sum_desc)s - %(err_desc)s - "
 
74
                    "Error code: %(err_code)d") % locals())
 
75
            else:
 
76
                (error, ret_val) = job.GetError()
 
77
                if not ret_val and error:
 
78
                    LOG.debug(_("WMI job failed with status %(job_state)d. "
 
79
                        "Error details: %(error)s") % locals())
 
80
                else:
 
81
                    LOG.debug(_("WMI job failed with status %(job_state)d. "
 
82
                        "No error description available") % locals())
70
83
            return False
71
84
        desc = job.Description
72
85
        elap = job.ElapsedTime
73
 
        LOG.debug(_("WMI job succeeded: %(desc)s, Elapsed=%(elap)s ")
 
86
        LOG.debug(_("WMI job succeeded: %(desc)s, Elapsed=%(elap)s")
74
87
                % locals())
75
88
        return True
76
89
 
 
90
    def get_instance_path(self, instance_name):
 
91
        instance_path = os.path.join(CONF.instances_path, instance_name)
 
92
        if not os.path.exists(instance_path):
 
93
                LOG.debug(_('Creating folder %s '), instance_path)
 
94
                os.makedirs(instance_path)
 
95
        return instance_path
 
96
 
77
97
    def get_vhd_path(self, instance_name):
78
 
        base_vhd_folder = os.path.join(FLAGS.instances_path, instance_name)
79
 
        if not os.path.exists(base_vhd_folder):
80
 
                LOG.debug(_('Creating folder %s '), base_vhd_folder)
81
 
                os.makedirs(base_vhd_folder)
82
 
        return os.path.join(base_vhd_folder, instance_name + ".vhd")
 
98
        instance_path = self.get_instance_path(instance_name)
 
99
        return os.path.join(instance_path, instance_name + ".vhd")
83
100
 
84
101
    def get_base_vhd_path(self, image_name):
85
 
        base_dir = os.path.join(FLAGS.instances_path, '_base')
 
102
        base_dir = os.path.join(CONF.instances_path, '_base')
86
103
        if not os.path.exists(base_dir):
87
104
            os.makedirs(base_dir)
88
105
        return os.path.join(base_dir, image_name + ".vhd")
89
106
 
90
107
    def make_export_path(self, instance_name):
91
 
        export_folder = os.path.join(FLAGS.instances_path, "export",
 
108
        export_folder = os.path.join(CONF.instances_path, "export",
92
109
                instance_name)
93
110
        if os.path.isdir(export_folder):
94
111
            LOG.debug(_('Removing existing folder %s '), export_folder)