コード例 #1
0
 def test_machines_listed_with_hdd(self):
     data = {
         'VM': {
             'm1': {
                 'name_label': 'machine1',
                 'VBDs': [
                     'vbd1',
                     'vbd2'
                 ],
                 'uuid': 'machine1-uuid'
             },
             'm2': {}
         },
         'VDI': {
             'vdi1': {}
         },
         'VBD': {
             'vbd1': {
                 'VDI': 'vdi1',
                 'uuid': 'vbd1-uuid',
                 'type': 'Disk',
                 'device': 'xvda'
             },
             'vbd2': {
                 'VDI': '',
                 'uuid': 'vbd2-uuid',
                 'type': 'CD',
                 'device': 'xvdd'
             }
         }
     }
     machine_list = services.machines(FakeXenAPIModule(data).Session())
     self.assertIn('m1', machine_list)
コード例 #2
0
 def test_machine_vbds_mapped(self):
     data = {
         'VM': {
             'm1': {
                 'name_label': 'machine1',
                 'VBDs': [
                     'vbd1',
                     'vbd2'
                 ],
                 'uuid': 'machine1-uuid'
             },
         },
         'VBD': {
             'vbd1': {
                 'VDI': 'vdi1',
                 'uuid': 'vbd1-uuid',
                 'type': 'Disk',
                 'device': 'xvda'
             },
             'vbd2': {
                 'VDI': '',
                 'uuid': 'vbd2-uuid',
                 'type': 'CD',
                 'device': 'xvdd'
             }
         },
     }
     m1 = services.machines(FakeXenAPIModule(data).Session())['m1']
     self.assertEquals(2, len(m1.vbds))
     self.assertEquals('vdi1', m1.vbds[0].vdi_ref)
コード例 #3
0
 def test_machines_listed_with_hdd(self):
     data = {
         'VM': {
             'm1': {
                 'name_label': 'machine1',
                 'VBDs': ['vbd1', 'vbd2'],
                 'uuid': 'machine1-uuid'
             },
             'm2': {}
         },
         'VDI': {
             'vdi1': {}
         },
         'VBD': {
             'vbd1': {
                 'VDI': 'vdi1',
                 'uuid': 'vbd1-uuid',
                 'type': 'Disk',
                 'device': 'xvda'
             },
             'vbd2': {
                 'VDI': '',
                 'uuid': 'vbd2-uuid',
                 'type': 'CD',
                 'device': 'xvdd'
             }
         }
     }
     machine_list = services.machines(FakeXenAPIModule(data).Session())
     self.assertIn('m1', machine_list)
コード例 #4
0
 def test_machine_vbds_mapped(self):
     data = {
         'VM': {
             'm1': {
                 'name_label': 'machine1',
                 'VBDs': ['vbd1', 'vbd2'],
                 'uuid': 'machine1-uuid'
             },
         },
         'VBD': {
             'vbd1': {
                 'VDI': 'vdi1',
                 'uuid': 'vbd1-uuid',
                 'type': 'Disk',
                 'device': 'xvda'
             },
             'vbd2': {
                 'VDI': '',
                 'uuid': 'vbd2-uuid',
                 'type': 'CD',
                 'device': 'xvdd'
             }
         },
     }
     m1 = services.machines(FakeXenAPIModule(data).Session())['m1']
     self.assertEquals(2, len(m1.vbds))
     self.assertEquals('vdi1', m1.vbds[0].vdi_ref)
コード例 #5
0
def main(args, writeline=None):
    def wl(s):
        sys.stdout.write(str(s) + '\n')

    writeline = writeline or wl
    options = parse_options(args)
    if options.failed:
        sys.stderr.write("Missing options, try %s --help\n" % args[0])
        sys.exit(1)
    if options.verbose:
        logger.setLevel(logging.DEBUG)

    session = services.get_session(options)
    for machine in services.machines(session).values():
        if machine.exportable:
            writeline("vm: %s (%s)" % (machine.label, machine.uuid))
            for vbd in machine.disk_vbds:
                vdi = services.get_vdi(session, vbd.vdi_ref)
                writeline("  disk: " + vdi.uuid)
                services.add_sr(session, vdi)
                writeline("    location: /var/run/sr-mount/%s/%s.vhd" %
                          (vdi.sr.uuid, vdi.uuid))
コード例 #6
0
ファイル: list_vhds.py プロジェクト: Alexlupa/xapi-openstack
def main(args, writeline=None):
    def wl(s):
        sys.stdout.write(str(s) + '\n')
    writeline = writeline or wl
    options = parse_options(args)
    if options.failed:
        sys.stderr.write("Missing options, try %s --help\n" % args[0])
        sys.exit(1)
    if options.verbose:
        logger.setLevel(logging.DEBUG)

    session = services.get_session(options)
    for machine in services.machines(session).values():
        if machine.exportable:
            writeline("vm: %s (%s)" % (machine.label, machine.uuid))
            for vbd in machine.disk_vbds:
                vdi = services.get_vdi(session, vbd.vdi_ref)
                writeline("  disk: " + vdi.uuid)
                services.add_sr(session, vdi)
                writeline(
                    "    location: /var/run/sr-mount/%s/%s.vhd" %
                    (vdi.sr.uuid, vdi.uuid))