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 @@ -86,6 +86,7 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
@Override
public boolean start() {
_executor.scheduleWithFixedDelay(new BucketUsageTask(), 60L, 3600L, TimeUnit.SECONDS);
_executor.scheduleWithFixedDelay(new BucketUsageCustomTask(), 60L, 60L, TimeUnit.SECONDS);
return true;
}

Expand Down Expand Up @@ -294,6 +295,35 @@ public void getBucketUsage() {
}
}

private class BucketUsageCustomTask extends ManagedContextRunnable {
public BucketUsageCustomTask() {
}

@Override
protected void runInContext() {
try {
List<ObjectStoreVO> objectStores = _objectStoreDao.listObjectStores();
for(ObjectStoreVO objectStoreVO: objectStores) {
List<BucketVO> buckets = _bucketDao.listByObjectStoreId(objectStoreVO.getId());
if (buckets.isEmpty()) {
continue;
}
ObjectStoreEntity objectStore = (ObjectStoreEntity)_dataStoreMgr.getDataStore(objectStoreVO.getId(), DataStoreRole.Object);
Map<String, Long> bucketSizes = objectStore.getAllBucketsUsage();
for(BucketVO bucket : buckets) {
Long size = bucketSizes.get(bucket.getName());
if( size != null){
bucket.setSize(size);
_bucketDao.update(bucket.getId(), bucket);
}
}
}
} catch (Exception e) {
logger.error("Error while fetching bucket usage", e);
}
}
}

