(diskSetting boshsettings.DiskSettings, mountPoint string)
| 1456 | } |
| 1457 | |
| 1458 | func (p linux) MountPersistentDisk(diskSetting boshsettings.DiskSettings, mountPoint string) error { |
| 1459 | p.logger.Debug(logTag, "Mounting persistent disk %+v at %s", diskSetting, mountPoint) |
| 1460 | |
| 1461 | devicePath, _, err := p.devicePathResolver.GetRealDevicePath(diskSetting) |
| 1462 | if err != nil { |
| 1463 | return bosherr.WrapError(err, "Getting real device path") |
| 1464 | } |
| 1465 | |
| 1466 | alreadyMountedPartPath, hasMountedDevice, err := p.IsMountPoint(mountPoint) |
| 1467 | if err != nil { |
| 1468 | return bosherr.WrapError(err, "Checking mount point already has a device monted onto") |
| 1469 | } |
| 1470 | p.logger.Info(logTag, "devicePath = %s, alreadyMountedPartPath = %s, hasMountedDevice = %t", devicePath, alreadyMountedPartPath, hasMountedDevice) |
| 1471 | |
| 1472 | firstPartitionPath := p.partitionPath(devicePath, 1) |
| 1473 | if hasMountedDevice { |
| 1474 | if alreadyMountedPartPath == firstPartitionPath { |
| 1475 | p.logger.Info(logTag, "device: %s is already mounted on %s, skipping mounting", alreadyMountedPartPath, mountPoint) |
| 1476 | return nil |
| 1477 | } |
| 1478 | |
| 1479 | mountPoint = p.dirProvider.StoreMigrationDir() |
| 1480 | } |
| 1481 | |
| 1482 | err = p.fs.MkdirAll(mountPoint, persistentDiskPermissions) |
| 1483 | if err != nil { |
| 1484 | return bosherr.WrapErrorf(err, "Creating directory %s", mountPoint) |
| 1485 | } |
| 1486 | |
| 1487 | var partitionPathToMount string |
| 1488 | if p.options.UsePreformattedPersistentDisk { |
| 1489 | partitionPathToMount = devicePath |
| 1490 | } else { |
| 1491 | partitionPathToMount = firstPartitionPath |
| 1492 | } |
| 1493 | |
| 1494 | err = p.diskManager.GetMounter().Mount(partitionPathToMount, mountPoint, diskSetting.MountOptions...) |
| 1495 | if err != nil { |
| 1496 | return bosherr.WrapError(err, "Mounting partition") |
| 1497 | } |
| 1498 | |
| 1499 | managedSettingsPath := filepath.Join(p.dirProvider.BoshDir(), "managed_disk_settings.json") |
| 1500 | |
| 1501 | err = p.fs.WriteFileString(managedSettingsPath, diskSetting.ID) |
| 1502 | if err != nil { |
| 1503 | return bosherr.WrapError(err, "Writing managed_disk_settings.json") |
| 1504 | } |
| 1505 | |
| 1506 | return nil |
| 1507 | } |
| 1508 | |
| 1509 | func (p linux) UnmountPersistentDisk(diskSettings boshsettings.DiskSettings) (bool, error) { |
| 1510 | p.logger.Debug(logTag, "Unmounting persistent disk %+v", diskSettings) |
nothing calls this directly
no test coverage detected