~ubuntu-branches/ubuntu/vivid/ceilometer/vivid

« back to all changes in this revision

Viewing changes to ceilometer/compute/virt/libvirt/inspector.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2014-03-06 14:44:28 UTC
  • mto: (28.1.1 utopic-proposed) (1.2.1)
  • mto: This revision was merged to the branch mainline in revision 19.
  • Revision ID: package-import@ubuntu.com-20140306144428-rvphsh4igwyulzf0
Tags: upstream-2014.1~b3
ImportĀ upstreamĀ versionĀ 2014.1~b3

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
    cfg.StrOpt('libvirt_type',
33
33
               default='kvm',
34
34
               help='Libvirt domain type (valid options are: '
35
 
                    'kvm, lxc, qemu, uml, xen)'),
 
35
                    'kvm, lxc, qemu, uml, xen).'),
36
36
    cfg.StrOpt('libvirt_uri',
37
37
               default='',
38
38
               help='Override the default libvirt URI '
39
 
                    '(which is dependent on libvirt_type)'),
 
39
                    '(which is dependent on libvirt_type).'),
40
40
]
41
41
 
42
42
CONF = cfg.CONF
107
107
 
108
108
    def inspect_cpus(self, instance_name):
109
109
        domain = self._lookup_by_name(instance_name)
110
 
        (_, _, _, num_cpu, cpu_time) = domain.info()
 
110
        (__, __, __, num_cpu, cpu_time) = domain.info()
111
111
        return virt_inspector.CPUStats(number=num_cpu, time=cpu_time)
112
112
 
113
113
    def inspect_vnics(self, instance_name):
114
114
        domain = self._lookup_by_name(instance_name)
 
115
        (state, __, __, __, __) = domain.info()
 
116
        if state == libvirt.VIR_DOMAIN_SHUTOFF:
 
117
            LOG.warn(_('Failed to inspect vnics of %(instance_name)s, '
 
118
                       'domain is in state of SHUTOFF'),
 
119
                     {'instance_name': instance_name})
 
120
            return
115
121
        tree = etree.fromstring(domain.XMLDesc(0))
116
122
        for iface in tree.findall('devices/interface'):
117
123
            target = iface.find('target')
132
138
                          for p in iface.findall('filterref/parameter'))
133
139
            interface = virt_inspector.Interface(name=name, mac=mac_address,
134
140
                                                 fref=fref, parameters=params)
135
 
            rx_bytes, rx_packets, _, _, \
136
 
                tx_bytes, tx_packets, _, _ = domain.interfaceStats(name)
 
141
            rx_bytes, rx_packets, __, __, \
 
142
                tx_bytes, tx_packets, __, __ = domain.interfaceStats(name)
137
143
            stats = virt_inspector.InterfaceStats(rx_bytes=rx_bytes,
138
144
                                                  rx_packets=rx_packets,
139
145
                                                  tx_bytes=tx_bytes,
142
148
 
143
149
    def inspect_disks(self, instance_name):
144
150
        domain = self._lookup_by_name(instance_name)
 
151
        (state, __, __, __, __) = domain.info()
 
152
        if state == libvirt.VIR_DOMAIN_SHUTOFF:
 
153
            LOG.warn(_('Failed to inspect disks of %(instance_name)s, '
 
154
                       'domain is in state of SHUTOFF'),
 
155
                     {'instance_name': instance_name})
 
156
            return
145
157
        tree = etree.fromstring(domain.XMLDesc(0))
146
158
        for device in filter(
147
159
                bool,