mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Add special Icon to Shared FileSystem Instances (#10857)
* Use special icon for sharedfs instance and prefix for sharedfs volumes * Give custom icon precedence over shared fs icon * Fix sharedfsvm icon size * Fix UT failure in StorageVmSharedFSLifeCycleTest
This commit is contained in:
parent
d5f6b7cd1d
commit
d72a05aa5a
@ -140,13 +140,18 @@ public class StorageVmSharedFSLifeCycle implements SharedFSLifeCycle {
|
|||||||
return fsVmConfig;
|
return fsVmConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getStorageVmName(String fileShareName) {
|
private String getStorageVmPrefix(String fileShareName) {
|
||||||
String prefix = String.format("%s-%s", SharedFSVmNamePrefix, fileShareName);
|
String prefix = String.format("%s-%s", SharedFSVmNamePrefix, fileShareName);
|
||||||
String suffix = Long.toHexString(System.currentTimeMillis());
|
|
||||||
|
|
||||||
if (!NetUtils.verifyDomainNameLabel(prefix, true)) {
|
if (!NetUtils.verifyDomainNameLabel(prefix, true)) {
|
||||||
prefix = prefix.replaceAll("[^a-zA-Z0-9-]", "");
|
prefix = prefix.replaceAll("[^a-zA-Z0-9-]", "");
|
||||||
}
|
}
|
||||||
|
return prefix;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getStorageVmName(String fileShareName) {
|
||||||
|
String prefix = getStorageVmPrefix(fileShareName);
|
||||||
|
String suffix = Long.toHexString(System.currentTimeMillis());
|
||||||
|
|
||||||
int nameLength = prefix.length() + suffix.length() + SharedFSVmNamePrefix.length();
|
int nameLength = prefix.length() + suffix.length() + SharedFSVmNamePrefix.length();
|
||||||
if (nameLength > 63) {
|
if (nameLength > 63) {
|
||||||
int prefixLength = prefix.length() - (nameLength - 63);
|
int prefixLength = prefix.length() - (nameLength - 63);
|
||||||
@ -236,8 +241,18 @@ public class StorageVmSharedFSLifeCycle implements SharedFSLifeCycle {
|
|||||||
Account owner = accountMgr.getActiveAccountById(sharedFS.getAccountId());
|
Account owner = accountMgr.getActiveAccountById(sharedFS.getAccountId());
|
||||||
UserVm vm = deploySharedFSVM(sharedFS.getDataCenterId(), owner, List.of(networkId), sharedFS.getName(), sharedFS.getServiceOfferingId(), diskOfferingId, sharedFS.getFsType(), size, minIops, maxIops);
|
UserVm vm = deploySharedFSVM(sharedFS.getDataCenterId(), owner, List.of(networkId), sharedFS.getName(), sharedFS.getServiceOfferingId(), diskOfferingId, sharedFS.getFsType(), size, minIops, maxIops);
|
||||||
|
|
||||||
List<VolumeVO> volumes = volumeDao.findByInstanceAndType(vm.getId(), Volume.Type.DATADISK);
|
List<VolumeVO> volumes = volumeDao.findByInstance(vm.getId());
|
||||||
return new Pair<>(volumes.get(0).getId(), vm.getId());
|
VolumeVO dataVol = null;
|
||||||
|
for (VolumeVO vol : volumes) {
|
||||||
|
String volumeName = vol.getName();
|
||||||
|
String updatedVolumeName = SharedFSVmNamePrefix + "-" + volumeName;
|
||||||
|
vol.setName(updatedVolumeName);
|
||||||
|
volumeDao.update(vol.getId(), vol);
|
||||||
|
if (vol.getVolumeType() == Volume.Type.DATADISK) {
|
||||||
|
dataVol = vol;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new Pair<>(dataVol.getId(), vm.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -260,9 +260,14 @@ public class StorageVmSharedFSLifeCycleTest {
|
|||||||
anyMap(), isNull(), isNull(), isNull(), isNull(),
|
anyMap(), isNull(), isNull(), isNull(), isNull(),
|
||||||
anyBoolean(), anyString(), isNull())).thenReturn(vm);
|
anyBoolean(), anyString(), isNull())).thenReturn(vm);
|
||||||
|
|
||||||
VolumeVO volume = mock(VolumeVO.class);
|
VolumeVO rootVol = mock(VolumeVO.class);
|
||||||
when(volume.getId()).thenReturn(s_volumeId);
|
when(rootVol.getVolumeType()).thenReturn(Volume.Type.ROOT);
|
||||||
when(volumeDao.findByInstanceAndType(s_vmId, Volume.Type.DATADISK)).thenReturn(List.of(volume));
|
when(rootVol.getName()).thenReturn("ROOT-1");
|
||||||
|
VolumeVO dataVol = mock(VolumeVO.class);
|
||||||
|
when(dataVol.getId()).thenReturn(s_volumeId);
|
||||||
|
when(dataVol.getName()).thenReturn("DATA-1");
|
||||||
|
when(dataVol.getVolumeType()).thenReturn(Volume.Type.DATADISK);
|
||||||
|
when(volumeDao.findByInstance(s_vmId)).thenReturn(List.of(rootVol, dataVol));
|
||||||
|
|
||||||
Pair<Long, Long> result = lifeCycle.deploySharedFS(sharedFS, s_networkId, s_diskOfferingId, s_size, s_minIops, s_maxIops);
|
Pair<Long, Long> result = lifeCycle.deploySharedFS(sharedFS, s_networkId, s_diskOfferingId, s_size, s_minIops, s_maxIops);
|
||||||
Assert.assertEquals(Optional.ofNullable(result.first()), Optional.ofNullable(s_volumeId));
|
Assert.assertEquals(Optional.ofNullable(result.first()), Optional.ofNullable(s_volumeId));
|
||||||
|
|||||||
@ -34,6 +34,9 @@
|
|||||||
<span v-if="(resource.icon && resource.icon.base64image || images.template || images.iso || resourceIcon) && !['router', 'systemvm', 'volume'].includes($route.path.split('/')[1])">
|
<span v-if="(resource.icon && resource.icon.base64image || images.template || images.iso || resourceIcon) && !['router', 'systemvm', 'volume'].includes($route.path.split('/')[1])">
|
||||||
<resource-icon :image="getImage(resource.icon && resource.icon.base64image || images.template || images.iso || resourceIcon)" size="4x" style="margin-right: 5px"/>
|
<resource-icon :image="getImage(resource.icon && resource.icon.base64image || images.template || images.iso || resourceIcon)" size="4x" style="margin-right: 5px"/>
|
||||||
</span>
|
</span>
|
||||||
|
<span v-else-if="resource.vmtype === 'sharedfsvm'">
|
||||||
|
<file-text-outlined style="font-size: 36px;" />
|
||||||
|
</span>
|
||||||
<span v-else>
|
<span v-else>
|
||||||
<os-logo v-if="resource.ostypeid || resource.ostypename || ['guestoscategory'].includes($route.path.split('/')[1])" :osId="resource.ostypeid" :osName="resource.ostypename || resource.name" size="3x" @update-osname="setResourceOsType"/>
|
<os-logo v-if="resource.ostypeid || resource.ostypename || ['guestoscategory'].includes($route.path.split('/')[1])" :osId="resource.ostypeid" :osName="resource.ostypename || resource.name" size="3x" @update-osname="setResourceOsType"/>
|
||||||
<render-icon v-else-if="typeof $route.meta.icon ==='string'" style="font-size: 36px" :icon="$route.meta.icon" />
|
<render-icon v-else-if="typeof $route.meta.icon ==='string'" style="font-size: 36px" :icon="$route.meta.icon" />
|
||||||
@ -876,6 +879,7 @@ import UploadResourceIcon from '@/components/view/UploadResourceIcon'
|
|||||||
import eventBus from '@/config/eventBus'
|
import eventBus from '@/config/eventBus'
|
||||||
import ResourceIcon from '@/components/view/ResourceIcon'
|
import ResourceIcon from '@/components/view/ResourceIcon'
|
||||||
import ResourceLabel from '@/components/widgets/ResourceLabel'
|
import ResourceLabel from '@/components/widgets/ResourceLabel'
|
||||||
|
import { FileTextOutlined } from '@ant-design/icons-vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'InfoCard',
|
name: 'InfoCard',
|
||||||
@ -887,7 +891,8 @@ export default {
|
|||||||
TooltipButton,
|
TooltipButton,
|
||||||
UploadResourceIcon,
|
UploadResourceIcon,
|
||||||
ResourceIcon,
|
ResourceIcon,
|
||||||
ResourceLabel
|
ResourceLabel,
|
||||||
|
FileTextOutlined
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
resource: {
|
resource: {
|
||||||
|
|||||||
@ -44,6 +44,9 @@
|
|||||||
<span v-if="record.icon && record.icon.base64image">
|
<span v-if="record.icon && record.icon.base64image">
|
||||||
<resource-icon :image="record.icon.base64image" size="2x"/>
|
<resource-icon :image="record.icon.base64image" size="2x"/>
|
||||||
</span>
|
</span>
|
||||||
|
<span v-else-if="record.vmtype === 'sharedfsvm'">
|
||||||
|
<file-text-outlined style="font-size: 18px;" />
|
||||||
|
</span>
|
||||||
<os-logo v-else :osId="record.ostypeid" :osName="record.osdisplayname" size="xl" />
|
<os-logo v-else :osId="record.ostypeid" :osName="record.osdisplayname" size="xl" />
|
||||||
</span>
|
</span>
|
||||||
<span style="min-width: 120px" >
|
<span style="min-width: 120px" >
|
||||||
@ -591,6 +594,7 @@ import { createPathBasedOnVmType } from '@/utils/plugins'
|
|||||||
import { validateLinks } from '@/utils/links'
|
import { validateLinks } from '@/utils/links'
|
||||||
import cronstrue from 'cronstrue/i18n'
|
import cronstrue from 'cronstrue/i18n'
|
||||||
import moment from 'moment-timezone'
|
import moment from 'moment-timezone'
|
||||||
|
import { FileTextOutlined } from '@ant-design/icons-vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'ListView',
|
name: 'ListView',
|
||||||
@ -601,7 +605,8 @@ export default {
|
|||||||
CopyLabel,
|
CopyLabel,
|
||||||
TooltipButton,
|
TooltipButton,
|
||||||
ResourceIcon,
|
ResourceIcon,
|
||||||
ResourceLabel
|
ResourceLabel,
|
||||||
|
FileTextOutlined
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
columns: {
|
columns: {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user