public static void validateRefreshLun(Action action) { if (action == null) { throw new ValidationException("Action is mandatory but was not provided."); } if ( (action.getHost()==null || action.getHost().getId()==null) && (action.getHost()==null || action.getHost().getName()==null) ) { throw new ValidationException("Parameters 'host.id' or 'host.name' are mandatory but both were not provided."); } }
protected Guid getHostId(Action action) { return getHostId(action.getHost()); }
public static void validateIsAttached(Action action) { if (action == null) { throw new ValidationException("Action is mandatory but was not provided."); } if (action.getHost()==null || action.getHost().getId()==null) { throw new ValidationException("Parameter 'host.id' is mandatory but was not provided."); } }
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."); }
public static Method getExportSignature(Action action) throws NoSuchMethodException, SecurityException { if (action == null) { throw new ValidationException("Action is mandatory but was not provided."); } /** * to_path_on_host */ if (action!=null && (action.getHost()!=null && action.getHost().getId()!=null || action.getHost()!=null && action.getHost().getName()!=null) && action.getDirectory()!=null ) { return TemplateResource.class.getMethod("exportToPathOnHost", Action.class); } /** * to_export_domain */ if (action!=null && (action.getStorageDomain()!=null && action.getStorageDomain().getId()!=null || action.getStorageDomain()!=null && action.getStorageDomain().getName()!=null) ) { return TemplateResource.class.getMethod("exportToExportDomain", Action.class); } throw new ValidationException("No matching signature found, make sure that mandatory attributes are provided."); }
public static Method getExportSignature(Action action) throws NoSuchMethodException, SecurityException { if (action == null) { throw new ValidationException("Action is mandatory but was not provided."); } /** * to_path_on_host */ if (action!=null && (action.getHost()!=null && action.getHost().getId()!=null || action.getHost()!=null && action.getHost().getName()!=null) && action.getDirectory()!=null ) { return VmResource.class.getMethod("exportToPathOnHost", Action.class); } /** * to_export_domain */ if (action!=null && (action.getStorageDomain()!=null && action.getStorageDomain().getId()!=null || action.getStorageDomain()!=null && action.getStorageDomain().getName()!=null) ) { return VmResource.class.getMethod("exportToExportDomain", Action.class); } throw new ValidationException("No matching signature found, make sure that mandatory attributes are provided."); }
private Response copy(Action action) { GlusterHookManageParameters params = new GlusterHookManageParameters(guid); if (action.isSetHost()) { validateParameters(action.getHost(), "id|name"); Guid hostId = getHostId(action); params.setSourceServerId(hostId); } return doAction(ActionType.UpdateGlusterHook, params, action); }
@Test public void testMigrateWithHostId() { setUriInfo(setUpActionExpectations(ActionType.MigrateVmToServer, MigrateVmToServerParameters.class, new String[] { "VmId", "VdsId", "ForceMigrationForNonMigratableVm" }, new Object[] { GUIDS[0], GUIDS[1], Boolean.FALSE })); Action action = new Action(); action.setHost(new Host()); action.getHost().setId(GUIDS[1].toString()); verifyActionResponse(resource.migrate(action)); }
@Test public void testMigrateWithHostName() { setUpGetHostByNameExpectations(1); setUriInfo(setUpActionExpectations(ActionType.MigrateVmToServer, MigrateVmToServerParameters.class, new String[] { "VmId", "VdsId", "ForceMigrationForNonMigratableVm" }, new Object[] { GUIDS[0], GUIDS[1], Boolean.FALSE })); Action action = new Action(); action.setHost(new Host()); action.getHost().setName(NAMES[1]); verifyActionResponse(resource.migrate(action)); }
to.setHost(adaptOut(from.getHost()));