public static Method getAddSignature(Host host) throws NoSuchMethodException, SecurityException { if (host == null) { throw new ValidationException("Parameter 'host' is mandatory but was not provided."); } if (host.getAddress()==null) { throw new ValidationException("Parameter 'host.address' is mandatory but was not provided."); } if (host.getName()==null) { throw new ValidationException("Parameter 'host.name' is mandatory but was not provided."); } if ( (host.getCluster()==null || host.getCluster().getId()==null) && (host.getCluster()==null || host.getCluster().getName()==null) ) { throw new ValidationException("Parameters 'host.cluster.id' or 'host.cluster.name' are mandatory but both were not provided."); } /** * using_root_password */ if (host!=null && host.getRootPassword()!=null ) { return HostsResource.class.getMethod("addUsingRootPassword", Host.class); } throw new ValidationException("No matching signature found, make sure that mandatory attributes are provided."); }
@Override public ActionParametersBase getParameters(Host incoming, VDS entity) { VdsStatic updated = getMapper(modelType, VdsStatic.class).map(incoming, entity.getStaticData()); UpdateVdsActionParameters updateParams = new UpdateVdsActionParameters(updated, incoming.getRootPassword(), false); // Updating Fence-agents is deprecated from this context, so the original, unchanged, list of agents is // passed to the engine. updateParams.setFenceAgents(entity.getFenceAgents()); if (incoming.isSetOverrideIptables()) { updateParams.setOverrideFirewall(incoming.isOverrideIptables()); } updateParams = (UpdateVdsActionParameters) getMapper (Host.class, VdsOperationActionParameters.class).map(incoming, updateParams); return updateParams; } }
public static Method getApproveSignature(Action action) throws NoSuchMethodException, SecurityException { if (action == null) { throw new ValidationException("Action is mandatory but was not provided."); } /** * using_root_password */ if (action!=null && action.getHost()!=null && action.getHost().getRootPassword()!=null ) { return HostResource.class.getMethod("approveUsingRootPassword", Action.class); } /** * using_ssh */ if (action!=null && action.getHost()!=null && action.getHost().getSsh()!=null && action.getHost().getSsh().getUser()!=null && action.getHost().getSsh().getUser().getUserName()!=null && action.getHost()!=null && action.getHost().getSsh()!=null && action.getHost().getSsh().getUser()!=null && action.getHost().getSsh().getUser().getPassword()!=null && action.getHost()!=null && action.getHost().getSsh()!=null && action.getHost().getSsh().getAuthenticationMethod()!=null ) { return HostResource.class.getMethod("approveUsingSsh", Action.class); } throw new ValidationException("No matching signature found, make sure that mandatory attributes are provided."); }
@Override public Response add(Host host) { validateParameters(host, "name", "address"); VdsStatic staticHost = getMapper(Host.class, VdsStatic.class).map(host, null); staticHost.setClusterId(getClusterId(host)); BackendExternalProviderHelper.completeExternalNetworkProviderConfigurations(this, host.getExternalNetworkProviderConfigurations()); AddVdsActionParameters addParams = new AddVdsActionParameters(staticHost, host.getRootPassword()); if (host.isSetOverrideIptables()) { addParams.setOverrideFirewall(host.isOverrideIptables()); } addParams.setHostedEngineDeployConfiguration(HostResourceParametersUtil.getHostedEngineDeployConfiguration(this)); addParams = (AddVdsActionParameters) getMapper (Host.class, VdsOperationActionParameters.class).map(host, addParams); //default value for 'activate' is true boolean activate = ParametersHelper.getBooleanParameter(httpHeaders, uriInfo, ACTIVATE, true, true); addParams.setActivateHost(activate); return performCreate(ActionType.AddVds, addParams, new QueryIdResolver<Guid>(QueryType.GetVdsByVdsId, IdQueryParameters.class)); }
@Mapping(from = Host.class, to = VdsOperationActionParameters.class) public static VdsOperationActionParameters map(Host host, VdsOperationActionParameters params) { params.setPassword(host.getRootPassword()); if (host.isSetSsh()) { if (host.getSsh().isSetUser()) { if (host.getSsh().getUser().isSetPassword()) { // For backward compatibility giving priority to rootPassword field if (params.getPassword() == null) { params.setPassword(host.getSsh().getUser().getPassword()); } } if (host.getSsh().getUser().isSetUserName()) { params.getvds().setSshUsername(host.getSsh().getUser().getUserName()); } } if (host.getSsh().isSetPort()) { params.getvds().setSshPort(host.getSsh().getPort()); } if (host.getSsh().isSetFingerprint()) { params.getvds().setSshKeyFingerprint(host.getSsh().getFingerprint()); } if (host.getSsh().isSetAuthenticationMethod()) { params.setAuthMethod(mapSshAuthenticationMethod(host.getSsh().getAuthenticationMethod())); } } return params; }
to.setRootPassword(from.getRootPassword());