Skip to content

Commit

Permalink
Allow adding host without IP address using force
Browse files Browse the repository at this point in the history
'ipa host-add foo.bar.z --force' is a valid command. We do not require
IP address being present in this case. This is essential for adding
virtual hosts that manage Kerberos services.

See ipatests/test_xmlrpc/test_service_plugin.py, for example. There are
plenty of tests that use 'host_add' with 'force=True'.

Signed-off-by: Alexander Bokovoy <[email protected]>
  • Loading branch information
abbra committed Jan 20, 2025
1 parent b5fab21 commit 14c228b
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/components/modals/HostModals/AddHost.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,6 @@ const AddHost = (props: PropsToAddHost) => {
pfError: ValidatedOptions.default,
});

useEffect(() => {
if (hostIpAddress === "") {
setForceCheckbox(false);
}
}, [hostIpAddress]);

const hostNameValidationHandler = (hostname: string) => {
if (hostname === "") {
const hostNameVal = {
Expand Down Expand Up @@ -200,7 +194,7 @@ const AddHost = (props: PropsToAddHost) => {
!hostNameValidationHandler(hostName) &&
hostName.length > 0 &&
dnsZoneSelected.length > 0 &&
isValidIpAddress(hostIpAddress)
(isValidIpAddress(hostIpAddress) || forceCheckbox)
) {
setButtonDisabled(false);
} else {
Expand Down Expand Up @@ -385,7 +379,7 @@ const AddHost = (props: PropsToAddHost) => {
id: "host-force",
name: "",
pfComponent: (
<div title="Skip the DNS check, but requires a valid IP address">
<div title="Skip the DNS and IP address checks">
<Checkbox
label="Force"
isChecked={forceCheckbox}
Expand All @@ -394,11 +388,11 @@ const AddHost = (props: PropsToAddHost) => {
name="forceCheckbox"
value="force"
onChange={handleForceCheckbox}
isDisabled={hostIpAddressValidation.isError || hostIpAddress === ""}
isDisabled={hostIpAddressValidation.isError}
/>
<HelperText>
<HelperTextItem variant="indeterminate">
Requires valid IP address
Requires valid IP address or can be skipped
</HelperTextItem>
</HelperText>
</div>
Expand Down

0 comments on commit 14c228b

Please sign in to comment.