Skip to content
Merged
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 @@ -573,6 +573,7 @@ public class ApiConstants {
public static final String AGGREGATE_NAME = "aggregatename";
public static final String POOL_NAME = "poolname";
public static final String VOLUME_NAME = "volumename";
public static final String VOLUME_STATE = "volumestate";
public static final String SNAPSHOT_POLICY = "snapshotpolicy";
public static final String SNAPSHOT_RESERVATION = "snapshotreservation";
public static final String IP_NETWORK_LIST = "iptonetworklist";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ public class SnapshotResponse extends BaseResponseWithTagInformation implements
@Param(description = "type of the disk volume")
private String volumeType;

@SerializedName(ApiConstants.VOLUME_STATE)
@Param(description = "state of the disk volume")
private String volumeState;

@SerializedName(ApiConstants.CREATED)
@Param(description = " the date the snapshot was created")
private Date created;
Expand Down Expand Up @@ -199,6 +203,10 @@ public void setVolumeType(String volumeType) {
this.volumeType = volumeType;
}

public void setVolumeState(String volumeState) {
this.volumeState = volumeState;
}

public void setCreated(Date created) {
this.created = created;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ SELECT
`volumes`.`uuid` AS `volume_uuid`,
`volumes`.`name` AS `volume_name`,
`volumes`.`volume_type` AS `volume_type`,
`volumes`.`state` AS `volume_state`,
`volumes`.`size` AS `volume_size`,
`data_center`.`id` AS `data_center_id`,
`data_center`.`uuid` AS `data_center_uuid`,
Expand Down
1 change: 1 addition & 0 deletions server/src/main/java/com/cloud/api/ApiResponseHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,7 @@ public SnapshotResponse createSnapshotResponse(Snapshot snapshot) {
snapshotResponse.setVolumeId(volume.getUuid());
snapshotResponse.setVolumeName(volume.getName());
snapshotResponse.setVolumeType(volume.getVolumeType().name());
snapshotResponse.setVolumeState(volume.getState().name());
snapshotResponse.setVirtualSize(volume.getSize());
DataCenter zone = ApiDBUtils.findZoneById(volume.getDataCenterId());
if (zone != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ public SnapshotResponse newSnapshotResponse(ResponseObject.ResponseView view, bo
snapshotResponse.setVolumeId(snapshot.getVolumeUuid());
snapshotResponse.setVolumeName(snapshot.getVolumeName());
snapshotResponse.setVolumeType(snapshot.getVolumeType().name());
snapshotResponse.setVolumeState(snapshot.getVolumeState().name());
snapshotResponse.setVirtualSize(snapshot.getVolumeSize());
VolumeVO volume = ApiDBUtils.findVolumeById(snapshot.getVolumeId());
if (volume != null && volume.getVolumeType() == Type.ROOT && volume.getInstanceId() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ public class SnapshotJoinVO extends BaseViewWithTagInformationVO implements Cont
@Enumerated(EnumType.STRING)
Volume.Type volumeType = Volume.Type.UNKNOWN;

@Column(name = "volume_state")
@Enumerated(EnumType.STRING)
Volume.State volumeState;

@Column(name = "volume_size")
Long volumeSize;

Expand Down Expand Up @@ -297,6 +301,10 @@ public Volume.Type getVolumeType() {
return volumeType;
}

public Volume.State getVolumeState() {
return volumeState;
}

public Long getVolumeSize() {
return volumeSize;
}
Expand Down
8 changes: 6 additions & 2 deletions ui/src/components/view/InfoCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,8 @@
<div class="resource-detail-item__label">{{ $t('label.volume') }}</div>
<div class="resource-detail-item__details">
<hdd-outlined />
<router-link :to="{ path: '/volume/' + resource.volumeid }">{{ resource.volumename || resource.volume || resource.volumeid }} </router-link>
<router-link v-if="validLinks.volume" :to="{ path: '/volume/' + resource.volumeid }">{{ resource.volumename || resource.volume || resource.volumeid }} </router-link>
<span v-else>{{ resource.volumename || resource.volume || resource.volumeid }}</span>
</div>
</div>
<div class="resource-detail-item" v-if="resource.associatednetworkid">
Expand Down Expand Up @@ -794,6 +795,7 @@
<script>
import { api } from '@/api'
import { createPathBasedOnVmType } from '@/utils/plugins'
import { validateLinks } from '@/utils/links'
import Console from '@/components/widgets/Console'
import OsLogo from '@/components/widgets/OsLogo'
import Status from '@/components/widgets/Status'
Expand Down Expand Up @@ -859,7 +861,8 @@ export default {
vpc: '',
network: ''
},
newResource: {}
newResource: {},
validLinks: {}
}
},
watch: {
Expand All @@ -876,6 +879,7 @@ export default {
this.newResource = newData
this.showKeys = false
this.setData()
this.validLinks = validateLinks(this.$router, this.isStatic, this.resource)

if ('apikey' in this.resource) {
this.getUserKeys()
Expand Down
16 changes: 15 additions & 1 deletion ui/src/components/view/ListView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@
<router-link :to="{ path: getVmRouteUsingType(record) + record.virtualmachineid }">{{ text }}</router-link>
</template>
<template v-if="column.key === 'volumename'">
<router-link :to="{ path: '/volume/' + record.volumeid }">{{ text }}</router-link>
<router-link v-if="resourceIdToValidLinksMap[record.id]?.volume" :to="{ path: '/volume/' + record.volumeid }">{{ text }}</router-link>
<span v-else>{{ text }}</span>
</template>
<template v-if="column.key === 'size'">
<span v-if="text && $route.path === '/kubernetes'">
Expand Down Expand Up @@ -488,6 +489,7 @@ import TooltipButton from '@/components/widgets/TooltipButton'
import ResourceIcon from '@/components/view/ResourceIcon'
import ResourceLabel from '@/components/widgets/ResourceLabel'
import { createPathBasedOnVmType } from '@/utils/plugins'
import { validateLinks } from '@/utils/links'
import cronstrue from 'cronstrue/i18n'
import moment from 'moment-timezone'

Expand Down Expand Up @@ -576,6 +578,18 @@ export default {
notification: 'storageallocatedthreshold',
disable: 'storageallocateddisablethreshold'
}
},
resourceIdToValidLinksMap: {}
}
},
watch: {
items: {
deep: true,
handler (newData, oldData) {
if (newData === oldData) return
this.items.forEach(record => {
this.resourceIdToValidLinksMap[record.id] = validateLinks(this.$router, false, record)
})
}
}
},
Expand Down
36 changes: 36 additions & 0 deletions ui/src/utils/links.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

export function validateLinks (router, isStatic, resource) {
const validLinks = {
volume: false
}

if (isStatic) {
return validLinks
}

if (resource.volumeid && router.resolve('/volume/' + resource.volumeid).matched[0].redirect !== '/exception/404') {
if (resource.volumestate) {
validLinks.volume = resource.volumestate !== 'Expunged'
} else {
validLinks.volume = true
}
}

return validLinks
}