Exemple #1
0
func (s *BlockDevicesSuite) TestSetMachineBlockDevicesUpdates(c *gc.C) {
	sda := state.BlockDeviceInfo{DeviceName: "sda"}
	sdb := state.BlockDeviceInfo{DeviceName: "sdb"}
	err := s.machine.SetMachineBlockDevices(sda, sdb)
	c.Assert(err, jc.ErrorIsNil)
	s.assertBlockDevices(c, s.machine.MachineTag(), []state.BlockDeviceInfo{sda, sdb})

	sdb.Label = "root"
	err = s.machine.SetMachineBlockDevices(sdb)
	c.Assert(err, jc.ErrorIsNil)
	s.assertBlockDevices(c, s.machine.MachineTag(), []state.BlockDeviceInfo{sdb})

	// If a device is attached, unattached, then attached again,
	// then it gets a new name.
	sdb.Label = "" // Label should be reset.
	sdb.FilesystemType = "ext4"
	err = s.machine.SetMachineBlockDevices(sda, sdb)
	c.Assert(err, jc.ErrorIsNil)
	s.assertBlockDevices(c, s.machine.MachineTag(), []state.BlockDeviceInfo{
		sda,
		sdb,
	})
}