private class BucketUsageTask extends ManagedContextRunnable {
public BucketUsageTask() {
}
Expand Down
1 change: 1 addition & 0 deletions ui/public/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -3890,6 +3890,7 @@
"router.health.checks": "Health check",
"side.by.side": "Side by Side",
"state.completed": "Completed",
"state.created": "Created",
"state.declined": "Declined",
"state.disabled": "Disabled",
"state.enabled": "Enabled",
Expand Down
1 change: 1 addition & 0 deletions ui/public/locales/ko_KR.json
Original file line number Diff line number Diff line change
Expand Up @@ -3889,6 +3889,7 @@
"router.health.checks": "\ud5ec\uc2a4 \uccb4\ud06c",
"side.by.side": "\ub098\ub780\ud788",
"state.completed": "\uc644\ub8cc",
"state.created": "\uc0dd\uc131\ub428",
"state.declined": "\uac70\uc808",
"state.disabled": "\ube44\ud65c\uc131\ud654",
"state.enabled": "\ud65c\uc131\ud654",
Expand Down
32 changes: 32 additions & 0 deletions ui/src/components/view/InfoCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,21 @@
<status class="status" :text="resource.resourcestate" displayText/>
</div>
</div>
<div class="resource-detail-item" v-if="$route.meta.name === 'buckets' && bucketQuotaKB > 0">
<div class="resource-detail-item__label">사용량</div>
<div class="resource-detail-item__details">
<hdd-outlined />
{{ toSize(Number(resource.size || 0)) }} / {{ resource.quota }} GiB
</div>
<div>
<a-progress
class="progress-bar"
size="small"
status="active"
:percent="bucketUsagePercent"
:format="(percent, successPercent) => parseFloat(percent).toFixed(2) + '% 사용됨'" />
</div>
</div>
<div class="resource-detail-item" v-if="['cluster', 'zone'].includes($route.meta.name) && resource.resourcedetails">
<div class="resource-detail-item__label">{{ $t('label.haenable') }}</div>
<div class="resource-detail-item__details">
Expand Down Expand Up @@ -1094,6 +1109,23 @@ export default {
}
return null
},
bucketQuotaKB () {
const quotaGiB = Number(this.resource?.quota)
if (!Number.isFinite(quotaGiB) || quotaGiB <= 0) {
return 0
}
return quotaGiB * 1024 * 1024
},
bucketUsagePercent () {
if (this.bucketQuotaKB <= 0) {
return 0
}
const sizeKB = Number(this.resource?.size || 0)
if (!Number.isFinite(sizeKB) || sizeKB <= 0) {
return 0
}
return Math.min(Number(((sizeKB / this.bucketQuotaKB) * 100).toFixed(2)), 100)
},
routeFromResourceType () {
return this.$getRouteFromResourceType(this.resource.resourcetype)
},
Expand Down
5 changes: 4 additions & 1 deletion ui/src/components/widgets/Status.vue
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ export default {
case 'nodata':
state = this.$t('state.nodata')
break
case 'created':
state = this.$t('state.created')
break
}
return state.charAt(0).toUpperCase() + state.slice(1)
}
Expand All @@ -190,6 +193,7 @@ export default {
getBadgeStatus (state) {
var status = 'default'
switch (state.toLowerCase()) {
case 'created':
case 'active':
case 'backedup':
case 'completed':
Expand Down Expand Up @@ -250,7 +254,6 @@ export default {
status = 'warning'
}
break
case 'created':
case 'maintenance':
case 'pending':
case 'unsecure':
Expand Down
52 changes: 46 additions & 6 deletions ui/src/views/compute/DeployVnfAppliance.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2260,20 +2260,30 @@ export default {
Object.entries(createVnfAppData).filter(([key, value]) => value !== undefined))

var idx = 0
const userdataDetailNames = new Set()
if (this.templateUserDataValues) {
for (const [key, value] of Object.entries(this.templateUserDataValues)) {
if (!this.isSafeUserDataDetailValue(value)) {
continue
}
createVnfAppData['userdatadetails[' + idx + '].' + `${key}`] = value
userdataDetailNames.add(key)
idx++
}
}
if (isUserdataAllowed && this.userDataValues) {
for (const [key, value] of Object.entries(this.userDataValues)) {
if (!this.isSafeUserDataDetailValue(value)) {
continue
}
createVnfAppData['userdatadetails[' + idx + '].' + `${key}`] = value
userdataDetailNames.add(key)
idx++
}
}
idx = this.addVnfDetailsToDeployParams(createVnfAppData, idx, userdataDetailNames)

const httpMethod = createVnfAppData.userdata ? 'POST' : 'GET'
const httpMethod = this.hasSensitiveDeployData(createVnfAppData) ? 'POST' : 'GET'
const args = httpMethod === 'POST' ? {} : createVnfAppData
const data = httpMethod === 'POST' ? createVnfAppData : {}

Expand All @@ -2289,6 +2299,7 @@ export default {
const name = vm.displayname || vm.name || vm.id
const username = vm.vnfdetails?.username || null
const password = vm.vnfdetails?.password || null
const effectivePassword = vm.password || password
const sshUsername = vm.vnfdetails?.ssh_user || null
const sshPassword = vm.vnfdetails?.ssh_password || null
const webUsername = vm.vnfdetails?.web_user || null
Expand All @@ -2297,8 +2308,8 @@ export default {
if (username) {
credentials.push(this.$t('label.username') + ' : ' + username)
}
if (password) {
credentials.push(this.$t('label.password.default') + ' : ' + password)
if (effectivePassword) {
credentials.push(this.$t('label.password.default') + ' : ' + effectivePassword)
}
if (webUsername) {
credentials.push('Web ' + this.$t('label.username') + ' : ' + webUsername)
Expand All @@ -2312,9 +2323,6 @@ export default {
if (sshPassword) {
credentials.push('SSH ' + this.$t('label.password.default') + ' : ' + sshPassword)
}
if (vm.password) {
credentials.push('New password : ' + vm.password)
}
if (credentials.length > 0) {
credentials.push(this.$t('message.vnf.credentials.change'))
} else {
Expand Down Expand Up @@ -2815,6 +2823,38 @@ export default {
handleNicsNetworkSelection (nicToNetworkSelection) {
this.nicToNetworkSelection = nicToNetworkSelection
},
getVnfDetailsForDeploy () {
const vnfDetails = this.template?.vnfdetails || {}
return Object.fromEntries(Object.entries(vnfDetails).filter(([key, value]) => {
return key && value !== undefined && value !== null && value !== ''
}))
},
addVnfDetailsToDeployParams (params, idx, existingDetailNames) {
const vnfDetails = this.getVnfDetailsForDeploy()
const vmPassword = vnfDetails.password || vnfDetails.ssh_password
if (!params.password && vmPassword) {
params.password = vmPassword
}
for (const [key, value] of Object.entries(vnfDetails)) {
if (existingDetailNames.has(key) || !this.isSafeUserDataDetailValue(value)) {
continue
}
params['userdatadetails[' + idx + '].' + key] = value
existingDetailNames.add(key)
idx++
}
return idx
},
isSafeUserDataDetailValue (value) {
// Backend serializes userdata details as Map.toString() and later splits on comma.
return !String(value).includes(',')
},
hasSensitiveDeployData (params) {
if (params.userdata || params.password) {
return true
}
return Object.keys(params).some(key => key.startsWith('userdatadetails[') && key.toLowerCase().includes('password'))
},
getSelectedNetworksWithExistingConfig (networks) {
for (var i in this.networks) {
var n = this.networks[i]
Expand Down
Loading