def test_no_admin_pass(self): # This is here to avoid masking errors, it shouldn't be used normally self.useFixture(fixtures.MonkeyPatch("nova.virt.xenapi.vm_utils.destroy_vdi", _fake_noop)) # Mocks instance = {} self.mox.StubOutWithMock(vm_utils, "safe_find_sr") vm_utils.safe_find_sr("session").AndReturn("sr_ref") self.mox.StubOutWithMock(vm_utils, "create_vdi") vm_utils.create_vdi("session", "sr_ref", instance, "config-2", "configdrive", 64 * 1024 * 1024).AndReturn( "vdi_ref" ) self.mox.StubOutWithMock(vm_utils, "vdi_attached_here") vm_utils.vdi_attached_here("session", "vdi_ref", read_only=False).AndReturn(contextified("mounted_dev")) class FakeInstanceMetadata(object): def __init__(self, instance, content=None, extra_md=None): pass def metadata_for_config_drive(self): return [] self.useFixture(fixtures.MonkeyPatch("nova.api.metadata.base.InstanceMetadata", FakeInstanceMetadata)) self.mox.StubOutWithMock(utils, "execute") utils.execute( "genisoimage", "-o", mox.IgnoreArg(), "-ldots", "-allow-lowercase", "-allow-multidot", "-l", "-publisher", mox.IgnoreArg(), "-quiet", "-J", "-r", "-V", "config-2", mox.IgnoreArg(), attempts=1, run_as_root=False, ).AndReturn(None) utils.execute("dd", mox.IgnoreArg(), mox.IgnoreArg(), run_as_root=True).AndReturn(None) self.mox.StubOutWithMock(vm_utils, "create_vbd") vm_utils.create_vbd("session", "vm_ref", "vdi_ref", mox.IgnoreArg(), bootable=False, read_only=True).AndReturn( None ) self.mox.ReplayAll() # And the actual call we're testing vm_utils.generate_configdrive("session", instance, "vm_ref", "userdevice")
def test_no_admin_pass(self): # This is here to avoid masking errors, it shouldn't be used normally self.useFixture(fixtures.MonkeyPatch( 'nova.virt.xenapi.vm_utils.destroy_vdi', _fake_noop)) # Mocks instance = {} self.mox.StubOutWithMock(vm_utils, 'safe_find_sr') vm_utils.safe_find_sr('session').AndReturn('sr_ref') self.mox.StubOutWithMock(vm_utils, 'create_vdi') vm_utils.create_vdi('session', 'sr_ref', instance, 'config-2', 'configdrive', 64 * 1024 * 1024).AndReturn('vdi_ref') self.mox.StubOutWithMock(vm_utils, 'vdi_attached_here') vm_utils.vdi_attached_here( 'session', 'vdi_ref', read_only=False).AndReturn( contextified('mounted_dev')) class FakeInstanceMetadata(object): def __init__(self, instance, content=None, extra_md=None): pass def metadata_for_config_drive(self): return [] self.useFixture(fixtures.MonkeyPatch( 'nova.api.metadata.base.InstanceMetadata', FakeInstanceMetadata)) self.mox.StubOutWithMock(utils, 'execute') utils.execute('genisoimage', '-o', mox.IgnoreArg(), '-ldots', '-allow-lowercase', '-allow-multidot', '-l', '-publisher', mox.IgnoreArg(), '-quiet', '-J', '-r', '-V', 'config-2', mox.IgnoreArg(), attempts=1, run_as_root=False).AndReturn(None) utils.execute('dd', mox.IgnoreArg(), mox.IgnoreArg(), run_as_root=True).AndReturn(None) self.mox.StubOutWithMock(vm_utils, 'create_vbd') vm_utils.create_vbd('session', 'vm_ref', 'vdi_ref', mox.IgnoreArg(), bootable=False, read_only=True).AndReturn(None) self.mox.ReplayAll() # And the actual call we're testing vm_utils.generate_configdrive('session', instance, 'vm_ref', 'userdevice')