Skip to content

Add special Icon to Shared FileSystem Instances #10857

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: 4.20
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,18 @@ private String getStorageVmConfig(final String fileSystem, final String hypervis
return fsVmConfig;
}

private String getStorageVmName(String fileShareName) {
private String getStorageVmPrefix(String fileShareName) {
String prefix = String.format("%s-%s", SharedFSVmNamePrefix, fileShareName);
String suffix = Long.toHexString(System.currentTimeMillis());

if (!NetUtils.verifyDomainNameLabel(prefix, true)) {
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();
if (nameLength > 63) {
int prefixLength = prefix.length() - (nameLength - 63);
Expand Down Expand Up @@ -236,8 +241,18 @@ public Pair<Long, Long> deploySharedFS(SharedFS sharedFS, Long networkId, Long d
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);

List<VolumeVO> volumes = volumeDao.findByInstanceAndType(vm.getId(), Volume.Type.DATADISK);
return new Pair<>(volumes.get(0).getId(), vm.getId());
List<VolumeVO> volumes = volumeDao.findByInstance(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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,14 @@ public void testDeploySharedFS() throws ResourceUnavailableException, Insufficie
anyMap(), isNull(), isNull(), isNull(), isNull(),
anyBoolean(), anyString(), isNull())).thenReturn(vm);

VolumeVO volume = mock(VolumeVO.class);
when(volume.getId()).thenReturn(s_volumeId);
when(volumeDao.findByInstanceAndType(s_vmId, Volume.Type.DATADISK)).thenReturn(List.of(volume));
VolumeVO rootVol = mock(VolumeVO.class);
when(rootVol.getVolumeType()).thenReturn(Volume.Type.ROOT);
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);
Assert.assertEquals(Optional.ofNullable(result.first()), Optional.ofNullable(s_volumeId));
Expand Down
7 changes: 6 additions & 1 deletion ui/src/components/view/InfoCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
<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"/>
</span>
<span v-else-if="resource.vmtype === 'sharedfsvm'">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

User can still set a custom resource icon for it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, user can set a custom icon.

<file-text-outlined style="font-size: 36px;" />
</span>
<span v-else>
<os-logo v-if="resource.ostypeid || resource.ostypename" :osId="resource.ostypeid" :osName="resource.ostypename" size="3x" @update-osname="setResourceOsType"/>
<render-icon v-else-if="typeof $route.meta.icon ==='string'" style="font-size: 36px" :icon="$route.meta.icon" />
Expand Down Expand Up @@ -870,6 +873,7 @@ import UploadResourceIcon from '@/components/view/UploadResourceIcon'
import eventBus from '@/config/eventBus'
import ResourceIcon from '@/components/view/ResourceIcon'
import ResourceLabel from '@/components/widgets/ResourceLabel'
import { FileTextOutlined } from '@ant-design/icons-vue'

export default {
name: 'InfoCard',
Expand All @@ -881,7 +885,8 @@ export default {
TooltipButton,
UploadResourceIcon,
ResourceIcon,
ResourceLabel
ResourceLabel,
FileTextOutlined
},
props: {
resource: {
Expand Down
7 changes: 6 additions & 1 deletion ui/src/components/view/ListView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
<span v-if="record.icon && record.icon.base64image">
<resource-icon :image="record.icon.base64image" size="2x"/>
</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" />
</span>
<span style="min-width: 120px" >
Expand Down Expand Up @@ -591,6 +594,7 @@ import { createPathBasedOnVmType } from '@/utils/plugins'
import { validateLinks } from '@/utils/links'
import cronstrue from 'cronstrue/i18n'
import moment from 'moment-timezone'
import { FileTextOutlined } from '@ant-design/icons-vue'

export default {
name: 'ListView',
Expand All @@ -601,7 +605,8 @@ export default {
CopyLabel,
TooltipButton,
ResourceIcon,
ResourceLabel
ResourceLabel,
FileTextOutlined
},
props: {
columns: {
Expand Down
Loading