Skip to content

Commit 34040e8

Browse files
committed
fix enable-disable
Signed-off-by: Abhishek Kumar <[email protected]>
1 parent 0beeeea commit 34040e8

File tree

5 files changed

+43
-3
lines changed

5 files changed

+43
-3
lines changed

framework/extensions/src/main/java/org/apache/cloudstack/framework/extensions/manager/ExtensionsManagerImpl.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ public Extension updateExtension(UpdateExtensionCmd cmd) {
506506
}
507507
}
508508
final boolean updateNeededFinal = updateNeeded;
509-
return Transaction.execute((TransactionCallbackWithException<ExtensionVO, CloudRuntimeException>) status -> {
509+
ExtensionVO result = Transaction.execute((TransactionCallbackWithException<ExtensionVO, CloudRuntimeException>) status -> {
510510
if (updateNeededFinal && !extensionDao.update(id, extensionVO)) {
511511
throw new CloudRuntimeException(String.format("Failed to updated the extension: %s",
512512
extensionVO.getName()));
@@ -523,6 +523,10 @@ public Extension updateExtension(UpdateExtensionCmd cmd) {
523523
}
524524
return extensionVO;
525525
});
526+
if (StringUtils.isNotBlank(stateStr) && Extension.State.Enabled.equals(result.getState())) {
527+
prepareExtensionEntryPointAcrossServers(result);
528+
}
529+
return result;
526530
}
527531

528532
@Override

plugins/hypervisors/external/src/main/java/org/apache/cloudstack/agent/manager/ExternalServerPlanner.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import javax.inject.Inject;
2525
import javax.naming.ConfigurationException;
2626

27+
import org.apache.cloudstack.extension.Extension;
2728
import org.apache.cloudstack.extension.ExtensionResourceMap;
2829
import org.apache.cloudstack.framework.extensions.dao.ExtensionDao;
2930
import org.apache.cloudstack.framework.extensions.dao.ExtensionResourceMapDao;
@@ -76,10 +77,15 @@ public DeployDestination plan(VirtualMachineProfile vmProfile, DeploymentPlan pl
7677
Long extensionId = template.getExtensionId();
7778
final ExtensionVO extensionVO = extensionDao.findById(extensionId);
7879
if (extensionVO == null) {
79-
logger.error("Extension associated with {} cannot be found during deployment external instance {}",
80+
logger.error("Extension associated with {} cannot be found during deployment of external instance {}",
8081
template, vmProfile.getInstanceName());
8182
return null;
8283
}
84+
if (!Extension.State.Enabled.equals(extensionVO.getState())) {
85+
logger.error("{} is not in enabled state therefore planning can not be done for deployment of external instance {}",
86+
extensionVO, vmProfile.getInstanceName());
87+
return null;
88+
}
8389

8490
String haVmTag = (String)vmProfile.getParameter(VirtualMachineProfile.Param.HaTag);
8591

ui/public/locales/en.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,7 @@
823823
"label.directdownload": "Direct download",
824824
"label.direction": "Direction",
825825
"label.disable.autoscale.vmgroup": "Disable AutoScaling Group",
826+
"label.disable.extension": "Disable Extension",
826827
"label.disable.host": "Disable host",
827828
"label.disable.network.offering": "Disable Network offering",
828829
"label.disable.provider": "Disable provider",
@@ -935,6 +936,7 @@
935936
"label.elastic": "Elastic",
936937
"label.email": "Email",
937938
"label.enable.autoscale.vmgroup": "Enable AutoScaling Group",
939+
"label.enable.extension": "Enable Extension",
938940
"label.enable.host": "Enable Host",
939941
"label.enable.network.offering": "Enable Network offering",
940942
"label.enable.oauth": "Enable OAuth Login",
@@ -2972,13 +2974,15 @@
29722974
"message.confirm.delete.traffic.type": "Please confirm that you would like to delete traffic type.",
29732975
"message.confirm.destroy.router": "All services provided by this virtual router will be interrupted. Please confirm that you want to stop this router. Please confirm that you would like to destroy this router.",
29742976
"message.confirm.disable.autoscale.vmgroup": "Please confirm that you want to disable this autoscaling group.",
2977+
"message.confirm.disable.extension": "Please confirm that you want to disable this extension.",
29752978
"message.confirm.disable.host": "Please confirm that you want to disable the host.",
29762979
"message.confirm.disable.network.offering": "Are you sure you want to disable this Network offering?",
29772980
"message.confirm.disable.provider": "Please confirm that you would like to disable this provider.",
29782981
"message.confirm.disable.storage": "Please confirm that you want to disable the storage pool.",
29792982
"message.confirm.disable.vpc.offering": "Are you sure you want to disable this VPC offering?",
29802983
"message.confirm.disable.webhook": "Please confirm that you want to disable this webhook.",
29812984
"message.confirm.enable.autoscale.vmgroup": "Please confirm that you want to enable this autoscaling group.",
2985+
"message.confirm.enable.extension": "Please confirm that you want to enable this extension.",
29822986
"message.confirm.enable.host": "Please confirm that you want to enable the host.",
29832987
"message.confirm.enable.network.offering": "Are you sure you want to enable this Network offering?",
29842988
"message.confirm.enable.provider": "Please confirm that you would like to enable this provider.",

ui/src/config/section/extension.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,30 @@ export default {
8484
popup: true,
8585
component: shallowRef(defineAsyncComponent(() => import('@/views/extension/RegisterExtension.vue')))
8686
},
87+
{
88+
api: 'updateExtension',
89+
icon: 'play-circle-outlined',
90+
label: 'label.enable.extension',
91+
message: 'message.confirm.enable.extension',
92+
dataView: true,
93+
groupAction: true,
94+
popup: true,
95+
defaultArgs: { state: 'Enabled' },
96+
groupMap: (selection) => { return selection.map(x => { return { id: x } }) },
97+
show: (record) => { return ['Disabled'].includes(record.state) }
98+
},
99+
{
100+
api: 'updateExtension',
101+
icon: 'pause-circle-outlined',
102+
label: 'label.disable.extension',
103+
message: 'message.confirm.disable.extension',
104+
dataView: true,
105+
groupAction: true,
106+
popup: true,
107+
defaultArgs: { state: 'Disabled' },
108+
groupMap: (selection) => { return selection.map(x => { return { id: x } }) },
109+
show: (record) => { return ['Enabled'].includes(record.state) }
110+
},
87111
{
88112
api: 'deleteExtension',
89113
icon: 'delete-outlined',

ui/src/views/extension/AddCustomAction.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,9 @@ export default {
161161
methods: {
162162
initForm () {
163163
this.formRef = ref()
164-
this.form = reactive({})
164+
this.form = reactive({
165+
enabled: true
166+
})
165167
this.rules = reactive({
166168
extensionid: [{ required: true, message: `${this.$t('message.error.select')}` }],
167169
name: [{ required: true, message: `${this.$t('message.error.name')}` }]

0 commit comments

Comments
 (0)