Skip to content

Commit bd5c038

Browse files
Nikhil-AshokaGitHub Enterprise
authored and
GitHub Enterprise
committed
Missing USB Firmware Update Policy Info (#73)
Updated the USB Firmware Update Policy enabled/disabled Info Available only for service login Fixed Incorrect toast notifications in policy page that existed Signed-off-by: Nikhil Ashoka <[email protected]>
1 parent 2f80b0b commit bd5c038

File tree

3 files changed

+128
-35
lines changed

3 files changed

+128
-35
lines changed

src/locales/en-US.json

+6-12
Original file line numberDiff line numberDiff line change
@@ -930,23 +930,17 @@
930930
"ipmiDescription": "Allow remote management of the platform via IPMI. Tools such as ipmitool require this setting to be enabled.",
931931
"networkServices": "Network services",
932932
"rtad": "RTAD",
933-
"rtadDescription": "This option enables or disables the Remote Trusted Attestation Daemon for host firmware",
933+
"rtadDescription": "This option enables or disables the Remote Trusted Attestation Daemon for host firmware.",
934934
"ssh": "BMC shell (via SSH)",
935935
"sshDescription": "Allow access to shell sessions via SSH, through port 22 on the BMC.",
936+
"usbFirmwareUpdatePolicy": "USB Firmware Update Policy",
937+
"usbFirmwareUpdatePolicyDescription": "Enabling the USB Firmware Update Policy will enable the functionality to allow firmware updates through a USB key.",
936938
"toast": {
937-
"errorRtadDisabled": "Error disabling RTAD security setting.",
938-
"errorRtadEnabled": "Error enabling RTAD security setting.",
939-
"errorVtpmDisabled": "Error disabling VitualTPM security setting.",
940-
"errorVtpmEnabled": "Error enabling VitualTPM security setting.",
941-
"successRtadDisabled": "Successfully disabled RTAD security setting.",
942-
"successRtadEnabled": "Successfully enabled RTAD security setting.",
943-
"successVtpmDisabled": "Successfully disabled VitualTPM security setting.",
944-
"successVtpmEnabled": "Successfully enabled VitualTPM security setting."
939+
"errorNetworkPolicyUpdate": "Error updating %{policy} policy.",
940+
"successNetworkPolicyUpdate": "Successfully updated %{policy} policy."
945941
},
946942
"vtpm": "VirtualTPM",
947-
"vtpmDescription": "Enabling vTPM makes a TPM available to the guest operating system.",
948-
"errorNetworkPolicyUpdate": "Error updating %{policy} policy.",
949-
"successNetworkPolicyUpdate": "Successfully updated %{policy} policy."
943+
"vtpmDescription": "Enabling vTPM makes a TPM available to the guest operating system."
950944
},
951945
"pagePower": {
952946
"delayTime": "Delay time (in seconds)",

src/store/modules/SecurityAndAccess/PoliciesStore.js

+65-22
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,16 @@ const PoliciesStore = {
99
rtadEnabled: 'Disabled',
1010
vtpmEnabled: 'Disabled',
1111
tpmPolicyEnabled: false,
12+
usbFirmwareUpdatePolicyEnabled: false,
1213
},
1314
getters: {
1415
sshProtocolEnabled: (state) => state.sshProtocolEnabled,
1516
ipmiProtocolEnabled: (state) => state.ipmiProtocolEnabled,
1617
rtadEnabled: (state) => state.rtadEnabled,
1718
vtpmEnabled: (state) => state.vtpmEnabled,
1819
tpmPolicyEnabled: (state) => state.tpmPolicyEnabled,
20+
usbFirmwareUpdatePolicyEnabled: (state) =>
21+
state.usbFirmwareUpdatePolicyEnabled,
1922
},
2023
mutations: {
2124
setSshProtocolEnabled: (state, sshProtocolEnabled) =>
@@ -26,6 +29,11 @@ const PoliciesStore = {
2629
setVtpmEnabled: (state, vtpmEnabled) => (state.vtpmEnabled = vtpmEnabled),
2730
setTpmPolicyEnabled: (state, tpmPolicyEnabled) =>
2831
(state.tpmPolicyEnabled = tpmPolicyEnabled),
32+
setUsbFirmwareUpdatePolicyEnabled: (
33+
state,
34+
usbFirmwareUpdatePolicyEnabled
35+
) =>
36+
(state.usbFirmwareUpdatePolicyEnabled = usbFirmwareUpdatePolicyEnabled),
2937
},
3038
actions: {
3139
async getNetworkProtocolStatus({ commit }) {
@@ -39,6 +47,17 @@ const PoliciesStore = {
3947
})
4048
.catch((error) => console.log(error));
4149
},
50+
async getUsbFirmwareUpdatePolicyEnabled({ commit }) {
51+
return await api
52+
.get('/redfish/v1/Managers/bmc')
53+
.then((response) => {
54+
commit(
55+
'setUsbFirmwareUpdatePolicyEnabled',
56+
response.data.Oem.IBM.USBCodeUpdateEnabled
57+
);
58+
})
59+
.catch((error) => console.log(error));
60+
},
4261
async getBiosStatus({ commit }) {
4362
return await api
4463
.get('/redfish/v1/Systems/system/Bios')
@@ -83,6 +102,32 @@ const PoliciesStore = {
83102
);
84103
});
85104
},
105+
async saveUsbFirmwareUpdatePolicyEnabled({ commit }, updatedUsbCode) {
106+
commit('setUsbFirmwareUpdatePolicyEnabled', updatedUsbCode);
107+
const oem = {
108+
Oem: {
109+
IBM: {
110+
USBCodeUpdateEnabled: updatedUsbCode,
111+
},
112+
},
113+
};
114+
return await api
115+
.patch('/redfish/v1/Managers/bmc', oem)
116+
.then(() => {
117+
return i18n.t('pagePolicies.toast.successNetworkPolicyUpdate', {
118+
policy: i18n.t('pagePolicies.usbFirmwareUpdatePolicy'),
119+
});
120+
})
121+
.catch((error) => {
122+
console.log(error);
123+
commit('setUsbFirmwareUpdatePolicyEnabled', !updatedUsbCode);
124+
throw new Error(
125+
i18n.t('pagePolicies.toast.errorNetworkPolicyUpdate', {
126+
policy: i18n.t('pagePolicies.usbFirmwareUpdatePolicy'),
127+
})
128+
);
129+
});
130+
},
86131
async saveIpmiProtocolState({ commit }, protocolEnabled) {
87132
commit('setIpmiProtocolEnabled', protocolEnabled);
88133
const ipmi = {
@@ -99,7 +144,7 @@ const PoliciesStore = {
99144
})
100145
.catch((error) => {
101146
console.log(error);
102-
commit('setTpmPolicyEnabled', !protocolEnabled);
147+
commit('setIpmiProtocolEnabled', !protocolEnabled);
103148
throw new Error(
104149
i18n.t('pagePolicies.toast.errorNetworkPolicyUpdate', {
105150
policy: i18n.t('pagePolicies.ipmi'),
@@ -123,7 +168,7 @@ const PoliciesStore = {
123168
})
124169
.catch((error) => {
125170
console.log(error);
126-
commit('setTpmPolicyEnabled', !protocolEnabled);
171+
commit('setSshProtocolEnabled', !protocolEnabled);
127172
throw new Error(
128173
i18n.t('pagePolicies.toast.errorNetworkPolicyUpdate', {
129174
policy: i18n.t('pagePolicies.ssh'),
@@ -140,19 +185,18 @@ const PoliciesStore = {
140185
},
141186
})
142187
.then(() => {
143-
if (updatedRtad === 'Enabled') {
144-
return i18n.t('pagePolicies.toast.successRtadEnabled');
145-
} else {
146-
return i18n.t('pagePolicies.toast.successRtadDisabled');
147-
}
188+
return i18n.t('pagePolicies.toast.successNetworkPolicyUpdate', {
189+
policy: i18n.t('pagePolicies.rtad'),
190+
});
148191
})
149192
.catch((error) => {
150193
console.log(error);
151-
if (updatedRtad === 'Enabled') {
152-
throw new Error(i18n.t('pagePolicies.toast.errorRtadEnabled'));
153-
} else {
154-
throw new Error(i18n.t('pagePolicies.toast.errorRtadDisabled'));
155-
}
194+
commit('setRtadEnabled', !updatedRtad);
195+
throw new Error(
196+
i18n.t('pagePolicies.toast.errorNetworkPolicyUpdate', {
197+
policy: i18n.t('pagePolicies.rtad'),
198+
})
199+
);
156200
});
157201
},
158202
async saveVtpmState({ commit }, updatedVtpm) {
@@ -164,19 +208,18 @@ const PoliciesStore = {
164208
},
165209
})
166210
.then(() => {
167-
if (updatedVtpm === 'Enabled') {
168-
return i18n.t('pagePolicies.toast.successVtpmEnabled');
169-
} else {
170-
return i18n.t('pagePolicies.toast.successVtpmDisabled');
171-
}
211+
return i18n.t('pagePolicies.toast.successNetworkPolicyUpdate', {
212+
policy: i18n.t('pagePolicies.vtpm'),
213+
});
172214
})
173215
.catch((error) => {
174216
console.log(error);
175-
if (updatedVtpm === 'Enabled') {
176-
throw new Error(i18n.t('pagePolicies.toast.errorVtpmEnabled'));
177-
} else {
178-
throw new Error(i18n.t('pagePolicies.toast.errorVtpmDisabled'));
179-
}
217+
commit('setVtpmEnabled', !updatedVtpm);
218+
throw new Error(
219+
i18n.t('pagePolicies.toast.errorNetworkPolicyUpdate', {
220+
policy: i18n.t('pagePolicies.vtpm'),
221+
})
222+
);
180223
});
181224
},
182225
},

src/views/SecurityAndAccess/Policies/Policies.vue

+57-1
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,31 @@
125125
</b-form-checkbox>
126126
</b-col>
127127
</b-row>
128+
<b-row v-if="isServiceUser" class="section-divider">
129+
<b-col class="d-flex align-items-center justify-content-between">
130+
<dl class="mt-3 mr-3 w-75">
131+
<dt>{{ $t('pagePolicies.usbFirmwareUpdatePolicy') }}</dt>
132+
<dd>
133+
{{ $t('pagePolicies.usbFirmwareUpdatePolicyDescription') }}
134+
</dd>
135+
</dl>
136+
<b-form-checkbox
137+
id="usbFirmwareUpdatePolicySwitch"
138+
v-model="usbFirmwareUpdatePolicyState"
139+
data-test-id="policies-toggle-usbFirmwareUpdatePolicy"
140+
switch
141+
@change="changeUsbFirmwareUpdatePolicyState"
142+
>
143+
<span class="sr-only">
144+
{{ $t('pagePolicies.usbFirmwareUpdatePolicy') }}
145+
</span>
146+
<span v-if="usbFirmwareUpdatePolicyState">
147+
{{ $t('global.status.enabled') }}
148+
</span>
149+
<span v-else>{{ $t('global.status.disabled') }}</span>
150+
</b-form-checkbox>
151+
</b-col>
152+
</b-row>
128153
</page-section>
129154
</b-col>
130155
</b-row>
@@ -152,6 +177,20 @@ export default {
152177
};
153178
},
154179
computed: {
180+
usbFirmwareUpdatePolicyState: {
181+
get() {
182+
return this.$store.getters['policies/usbFirmwareUpdatePolicyEnabled'];
183+
},
184+
set(newValue) {
185+
return newValue;
186+
},
187+
},
188+
currentUser() {
189+
return this.$store.getters['global/currentUser'];
190+
},
191+
isServiceUser() {
192+
return this.$store.getters['global/isServiceUser'];
193+
},
155194
sshProtocolState: {
156195
get() {
157196
return this.$store.getters['policies/sshProtocolEnabled'];
@@ -206,10 +245,21 @@ export default {
206245
Promise.all([
207246
this.$store.dispatch('policies/getBiosStatus'),
208247
this.$store.dispatch('policies/getNetworkProtocolStatus'),
248+
this.$store.dispatch('policies/getUsbFirmwareUpdatePolicyEnabled'),
209249
this.$store.dispatch('policies/getTpmPolicy'),
210-
]).finally(() => this.endLoader());
250+
this.$store.dispatch('userManagement/getUsers'),
251+
this.checkForUserData(),
252+
]).finally(() => {
253+
this.endLoader();
254+
});
211255
},
212256
methods: {
257+
changeUsbFirmwareUpdatePolicyState(state) {
258+
this.$store
259+
.dispatch('policies/saveUsbFirmwareUpdatePolicyEnabled', state)
260+
.then((message) => this.successToast(message))
261+
.catch(({ message }) => this.errorToast(message));
262+
},
213263
changeIpmiProtocolState(state) {
214264
this.$store
215265
.dispatch('policies/saveIpmiProtocolState', state)
@@ -240,6 +290,12 @@ export default {
240290
.then((message) => this.successToast(message))
241291
.catch(({ message }) => this.errorToast(message));
242292
},
293+
checkForUserData() {
294+
if (!this.currentUser) {
295+
this.$store.dispatch('userManagement/getUsers');
296+
this.$store.dispatch('global/getCurrentUser');
297+
}
298+
},
243299
},
244300
};
245301
</script>

0 commit comments

Comments
 (0)