@SuppressWarnings("unchecked") @Override protected void configure() { super.configure(); bind(new TypeLiteral<ComputeServiceAdapter<ServerInfo, Hardware, LibraryDrive, Location>>() { }).to(CloudSigma2ComputeServiceAdapter.class); bind(new TypeLiteral<Function<ServerInfo, NodeMetadata>>() { }).to(ServerInfoToNodeMetadata.class); bind(new TypeLiteral<Function<LibraryDrive, Image>>() { }).to(LibraryDriveToImage.class); bind(new TypeLiteral<Function<ServerDrive, Volume>>() { }).to(ServerDriveToVolume.class); bind(new TypeLiteral<Function<Hardware, Hardware>>() { }).to(Class.class.cast(IdentityFunction.class)); bind(new TypeLiteral<Function<Location, Location>>() { }).to(Class.class.cast(IdentityFunction.class)); bind(new TypeLiteral<Function<NIC, String>>() { }).to(NICToAddress.class); bind(TemplateOptions.class).to(CloudSigma2TemplateOptions.class); bind(NodeAndTemplateOptionsToStatement.class).to(NodeAndTemplateOptionsToStatementWithoutPublicKey.class); }
@Provides @Singleton @Named(TIMEOUT_DRIVE_CLONED) protected Predicate<DriveInfo> provideDriveClonedPredicate(final CloudSigma2Api api, @Named(TIMEOUT_DRIVE_CLONED) long driveClonedTimeout) { return retry(new DriveClonedPredicate(api), driveClonedTimeout); }
@Provides @Singleton @Named(TIMEOUT_NODE_SUSPENDED) protected Predicate<String> provideServerStoppedPredicate(final CloudSigma2Api api, Timeouts timeouts, PollPeriod pollPeriod) { return retry(new ServerStatusPredicate(api, ServerStatus.STOPPED), timeouts.nodeSuspended, pollPeriod.pollInitialPeriod, pollPeriod.pollMaxPeriod); }
public void testDriveCloned() { CloudSigma2Api api = EasyMock.createMock(CloudSigma2Api.class); for (DriveStatus status : DriveStatus.values()) { expect(api.getDriveInfo(status.name())).andReturn(mockDrive(status)); } replay(api); DriveClonedPredicate predicate = new DriveClonedPredicate(api); assertFalse(predicate.apply(mockDrive(DriveStatus.COPYING))); assertFalse(predicate.apply(mockDrive(DriveStatus.UNAVAILABLE))); assertTrue(predicate.apply(mockDrive(DriveStatus.MOUNTED))); assertTrue(predicate.apply(mockDrive(DriveStatus.UNMOUNTED))); verify(api); }
public void testServerStatus() { CloudSigma2Api api = EasyMock.createMock(CloudSigma2Api.class); expect(api.getServerInfo("one")).andReturn(new ServerInfo.Builder().status(STOPPED).build()); expect(api.getServerInfo("two")).andReturn(new ServerInfo.Builder().status(STOPPING).build()); replay(api); ServerStatusPredicate predicate = new ServerStatusPredicate(api, STOPPED); assertTrue(predicate.apply("one")); assertFalse(predicate.apply("two")); verify(api); }
@Provides @Singleton @Named(TIMEOUT_DRIVE_CLONED) protected Predicate<DriveInfo> provideDriveClonedPredicate(final CloudSigma2Api api, @Named(TIMEOUT_DRIVE_CLONED) long driveClonedTimeout) { return retry(new DriveClonedPredicate(api), driveClonedTimeout); }
@Provides @Singleton @Named(TIMEOUT_NODE_SUSPENDED) protected Predicate<String> provideServerStoppedPredicate(final CloudSigma2Api api, Timeouts timeouts, PollPeriod pollPeriod) { return retry(new ServerStatusPredicate(api, ServerStatus.STOPPED), timeouts.nodeSuspended, pollPeriod.pollInitialPeriod, pollPeriod.pollMaxPeriod); }
@SuppressWarnings("unchecked") @Override protected void configure() { super.configure(); bind(new TypeLiteral<ComputeServiceAdapter<ServerInfo, Hardware, LibraryDrive, Location>>() { }).to(CloudSigma2ComputeServiceAdapter.class); bind(new TypeLiteral<Function<ServerInfo, NodeMetadata>>() { }).to(ServerInfoToNodeMetadata.class); bind(new TypeLiteral<Function<LibraryDrive, Image>>() { }).to(LibraryDriveToImage.class); bind(new TypeLiteral<Function<ServerDrive, Volume>>() { }).to(ServerDriveToVolume.class); bind(new TypeLiteral<Function<Hardware, Hardware>>() { }).to(Class.class.cast(IdentityFunction.class)); bind(new TypeLiteral<Function<Location, Location>>() { }).to(Class.class.cast(IdentityFunction.class)); bind(new TypeLiteral<Function<NIC, String>>() { }).to(NICToAddress.class); bind(TemplateOptions.class).to(CloudSigma2TemplateOptions.class); bind(NodeAndTemplateOptionsToStatement.class).to(NodeAndTemplateOptionsToStatementWithoutPublicKey.class); }