target
stringlengths
20
113k
src_fm
stringlengths
11
86.3k
src_fm_fc
stringlengths
21
86.4k
src_fm_fc_co
stringlengths
30
86.4k
src_fm_fc_ms
stringlengths
42
86.8k
src_fm_fc_ms_ff
stringlengths
43
86.8k
@Test public void testautoAssignFloatingIpDefault() { NovaTemplateOptions options = new NovaTemplateOptions(); assert !options.shouldAutoAssignFloatingIp(); }
public boolean shouldAutoAssignFloatingIp() { return autoAssignFloatingIp; }
NovaTemplateOptions extends TemplateOptions implements Cloneable { public boolean shouldAutoAssignFloatingIp() { return autoAssignFloatingIp; } }
NovaTemplateOptions extends TemplateOptions implements Cloneable { public boolean shouldAutoAssignFloatingIp() { return autoAssignFloatingIp; } }
NovaTemplateOptions extends TemplateOptions implements Cloneable { public boolean shouldAutoAssignFloatingIp() { return autoAssignFloatingIp; } @Override NovaTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override ToStringHelper string(); NovaTemplateOptions autoAssignFloatingIp(boolean enable); NovaTemplateOptions floatingIpPoolNames(String... floatingIpPoolNames); NovaTemplateOptions floatingIpPoolNames(Iterable<String> floatingIpPoolNames); NovaTemplateOptions generateKeyPair(boolean enable); NovaTemplateOptions keyPairName(String keyPairName); boolean shouldAutoAssignFloatingIp(); NovaTemplateOptions availabilityZone(String availabilityZone); NovaTemplateOptions blockDeviceMappings(BlockDeviceMapping... blockDeviceMappings); NovaTemplateOptions blockDeviceMappings(Iterable<BlockDeviceMapping> blockDeviceMappings); Optional<Set<String>> getFloatingIpPoolNames(); String getKeyPairName(); boolean shouldGenerateKeyPair(); byte[] getUserData(); String getDiskConfig(); boolean getConfigDrive(); Set<Network> getNovaNetworks(); String getAvailabilityZone(); Set<BlockDeviceMapping> getBlockDeviceMappings(); @Override NovaTemplateOptions blockOnPort(int port, int seconds); @Override NovaTemplateOptions inboundPorts(int... ports); @Override NovaTemplateOptions authorizePublicKey(String publicKey); @Override NovaTemplateOptions installPrivateKey(String privateKey); @Override NovaTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override NovaTemplateOptions dontAuthorizePublicKey(); @Override NovaTemplateOptions nameTask(String name); @Override NovaTemplateOptions runAsRoot(boolean runAsRoot); @Override NovaTemplateOptions runScript(Statement script); @Override NovaTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override NovaTemplateOptions overrideLoginPassword(String password); @Override NovaTemplateOptions overrideLoginPrivateKey(String privateKey); @Override NovaTemplateOptions overrideLoginUser(String loginUser); @Override NovaTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override NovaTemplateOptions userMetadata(Map<String, String> userMetadata); @Override NovaTemplateOptions userMetadata(String key, String value); @Override NovaTemplateOptions nodeNames(Iterable<String> nodeNames); @Override NovaTemplateOptions networks(Iterable<String> networks); @Override NovaTemplateOptions networks(String... networks); NovaTemplateOptions userData(byte[] userData); NovaTemplateOptions diskConfig(String diskConfig); NovaTemplateOptions configDrive(boolean configDrive); NovaTemplateOptions novaNetworks(Set<Network> novaNetworks); }
NovaTemplateOptions extends TemplateOptions implements Cloneable { public boolean shouldAutoAssignFloatingIp() { return autoAssignFloatingIp; } @Override NovaTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override ToStringHelper string(); NovaTemplateOptions autoAssignFloatingIp(boolean enable); NovaTemplateOptions floatingIpPoolNames(String... floatingIpPoolNames); NovaTemplateOptions floatingIpPoolNames(Iterable<String> floatingIpPoolNames); NovaTemplateOptions generateKeyPair(boolean enable); NovaTemplateOptions keyPairName(String keyPairName); boolean shouldAutoAssignFloatingIp(); NovaTemplateOptions availabilityZone(String availabilityZone); NovaTemplateOptions blockDeviceMappings(BlockDeviceMapping... blockDeviceMappings); NovaTemplateOptions blockDeviceMappings(Iterable<BlockDeviceMapping> blockDeviceMappings); Optional<Set<String>> getFloatingIpPoolNames(); String getKeyPairName(); boolean shouldGenerateKeyPair(); byte[] getUserData(); String getDiskConfig(); boolean getConfigDrive(); Set<Network> getNovaNetworks(); String getAvailabilityZone(); Set<BlockDeviceMapping> getBlockDeviceMappings(); @Override NovaTemplateOptions blockOnPort(int port, int seconds); @Override NovaTemplateOptions inboundPorts(int... ports); @Override NovaTemplateOptions authorizePublicKey(String publicKey); @Override NovaTemplateOptions installPrivateKey(String privateKey); @Override NovaTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override NovaTemplateOptions dontAuthorizePublicKey(); @Override NovaTemplateOptions nameTask(String name); @Override NovaTemplateOptions runAsRoot(boolean runAsRoot); @Override NovaTemplateOptions runScript(Statement script); @Override NovaTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override NovaTemplateOptions overrideLoginPassword(String password); @Override NovaTemplateOptions overrideLoginPrivateKey(String privateKey); @Override NovaTemplateOptions overrideLoginUser(String loginUser); @Override NovaTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override NovaTemplateOptions userMetadata(Map<String, String> userMetadata); @Override NovaTemplateOptions userMetadata(String key, String value); @Override NovaTemplateOptions nodeNames(Iterable<String> nodeNames); @Override NovaTemplateOptions networks(Iterable<String> networks); @Override NovaTemplateOptions networks(String... networks); NovaTemplateOptions userData(byte[] userData); NovaTemplateOptions diskConfig(String diskConfig); NovaTemplateOptions configDrive(boolean configDrive); NovaTemplateOptions novaNetworks(Set<Network> novaNetworks); }
@Test public void testautoAssignFloatingIp() { NovaTemplateOptions options = new NovaTemplateOptions().autoAssignFloatingIp(true); assert options.shouldAutoAssignFloatingIp(); }
public NovaTemplateOptions autoAssignFloatingIp(boolean enable) { this.autoAssignFloatingIp = enable; return this; }
NovaTemplateOptions extends TemplateOptions implements Cloneable { public NovaTemplateOptions autoAssignFloatingIp(boolean enable) { this.autoAssignFloatingIp = enable; return this; } }
NovaTemplateOptions extends TemplateOptions implements Cloneable { public NovaTemplateOptions autoAssignFloatingIp(boolean enable) { this.autoAssignFloatingIp = enable; return this; } }
NovaTemplateOptions extends TemplateOptions implements Cloneable { public NovaTemplateOptions autoAssignFloatingIp(boolean enable) { this.autoAssignFloatingIp = enable; return this; } @Override NovaTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override ToStringHelper string(); NovaTemplateOptions autoAssignFloatingIp(boolean enable); NovaTemplateOptions floatingIpPoolNames(String... floatingIpPoolNames); NovaTemplateOptions floatingIpPoolNames(Iterable<String> floatingIpPoolNames); NovaTemplateOptions generateKeyPair(boolean enable); NovaTemplateOptions keyPairName(String keyPairName); boolean shouldAutoAssignFloatingIp(); NovaTemplateOptions availabilityZone(String availabilityZone); NovaTemplateOptions blockDeviceMappings(BlockDeviceMapping... blockDeviceMappings); NovaTemplateOptions blockDeviceMappings(Iterable<BlockDeviceMapping> blockDeviceMappings); Optional<Set<String>> getFloatingIpPoolNames(); String getKeyPairName(); boolean shouldGenerateKeyPair(); byte[] getUserData(); String getDiskConfig(); boolean getConfigDrive(); Set<Network> getNovaNetworks(); String getAvailabilityZone(); Set<BlockDeviceMapping> getBlockDeviceMappings(); @Override NovaTemplateOptions blockOnPort(int port, int seconds); @Override NovaTemplateOptions inboundPorts(int... ports); @Override NovaTemplateOptions authorizePublicKey(String publicKey); @Override NovaTemplateOptions installPrivateKey(String privateKey); @Override NovaTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override NovaTemplateOptions dontAuthorizePublicKey(); @Override NovaTemplateOptions nameTask(String name); @Override NovaTemplateOptions runAsRoot(boolean runAsRoot); @Override NovaTemplateOptions runScript(Statement script); @Override NovaTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override NovaTemplateOptions overrideLoginPassword(String password); @Override NovaTemplateOptions overrideLoginPrivateKey(String privateKey); @Override NovaTemplateOptions overrideLoginUser(String loginUser); @Override NovaTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override NovaTemplateOptions userMetadata(Map<String, String> userMetadata); @Override NovaTemplateOptions userMetadata(String key, String value); @Override NovaTemplateOptions nodeNames(Iterable<String> nodeNames); @Override NovaTemplateOptions networks(Iterable<String> networks); @Override NovaTemplateOptions networks(String... networks); NovaTemplateOptions userData(byte[] userData); NovaTemplateOptions diskConfig(String diskConfig); NovaTemplateOptions configDrive(boolean configDrive); NovaTemplateOptions novaNetworks(Set<Network> novaNetworks); }
NovaTemplateOptions extends TemplateOptions implements Cloneable { public NovaTemplateOptions autoAssignFloatingIp(boolean enable) { this.autoAssignFloatingIp = enable; return this; } @Override NovaTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override ToStringHelper string(); NovaTemplateOptions autoAssignFloatingIp(boolean enable); NovaTemplateOptions floatingIpPoolNames(String... floatingIpPoolNames); NovaTemplateOptions floatingIpPoolNames(Iterable<String> floatingIpPoolNames); NovaTemplateOptions generateKeyPair(boolean enable); NovaTemplateOptions keyPairName(String keyPairName); boolean shouldAutoAssignFloatingIp(); NovaTemplateOptions availabilityZone(String availabilityZone); NovaTemplateOptions blockDeviceMappings(BlockDeviceMapping... blockDeviceMappings); NovaTemplateOptions blockDeviceMappings(Iterable<BlockDeviceMapping> blockDeviceMappings); Optional<Set<String>> getFloatingIpPoolNames(); String getKeyPairName(); boolean shouldGenerateKeyPair(); byte[] getUserData(); String getDiskConfig(); boolean getConfigDrive(); Set<Network> getNovaNetworks(); String getAvailabilityZone(); Set<BlockDeviceMapping> getBlockDeviceMappings(); @Override NovaTemplateOptions blockOnPort(int port, int seconds); @Override NovaTemplateOptions inboundPorts(int... ports); @Override NovaTemplateOptions authorizePublicKey(String publicKey); @Override NovaTemplateOptions installPrivateKey(String privateKey); @Override NovaTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override NovaTemplateOptions dontAuthorizePublicKey(); @Override NovaTemplateOptions nameTask(String name); @Override NovaTemplateOptions runAsRoot(boolean runAsRoot); @Override NovaTemplateOptions runScript(Statement script); @Override NovaTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override NovaTemplateOptions overrideLoginPassword(String password); @Override NovaTemplateOptions overrideLoginPrivateKey(String privateKey); @Override NovaTemplateOptions overrideLoginUser(String loginUser); @Override NovaTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override NovaTemplateOptions userMetadata(Map<String, String> userMetadata); @Override NovaTemplateOptions userMetadata(String key, String value); @Override NovaTemplateOptions nodeNames(Iterable<String> nodeNames); @Override NovaTemplateOptions networks(Iterable<String> networks); @Override NovaTemplateOptions networks(String... networks); NovaTemplateOptions userData(byte[] userData); NovaTemplateOptions diskConfig(String diskConfig); NovaTemplateOptions configDrive(boolean configDrive); NovaTemplateOptions novaNetworks(Set<Network> novaNetworks); }
@Test public void testGenerateKeyPairDefault() { NovaTemplateOptions options = new NovaTemplateOptions(); assert !options.shouldGenerateKeyPair(); }
public boolean shouldGenerateKeyPair() { return generateKeyPair; }
NovaTemplateOptions extends TemplateOptions implements Cloneable { public boolean shouldGenerateKeyPair() { return generateKeyPair; } }
NovaTemplateOptions extends TemplateOptions implements Cloneable { public boolean shouldGenerateKeyPair() { return generateKeyPair; } }
NovaTemplateOptions extends TemplateOptions implements Cloneable { public boolean shouldGenerateKeyPair() { return generateKeyPair; } @Override NovaTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override ToStringHelper string(); NovaTemplateOptions autoAssignFloatingIp(boolean enable); NovaTemplateOptions floatingIpPoolNames(String... floatingIpPoolNames); NovaTemplateOptions floatingIpPoolNames(Iterable<String> floatingIpPoolNames); NovaTemplateOptions generateKeyPair(boolean enable); NovaTemplateOptions keyPairName(String keyPairName); boolean shouldAutoAssignFloatingIp(); NovaTemplateOptions availabilityZone(String availabilityZone); NovaTemplateOptions blockDeviceMappings(BlockDeviceMapping... blockDeviceMappings); NovaTemplateOptions blockDeviceMappings(Iterable<BlockDeviceMapping> blockDeviceMappings); Optional<Set<String>> getFloatingIpPoolNames(); String getKeyPairName(); boolean shouldGenerateKeyPair(); byte[] getUserData(); String getDiskConfig(); boolean getConfigDrive(); Set<Network> getNovaNetworks(); String getAvailabilityZone(); Set<BlockDeviceMapping> getBlockDeviceMappings(); @Override NovaTemplateOptions blockOnPort(int port, int seconds); @Override NovaTemplateOptions inboundPorts(int... ports); @Override NovaTemplateOptions authorizePublicKey(String publicKey); @Override NovaTemplateOptions installPrivateKey(String privateKey); @Override NovaTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override NovaTemplateOptions dontAuthorizePublicKey(); @Override NovaTemplateOptions nameTask(String name); @Override NovaTemplateOptions runAsRoot(boolean runAsRoot); @Override NovaTemplateOptions runScript(Statement script); @Override NovaTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override NovaTemplateOptions overrideLoginPassword(String password); @Override NovaTemplateOptions overrideLoginPrivateKey(String privateKey); @Override NovaTemplateOptions overrideLoginUser(String loginUser); @Override NovaTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override NovaTemplateOptions userMetadata(Map<String, String> userMetadata); @Override NovaTemplateOptions userMetadata(String key, String value); @Override NovaTemplateOptions nodeNames(Iterable<String> nodeNames); @Override NovaTemplateOptions networks(Iterable<String> networks); @Override NovaTemplateOptions networks(String... networks); NovaTemplateOptions userData(byte[] userData); NovaTemplateOptions diskConfig(String diskConfig); NovaTemplateOptions configDrive(boolean configDrive); NovaTemplateOptions novaNetworks(Set<Network> novaNetworks); }
NovaTemplateOptions extends TemplateOptions implements Cloneable { public boolean shouldGenerateKeyPair() { return generateKeyPair; } @Override NovaTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override ToStringHelper string(); NovaTemplateOptions autoAssignFloatingIp(boolean enable); NovaTemplateOptions floatingIpPoolNames(String... floatingIpPoolNames); NovaTemplateOptions floatingIpPoolNames(Iterable<String> floatingIpPoolNames); NovaTemplateOptions generateKeyPair(boolean enable); NovaTemplateOptions keyPairName(String keyPairName); boolean shouldAutoAssignFloatingIp(); NovaTemplateOptions availabilityZone(String availabilityZone); NovaTemplateOptions blockDeviceMappings(BlockDeviceMapping... blockDeviceMappings); NovaTemplateOptions blockDeviceMappings(Iterable<BlockDeviceMapping> blockDeviceMappings); Optional<Set<String>> getFloatingIpPoolNames(); String getKeyPairName(); boolean shouldGenerateKeyPair(); byte[] getUserData(); String getDiskConfig(); boolean getConfigDrive(); Set<Network> getNovaNetworks(); String getAvailabilityZone(); Set<BlockDeviceMapping> getBlockDeviceMappings(); @Override NovaTemplateOptions blockOnPort(int port, int seconds); @Override NovaTemplateOptions inboundPorts(int... ports); @Override NovaTemplateOptions authorizePublicKey(String publicKey); @Override NovaTemplateOptions installPrivateKey(String privateKey); @Override NovaTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override NovaTemplateOptions dontAuthorizePublicKey(); @Override NovaTemplateOptions nameTask(String name); @Override NovaTemplateOptions runAsRoot(boolean runAsRoot); @Override NovaTemplateOptions runScript(Statement script); @Override NovaTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override NovaTemplateOptions overrideLoginPassword(String password); @Override NovaTemplateOptions overrideLoginPrivateKey(String privateKey); @Override NovaTemplateOptions overrideLoginUser(String loginUser); @Override NovaTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override NovaTemplateOptions userMetadata(Map<String, String> userMetadata); @Override NovaTemplateOptions userMetadata(String key, String value); @Override NovaTemplateOptions nodeNames(Iterable<String> nodeNames); @Override NovaTemplateOptions networks(Iterable<String> networks); @Override NovaTemplateOptions networks(String... networks); NovaTemplateOptions userData(byte[] userData); NovaTemplateOptions diskConfig(String diskConfig); NovaTemplateOptions configDrive(boolean configDrive); NovaTemplateOptions novaNetworks(Set<Network> novaNetworks); }
@Test public void testGenerateKeyPair() { NovaTemplateOptions options = new NovaTemplateOptions().generateKeyPair(true); assert options.shouldGenerateKeyPair(); }
public NovaTemplateOptions generateKeyPair(boolean enable) { this.generateKeyPair = enable; return this; }
NovaTemplateOptions extends TemplateOptions implements Cloneable { public NovaTemplateOptions generateKeyPair(boolean enable) { this.generateKeyPair = enable; return this; } }
NovaTemplateOptions extends TemplateOptions implements Cloneable { public NovaTemplateOptions generateKeyPair(boolean enable) { this.generateKeyPair = enable; return this; } }
NovaTemplateOptions extends TemplateOptions implements Cloneable { public NovaTemplateOptions generateKeyPair(boolean enable) { this.generateKeyPair = enable; return this; } @Override NovaTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override ToStringHelper string(); NovaTemplateOptions autoAssignFloatingIp(boolean enable); NovaTemplateOptions floatingIpPoolNames(String... floatingIpPoolNames); NovaTemplateOptions floatingIpPoolNames(Iterable<String> floatingIpPoolNames); NovaTemplateOptions generateKeyPair(boolean enable); NovaTemplateOptions keyPairName(String keyPairName); boolean shouldAutoAssignFloatingIp(); NovaTemplateOptions availabilityZone(String availabilityZone); NovaTemplateOptions blockDeviceMappings(BlockDeviceMapping... blockDeviceMappings); NovaTemplateOptions blockDeviceMappings(Iterable<BlockDeviceMapping> blockDeviceMappings); Optional<Set<String>> getFloatingIpPoolNames(); String getKeyPairName(); boolean shouldGenerateKeyPair(); byte[] getUserData(); String getDiskConfig(); boolean getConfigDrive(); Set<Network> getNovaNetworks(); String getAvailabilityZone(); Set<BlockDeviceMapping> getBlockDeviceMappings(); @Override NovaTemplateOptions blockOnPort(int port, int seconds); @Override NovaTemplateOptions inboundPorts(int... ports); @Override NovaTemplateOptions authorizePublicKey(String publicKey); @Override NovaTemplateOptions installPrivateKey(String privateKey); @Override NovaTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override NovaTemplateOptions dontAuthorizePublicKey(); @Override NovaTemplateOptions nameTask(String name); @Override NovaTemplateOptions runAsRoot(boolean runAsRoot); @Override NovaTemplateOptions runScript(Statement script); @Override NovaTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override NovaTemplateOptions overrideLoginPassword(String password); @Override NovaTemplateOptions overrideLoginPrivateKey(String privateKey); @Override NovaTemplateOptions overrideLoginUser(String loginUser); @Override NovaTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override NovaTemplateOptions userMetadata(Map<String, String> userMetadata); @Override NovaTemplateOptions userMetadata(String key, String value); @Override NovaTemplateOptions nodeNames(Iterable<String> nodeNames); @Override NovaTemplateOptions networks(Iterable<String> networks); @Override NovaTemplateOptions networks(String... networks); NovaTemplateOptions userData(byte[] userData); NovaTemplateOptions diskConfig(String diskConfig); NovaTemplateOptions configDrive(boolean configDrive); NovaTemplateOptions novaNetworks(Set<Network> novaNetworks); }
NovaTemplateOptions extends TemplateOptions implements Cloneable { public NovaTemplateOptions generateKeyPair(boolean enable) { this.generateKeyPair = enable; return this; } @Override NovaTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override ToStringHelper string(); NovaTemplateOptions autoAssignFloatingIp(boolean enable); NovaTemplateOptions floatingIpPoolNames(String... floatingIpPoolNames); NovaTemplateOptions floatingIpPoolNames(Iterable<String> floatingIpPoolNames); NovaTemplateOptions generateKeyPair(boolean enable); NovaTemplateOptions keyPairName(String keyPairName); boolean shouldAutoAssignFloatingIp(); NovaTemplateOptions availabilityZone(String availabilityZone); NovaTemplateOptions blockDeviceMappings(BlockDeviceMapping... blockDeviceMappings); NovaTemplateOptions blockDeviceMappings(Iterable<BlockDeviceMapping> blockDeviceMappings); Optional<Set<String>> getFloatingIpPoolNames(); String getKeyPairName(); boolean shouldGenerateKeyPair(); byte[] getUserData(); String getDiskConfig(); boolean getConfigDrive(); Set<Network> getNovaNetworks(); String getAvailabilityZone(); Set<BlockDeviceMapping> getBlockDeviceMappings(); @Override NovaTemplateOptions blockOnPort(int port, int seconds); @Override NovaTemplateOptions inboundPorts(int... ports); @Override NovaTemplateOptions authorizePublicKey(String publicKey); @Override NovaTemplateOptions installPrivateKey(String privateKey); @Override NovaTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override NovaTemplateOptions dontAuthorizePublicKey(); @Override NovaTemplateOptions nameTask(String name); @Override NovaTemplateOptions runAsRoot(boolean runAsRoot); @Override NovaTemplateOptions runScript(Statement script); @Override NovaTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override NovaTemplateOptions overrideLoginPassword(String password); @Override NovaTemplateOptions overrideLoginPrivateKey(String privateKey); @Override NovaTemplateOptions overrideLoginUser(String loginUser); @Override NovaTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override NovaTemplateOptions userMetadata(Map<String, String> userMetadata); @Override NovaTemplateOptions userMetadata(String key, String value); @Override NovaTemplateOptions nodeNames(Iterable<String> nodeNames); @Override NovaTemplateOptions networks(Iterable<String> networks); @Override NovaTemplateOptions networks(String... networks); NovaTemplateOptions userData(byte[] userData); NovaTemplateOptions diskConfig(String diskConfig); NovaTemplateOptions configDrive(boolean configDrive); NovaTemplateOptions novaNetworks(Set<Network> novaNetworks); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testinstallPrivateKeyBadFormat() { NovaTemplateOptions options = new NovaTemplateOptions(); options.installPrivateKey("whompy"); }
@Override public NovaTemplateOptions installPrivateKey(String privateKey) { return NovaTemplateOptions.class.cast(super.installPrivateKey(privateKey)); }
NovaTemplateOptions extends TemplateOptions implements Cloneable { @Override public NovaTemplateOptions installPrivateKey(String privateKey) { return NovaTemplateOptions.class.cast(super.installPrivateKey(privateKey)); } }
NovaTemplateOptions extends TemplateOptions implements Cloneable { @Override public NovaTemplateOptions installPrivateKey(String privateKey) { return NovaTemplateOptions.class.cast(super.installPrivateKey(privateKey)); } }
NovaTemplateOptions extends TemplateOptions implements Cloneable { @Override public NovaTemplateOptions installPrivateKey(String privateKey) { return NovaTemplateOptions.class.cast(super.installPrivateKey(privateKey)); } @Override NovaTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override ToStringHelper string(); NovaTemplateOptions autoAssignFloatingIp(boolean enable); NovaTemplateOptions floatingIpPoolNames(String... floatingIpPoolNames); NovaTemplateOptions floatingIpPoolNames(Iterable<String> floatingIpPoolNames); NovaTemplateOptions generateKeyPair(boolean enable); NovaTemplateOptions keyPairName(String keyPairName); boolean shouldAutoAssignFloatingIp(); NovaTemplateOptions availabilityZone(String availabilityZone); NovaTemplateOptions blockDeviceMappings(BlockDeviceMapping... blockDeviceMappings); NovaTemplateOptions blockDeviceMappings(Iterable<BlockDeviceMapping> blockDeviceMappings); Optional<Set<String>> getFloatingIpPoolNames(); String getKeyPairName(); boolean shouldGenerateKeyPair(); byte[] getUserData(); String getDiskConfig(); boolean getConfigDrive(); Set<Network> getNovaNetworks(); String getAvailabilityZone(); Set<BlockDeviceMapping> getBlockDeviceMappings(); @Override NovaTemplateOptions blockOnPort(int port, int seconds); @Override NovaTemplateOptions inboundPorts(int... ports); @Override NovaTemplateOptions authorizePublicKey(String publicKey); @Override NovaTemplateOptions installPrivateKey(String privateKey); @Override NovaTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override NovaTemplateOptions dontAuthorizePublicKey(); @Override NovaTemplateOptions nameTask(String name); @Override NovaTemplateOptions runAsRoot(boolean runAsRoot); @Override NovaTemplateOptions runScript(Statement script); @Override NovaTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override NovaTemplateOptions overrideLoginPassword(String password); @Override NovaTemplateOptions overrideLoginPrivateKey(String privateKey); @Override NovaTemplateOptions overrideLoginUser(String loginUser); @Override NovaTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override NovaTemplateOptions userMetadata(Map<String, String> userMetadata); @Override NovaTemplateOptions userMetadata(String key, String value); @Override NovaTemplateOptions nodeNames(Iterable<String> nodeNames); @Override NovaTemplateOptions networks(Iterable<String> networks); @Override NovaTemplateOptions networks(String... networks); NovaTemplateOptions userData(byte[] userData); NovaTemplateOptions diskConfig(String diskConfig); NovaTemplateOptions configDrive(boolean configDrive); NovaTemplateOptions novaNetworks(Set<Network> novaNetworks); }
NovaTemplateOptions extends TemplateOptions implements Cloneable { @Override public NovaTemplateOptions installPrivateKey(String privateKey) { return NovaTemplateOptions.class.cast(super.installPrivateKey(privateKey)); } @Override NovaTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override ToStringHelper string(); NovaTemplateOptions autoAssignFloatingIp(boolean enable); NovaTemplateOptions floatingIpPoolNames(String... floatingIpPoolNames); NovaTemplateOptions floatingIpPoolNames(Iterable<String> floatingIpPoolNames); NovaTemplateOptions generateKeyPair(boolean enable); NovaTemplateOptions keyPairName(String keyPairName); boolean shouldAutoAssignFloatingIp(); NovaTemplateOptions availabilityZone(String availabilityZone); NovaTemplateOptions blockDeviceMappings(BlockDeviceMapping... blockDeviceMappings); NovaTemplateOptions blockDeviceMappings(Iterable<BlockDeviceMapping> blockDeviceMappings); Optional<Set<String>> getFloatingIpPoolNames(); String getKeyPairName(); boolean shouldGenerateKeyPair(); byte[] getUserData(); String getDiskConfig(); boolean getConfigDrive(); Set<Network> getNovaNetworks(); String getAvailabilityZone(); Set<BlockDeviceMapping> getBlockDeviceMappings(); @Override NovaTemplateOptions blockOnPort(int port, int seconds); @Override NovaTemplateOptions inboundPorts(int... ports); @Override NovaTemplateOptions authorizePublicKey(String publicKey); @Override NovaTemplateOptions installPrivateKey(String privateKey); @Override NovaTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override NovaTemplateOptions dontAuthorizePublicKey(); @Override NovaTemplateOptions nameTask(String name); @Override NovaTemplateOptions runAsRoot(boolean runAsRoot); @Override NovaTemplateOptions runScript(Statement script); @Override NovaTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override NovaTemplateOptions overrideLoginPassword(String password); @Override NovaTemplateOptions overrideLoginPrivateKey(String privateKey); @Override NovaTemplateOptions overrideLoginUser(String loginUser); @Override NovaTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override NovaTemplateOptions userMetadata(Map<String, String> userMetadata); @Override NovaTemplateOptions userMetadata(String key, String value); @Override NovaTemplateOptions nodeNames(Iterable<String> nodeNames); @Override NovaTemplateOptions networks(Iterable<String> networks); @Override NovaTemplateOptions networks(String... networks); NovaTemplateOptions userData(byte[] userData); NovaTemplateOptions diskConfig(String diskConfig); NovaTemplateOptions configDrive(boolean configDrive); NovaTemplateOptions novaNetworks(Set<Network> novaNetworks); }
@Test public void testinstallPrivateKey() throws IOException { NovaTemplateOptions options = new NovaTemplateOptions(); options.installPrivateKey("-----BEGIN RSA PRIVATE KEY-----"); assertEquals(options.getPrivateKey(), "-----BEGIN RSA PRIVATE KEY-----"); }
@Override public NovaTemplateOptions installPrivateKey(String privateKey) { return NovaTemplateOptions.class.cast(super.installPrivateKey(privateKey)); }
NovaTemplateOptions extends TemplateOptions implements Cloneable { @Override public NovaTemplateOptions installPrivateKey(String privateKey) { return NovaTemplateOptions.class.cast(super.installPrivateKey(privateKey)); } }
NovaTemplateOptions extends TemplateOptions implements Cloneable { @Override public NovaTemplateOptions installPrivateKey(String privateKey) { return NovaTemplateOptions.class.cast(super.installPrivateKey(privateKey)); } }
NovaTemplateOptions extends TemplateOptions implements Cloneable { @Override public NovaTemplateOptions installPrivateKey(String privateKey) { return NovaTemplateOptions.class.cast(super.installPrivateKey(privateKey)); } @Override NovaTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override ToStringHelper string(); NovaTemplateOptions autoAssignFloatingIp(boolean enable); NovaTemplateOptions floatingIpPoolNames(String... floatingIpPoolNames); NovaTemplateOptions floatingIpPoolNames(Iterable<String> floatingIpPoolNames); NovaTemplateOptions generateKeyPair(boolean enable); NovaTemplateOptions keyPairName(String keyPairName); boolean shouldAutoAssignFloatingIp(); NovaTemplateOptions availabilityZone(String availabilityZone); NovaTemplateOptions blockDeviceMappings(BlockDeviceMapping... blockDeviceMappings); NovaTemplateOptions blockDeviceMappings(Iterable<BlockDeviceMapping> blockDeviceMappings); Optional<Set<String>> getFloatingIpPoolNames(); String getKeyPairName(); boolean shouldGenerateKeyPair(); byte[] getUserData(); String getDiskConfig(); boolean getConfigDrive(); Set<Network> getNovaNetworks(); String getAvailabilityZone(); Set<BlockDeviceMapping> getBlockDeviceMappings(); @Override NovaTemplateOptions blockOnPort(int port, int seconds); @Override NovaTemplateOptions inboundPorts(int... ports); @Override NovaTemplateOptions authorizePublicKey(String publicKey); @Override NovaTemplateOptions installPrivateKey(String privateKey); @Override NovaTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override NovaTemplateOptions dontAuthorizePublicKey(); @Override NovaTemplateOptions nameTask(String name); @Override NovaTemplateOptions runAsRoot(boolean runAsRoot); @Override NovaTemplateOptions runScript(Statement script); @Override NovaTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override NovaTemplateOptions overrideLoginPassword(String password); @Override NovaTemplateOptions overrideLoginPrivateKey(String privateKey); @Override NovaTemplateOptions overrideLoginUser(String loginUser); @Override NovaTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override NovaTemplateOptions userMetadata(Map<String, String> userMetadata); @Override NovaTemplateOptions userMetadata(String key, String value); @Override NovaTemplateOptions nodeNames(Iterable<String> nodeNames); @Override NovaTemplateOptions networks(Iterable<String> networks); @Override NovaTemplateOptions networks(String... networks); NovaTemplateOptions userData(byte[] userData); NovaTemplateOptions diskConfig(String diskConfig); NovaTemplateOptions configDrive(boolean configDrive); NovaTemplateOptions novaNetworks(Set<Network> novaNetworks); }
NovaTemplateOptions extends TemplateOptions implements Cloneable { @Override public NovaTemplateOptions installPrivateKey(String privateKey) { return NovaTemplateOptions.class.cast(super.installPrivateKey(privateKey)); } @Override NovaTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override ToStringHelper string(); NovaTemplateOptions autoAssignFloatingIp(boolean enable); NovaTemplateOptions floatingIpPoolNames(String... floatingIpPoolNames); NovaTemplateOptions floatingIpPoolNames(Iterable<String> floatingIpPoolNames); NovaTemplateOptions generateKeyPair(boolean enable); NovaTemplateOptions keyPairName(String keyPairName); boolean shouldAutoAssignFloatingIp(); NovaTemplateOptions availabilityZone(String availabilityZone); NovaTemplateOptions blockDeviceMappings(BlockDeviceMapping... blockDeviceMappings); NovaTemplateOptions blockDeviceMappings(Iterable<BlockDeviceMapping> blockDeviceMappings); Optional<Set<String>> getFloatingIpPoolNames(); String getKeyPairName(); boolean shouldGenerateKeyPair(); byte[] getUserData(); String getDiskConfig(); boolean getConfigDrive(); Set<Network> getNovaNetworks(); String getAvailabilityZone(); Set<BlockDeviceMapping> getBlockDeviceMappings(); @Override NovaTemplateOptions blockOnPort(int port, int seconds); @Override NovaTemplateOptions inboundPorts(int... ports); @Override NovaTemplateOptions authorizePublicKey(String publicKey); @Override NovaTemplateOptions installPrivateKey(String privateKey); @Override NovaTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override NovaTemplateOptions dontAuthorizePublicKey(); @Override NovaTemplateOptions nameTask(String name); @Override NovaTemplateOptions runAsRoot(boolean runAsRoot); @Override NovaTemplateOptions runScript(Statement script); @Override NovaTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override NovaTemplateOptions overrideLoginPassword(String password); @Override NovaTemplateOptions overrideLoginPrivateKey(String privateKey); @Override NovaTemplateOptions overrideLoginUser(String loginUser); @Override NovaTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override NovaTemplateOptions userMetadata(Map<String, String> userMetadata); @Override NovaTemplateOptions userMetadata(String key, String value); @Override NovaTemplateOptions nodeNames(Iterable<String> nodeNames); @Override NovaTemplateOptions networks(Iterable<String> networks); @Override NovaTemplateOptions networks(String... networks); NovaTemplateOptions userData(byte[] userData); NovaTemplateOptions diskConfig(String diskConfig); NovaTemplateOptions configDrive(boolean configDrive); NovaTemplateOptions novaNetworks(Set<Network> novaNetworks); }
@Test public void testinstallPrivateKeyStatic() throws IOException { NovaTemplateOptions options = installPrivateKey("-----BEGIN RSA PRIVATE KEY-----"); assertEquals(options.getPrivateKey(), "-----BEGIN RSA PRIVATE KEY-----"); }
@Override public NovaTemplateOptions installPrivateKey(String privateKey) { return NovaTemplateOptions.class.cast(super.installPrivateKey(privateKey)); }
NovaTemplateOptions extends TemplateOptions implements Cloneable { @Override public NovaTemplateOptions installPrivateKey(String privateKey) { return NovaTemplateOptions.class.cast(super.installPrivateKey(privateKey)); } }
NovaTemplateOptions extends TemplateOptions implements Cloneable { @Override public NovaTemplateOptions installPrivateKey(String privateKey) { return NovaTemplateOptions.class.cast(super.installPrivateKey(privateKey)); } }
NovaTemplateOptions extends TemplateOptions implements Cloneable { @Override public NovaTemplateOptions installPrivateKey(String privateKey) { return NovaTemplateOptions.class.cast(super.installPrivateKey(privateKey)); } @Override NovaTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override ToStringHelper string(); NovaTemplateOptions autoAssignFloatingIp(boolean enable); NovaTemplateOptions floatingIpPoolNames(String... floatingIpPoolNames); NovaTemplateOptions floatingIpPoolNames(Iterable<String> floatingIpPoolNames); NovaTemplateOptions generateKeyPair(boolean enable); NovaTemplateOptions keyPairName(String keyPairName); boolean shouldAutoAssignFloatingIp(); NovaTemplateOptions availabilityZone(String availabilityZone); NovaTemplateOptions blockDeviceMappings(BlockDeviceMapping... blockDeviceMappings); NovaTemplateOptions blockDeviceMappings(Iterable<BlockDeviceMapping> blockDeviceMappings); Optional<Set<String>> getFloatingIpPoolNames(); String getKeyPairName(); boolean shouldGenerateKeyPair(); byte[] getUserData(); String getDiskConfig(); boolean getConfigDrive(); Set<Network> getNovaNetworks(); String getAvailabilityZone(); Set<BlockDeviceMapping> getBlockDeviceMappings(); @Override NovaTemplateOptions blockOnPort(int port, int seconds); @Override NovaTemplateOptions inboundPorts(int... ports); @Override NovaTemplateOptions authorizePublicKey(String publicKey); @Override NovaTemplateOptions installPrivateKey(String privateKey); @Override NovaTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override NovaTemplateOptions dontAuthorizePublicKey(); @Override NovaTemplateOptions nameTask(String name); @Override NovaTemplateOptions runAsRoot(boolean runAsRoot); @Override NovaTemplateOptions runScript(Statement script); @Override NovaTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override NovaTemplateOptions overrideLoginPassword(String password); @Override NovaTemplateOptions overrideLoginPrivateKey(String privateKey); @Override NovaTemplateOptions overrideLoginUser(String loginUser); @Override NovaTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override NovaTemplateOptions userMetadata(Map<String, String> userMetadata); @Override NovaTemplateOptions userMetadata(String key, String value); @Override NovaTemplateOptions nodeNames(Iterable<String> nodeNames); @Override NovaTemplateOptions networks(Iterable<String> networks); @Override NovaTemplateOptions networks(String... networks); NovaTemplateOptions userData(byte[] userData); NovaTemplateOptions diskConfig(String diskConfig); NovaTemplateOptions configDrive(boolean configDrive); NovaTemplateOptions novaNetworks(Set<Network> novaNetworks); }
NovaTemplateOptions extends TemplateOptions implements Cloneable { @Override public NovaTemplateOptions installPrivateKey(String privateKey) { return NovaTemplateOptions.class.cast(super.installPrivateKey(privateKey)); } @Override NovaTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override ToStringHelper string(); NovaTemplateOptions autoAssignFloatingIp(boolean enable); NovaTemplateOptions floatingIpPoolNames(String... floatingIpPoolNames); NovaTemplateOptions floatingIpPoolNames(Iterable<String> floatingIpPoolNames); NovaTemplateOptions generateKeyPair(boolean enable); NovaTemplateOptions keyPairName(String keyPairName); boolean shouldAutoAssignFloatingIp(); NovaTemplateOptions availabilityZone(String availabilityZone); NovaTemplateOptions blockDeviceMappings(BlockDeviceMapping... blockDeviceMappings); NovaTemplateOptions blockDeviceMappings(Iterable<BlockDeviceMapping> blockDeviceMappings); Optional<Set<String>> getFloatingIpPoolNames(); String getKeyPairName(); boolean shouldGenerateKeyPair(); byte[] getUserData(); String getDiskConfig(); boolean getConfigDrive(); Set<Network> getNovaNetworks(); String getAvailabilityZone(); Set<BlockDeviceMapping> getBlockDeviceMappings(); @Override NovaTemplateOptions blockOnPort(int port, int seconds); @Override NovaTemplateOptions inboundPorts(int... ports); @Override NovaTemplateOptions authorizePublicKey(String publicKey); @Override NovaTemplateOptions installPrivateKey(String privateKey); @Override NovaTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override NovaTemplateOptions dontAuthorizePublicKey(); @Override NovaTemplateOptions nameTask(String name); @Override NovaTemplateOptions runAsRoot(boolean runAsRoot); @Override NovaTemplateOptions runScript(Statement script); @Override NovaTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override NovaTemplateOptions overrideLoginPassword(String password); @Override NovaTemplateOptions overrideLoginPrivateKey(String privateKey); @Override NovaTemplateOptions overrideLoginUser(String loginUser); @Override NovaTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override NovaTemplateOptions userMetadata(Map<String, String> userMetadata); @Override NovaTemplateOptions userMetadata(String key, String value); @Override NovaTemplateOptions nodeNames(Iterable<String> nodeNames); @Override NovaTemplateOptions networks(Iterable<String> networks); @Override NovaTemplateOptions networks(String... networks); NovaTemplateOptions userData(byte[] userData); NovaTemplateOptions diskConfig(String diskConfig); NovaTemplateOptions configDrive(boolean configDrive); NovaTemplateOptions novaNetworks(Set<Network> novaNetworks); }
@Test(expectedExceptions = NullPointerException.class) public void testinstallPrivateKeyNPE() { installPrivateKey(null); }
@Override public NovaTemplateOptions installPrivateKey(String privateKey) { return NovaTemplateOptions.class.cast(super.installPrivateKey(privateKey)); }
NovaTemplateOptions extends TemplateOptions implements Cloneable { @Override public NovaTemplateOptions installPrivateKey(String privateKey) { return NovaTemplateOptions.class.cast(super.installPrivateKey(privateKey)); } }
NovaTemplateOptions extends TemplateOptions implements Cloneable { @Override public NovaTemplateOptions installPrivateKey(String privateKey) { return NovaTemplateOptions.class.cast(super.installPrivateKey(privateKey)); } }
NovaTemplateOptions extends TemplateOptions implements Cloneable { @Override public NovaTemplateOptions installPrivateKey(String privateKey) { return NovaTemplateOptions.class.cast(super.installPrivateKey(privateKey)); } @Override NovaTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override ToStringHelper string(); NovaTemplateOptions autoAssignFloatingIp(boolean enable); NovaTemplateOptions floatingIpPoolNames(String... floatingIpPoolNames); NovaTemplateOptions floatingIpPoolNames(Iterable<String> floatingIpPoolNames); NovaTemplateOptions generateKeyPair(boolean enable); NovaTemplateOptions keyPairName(String keyPairName); boolean shouldAutoAssignFloatingIp(); NovaTemplateOptions availabilityZone(String availabilityZone); NovaTemplateOptions blockDeviceMappings(BlockDeviceMapping... blockDeviceMappings); NovaTemplateOptions blockDeviceMappings(Iterable<BlockDeviceMapping> blockDeviceMappings); Optional<Set<String>> getFloatingIpPoolNames(); String getKeyPairName(); boolean shouldGenerateKeyPair(); byte[] getUserData(); String getDiskConfig(); boolean getConfigDrive(); Set<Network> getNovaNetworks(); String getAvailabilityZone(); Set<BlockDeviceMapping> getBlockDeviceMappings(); @Override NovaTemplateOptions blockOnPort(int port, int seconds); @Override NovaTemplateOptions inboundPorts(int... ports); @Override NovaTemplateOptions authorizePublicKey(String publicKey); @Override NovaTemplateOptions installPrivateKey(String privateKey); @Override NovaTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override NovaTemplateOptions dontAuthorizePublicKey(); @Override NovaTemplateOptions nameTask(String name); @Override NovaTemplateOptions runAsRoot(boolean runAsRoot); @Override NovaTemplateOptions runScript(Statement script); @Override NovaTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override NovaTemplateOptions overrideLoginPassword(String password); @Override NovaTemplateOptions overrideLoginPrivateKey(String privateKey); @Override NovaTemplateOptions overrideLoginUser(String loginUser); @Override NovaTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override NovaTemplateOptions userMetadata(Map<String, String> userMetadata); @Override NovaTemplateOptions userMetadata(String key, String value); @Override NovaTemplateOptions nodeNames(Iterable<String> nodeNames); @Override NovaTemplateOptions networks(Iterable<String> networks); @Override NovaTemplateOptions networks(String... networks); NovaTemplateOptions userData(byte[] userData); NovaTemplateOptions diskConfig(String diskConfig); NovaTemplateOptions configDrive(boolean configDrive); NovaTemplateOptions novaNetworks(Set<Network> novaNetworks); }
NovaTemplateOptions extends TemplateOptions implements Cloneable { @Override public NovaTemplateOptions installPrivateKey(String privateKey) { return NovaTemplateOptions.class.cast(super.installPrivateKey(privateKey)); } @Override NovaTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override ToStringHelper string(); NovaTemplateOptions autoAssignFloatingIp(boolean enable); NovaTemplateOptions floatingIpPoolNames(String... floatingIpPoolNames); NovaTemplateOptions floatingIpPoolNames(Iterable<String> floatingIpPoolNames); NovaTemplateOptions generateKeyPair(boolean enable); NovaTemplateOptions keyPairName(String keyPairName); boolean shouldAutoAssignFloatingIp(); NovaTemplateOptions availabilityZone(String availabilityZone); NovaTemplateOptions blockDeviceMappings(BlockDeviceMapping... blockDeviceMappings); NovaTemplateOptions blockDeviceMappings(Iterable<BlockDeviceMapping> blockDeviceMappings); Optional<Set<String>> getFloatingIpPoolNames(); String getKeyPairName(); boolean shouldGenerateKeyPair(); byte[] getUserData(); String getDiskConfig(); boolean getConfigDrive(); Set<Network> getNovaNetworks(); String getAvailabilityZone(); Set<BlockDeviceMapping> getBlockDeviceMappings(); @Override NovaTemplateOptions blockOnPort(int port, int seconds); @Override NovaTemplateOptions inboundPorts(int... ports); @Override NovaTemplateOptions authorizePublicKey(String publicKey); @Override NovaTemplateOptions installPrivateKey(String privateKey); @Override NovaTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override NovaTemplateOptions dontAuthorizePublicKey(); @Override NovaTemplateOptions nameTask(String name); @Override NovaTemplateOptions runAsRoot(boolean runAsRoot); @Override NovaTemplateOptions runScript(Statement script); @Override NovaTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override NovaTemplateOptions overrideLoginPassword(String password); @Override NovaTemplateOptions overrideLoginPrivateKey(String privateKey); @Override NovaTemplateOptions overrideLoginUser(String loginUser); @Override NovaTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override NovaTemplateOptions userMetadata(Map<String, String> userMetadata); @Override NovaTemplateOptions userMetadata(String key, String value); @Override NovaTemplateOptions nodeNames(Iterable<String> nodeNames); @Override NovaTemplateOptions networks(Iterable<String> networks); @Override NovaTemplateOptions networks(String... networks); NovaTemplateOptions userData(byte[] userData); NovaTemplateOptions diskConfig(String diskConfig); NovaTemplateOptions configDrive(boolean configDrive); NovaTemplateOptions novaNetworks(Set<Network> novaNetworks); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testauthorizePublicKeyBadFormat() { NovaTemplateOptions options = new NovaTemplateOptions(); options.authorizePublicKey("whompy"); }
@Override public NovaTemplateOptions authorizePublicKey(String publicKey) { return NovaTemplateOptions.class.cast(super.authorizePublicKey(publicKey)); }
NovaTemplateOptions extends TemplateOptions implements Cloneable { @Override public NovaTemplateOptions authorizePublicKey(String publicKey) { return NovaTemplateOptions.class.cast(super.authorizePublicKey(publicKey)); } }
NovaTemplateOptions extends TemplateOptions implements Cloneable { @Override public NovaTemplateOptions authorizePublicKey(String publicKey) { return NovaTemplateOptions.class.cast(super.authorizePublicKey(publicKey)); } }
NovaTemplateOptions extends TemplateOptions implements Cloneable { @Override public NovaTemplateOptions authorizePublicKey(String publicKey) { return NovaTemplateOptions.class.cast(super.authorizePublicKey(publicKey)); } @Override NovaTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override ToStringHelper string(); NovaTemplateOptions autoAssignFloatingIp(boolean enable); NovaTemplateOptions floatingIpPoolNames(String... floatingIpPoolNames); NovaTemplateOptions floatingIpPoolNames(Iterable<String> floatingIpPoolNames); NovaTemplateOptions generateKeyPair(boolean enable); NovaTemplateOptions keyPairName(String keyPairName); boolean shouldAutoAssignFloatingIp(); NovaTemplateOptions availabilityZone(String availabilityZone); NovaTemplateOptions blockDeviceMappings(BlockDeviceMapping... blockDeviceMappings); NovaTemplateOptions blockDeviceMappings(Iterable<BlockDeviceMapping> blockDeviceMappings); Optional<Set<String>> getFloatingIpPoolNames(); String getKeyPairName(); boolean shouldGenerateKeyPair(); byte[] getUserData(); String getDiskConfig(); boolean getConfigDrive(); Set<Network> getNovaNetworks(); String getAvailabilityZone(); Set<BlockDeviceMapping> getBlockDeviceMappings(); @Override NovaTemplateOptions blockOnPort(int port, int seconds); @Override NovaTemplateOptions inboundPorts(int... ports); @Override NovaTemplateOptions authorizePublicKey(String publicKey); @Override NovaTemplateOptions installPrivateKey(String privateKey); @Override NovaTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override NovaTemplateOptions dontAuthorizePublicKey(); @Override NovaTemplateOptions nameTask(String name); @Override NovaTemplateOptions runAsRoot(boolean runAsRoot); @Override NovaTemplateOptions runScript(Statement script); @Override NovaTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override NovaTemplateOptions overrideLoginPassword(String password); @Override NovaTemplateOptions overrideLoginPrivateKey(String privateKey); @Override NovaTemplateOptions overrideLoginUser(String loginUser); @Override NovaTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override NovaTemplateOptions userMetadata(Map<String, String> userMetadata); @Override NovaTemplateOptions userMetadata(String key, String value); @Override NovaTemplateOptions nodeNames(Iterable<String> nodeNames); @Override NovaTemplateOptions networks(Iterable<String> networks); @Override NovaTemplateOptions networks(String... networks); NovaTemplateOptions userData(byte[] userData); NovaTemplateOptions diskConfig(String diskConfig); NovaTemplateOptions configDrive(boolean configDrive); NovaTemplateOptions novaNetworks(Set<Network> novaNetworks); }
NovaTemplateOptions extends TemplateOptions implements Cloneable { @Override public NovaTemplateOptions authorizePublicKey(String publicKey) { return NovaTemplateOptions.class.cast(super.authorizePublicKey(publicKey)); } @Override NovaTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override ToStringHelper string(); NovaTemplateOptions autoAssignFloatingIp(boolean enable); NovaTemplateOptions floatingIpPoolNames(String... floatingIpPoolNames); NovaTemplateOptions floatingIpPoolNames(Iterable<String> floatingIpPoolNames); NovaTemplateOptions generateKeyPair(boolean enable); NovaTemplateOptions keyPairName(String keyPairName); boolean shouldAutoAssignFloatingIp(); NovaTemplateOptions availabilityZone(String availabilityZone); NovaTemplateOptions blockDeviceMappings(BlockDeviceMapping... blockDeviceMappings); NovaTemplateOptions blockDeviceMappings(Iterable<BlockDeviceMapping> blockDeviceMappings); Optional<Set<String>> getFloatingIpPoolNames(); String getKeyPairName(); boolean shouldGenerateKeyPair(); byte[] getUserData(); String getDiskConfig(); boolean getConfigDrive(); Set<Network> getNovaNetworks(); String getAvailabilityZone(); Set<BlockDeviceMapping> getBlockDeviceMappings(); @Override NovaTemplateOptions blockOnPort(int port, int seconds); @Override NovaTemplateOptions inboundPorts(int... ports); @Override NovaTemplateOptions authorizePublicKey(String publicKey); @Override NovaTemplateOptions installPrivateKey(String privateKey); @Override NovaTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override NovaTemplateOptions dontAuthorizePublicKey(); @Override NovaTemplateOptions nameTask(String name); @Override NovaTemplateOptions runAsRoot(boolean runAsRoot); @Override NovaTemplateOptions runScript(Statement script); @Override NovaTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override NovaTemplateOptions overrideLoginPassword(String password); @Override NovaTemplateOptions overrideLoginPrivateKey(String privateKey); @Override NovaTemplateOptions overrideLoginUser(String loginUser); @Override NovaTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override NovaTemplateOptions userMetadata(Map<String, String> userMetadata); @Override NovaTemplateOptions userMetadata(String key, String value); @Override NovaTemplateOptions nodeNames(Iterable<String> nodeNames); @Override NovaTemplateOptions networks(Iterable<String> networks); @Override NovaTemplateOptions networks(String... networks); NovaTemplateOptions userData(byte[] userData); NovaTemplateOptions diskConfig(String diskConfig); NovaTemplateOptions configDrive(boolean configDrive); NovaTemplateOptions novaNetworks(Set<Network> novaNetworks); }
@Test public void testauthorizePublicKey() throws IOException { NovaTemplateOptions options = new NovaTemplateOptions(); options.authorizePublicKey("ssh-rsa"); assertEquals(options.getPublicKey(), "ssh-rsa"); }
@Override public NovaTemplateOptions authorizePublicKey(String publicKey) { return NovaTemplateOptions.class.cast(super.authorizePublicKey(publicKey)); }
NovaTemplateOptions extends TemplateOptions implements Cloneable { @Override public NovaTemplateOptions authorizePublicKey(String publicKey) { return NovaTemplateOptions.class.cast(super.authorizePublicKey(publicKey)); } }
NovaTemplateOptions extends TemplateOptions implements Cloneable { @Override public NovaTemplateOptions authorizePublicKey(String publicKey) { return NovaTemplateOptions.class.cast(super.authorizePublicKey(publicKey)); } }
NovaTemplateOptions extends TemplateOptions implements Cloneable { @Override public NovaTemplateOptions authorizePublicKey(String publicKey) { return NovaTemplateOptions.class.cast(super.authorizePublicKey(publicKey)); } @Override NovaTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override ToStringHelper string(); NovaTemplateOptions autoAssignFloatingIp(boolean enable); NovaTemplateOptions floatingIpPoolNames(String... floatingIpPoolNames); NovaTemplateOptions floatingIpPoolNames(Iterable<String> floatingIpPoolNames); NovaTemplateOptions generateKeyPair(boolean enable); NovaTemplateOptions keyPairName(String keyPairName); boolean shouldAutoAssignFloatingIp(); NovaTemplateOptions availabilityZone(String availabilityZone); NovaTemplateOptions blockDeviceMappings(BlockDeviceMapping... blockDeviceMappings); NovaTemplateOptions blockDeviceMappings(Iterable<BlockDeviceMapping> blockDeviceMappings); Optional<Set<String>> getFloatingIpPoolNames(); String getKeyPairName(); boolean shouldGenerateKeyPair(); byte[] getUserData(); String getDiskConfig(); boolean getConfigDrive(); Set<Network> getNovaNetworks(); String getAvailabilityZone(); Set<BlockDeviceMapping> getBlockDeviceMappings(); @Override NovaTemplateOptions blockOnPort(int port, int seconds); @Override NovaTemplateOptions inboundPorts(int... ports); @Override NovaTemplateOptions authorizePublicKey(String publicKey); @Override NovaTemplateOptions installPrivateKey(String privateKey); @Override NovaTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override NovaTemplateOptions dontAuthorizePublicKey(); @Override NovaTemplateOptions nameTask(String name); @Override NovaTemplateOptions runAsRoot(boolean runAsRoot); @Override NovaTemplateOptions runScript(Statement script); @Override NovaTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override NovaTemplateOptions overrideLoginPassword(String password); @Override NovaTemplateOptions overrideLoginPrivateKey(String privateKey); @Override NovaTemplateOptions overrideLoginUser(String loginUser); @Override NovaTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override NovaTemplateOptions userMetadata(Map<String, String> userMetadata); @Override NovaTemplateOptions userMetadata(String key, String value); @Override NovaTemplateOptions nodeNames(Iterable<String> nodeNames); @Override NovaTemplateOptions networks(Iterable<String> networks); @Override NovaTemplateOptions networks(String... networks); NovaTemplateOptions userData(byte[] userData); NovaTemplateOptions diskConfig(String diskConfig); NovaTemplateOptions configDrive(boolean configDrive); NovaTemplateOptions novaNetworks(Set<Network> novaNetworks); }
NovaTemplateOptions extends TemplateOptions implements Cloneable { @Override public NovaTemplateOptions authorizePublicKey(String publicKey) { return NovaTemplateOptions.class.cast(super.authorizePublicKey(publicKey)); } @Override NovaTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override ToStringHelper string(); NovaTemplateOptions autoAssignFloatingIp(boolean enable); NovaTemplateOptions floatingIpPoolNames(String... floatingIpPoolNames); NovaTemplateOptions floatingIpPoolNames(Iterable<String> floatingIpPoolNames); NovaTemplateOptions generateKeyPair(boolean enable); NovaTemplateOptions keyPairName(String keyPairName); boolean shouldAutoAssignFloatingIp(); NovaTemplateOptions availabilityZone(String availabilityZone); NovaTemplateOptions blockDeviceMappings(BlockDeviceMapping... blockDeviceMappings); NovaTemplateOptions blockDeviceMappings(Iterable<BlockDeviceMapping> blockDeviceMappings); Optional<Set<String>> getFloatingIpPoolNames(); String getKeyPairName(); boolean shouldGenerateKeyPair(); byte[] getUserData(); String getDiskConfig(); boolean getConfigDrive(); Set<Network> getNovaNetworks(); String getAvailabilityZone(); Set<BlockDeviceMapping> getBlockDeviceMappings(); @Override NovaTemplateOptions blockOnPort(int port, int seconds); @Override NovaTemplateOptions inboundPorts(int... ports); @Override NovaTemplateOptions authorizePublicKey(String publicKey); @Override NovaTemplateOptions installPrivateKey(String privateKey); @Override NovaTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override NovaTemplateOptions dontAuthorizePublicKey(); @Override NovaTemplateOptions nameTask(String name); @Override NovaTemplateOptions runAsRoot(boolean runAsRoot); @Override NovaTemplateOptions runScript(Statement script); @Override NovaTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override NovaTemplateOptions overrideLoginPassword(String password); @Override NovaTemplateOptions overrideLoginPrivateKey(String privateKey); @Override NovaTemplateOptions overrideLoginUser(String loginUser); @Override NovaTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override NovaTemplateOptions userMetadata(Map<String, String> userMetadata); @Override NovaTemplateOptions userMetadata(String key, String value); @Override NovaTemplateOptions nodeNames(Iterable<String> nodeNames); @Override NovaTemplateOptions networks(Iterable<String> networks); @Override NovaTemplateOptions networks(String... networks); NovaTemplateOptions userData(byte[] userData); NovaTemplateOptions diskConfig(String diskConfig); NovaTemplateOptions configDrive(boolean configDrive); NovaTemplateOptions novaNetworks(Set<Network> novaNetworks); }
@Test public void testCreatePayload() { CreateDataCenterRequestBinder binder = new CreateDataCenterRequestBinder(); DataCenter.Request.CreatePayload payload = DataCenter.Request.creatingPayload("JClouds-DC", Location.DE_FKB); String actual = binder.createPayload(payload); assertNotNull(actual, "Binder returned null payload"); assertEquals(actual, expectedPayload); }
@Override protected String createPayload(DataCenter.Request.CreatePayload payload) { requestBuilder.append("<ws:createDataCenter>") .append("<request>") .append(format("<dataCenterName>%s</dataCenterName>", payload.name())) .append(format("<location>%s</location>", payload.location().getId())) .append("</request>") .append("</ws:createDataCenter>"); return requestBuilder.toString(); }
CreateDataCenterRequestBinder extends BaseProfitBricksRequestBinder<DataCenter.Request.CreatePayload> { @Override protected String createPayload(DataCenter.Request.CreatePayload payload) { requestBuilder.append("<ws:createDataCenter>") .append("<request>") .append(format("<dataCenterName>%s</dataCenterName>", payload.name())) .append(format("<location>%s</location>", payload.location().getId())) .append("</request>") .append("</ws:createDataCenter>"); return requestBuilder.toString(); } }
CreateDataCenterRequestBinder extends BaseProfitBricksRequestBinder<DataCenter.Request.CreatePayload> { @Override protected String createPayload(DataCenter.Request.CreatePayload payload) { requestBuilder.append("<ws:createDataCenter>") .append("<request>") .append(format("<dataCenterName>%s</dataCenterName>", payload.name())) .append(format("<location>%s</location>", payload.location().getId())) .append("</request>") .append("</ws:createDataCenter>"); return requestBuilder.toString(); } CreateDataCenterRequestBinder(); }
CreateDataCenterRequestBinder extends BaseProfitBricksRequestBinder<DataCenter.Request.CreatePayload> { @Override protected String createPayload(DataCenter.Request.CreatePayload payload) { requestBuilder.append("<ws:createDataCenter>") .append("<request>") .append(format("<dataCenterName>%s</dataCenterName>", payload.name())) .append(format("<location>%s</location>", payload.location().getId())) .append("</request>") .append("</ws:createDataCenter>"); return requestBuilder.toString(); } CreateDataCenterRequestBinder(); }
CreateDataCenterRequestBinder extends BaseProfitBricksRequestBinder<DataCenter.Request.CreatePayload> { @Override protected String createPayload(DataCenter.Request.CreatePayload payload) { requestBuilder.append("<ws:createDataCenter>") .append("<request>") .append(format("<dataCenterName>%s</dataCenterName>", payload.name())) .append(format("<location>%s</location>", payload.location().getId())) .append("</request>") .append("</ws:createDataCenter>"); return requestBuilder.toString(); } CreateDataCenterRequestBinder(); }
@Test public void testauthorizePublicKeyStatic() throws IOException { NovaTemplateOptions options = authorizePublicKey("ssh-rsa"); assertEquals(options.getPublicKey(), "ssh-rsa"); }
@Override public NovaTemplateOptions authorizePublicKey(String publicKey) { return NovaTemplateOptions.class.cast(super.authorizePublicKey(publicKey)); }
NovaTemplateOptions extends TemplateOptions implements Cloneable { @Override public NovaTemplateOptions authorizePublicKey(String publicKey) { return NovaTemplateOptions.class.cast(super.authorizePublicKey(publicKey)); } }
NovaTemplateOptions extends TemplateOptions implements Cloneable { @Override public NovaTemplateOptions authorizePublicKey(String publicKey) { return NovaTemplateOptions.class.cast(super.authorizePublicKey(publicKey)); } }
NovaTemplateOptions extends TemplateOptions implements Cloneable { @Override public NovaTemplateOptions authorizePublicKey(String publicKey) { return NovaTemplateOptions.class.cast(super.authorizePublicKey(publicKey)); } @Override NovaTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override ToStringHelper string(); NovaTemplateOptions autoAssignFloatingIp(boolean enable); NovaTemplateOptions floatingIpPoolNames(String... floatingIpPoolNames); NovaTemplateOptions floatingIpPoolNames(Iterable<String> floatingIpPoolNames); NovaTemplateOptions generateKeyPair(boolean enable); NovaTemplateOptions keyPairName(String keyPairName); boolean shouldAutoAssignFloatingIp(); NovaTemplateOptions availabilityZone(String availabilityZone); NovaTemplateOptions blockDeviceMappings(BlockDeviceMapping... blockDeviceMappings); NovaTemplateOptions blockDeviceMappings(Iterable<BlockDeviceMapping> blockDeviceMappings); Optional<Set<String>> getFloatingIpPoolNames(); String getKeyPairName(); boolean shouldGenerateKeyPair(); byte[] getUserData(); String getDiskConfig(); boolean getConfigDrive(); Set<Network> getNovaNetworks(); String getAvailabilityZone(); Set<BlockDeviceMapping> getBlockDeviceMappings(); @Override NovaTemplateOptions blockOnPort(int port, int seconds); @Override NovaTemplateOptions inboundPorts(int... ports); @Override NovaTemplateOptions authorizePublicKey(String publicKey); @Override NovaTemplateOptions installPrivateKey(String privateKey); @Override NovaTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override NovaTemplateOptions dontAuthorizePublicKey(); @Override NovaTemplateOptions nameTask(String name); @Override NovaTemplateOptions runAsRoot(boolean runAsRoot); @Override NovaTemplateOptions runScript(Statement script); @Override NovaTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override NovaTemplateOptions overrideLoginPassword(String password); @Override NovaTemplateOptions overrideLoginPrivateKey(String privateKey); @Override NovaTemplateOptions overrideLoginUser(String loginUser); @Override NovaTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override NovaTemplateOptions userMetadata(Map<String, String> userMetadata); @Override NovaTemplateOptions userMetadata(String key, String value); @Override NovaTemplateOptions nodeNames(Iterable<String> nodeNames); @Override NovaTemplateOptions networks(Iterable<String> networks); @Override NovaTemplateOptions networks(String... networks); NovaTemplateOptions userData(byte[] userData); NovaTemplateOptions diskConfig(String diskConfig); NovaTemplateOptions configDrive(boolean configDrive); NovaTemplateOptions novaNetworks(Set<Network> novaNetworks); }
NovaTemplateOptions extends TemplateOptions implements Cloneable { @Override public NovaTemplateOptions authorizePublicKey(String publicKey) { return NovaTemplateOptions.class.cast(super.authorizePublicKey(publicKey)); } @Override NovaTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override ToStringHelper string(); NovaTemplateOptions autoAssignFloatingIp(boolean enable); NovaTemplateOptions floatingIpPoolNames(String... floatingIpPoolNames); NovaTemplateOptions floatingIpPoolNames(Iterable<String> floatingIpPoolNames); NovaTemplateOptions generateKeyPair(boolean enable); NovaTemplateOptions keyPairName(String keyPairName); boolean shouldAutoAssignFloatingIp(); NovaTemplateOptions availabilityZone(String availabilityZone); NovaTemplateOptions blockDeviceMappings(BlockDeviceMapping... blockDeviceMappings); NovaTemplateOptions blockDeviceMappings(Iterable<BlockDeviceMapping> blockDeviceMappings); Optional<Set<String>> getFloatingIpPoolNames(); String getKeyPairName(); boolean shouldGenerateKeyPair(); byte[] getUserData(); String getDiskConfig(); boolean getConfigDrive(); Set<Network> getNovaNetworks(); String getAvailabilityZone(); Set<BlockDeviceMapping> getBlockDeviceMappings(); @Override NovaTemplateOptions blockOnPort(int port, int seconds); @Override NovaTemplateOptions inboundPorts(int... ports); @Override NovaTemplateOptions authorizePublicKey(String publicKey); @Override NovaTemplateOptions installPrivateKey(String privateKey); @Override NovaTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override NovaTemplateOptions dontAuthorizePublicKey(); @Override NovaTemplateOptions nameTask(String name); @Override NovaTemplateOptions runAsRoot(boolean runAsRoot); @Override NovaTemplateOptions runScript(Statement script); @Override NovaTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override NovaTemplateOptions overrideLoginPassword(String password); @Override NovaTemplateOptions overrideLoginPrivateKey(String privateKey); @Override NovaTemplateOptions overrideLoginUser(String loginUser); @Override NovaTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override NovaTemplateOptions userMetadata(Map<String, String> userMetadata); @Override NovaTemplateOptions userMetadata(String key, String value); @Override NovaTemplateOptions nodeNames(Iterable<String> nodeNames); @Override NovaTemplateOptions networks(Iterable<String> networks); @Override NovaTemplateOptions networks(String... networks); NovaTemplateOptions userData(byte[] userData); NovaTemplateOptions diskConfig(String diskConfig); NovaTemplateOptions configDrive(boolean configDrive); NovaTemplateOptions novaNetworks(Set<Network> novaNetworks); }
@Test(expectedExceptions = NullPointerException.class) public void testauthorizePublicKeyNPE() { authorizePublicKey(null); }
@Override public NovaTemplateOptions authorizePublicKey(String publicKey) { return NovaTemplateOptions.class.cast(super.authorizePublicKey(publicKey)); }
NovaTemplateOptions extends TemplateOptions implements Cloneable { @Override public NovaTemplateOptions authorizePublicKey(String publicKey) { return NovaTemplateOptions.class.cast(super.authorizePublicKey(publicKey)); } }
NovaTemplateOptions extends TemplateOptions implements Cloneable { @Override public NovaTemplateOptions authorizePublicKey(String publicKey) { return NovaTemplateOptions.class.cast(super.authorizePublicKey(publicKey)); } }
NovaTemplateOptions extends TemplateOptions implements Cloneable { @Override public NovaTemplateOptions authorizePublicKey(String publicKey) { return NovaTemplateOptions.class.cast(super.authorizePublicKey(publicKey)); } @Override NovaTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override ToStringHelper string(); NovaTemplateOptions autoAssignFloatingIp(boolean enable); NovaTemplateOptions floatingIpPoolNames(String... floatingIpPoolNames); NovaTemplateOptions floatingIpPoolNames(Iterable<String> floatingIpPoolNames); NovaTemplateOptions generateKeyPair(boolean enable); NovaTemplateOptions keyPairName(String keyPairName); boolean shouldAutoAssignFloatingIp(); NovaTemplateOptions availabilityZone(String availabilityZone); NovaTemplateOptions blockDeviceMappings(BlockDeviceMapping... blockDeviceMappings); NovaTemplateOptions blockDeviceMappings(Iterable<BlockDeviceMapping> blockDeviceMappings); Optional<Set<String>> getFloatingIpPoolNames(); String getKeyPairName(); boolean shouldGenerateKeyPair(); byte[] getUserData(); String getDiskConfig(); boolean getConfigDrive(); Set<Network> getNovaNetworks(); String getAvailabilityZone(); Set<BlockDeviceMapping> getBlockDeviceMappings(); @Override NovaTemplateOptions blockOnPort(int port, int seconds); @Override NovaTemplateOptions inboundPorts(int... ports); @Override NovaTemplateOptions authorizePublicKey(String publicKey); @Override NovaTemplateOptions installPrivateKey(String privateKey); @Override NovaTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override NovaTemplateOptions dontAuthorizePublicKey(); @Override NovaTemplateOptions nameTask(String name); @Override NovaTemplateOptions runAsRoot(boolean runAsRoot); @Override NovaTemplateOptions runScript(Statement script); @Override NovaTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override NovaTemplateOptions overrideLoginPassword(String password); @Override NovaTemplateOptions overrideLoginPrivateKey(String privateKey); @Override NovaTemplateOptions overrideLoginUser(String loginUser); @Override NovaTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override NovaTemplateOptions userMetadata(Map<String, String> userMetadata); @Override NovaTemplateOptions userMetadata(String key, String value); @Override NovaTemplateOptions nodeNames(Iterable<String> nodeNames); @Override NovaTemplateOptions networks(Iterable<String> networks); @Override NovaTemplateOptions networks(String... networks); NovaTemplateOptions userData(byte[] userData); NovaTemplateOptions diskConfig(String diskConfig); NovaTemplateOptions configDrive(boolean configDrive); NovaTemplateOptions novaNetworks(Set<Network> novaNetworks); }
NovaTemplateOptions extends TemplateOptions implements Cloneable { @Override public NovaTemplateOptions authorizePublicKey(String publicKey) { return NovaTemplateOptions.class.cast(super.authorizePublicKey(publicKey)); } @Override NovaTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override ToStringHelper string(); NovaTemplateOptions autoAssignFloatingIp(boolean enable); NovaTemplateOptions floatingIpPoolNames(String... floatingIpPoolNames); NovaTemplateOptions floatingIpPoolNames(Iterable<String> floatingIpPoolNames); NovaTemplateOptions generateKeyPair(boolean enable); NovaTemplateOptions keyPairName(String keyPairName); boolean shouldAutoAssignFloatingIp(); NovaTemplateOptions availabilityZone(String availabilityZone); NovaTemplateOptions blockDeviceMappings(BlockDeviceMapping... blockDeviceMappings); NovaTemplateOptions blockDeviceMappings(Iterable<BlockDeviceMapping> blockDeviceMappings); Optional<Set<String>> getFloatingIpPoolNames(); String getKeyPairName(); boolean shouldGenerateKeyPair(); byte[] getUserData(); String getDiskConfig(); boolean getConfigDrive(); Set<Network> getNovaNetworks(); String getAvailabilityZone(); Set<BlockDeviceMapping> getBlockDeviceMappings(); @Override NovaTemplateOptions blockOnPort(int port, int seconds); @Override NovaTemplateOptions inboundPorts(int... ports); @Override NovaTemplateOptions authorizePublicKey(String publicKey); @Override NovaTemplateOptions installPrivateKey(String privateKey); @Override NovaTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override NovaTemplateOptions dontAuthorizePublicKey(); @Override NovaTemplateOptions nameTask(String name); @Override NovaTemplateOptions runAsRoot(boolean runAsRoot); @Override NovaTemplateOptions runScript(Statement script); @Override NovaTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override NovaTemplateOptions overrideLoginPassword(String password); @Override NovaTemplateOptions overrideLoginPrivateKey(String privateKey); @Override NovaTemplateOptions overrideLoginUser(String loginUser); @Override NovaTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override NovaTemplateOptions userMetadata(Map<String, String> userMetadata); @Override NovaTemplateOptions userMetadata(String key, String value); @Override NovaTemplateOptions nodeNames(Iterable<String> nodeNames); @Override NovaTemplateOptions networks(Iterable<String> networks); @Override NovaTemplateOptions networks(String... networks); NovaTemplateOptions userData(byte[] userData); NovaTemplateOptions diskConfig(String diskConfig); NovaTemplateOptions configDrive(boolean configDrive); NovaTemplateOptions novaNetworks(Set<Network> novaNetworks); }
@Test public void testUserData() { NovaTemplateOptions options = new NovaTemplateOptions(); options.userData("test".getBytes()); assertEquals(new String(options.getUserData()), "test"); }
public NovaTemplateOptions userData(byte[] userData) { checkArgument(checkNotNull(userData, "userData").length <= 16 * 1024, "userData cannot be larger than 16kb"); this.userData = userData; return this; }
NovaTemplateOptions extends TemplateOptions implements Cloneable { public NovaTemplateOptions userData(byte[] userData) { checkArgument(checkNotNull(userData, "userData").length <= 16 * 1024, "userData cannot be larger than 16kb"); this.userData = userData; return this; } }
NovaTemplateOptions extends TemplateOptions implements Cloneable { public NovaTemplateOptions userData(byte[] userData) { checkArgument(checkNotNull(userData, "userData").length <= 16 * 1024, "userData cannot be larger than 16kb"); this.userData = userData; return this; } }
NovaTemplateOptions extends TemplateOptions implements Cloneable { public NovaTemplateOptions userData(byte[] userData) { checkArgument(checkNotNull(userData, "userData").length <= 16 * 1024, "userData cannot be larger than 16kb"); this.userData = userData; return this; } @Override NovaTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override ToStringHelper string(); NovaTemplateOptions autoAssignFloatingIp(boolean enable); NovaTemplateOptions floatingIpPoolNames(String... floatingIpPoolNames); NovaTemplateOptions floatingIpPoolNames(Iterable<String> floatingIpPoolNames); NovaTemplateOptions generateKeyPair(boolean enable); NovaTemplateOptions keyPairName(String keyPairName); boolean shouldAutoAssignFloatingIp(); NovaTemplateOptions availabilityZone(String availabilityZone); NovaTemplateOptions blockDeviceMappings(BlockDeviceMapping... blockDeviceMappings); NovaTemplateOptions blockDeviceMappings(Iterable<BlockDeviceMapping> blockDeviceMappings); Optional<Set<String>> getFloatingIpPoolNames(); String getKeyPairName(); boolean shouldGenerateKeyPair(); byte[] getUserData(); String getDiskConfig(); boolean getConfigDrive(); Set<Network> getNovaNetworks(); String getAvailabilityZone(); Set<BlockDeviceMapping> getBlockDeviceMappings(); @Override NovaTemplateOptions blockOnPort(int port, int seconds); @Override NovaTemplateOptions inboundPorts(int... ports); @Override NovaTemplateOptions authorizePublicKey(String publicKey); @Override NovaTemplateOptions installPrivateKey(String privateKey); @Override NovaTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override NovaTemplateOptions dontAuthorizePublicKey(); @Override NovaTemplateOptions nameTask(String name); @Override NovaTemplateOptions runAsRoot(boolean runAsRoot); @Override NovaTemplateOptions runScript(Statement script); @Override NovaTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override NovaTemplateOptions overrideLoginPassword(String password); @Override NovaTemplateOptions overrideLoginPrivateKey(String privateKey); @Override NovaTemplateOptions overrideLoginUser(String loginUser); @Override NovaTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override NovaTemplateOptions userMetadata(Map<String, String> userMetadata); @Override NovaTemplateOptions userMetadata(String key, String value); @Override NovaTemplateOptions nodeNames(Iterable<String> nodeNames); @Override NovaTemplateOptions networks(Iterable<String> networks); @Override NovaTemplateOptions networks(String... networks); NovaTemplateOptions userData(byte[] userData); NovaTemplateOptions diskConfig(String diskConfig); NovaTemplateOptions configDrive(boolean configDrive); NovaTemplateOptions novaNetworks(Set<Network> novaNetworks); }
NovaTemplateOptions extends TemplateOptions implements Cloneable { public NovaTemplateOptions userData(byte[] userData) { checkArgument(checkNotNull(userData, "userData").length <= 16 * 1024, "userData cannot be larger than 16kb"); this.userData = userData; return this; } @Override NovaTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override ToStringHelper string(); NovaTemplateOptions autoAssignFloatingIp(boolean enable); NovaTemplateOptions floatingIpPoolNames(String... floatingIpPoolNames); NovaTemplateOptions floatingIpPoolNames(Iterable<String> floatingIpPoolNames); NovaTemplateOptions generateKeyPair(boolean enable); NovaTemplateOptions keyPairName(String keyPairName); boolean shouldAutoAssignFloatingIp(); NovaTemplateOptions availabilityZone(String availabilityZone); NovaTemplateOptions blockDeviceMappings(BlockDeviceMapping... blockDeviceMappings); NovaTemplateOptions blockDeviceMappings(Iterable<BlockDeviceMapping> blockDeviceMappings); Optional<Set<String>> getFloatingIpPoolNames(); String getKeyPairName(); boolean shouldGenerateKeyPair(); byte[] getUserData(); String getDiskConfig(); boolean getConfigDrive(); Set<Network> getNovaNetworks(); String getAvailabilityZone(); Set<BlockDeviceMapping> getBlockDeviceMappings(); @Override NovaTemplateOptions blockOnPort(int port, int seconds); @Override NovaTemplateOptions inboundPorts(int... ports); @Override NovaTemplateOptions authorizePublicKey(String publicKey); @Override NovaTemplateOptions installPrivateKey(String privateKey); @Override NovaTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override NovaTemplateOptions dontAuthorizePublicKey(); @Override NovaTemplateOptions nameTask(String name); @Override NovaTemplateOptions runAsRoot(boolean runAsRoot); @Override NovaTemplateOptions runScript(Statement script); @Override NovaTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override NovaTemplateOptions overrideLoginPassword(String password); @Override NovaTemplateOptions overrideLoginPrivateKey(String privateKey); @Override NovaTemplateOptions overrideLoginUser(String loginUser); @Override NovaTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override NovaTemplateOptions userMetadata(Map<String, String> userMetadata); @Override NovaTemplateOptions userMetadata(String key, String value); @Override NovaTemplateOptions nodeNames(Iterable<String> nodeNames); @Override NovaTemplateOptions networks(Iterable<String> networks); @Override NovaTemplateOptions networks(String... networks); NovaTemplateOptions userData(byte[] userData); NovaTemplateOptions diskConfig(String diskConfig); NovaTemplateOptions configDrive(boolean configDrive); NovaTemplateOptions novaNetworks(Set<Network> novaNetworks); }
@Test public void testAvailabilityZone() { NovaTemplateOptions options = new NovaTemplateOptions(); options.availabilityZone("nova"); assertEquals(options.getAvailabilityZone(), "nova"); }
public NovaTemplateOptions availabilityZone(String availabilityZone) { this.availabilityZone = availabilityZone; return this; }
NovaTemplateOptions extends TemplateOptions implements Cloneable { public NovaTemplateOptions availabilityZone(String availabilityZone) { this.availabilityZone = availabilityZone; return this; } }
NovaTemplateOptions extends TemplateOptions implements Cloneable { public NovaTemplateOptions availabilityZone(String availabilityZone) { this.availabilityZone = availabilityZone; return this; } }
NovaTemplateOptions extends TemplateOptions implements Cloneable { public NovaTemplateOptions availabilityZone(String availabilityZone) { this.availabilityZone = availabilityZone; return this; } @Override NovaTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override ToStringHelper string(); NovaTemplateOptions autoAssignFloatingIp(boolean enable); NovaTemplateOptions floatingIpPoolNames(String... floatingIpPoolNames); NovaTemplateOptions floatingIpPoolNames(Iterable<String> floatingIpPoolNames); NovaTemplateOptions generateKeyPair(boolean enable); NovaTemplateOptions keyPairName(String keyPairName); boolean shouldAutoAssignFloatingIp(); NovaTemplateOptions availabilityZone(String availabilityZone); NovaTemplateOptions blockDeviceMappings(BlockDeviceMapping... blockDeviceMappings); NovaTemplateOptions blockDeviceMappings(Iterable<BlockDeviceMapping> blockDeviceMappings); Optional<Set<String>> getFloatingIpPoolNames(); String getKeyPairName(); boolean shouldGenerateKeyPair(); byte[] getUserData(); String getDiskConfig(); boolean getConfigDrive(); Set<Network> getNovaNetworks(); String getAvailabilityZone(); Set<BlockDeviceMapping> getBlockDeviceMappings(); @Override NovaTemplateOptions blockOnPort(int port, int seconds); @Override NovaTemplateOptions inboundPorts(int... ports); @Override NovaTemplateOptions authorizePublicKey(String publicKey); @Override NovaTemplateOptions installPrivateKey(String privateKey); @Override NovaTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override NovaTemplateOptions dontAuthorizePublicKey(); @Override NovaTemplateOptions nameTask(String name); @Override NovaTemplateOptions runAsRoot(boolean runAsRoot); @Override NovaTemplateOptions runScript(Statement script); @Override NovaTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override NovaTemplateOptions overrideLoginPassword(String password); @Override NovaTemplateOptions overrideLoginPrivateKey(String privateKey); @Override NovaTemplateOptions overrideLoginUser(String loginUser); @Override NovaTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override NovaTemplateOptions userMetadata(Map<String, String> userMetadata); @Override NovaTemplateOptions userMetadata(String key, String value); @Override NovaTemplateOptions nodeNames(Iterable<String> nodeNames); @Override NovaTemplateOptions networks(Iterable<String> networks); @Override NovaTemplateOptions networks(String... networks); NovaTemplateOptions userData(byte[] userData); NovaTemplateOptions diskConfig(String diskConfig); NovaTemplateOptions configDrive(boolean configDrive); NovaTemplateOptions novaNetworks(Set<Network> novaNetworks); }
NovaTemplateOptions extends TemplateOptions implements Cloneable { public NovaTemplateOptions availabilityZone(String availabilityZone) { this.availabilityZone = availabilityZone; return this; } @Override NovaTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override ToStringHelper string(); NovaTemplateOptions autoAssignFloatingIp(boolean enable); NovaTemplateOptions floatingIpPoolNames(String... floatingIpPoolNames); NovaTemplateOptions floatingIpPoolNames(Iterable<String> floatingIpPoolNames); NovaTemplateOptions generateKeyPair(boolean enable); NovaTemplateOptions keyPairName(String keyPairName); boolean shouldAutoAssignFloatingIp(); NovaTemplateOptions availabilityZone(String availabilityZone); NovaTemplateOptions blockDeviceMappings(BlockDeviceMapping... blockDeviceMappings); NovaTemplateOptions blockDeviceMappings(Iterable<BlockDeviceMapping> blockDeviceMappings); Optional<Set<String>> getFloatingIpPoolNames(); String getKeyPairName(); boolean shouldGenerateKeyPair(); byte[] getUserData(); String getDiskConfig(); boolean getConfigDrive(); Set<Network> getNovaNetworks(); String getAvailabilityZone(); Set<BlockDeviceMapping> getBlockDeviceMappings(); @Override NovaTemplateOptions blockOnPort(int port, int seconds); @Override NovaTemplateOptions inboundPorts(int... ports); @Override NovaTemplateOptions authorizePublicKey(String publicKey); @Override NovaTemplateOptions installPrivateKey(String privateKey); @Override NovaTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override NovaTemplateOptions dontAuthorizePublicKey(); @Override NovaTemplateOptions nameTask(String name); @Override NovaTemplateOptions runAsRoot(boolean runAsRoot); @Override NovaTemplateOptions runScript(Statement script); @Override NovaTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override NovaTemplateOptions overrideLoginPassword(String password); @Override NovaTemplateOptions overrideLoginPrivateKey(String privateKey); @Override NovaTemplateOptions overrideLoginUser(String loginUser); @Override NovaTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override NovaTemplateOptions userMetadata(Map<String, String> userMetadata); @Override NovaTemplateOptions userMetadata(String key, String value); @Override NovaTemplateOptions nodeNames(Iterable<String> nodeNames); @Override NovaTemplateOptions networks(Iterable<String> networks); @Override NovaTemplateOptions networks(String... networks); NovaTemplateOptions userData(byte[] userData); NovaTemplateOptions diskConfig(String diskConfig); NovaTemplateOptions configDrive(boolean configDrive); NovaTemplateOptions novaNetworks(Set<Network> novaNetworks); }
@Test public void testDiskConfig() { NovaTemplateOptions options = new NovaTemplateOptions(); options.diskConfig(Server.DISK_CONFIG_AUTO); assertEquals(options.getDiskConfig(), Server.DISK_CONFIG_AUTO); }
public NovaTemplateOptions diskConfig(String diskConfig) { this.diskConfig = diskConfig; return this; }
NovaTemplateOptions extends TemplateOptions implements Cloneable { public NovaTemplateOptions diskConfig(String diskConfig) { this.diskConfig = diskConfig; return this; } }
NovaTemplateOptions extends TemplateOptions implements Cloneable { public NovaTemplateOptions diskConfig(String diskConfig) { this.diskConfig = diskConfig; return this; } }
NovaTemplateOptions extends TemplateOptions implements Cloneable { public NovaTemplateOptions diskConfig(String diskConfig) { this.diskConfig = diskConfig; return this; } @Override NovaTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override ToStringHelper string(); NovaTemplateOptions autoAssignFloatingIp(boolean enable); NovaTemplateOptions floatingIpPoolNames(String... floatingIpPoolNames); NovaTemplateOptions floatingIpPoolNames(Iterable<String> floatingIpPoolNames); NovaTemplateOptions generateKeyPair(boolean enable); NovaTemplateOptions keyPairName(String keyPairName); boolean shouldAutoAssignFloatingIp(); NovaTemplateOptions availabilityZone(String availabilityZone); NovaTemplateOptions blockDeviceMappings(BlockDeviceMapping... blockDeviceMappings); NovaTemplateOptions blockDeviceMappings(Iterable<BlockDeviceMapping> blockDeviceMappings); Optional<Set<String>> getFloatingIpPoolNames(); String getKeyPairName(); boolean shouldGenerateKeyPair(); byte[] getUserData(); String getDiskConfig(); boolean getConfigDrive(); Set<Network> getNovaNetworks(); String getAvailabilityZone(); Set<BlockDeviceMapping> getBlockDeviceMappings(); @Override NovaTemplateOptions blockOnPort(int port, int seconds); @Override NovaTemplateOptions inboundPorts(int... ports); @Override NovaTemplateOptions authorizePublicKey(String publicKey); @Override NovaTemplateOptions installPrivateKey(String privateKey); @Override NovaTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override NovaTemplateOptions dontAuthorizePublicKey(); @Override NovaTemplateOptions nameTask(String name); @Override NovaTemplateOptions runAsRoot(boolean runAsRoot); @Override NovaTemplateOptions runScript(Statement script); @Override NovaTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override NovaTemplateOptions overrideLoginPassword(String password); @Override NovaTemplateOptions overrideLoginPrivateKey(String privateKey); @Override NovaTemplateOptions overrideLoginUser(String loginUser); @Override NovaTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override NovaTemplateOptions userMetadata(Map<String, String> userMetadata); @Override NovaTemplateOptions userMetadata(String key, String value); @Override NovaTemplateOptions nodeNames(Iterable<String> nodeNames); @Override NovaTemplateOptions networks(Iterable<String> networks); @Override NovaTemplateOptions networks(String... networks); NovaTemplateOptions userData(byte[] userData); NovaTemplateOptions diskConfig(String diskConfig); NovaTemplateOptions configDrive(boolean configDrive); NovaTemplateOptions novaNetworks(Set<Network> novaNetworks); }
NovaTemplateOptions extends TemplateOptions implements Cloneable { public NovaTemplateOptions diskConfig(String diskConfig) { this.diskConfig = diskConfig; return this; } @Override NovaTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override ToStringHelper string(); NovaTemplateOptions autoAssignFloatingIp(boolean enable); NovaTemplateOptions floatingIpPoolNames(String... floatingIpPoolNames); NovaTemplateOptions floatingIpPoolNames(Iterable<String> floatingIpPoolNames); NovaTemplateOptions generateKeyPair(boolean enable); NovaTemplateOptions keyPairName(String keyPairName); boolean shouldAutoAssignFloatingIp(); NovaTemplateOptions availabilityZone(String availabilityZone); NovaTemplateOptions blockDeviceMappings(BlockDeviceMapping... blockDeviceMappings); NovaTemplateOptions blockDeviceMappings(Iterable<BlockDeviceMapping> blockDeviceMappings); Optional<Set<String>> getFloatingIpPoolNames(); String getKeyPairName(); boolean shouldGenerateKeyPair(); byte[] getUserData(); String getDiskConfig(); boolean getConfigDrive(); Set<Network> getNovaNetworks(); String getAvailabilityZone(); Set<BlockDeviceMapping> getBlockDeviceMappings(); @Override NovaTemplateOptions blockOnPort(int port, int seconds); @Override NovaTemplateOptions inboundPorts(int... ports); @Override NovaTemplateOptions authorizePublicKey(String publicKey); @Override NovaTemplateOptions installPrivateKey(String privateKey); @Override NovaTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override NovaTemplateOptions dontAuthorizePublicKey(); @Override NovaTemplateOptions nameTask(String name); @Override NovaTemplateOptions runAsRoot(boolean runAsRoot); @Override NovaTemplateOptions runScript(Statement script); @Override NovaTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override NovaTemplateOptions overrideLoginPassword(String password); @Override NovaTemplateOptions overrideLoginPrivateKey(String privateKey); @Override NovaTemplateOptions overrideLoginUser(String loginUser); @Override NovaTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override NovaTemplateOptions userMetadata(Map<String, String> userMetadata); @Override NovaTemplateOptions userMetadata(String key, String value); @Override NovaTemplateOptions nodeNames(Iterable<String> nodeNames); @Override NovaTemplateOptions networks(Iterable<String> networks); @Override NovaTemplateOptions networks(String... networks); NovaTemplateOptions userData(byte[] userData); NovaTemplateOptions diskConfig(String diskConfig); NovaTemplateOptions configDrive(boolean configDrive); NovaTemplateOptions novaNetworks(Set<Network> novaNetworks); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testblockOnPortBadFormat() { NovaTemplateOptions options = new NovaTemplateOptions(); options.blockOnPort(-1, -1); }
@Override public NovaTemplateOptions blockOnPort(int port, int seconds) { return NovaTemplateOptions.class.cast(super.blockOnPort(port, seconds)); }
NovaTemplateOptions extends TemplateOptions implements Cloneable { @Override public NovaTemplateOptions blockOnPort(int port, int seconds) { return NovaTemplateOptions.class.cast(super.blockOnPort(port, seconds)); } }
NovaTemplateOptions extends TemplateOptions implements Cloneable { @Override public NovaTemplateOptions blockOnPort(int port, int seconds) { return NovaTemplateOptions.class.cast(super.blockOnPort(port, seconds)); } }
NovaTemplateOptions extends TemplateOptions implements Cloneable { @Override public NovaTemplateOptions blockOnPort(int port, int seconds) { return NovaTemplateOptions.class.cast(super.blockOnPort(port, seconds)); } @Override NovaTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override ToStringHelper string(); NovaTemplateOptions autoAssignFloatingIp(boolean enable); NovaTemplateOptions floatingIpPoolNames(String... floatingIpPoolNames); NovaTemplateOptions floatingIpPoolNames(Iterable<String> floatingIpPoolNames); NovaTemplateOptions generateKeyPair(boolean enable); NovaTemplateOptions keyPairName(String keyPairName); boolean shouldAutoAssignFloatingIp(); NovaTemplateOptions availabilityZone(String availabilityZone); NovaTemplateOptions blockDeviceMappings(BlockDeviceMapping... blockDeviceMappings); NovaTemplateOptions blockDeviceMappings(Iterable<BlockDeviceMapping> blockDeviceMappings); Optional<Set<String>> getFloatingIpPoolNames(); String getKeyPairName(); boolean shouldGenerateKeyPair(); byte[] getUserData(); String getDiskConfig(); boolean getConfigDrive(); Set<Network> getNovaNetworks(); String getAvailabilityZone(); Set<BlockDeviceMapping> getBlockDeviceMappings(); @Override NovaTemplateOptions blockOnPort(int port, int seconds); @Override NovaTemplateOptions inboundPorts(int... ports); @Override NovaTemplateOptions authorizePublicKey(String publicKey); @Override NovaTemplateOptions installPrivateKey(String privateKey); @Override NovaTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override NovaTemplateOptions dontAuthorizePublicKey(); @Override NovaTemplateOptions nameTask(String name); @Override NovaTemplateOptions runAsRoot(boolean runAsRoot); @Override NovaTemplateOptions runScript(Statement script); @Override NovaTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override NovaTemplateOptions overrideLoginPassword(String password); @Override NovaTemplateOptions overrideLoginPrivateKey(String privateKey); @Override NovaTemplateOptions overrideLoginUser(String loginUser); @Override NovaTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override NovaTemplateOptions userMetadata(Map<String, String> userMetadata); @Override NovaTemplateOptions userMetadata(String key, String value); @Override NovaTemplateOptions nodeNames(Iterable<String> nodeNames); @Override NovaTemplateOptions networks(Iterable<String> networks); @Override NovaTemplateOptions networks(String... networks); NovaTemplateOptions userData(byte[] userData); NovaTemplateOptions diskConfig(String diskConfig); NovaTemplateOptions configDrive(boolean configDrive); NovaTemplateOptions novaNetworks(Set<Network> novaNetworks); }
NovaTemplateOptions extends TemplateOptions implements Cloneable { @Override public NovaTemplateOptions blockOnPort(int port, int seconds) { return NovaTemplateOptions.class.cast(super.blockOnPort(port, seconds)); } @Override NovaTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override ToStringHelper string(); NovaTemplateOptions autoAssignFloatingIp(boolean enable); NovaTemplateOptions floatingIpPoolNames(String... floatingIpPoolNames); NovaTemplateOptions floatingIpPoolNames(Iterable<String> floatingIpPoolNames); NovaTemplateOptions generateKeyPair(boolean enable); NovaTemplateOptions keyPairName(String keyPairName); boolean shouldAutoAssignFloatingIp(); NovaTemplateOptions availabilityZone(String availabilityZone); NovaTemplateOptions blockDeviceMappings(BlockDeviceMapping... blockDeviceMappings); NovaTemplateOptions blockDeviceMappings(Iterable<BlockDeviceMapping> blockDeviceMappings); Optional<Set<String>> getFloatingIpPoolNames(); String getKeyPairName(); boolean shouldGenerateKeyPair(); byte[] getUserData(); String getDiskConfig(); boolean getConfigDrive(); Set<Network> getNovaNetworks(); String getAvailabilityZone(); Set<BlockDeviceMapping> getBlockDeviceMappings(); @Override NovaTemplateOptions blockOnPort(int port, int seconds); @Override NovaTemplateOptions inboundPorts(int... ports); @Override NovaTemplateOptions authorizePublicKey(String publicKey); @Override NovaTemplateOptions installPrivateKey(String privateKey); @Override NovaTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override NovaTemplateOptions dontAuthorizePublicKey(); @Override NovaTemplateOptions nameTask(String name); @Override NovaTemplateOptions runAsRoot(boolean runAsRoot); @Override NovaTemplateOptions runScript(Statement script); @Override NovaTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override NovaTemplateOptions overrideLoginPassword(String password); @Override NovaTemplateOptions overrideLoginPrivateKey(String privateKey); @Override NovaTemplateOptions overrideLoginUser(String loginUser); @Override NovaTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override NovaTemplateOptions userMetadata(Map<String, String> userMetadata); @Override NovaTemplateOptions userMetadata(String key, String value); @Override NovaTemplateOptions nodeNames(Iterable<String> nodeNames); @Override NovaTemplateOptions networks(Iterable<String> networks); @Override NovaTemplateOptions networks(String... networks); NovaTemplateOptions userData(byte[] userData); NovaTemplateOptions diskConfig(String diskConfig); NovaTemplateOptions configDrive(boolean configDrive); NovaTemplateOptions novaNetworks(Set<Network> novaNetworks); }
@Test public void testblockOnPort() { NovaTemplateOptions options = new NovaTemplateOptions(); options.blockOnPort(22, 30); assertEquals(options.getPort(), 22); assertEquals(options.getSeconds(), 30); }
@Override public NovaTemplateOptions blockOnPort(int port, int seconds) { return NovaTemplateOptions.class.cast(super.blockOnPort(port, seconds)); }
NovaTemplateOptions extends TemplateOptions implements Cloneable { @Override public NovaTemplateOptions blockOnPort(int port, int seconds) { return NovaTemplateOptions.class.cast(super.blockOnPort(port, seconds)); } }
NovaTemplateOptions extends TemplateOptions implements Cloneable { @Override public NovaTemplateOptions blockOnPort(int port, int seconds) { return NovaTemplateOptions.class.cast(super.blockOnPort(port, seconds)); } }
NovaTemplateOptions extends TemplateOptions implements Cloneable { @Override public NovaTemplateOptions blockOnPort(int port, int seconds) { return NovaTemplateOptions.class.cast(super.blockOnPort(port, seconds)); } @Override NovaTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override ToStringHelper string(); NovaTemplateOptions autoAssignFloatingIp(boolean enable); NovaTemplateOptions floatingIpPoolNames(String... floatingIpPoolNames); NovaTemplateOptions floatingIpPoolNames(Iterable<String> floatingIpPoolNames); NovaTemplateOptions generateKeyPair(boolean enable); NovaTemplateOptions keyPairName(String keyPairName); boolean shouldAutoAssignFloatingIp(); NovaTemplateOptions availabilityZone(String availabilityZone); NovaTemplateOptions blockDeviceMappings(BlockDeviceMapping... blockDeviceMappings); NovaTemplateOptions blockDeviceMappings(Iterable<BlockDeviceMapping> blockDeviceMappings); Optional<Set<String>> getFloatingIpPoolNames(); String getKeyPairName(); boolean shouldGenerateKeyPair(); byte[] getUserData(); String getDiskConfig(); boolean getConfigDrive(); Set<Network> getNovaNetworks(); String getAvailabilityZone(); Set<BlockDeviceMapping> getBlockDeviceMappings(); @Override NovaTemplateOptions blockOnPort(int port, int seconds); @Override NovaTemplateOptions inboundPorts(int... ports); @Override NovaTemplateOptions authorizePublicKey(String publicKey); @Override NovaTemplateOptions installPrivateKey(String privateKey); @Override NovaTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override NovaTemplateOptions dontAuthorizePublicKey(); @Override NovaTemplateOptions nameTask(String name); @Override NovaTemplateOptions runAsRoot(boolean runAsRoot); @Override NovaTemplateOptions runScript(Statement script); @Override NovaTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override NovaTemplateOptions overrideLoginPassword(String password); @Override NovaTemplateOptions overrideLoginPrivateKey(String privateKey); @Override NovaTemplateOptions overrideLoginUser(String loginUser); @Override NovaTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override NovaTemplateOptions userMetadata(Map<String, String> userMetadata); @Override NovaTemplateOptions userMetadata(String key, String value); @Override NovaTemplateOptions nodeNames(Iterable<String> nodeNames); @Override NovaTemplateOptions networks(Iterable<String> networks); @Override NovaTemplateOptions networks(String... networks); NovaTemplateOptions userData(byte[] userData); NovaTemplateOptions diskConfig(String diskConfig); NovaTemplateOptions configDrive(boolean configDrive); NovaTemplateOptions novaNetworks(Set<Network> novaNetworks); }
NovaTemplateOptions extends TemplateOptions implements Cloneable { @Override public NovaTemplateOptions blockOnPort(int port, int seconds) { return NovaTemplateOptions.class.cast(super.blockOnPort(port, seconds)); } @Override NovaTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override ToStringHelper string(); NovaTemplateOptions autoAssignFloatingIp(boolean enable); NovaTemplateOptions floatingIpPoolNames(String... floatingIpPoolNames); NovaTemplateOptions floatingIpPoolNames(Iterable<String> floatingIpPoolNames); NovaTemplateOptions generateKeyPair(boolean enable); NovaTemplateOptions keyPairName(String keyPairName); boolean shouldAutoAssignFloatingIp(); NovaTemplateOptions availabilityZone(String availabilityZone); NovaTemplateOptions blockDeviceMappings(BlockDeviceMapping... blockDeviceMappings); NovaTemplateOptions blockDeviceMappings(Iterable<BlockDeviceMapping> blockDeviceMappings); Optional<Set<String>> getFloatingIpPoolNames(); String getKeyPairName(); boolean shouldGenerateKeyPair(); byte[] getUserData(); String getDiskConfig(); boolean getConfigDrive(); Set<Network> getNovaNetworks(); String getAvailabilityZone(); Set<BlockDeviceMapping> getBlockDeviceMappings(); @Override NovaTemplateOptions blockOnPort(int port, int seconds); @Override NovaTemplateOptions inboundPorts(int... ports); @Override NovaTemplateOptions authorizePublicKey(String publicKey); @Override NovaTemplateOptions installPrivateKey(String privateKey); @Override NovaTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override NovaTemplateOptions dontAuthorizePublicKey(); @Override NovaTemplateOptions nameTask(String name); @Override NovaTemplateOptions runAsRoot(boolean runAsRoot); @Override NovaTemplateOptions runScript(Statement script); @Override NovaTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override NovaTemplateOptions overrideLoginPassword(String password); @Override NovaTemplateOptions overrideLoginPrivateKey(String privateKey); @Override NovaTemplateOptions overrideLoginUser(String loginUser); @Override NovaTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override NovaTemplateOptions userMetadata(Map<String, String> userMetadata); @Override NovaTemplateOptions userMetadata(String key, String value); @Override NovaTemplateOptions nodeNames(Iterable<String> nodeNames); @Override NovaTemplateOptions networks(Iterable<String> networks); @Override NovaTemplateOptions networks(String... networks); NovaTemplateOptions userData(byte[] userData); NovaTemplateOptions diskConfig(String diskConfig); NovaTemplateOptions configDrive(boolean configDrive); NovaTemplateOptions novaNetworks(Set<Network> novaNetworks); }
@Test public void testblockOnPortStatic() { NovaTemplateOptions options = blockOnPort(22, 30); assertEquals(options.getPort(), 22); assertEquals(options.getSeconds(), 30); }
@Override public NovaTemplateOptions blockOnPort(int port, int seconds) { return NovaTemplateOptions.class.cast(super.blockOnPort(port, seconds)); }
NovaTemplateOptions extends TemplateOptions implements Cloneable { @Override public NovaTemplateOptions blockOnPort(int port, int seconds) { return NovaTemplateOptions.class.cast(super.blockOnPort(port, seconds)); } }
NovaTemplateOptions extends TemplateOptions implements Cloneable { @Override public NovaTemplateOptions blockOnPort(int port, int seconds) { return NovaTemplateOptions.class.cast(super.blockOnPort(port, seconds)); } }
NovaTemplateOptions extends TemplateOptions implements Cloneable { @Override public NovaTemplateOptions blockOnPort(int port, int seconds) { return NovaTemplateOptions.class.cast(super.blockOnPort(port, seconds)); } @Override NovaTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override ToStringHelper string(); NovaTemplateOptions autoAssignFloatingIp(boolean enable); NovaTemplateOptions floatingIpPoolNames(String... floatingIpPoolNames); NovaTemplateOptions floatingIpPoolNames(Iterable<String> floatingIpPoolNames); NovaTemplateOptions generateKeyPair(boolean enable); NovaTemplateOptions keyPairName(String keyPairName); boolean shouldAutoAssignFloatingIp(); NovaTemplateOptions availabilityZone(String availabilityZone); NovaTemplateOptions blockDeviceMappings(BlockDeviceMapping... blockDeviceMappings); NovaTemplateOptions blockDeviceMappings(Iterable<BlockDeviceMapping> blockDeviceMappings); Optional<Set<String>> getFloatingIpPoolNames(); String getKeyPairName(); boolean shouldGenerateKeyPair(); byte[] getUserData(); String getDiskConfig(); boolean getConfigDrive(); Set<Network> getNovaNetworks(); String getAvailabilityZone(); Set<BlockDeviceMapping> getBlockDeviceMappings(); @Override NovaTemplateOptions blockOnPort(int port, int seconds); @Override NovaTemplateOptions inboundPorts(int... ports); @Override NovaTemplateOptions authorizePublicKey(String publicKey); @Override NovaTemplateOptions installPrivateKey(String privateKey); @Override NovaTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override NovaTemplateOptions dontAuthorizePublicKey(); @Override NovaTemplateOptions nameTask(String name); @Override NovaTemplateOptions runAsRoot(boolean runAsRoot); @Override NovaTemplateOptions runScript(Statement script); @Override NovaTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override NovaTemplateOptions overrideLoginPassword(String password); @Override NovaTemplateOptions overrideLoginPrivateKey(String privateKey); @Override NovaTemplateOptions overrideLoginUser(String loginUser); @Override NovaTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override NovaTemplateOptions userMetadata(Map<String, String> userMetadata); @Override NovaTemplateOptions userMetadata(String key, String value); @Override NovaTemplateOptions nodeNames(Iterable<String> nodeNames); @Override NovaTemplateOptions networks(Iterable<String> networks); @Override NovaTemplateOptions networks(String... networks); NovaTemplateOptions userData(byte[] userData); NovaTemplateOptions diskConfig(String diskConfig); NovaTemplateOptions configDrive(boolean configDrive); NovaTemplateOptions novaNetworks(Set<Network> novaNetworks); }
NovaTemplateOptions extends TemplateOptions implements Cloneable { @Override public NovaTemplateOptions blockOnPort(int port, int seconds) { return NovaTemplateOptions.class.cast(super.blockOnPort(port, seconds)); } @Override NovaTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override ToStringHelper string(); NovaTemplateOptions autoAssignFloatingIp(boolean enable); NovaTemplateOptions floatingIpPoolNames(String... floatingIpPoolNames); NovaTemplateOptions floatingIpPoolNames(Iterable<String> floatingIpPoolNames); NovaTemplateOptions generateKeyPair(boolean enable); NovaTemplateOptions keyPairName(String keyPairName); boolean shouldAutoAssignFloatingIp(); NovaTemplateOptions availabilityZone(String availabilityZone); NovaTemplateOptions blockDeviceMappings(BlockDeviceMapping... blockDeviceMappings); NovaTemplateOptions blockDeviceMappings(Iterable<BlockDeviceMapping> blockDeviceMappings); Optional<Set<String>> getFloatingIpPoolNames(); String getKeyPairName(); boolean shouldGenerateKeyPair(); byte[] getUserData(); String getDiskConfig(); boolean getConfigDrive(); Set<Network> getNovaNetworks(); String getAvailabilityZone(); Set<BlockDeviceMapping> getBlockDeviceMappings(); @Override NovaTemplateOptions blockOnPort(int port, int seconds); @Override NovaTemplateOptions inboundPorts(int... ports); @Override NovaTemplateOptions authorizePublicKey(String publicKey); @Override NovaTemplateOptions installPrivateKey(String privateKey); @Override NovaTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override NovaTemplateOptions dontAuthorizePublicKey(); @Override NovaTemplateOptions nameTask(String name); @Override NovaTemplateOptions runAsRoot(boolean runAsRoot); @Override NovaTemplateOptions runScript(Statement script); @Override NovaTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override NovaTemplateOptions overrideLoginPassword(String password); @Override NovaTemplateOptions overrideLoginPrivateKey(String privateKey); @Override NovaTemplateOptions overrideLoginUser(String loginUser); @Override NovaTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override NovaTemplateOptions userMetadata(Map<String, String> userMetadata); @Override NovaTemplateOptions userMetadata(String key, String value); @Override NovaTemplateOptions nodeNames(Iterable<String> nodeNames); @Override NovaTemplateOptions networks(Iterable<String> networks); @Override NovaTemplateOptions networks(String... networks); NovaTemplateOptions userData(byte[] userData); NovaTemplateOptions diskConfig(String diskConfig); NovaTemplateOptions configDrive(boolean configDrive); NovaTemplateOptions novaNetworks(Set<Network> novaNetworks); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testinboundPortsBadFormat() { NovaTemplateOptions options = new NovaTemplateOptions(); options.inboundPorts(-1, -1); }
@Override public NovaTemplateOptions inboundPorts(int... ports) { return NovaTemplateOptions.class.cast(super.inboundPorts(ports)); }
NovaTemplateOptions extends TemplateOptions implements Cloneable { @Override public NovaTemplateOptions inboundPorts(int... ports) { return NovaTemplateOptions.class.cast(super.inboundPorts(ports)); } }
NovaTemplateOptions extends TemplateOptions implements Cloneable { @Override public NovaTemplateOptions inboundPorts(int... ports) { return NovaTemplateOptions.class.cast(super.inboundPorts(ports)); } }
NovaTemplateOptions extends TemplateOptions implements Cloneable { @Override public NovaTemplateOptions inboundPorts(int... ports) { return NovaTemplateOptions.class.cast(super.inboundPorts(ports)); } @Override NovaTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override ToStringHelper string(); NovaTemplateOptions autoAssignFloatingIp(boolean enable); NovaTemplateOptions floatingIpPoolNames(String... floatingIpPoolNames); NovaTemplateOptions floatingIpPoolNames(Iterable<String> floatingIpPoolNames); NovaTemplateOptions generateKeyPair(boolean enable); NovaTemplateOptions keyPairName(String keyPairName); boolean shouldAutoAssignFloatingIp(); NovaTemplateOptions availabilityZone(String availabilityZone); NovaTemplateOptions blockDeviceMappings(BlockDeviceMapping... blockDeviceMappings); NovaTemplateOptions blockDeviceMappings(Iterable<BlockDeviceMapping> blockDeviceMappings); Optional<Set<String>> getFloatingIpPoolNames(); String getKeyPairName(); boolean shouldGenerateKeyPair(); byte[] getUserData(); String getDiskConfig(); boolean getConfigDrive(); Set<Network> getNovaNetworks(); String getAvailabilityZone(); Set<BlockDeviceMapping> getBlockDeviceMappings(); @Override NovaTemplateOptions blockOnPort(int port, int seconds); @Override NovaTemplateOptions inboundPorts(int... ports); @Override NovaTemplateOptions authorizePublicKey(String publicKey); @Override NovaTemplateOptions installPrivateKey(String privateKey); @Override NovaTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override NovaTemplateOptions dontAuthorizePublicKey(); @Override NovaTemplateOptions nameTask(String name); @Override NovaTemplateOptions runAsRoot(boolean runAsRoot); @Override NovaTemplateOptions runScript(Statement script); @Override NovaTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override NovaTemplateOptions overrideLoginPassword(String password); @Override NovaTemplateOptions overrideLoginPrivateKey(String privateKey); @Override NovaTemplateOptions overrideLoginUser(String loginUser); @Override NovaTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override NovaTemplateOptions userMetadata(Map<String, String> userMetadata); @Override NovaTemplateOptions userMetadata(String key, String value); @Override NovaTemplateOptions nodeNames(Iterable<String> nodeNames); @Override NovaTemplateOptions networks(Iterable<String> networks); @Override NovaTemplateOptions networks(String... networks); NovaTemplateOptions userData(byte[] userData); NovaTemplateOptions diskConfig(String diskConfig); NovaTemplateOptions configDrive(boolean configDrive); NovaTemplateOptions novaNetworks(Set<Network> novaNetworks); }
NovaTemplateOptions extends TemplateOptions implements Cloneable { @Override public NovaTemplateOptions inboundPorts(int... ports) { return NovaTemplateOptions.class.cast(super.inboundPorts(ports)); } @Override NovaTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override ToStringHelper string(); NovaTemplateOptions autoAssignFloatingIp(boolean enable); NovaTemplateOptions floatingIpPoolNames(String... floatingIpPoolNames); NovaTemplateOptions floatingIpPoolNames(Iterable<String> floatingIpPoolNames); NovaTemplateOptions generateKeyPair(boolean enable); NovaTemplateOptions keyPairName(String keyPairName); boolean shouldAutoAssignFloatingIp(); NovaTemplateOptions availabilityZone(String availabilityZone); NovaTemplateOptions blockDeviceMappings(BlockDeviceMapping... blockDeviceMappings); NovaTemplateOptions blockDeviceMappings(Iterable<BlockDeviceMapping> blockDeviceMappings); Optional<Set<String>> getFloatingIpPoolNames(); String getKeyPairName(); boolean shouldGenerateKeyPair(); byte[] getUserData(); String getDiskConfig(); boolean getConfigDrive(); Set<Network> getNovaNetworks(); String getAvailabilityZone(); Set<BlockDeviceMapping> getBlockDeviceMappings(); @Override NovaTemplateOptions blockOnPort(int port, int seconds); @Override NovaTemplateOptions inboundPorts(int... ports); @Override NovaTemplateOptions authorizePublicKey(String publicKey); @Override NovaTemplateOptions installPrivateKey(String privateKey); @Override NovaTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override NovaTemplateOptions dontAuthorizePublicKey(); @Override NovaTemplateOptions nameTask(String name); @Override NovaTemplateOptions runAsRoot(boolean runAsRoot); @Override NovaTemplateOptions runScript(Statement script); @Override NovaTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override NovaTemplateOptions overrideLoginPassword(String password); @Override NovaTemplateOptions overrideLoginPrivateKey(String privateKey); @Override NovaTemplateOptions overrideLoginUser(String loginUser); @Override NovaTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override NovaTemplateOptions userMetadata(Map<String, String> userMetadata); @Override NovaTemplateOptions userMetadata(String key, String value); @Override NovaTemplateOptions nodeNames(Iterable<String> nodeNames); @Override NovaTemplateOptions networks(Iterable<String> networks); @Override NovaTemplateOptions networks(String... networks); NovaTemplateOptions userData(byte[] userData); NovaTemplateOptions diskConfig(String diskConfig); NovaTemplateOptions configDrive(boolean configDrive); NovaTemplateOptions novaNetworks(Set<Network> novaNetworks); }
@Test public void testinboundPorts() { NovaTemplateOptions options = new NovaTemplateOptions(); options.inboundPorts(22, 30); assertEquals(options.getInboundPorts()[0], 22); assertEquals(options.getInboundPorts()[1], 30); }
@Override public NovaTemplateOptions inboundPorts(int... ports) { return NovaTemplateOptions.class.cast(super.inboundPorts(ports)); }
NovaTemplateOptions extends TemplateOptions implements Cloneable { @Override public NovaTemplateOptions inboundPorts(int... ports) { return NovaTemplateOptions.class.cast(super.inboundPorts(ports)); } }
NovaTemplateOptions extends TemplateOptions implements Cloneable { @Override public NovaTemplateOptions inboundPorts(int... ports) { return NovaTemplateOptions.class.cast(super.inboundPorts(ports)); } }
NovaTemplateOptions extends TemplateOptions implements Cloneable { @Override public NovaTemplateOptions inboundPorts(int... ports) { return NovaTemplateOptions.class.cast(super.inboundPorts(ports)); } @Override NovaTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override ToStringHelper string(); NovaTemplateOptions autoAssignFloatingIp(boolean enable); NovaTemplateOptions floatingIpPoolNames(String... floatingIpPoolNames); NovaTemplateOptions floatingIpPoolNames(Iterable<String> floatingIpPoolNames); NovaTemplateOptions generateKeyPair(boolean enable); NovaTemplateOptions keyPairName(String keyPairName); boolean shouldAutoAssignFloatingIp(); NovaTemplateOptions availabilityZone(String availabilityZone); NovaTemplateOptions blockDeviceMappings(BlockDeviceMapping... blockDeviceMappings); NovaTemplateOptions blockDeviceMappings(Iterable<BlockDeviceMapping> blockDeviceMappings); Optional<Set<String>> getFloatingIpPoolNames(); String getKeyPairName(); boolean shouldGenerateKeyPair(); byte[] getUserData(); String getDiskConfig(); boolean getConfigDrive(); Set<Network> getNovaNetworks(); String getAvailabilityZone(); Set<BlockDeviceMapping> getBlockDeviceMappings(); @Override NovaTemplateOptions blockOnPort(int port, int seconds); @Override NovaTemplateOptions inboundPorts(int... ports); @Override NovaTemplateOptions authorizePublicKey(String publicKey); @Override NovaTemplateOptions installPrivateKey(String privateKey); @Override NovaTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override NovaTemplateOptions dontAuthorizePublicKey(); @Override NovaTemplateOptions nameTask(String name); @Override NovaTemplateOptions runAsRoot(boolean runAsRoot); @Override NovaTemplateOptions runScript(Statement script); @Override NovaTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override NovaTemplateOptions overrideLoginPassword(String password); @Override NovaTemplateOptions overrideLoginPrivateKey(String privateKey); @Override NovaTemplateOptions overrideLoginUser(String loginUser); @Override NovaTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override NovaTemplateOptions userMetadata(Map<String, String> userMetadata); @Override NovaTemplateOptions userMetadata(String key, String value); @Override NovaTemplateOptions nodeNames(Iterable<String> nodeNames); @Override NovaTemplateOptions networks(Iterable<String> networks); @Override NovaTemplateOptions networks(String... networks); NovaTemplateOptions userData(byte[] userData); NovaTemplateOptions diskConfig(String diskConfig); NovaTemplateOptions configDrive(boolean configDrive); NovaTemplateOptions novaNetworks(Set<Network> novaNetworks); }
NovaTemplateOptions extends TemplateOptions implements Cloneable { @Override public NovaTemplateOptions inboundPorts(int... ports) { return NovaTemplateOptions.class.cast(super.inboundPorts(ports)); } @Override NovaTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override ToStringHelper string(); NovaTemplateOptions autoAssignFloatingIp(boolean enable); NovaTemplateOptions floatingIpPoolNames(String... floatingIpPoolNames); NovaTemplateOptions floatingIpPoolNames(Iterable<String> floatingIpPoolNames); NovaTemplateOptions generateKeyPair(boolean enable); NovaTemplateOptions keyPairName(String keyPairName); boolean shouldAutoAssignFloatingIp(); NovaTemplateOptions availabilityZone(String availabilityZone); NovaTemplateOptions blockDeviceMappings(BlockDeviceMapping... blockDeviceMappings); NovaTemplateOptions blockDeviceMappings(Iterable<BlockDeviceMapping> blockDeviceMappings); Optional<Set<String>> getFloatingIpPoolNames(); String getKeyPairName(); boolean shouldGenerateKeyPair(); byte[] getUserData(); String getDiskConfig(); boolean getConfigDrive(); Set<Network> getNovaNetworks(); String getAvailabilityZone(); Set<BlockDeviceMapping> getBlockDeviceMappings(); @Override NovaTemplateOptions blockOnPort(int port, int seconds); @Override NovaTemplateOptions inboundPorts(int... ports); @Override NovaTemplateOptions authorizePublicKey(String publicKey); @Override NovaTemplateOptions installPrivateKey(String privateKey); @Override NovaTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override NovaTemplateOptions dontAuthorizePublicKey(); @Override NovaTemplateOptions nameTask(String name); @Override NovaTemplateOptions runAsRoot(boolean runAsRoot); @Override NovaTemplateOptions runScript(Statement script); @Override NovaTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override NovaTemplateOptions overrideLoginPassword(String password); @Override NovaTemplateOptions overrideLoginPrivateKey(String privateKey); @Override NovaTemplateOptions overrideLoginUser(String loginUser); @Override NovaTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override NovaTemplateOptions userMetadata(Map<String, String> userMetadata); @Override NovaTemplateOptions userMetadata(String key, String value); @Override NovaTemplateOptions nodeNames(Iterable<String> nodeNames); @Override NovaTemplateOptions networks(Iterable<String> networks); @Override NovaTemplateOptions networks(String... networks); NovaTemplateOptions userData(byte[] userData); NovaTemplateOptions diskConfig(String diskConfig); NovaTemplateOptions configDrive(boolean configDrive); NovaTemplateOptions novaNetworks(Set<Network> novaNetworks); }
@Test public void testCreatePayload() { UpdateDataCenterRequestBinder binder = new UpdateDataCenterRequestBinder(); DataCenter.Request.UpdatePayload payload = DataCenter.Request.updatingPayload("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", "Apache-DC"); String actual = binder.createPayload(payload); assertNotNull(actual, "Binder returned null payload"); assertEquals(actual, expectedPayload); }
@Override protected String createPayload(DataCenter.Request.UpdatePayload payload) { requestBuilder.append("<ws:updateDataCenter>") .append("<request>") .append(format("<dataCenterId>%s</dataCenterId>", payload.id())) .append(format("<dataCenterName>%s</dataCenterName>", payload.name())) .append("</request>") .append("</ws:updateDataCenter>"); return requestBuilder.toString(); }
UpdateDataCenterRequestBinder extends BaseProfitBricksRequestBinder<DataCenter.Request.UpdatePayload> { @Override protected String createPayload(DataCenter.Request.UpdatePayload payload) { requestBuilder.append("<ws:updateDataCenter>") .append("<request>") .append(format("<dataCenterId>%s</dataCenterId>", payload.id())) .append(format("<dataCenterName>%s</dataCenterName>", payload.name())) .append("</request>") .append("</ws:updateDataCenter>"); return requestBuilder.toString(); } }
UpdateDataCenterRequestBinder extends BaseProfitBricksRequestBinder<DataCenter.Request.UpdatePayload> { @Override protected String createPayload(DataCenter.Request.UpdatePayload payload) { requestBuilder.append("<ws:updateDataCenter>") .append("<request>") .append(format("<dataCenterId>%s</dataCenterId>", payload.id())) .append(format("<dataCenterName>%s</dataCenterName>", payload.name())) .append("</request>") .append("</ws:updateDataCenter>"); return requestBuilder.toString(); } UpdateDataCenterRequestBinder(); }
UpdateDataCenterRequestBinder extends BaseProfitBricksRequestBinder<DataCenter.Request.UpdatePayload> { @Override protected String createPayload(DataCenter.Request.UpdatePayload payload) { requestBuilder.append("<ws:updateDataCenter>") .append("<request>") .append(format("<dataCenterId>%s</dataCenterId>", payload.id())) .append(format("<dataCenterName>%s</dataCenterName>", payload.name())) .append("</request>") .append("</ws:updateDataCenter>"); return requestBuilder.toString(); } UpdateDataCenterRequestBinder(); }
UpdateDataCenterRequestBinder extends BaseProfitBricksRequestBinder<DataCenter.Request.UpdatePayload> { @Override protected String createPayload(DataCenter.Request.UpdatePayload payload) { requestBuilder.append("<ws:updateDataCenter>") .append("<request>") .append(format("<dataCenterId>%s</dataCenterId>", payload.id())) .append(format("<dataCenterName>%s</dataCenterName>", payload.name())) .append("</request>") .append("</ws:updateDataCenter>"); return requestBuilder.toString(); } UpdateDataCenterRequestBinder(); }
@Test public void testinboundPortsStatic() { NovaTemplateOptions options = inboundPorts(22, 30); assertEquals(options.getInboundPorts()[0], 22); assertEquals(options.getInboundPorts()[1], 30); }
@Override public NovaTemplateOptions inboundPorts(int... ports) { return NovaTemplateOptions.class.cast(super.inboundPorts(ports)); }
NovaTemplateOptions extends TemplateOptions implements Cloneable { @Override public NovaTemplateOptions inboundPorts(int... ports) { return NovaTemplateOptions.class.cast(super.inboundPorts(ports)); } }
NovaTemplateOptions extends TemplateOptions implements Cloneable { @Override public NovaTemplateOptions inboundPorts(int... ports) { return NovaTemplateOptions.class.cast(super.inboundPorts(ports)); } }
NovaTemplateOptions extends TemplateOptions implements Cloneable { @Override public NovaTemplateOptions inboundPorts(int... ports) { return NovaTemplateOptions.class.cast(super.inboundPorts(ports)); } @Override NovaTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override ToStringHelper string(); NovaTemplateOptions autoAssignFloatingIp(boolean enable); NovaTemplateOptions floatingIpPoolNames(String... floatingIpPoolNames); NovaTemplateOptions floatingIpPoolNames(Iterable<String> floatingIpPoolNames); NovaTemplateOptions generateKeyPair(boolean enable); NovaTemplateOptions keyPairName(String keyPairName); boolean shouldAutoAssignFloatingIp(); NovaTemplateOptions availabilityZone(String availabilityZone); NovaTemplateOptions blockDeviceMappings(BlockDeviceMapping... blockDeviceMappings); NovaTemplateOptions blockDeviceMappings(Iterable<BlockDeviceMapping> blockDeviceMappings); Optional<Set<String>> getFloatingIpPoolNames(); String getKeyPairName(); boolean shouldGenerateKeyPair(); byte[] getUserData(); String getDiskConfig(); boolean getConfigDrive(); Set<Network> getNovaNetworks(); String getAvailabilityZone(); Set<BlockDeviceMapping> getBlockDeviceMappings(); @Override NovaTemplateOptions blockOnPort(int port, int seconds); @Override NovaTemplateOptions inboundPorts(int... ports); @Override NovaTemplateOptions authorizePublicKey(String publicKey); @Override NovaTemplateOptions installPrivateKey(String privateKey); @Override NovaTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override NovaTemplateOptions dontAuthorizePublicKey(); @Override NovaTemplateOptions nameTask(String name); @Override NovaTemplateOptions runAsRoot(boolean runAsRoot); @Override NovaTemplateOptions runScript(Statement script); @Override NovaTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override NovaTemplateOptions overrideLoginPassword(String password); @Override NovaTemplateOptions overrideLoginPrivateKey(String privateKey); @Override NovaTemplateOptions overrideLoginUser(String loginUser); @Override NovaTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override NovaTemplateOptions userMetadata(Map<String, String> userMetadata); @Override NovaTemplateOptions userMetadata(String key, String value); @Override NovaTemplateOptions nodeNames(Iterable<String> nodeNames); @Override NovaTemplateOptions networks(Iterable<String> networks); @Override NovaTemplateOptions networks(String... networks); NovaTemplateOptions userData(byte[] userData); NovaTemplateOptions diskConfig(String diskConfig); NovaTemplateOptions configDrive(boolean configDrive); NovaTemplateOptions novaNetworks(Set<Network> novaNetworks); }
NovaTemplateOptions extends TemplateOptions implements Cloneable { @Override public NovaTemplateOptions inboundPorts(int... ports) { return NovaTemplateOptions.class.cast(super.inboundPorts(ports)); } @Override NovaTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override ToStringHelper string(); NovaTemplateOptions autoAssignFloatingIp(boolean enable); NovaTemplateOptions floatingIpPoolNames(String... floatingIpPoolNames); NovaTemplateOptions floatingIpPoolNames(Iterable<String> floatingIpPoolNames); NovaTemplateOptions generateKeyPair(boolean enable); NovaTemplateOptions keyPairName(String keyPairName); boolean shouldAutoAssignFloatingIp(); NovaTemplateOptions availabilityZone(String availabilityZone); NovaTemplateOptions blockDeviceMappings(BlockDeviceMapping... blockDeviceMappings); NovaTemplateOptions blockDeviceMappings(Iterable<BlockDeviceMapping> blockDeviceMappings); Optional<Set<String>> getFloatingIpPoolNames(); String getKeyPairName(); boolean shouldGenerateKeyPair(); byte[] getUserData(); String getDiskConfig(); boolean getConfigDrive(); Set<Network> getNovaNetworks(); String getAvailabilityZone(); Set<BlockDeviceMapping> getBlockDeviceMappings(); @Override NovaTemplateOptions blockOnPort(int port, int seconds); @Override NovaTemplateOptions inboundPorts(int... ports); @Override NovaTemplateOptions authorizePublicKey(String publicKey); @Override NovaTemplateOptions installPrivateKey(String privateKey); @Override NovaTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override NovaTemplateOptions dontAuthorizePublicKey(); @Override NovaTemplateOptions nameTask(String name); @Override NovaTemplateOptions runAsRoot(boolean runAsRoot); @Override NovaTemplateOptions runScript(Statement script); @Override NovaTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override NovaTemplateOptions overrideLoginPassword(String password); @Override NovaTemplateOptions overrideLoginPrivateKey(String privateKey); @Override NovaTemplateOptions overrideLoginUser(String loginUser); @Override NovaTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override NovaTemplateOptions userMetadata(Map<String, String> userMetadata); @Override NovaTemplateOptions userMetadata(String key, String value); @Override NovaTemplateOptions nodeNames(Iterable<String> nodeNames); @Override NovaTemplateOptions networks(Iterable<String> networks); @Override NovaTemplateOptions networks(String... networks); NovaTemplateOptions userData(byte[] userData); NovaTemplateOptions diskConfig(String diskConfig); NovaTemplateOptions configDrive(boolean configDrive); NovaTemplateOptions novaNetworks(Set<Network> novaNetworks); }
@Test public void testWhenComputeServiceSaysAllNodesAreDeadBothGroupsAreReturned() { ServerInRegion withoutHost = new ServerInRegion(new ServerInRegionToNodeMetadataTest().expectedServer(), "az-1.region-a.geo-1"); ServerInRegion withHost = new ServerInRegion(new ParseServerTest().expected(), "az-1.region-a.geo-1"); ServerInRegionToNodeMetadata converter = new ServerInRegionToNodeMetadata( NovaComputeServiceContextModule.toPortableNodeStatus, locationIndex, Suppliers .<Set<? extends Image>> ofInstance(ImmutableSet.<Image> of()), Suppliers .<Set<? extends Hardware>> ofInstance(ImmutableSet.<Hardware> of()), namingConvention); Set<? extends NodeMetadata> set = ImmutableSet.of(converter.apply(withHost), converter.apply(withoutHost)); assertEquals(new OrphanedGroupsByRegionId(Predicates.<RegionAndName> alwaysTrue()).apply(set), ImmutableMultimap .<String, String> builder().putAll("az-1.region-a.geo-1", "sample", "test").build()); }
public Multimap<String, String> apply(Set<? extends NodeMetadata> deadNodes) { Iterable<? extends NodeMetadata> nodesWithGroup = filter(deadNodes, NodePredicates.hasGroup()); Set<RegionAndName> regionAndGroupNames = ImmutableSet.copyOf(filter(transform(nodesWithGroup, new Function<NodeMetadata, RegionAndName>() { @Override public RegionAndName apply(NodeMetadata input) { String regionId = input.getLocation().getScope() == LocationScope.HOST ? input.getLocation() .getParent().getId() : input.getLocation().getId(); return RegionAndName.fromRegionAndName(regionId, input.getGroup()); } }), allNodesInGroupTerminated)); Multimap<String, String> regionToRegionAndGroupNames = Multimaps.transformValues(Multimaps.index(regionAndGroupNames, RegionAndName.REGION_FUNCTION), RegionAndName.NAME_FUNCTION); return regionToRegionAndGroupNames; }
OrphanedGroupsByRegionId implements Function<Set<? extends NodeMetadata>, Multimap<String, String>> { public Multimap<String, String> apply(Set<? extends NodeMetadata> deadNodes) { Iterable<? extends NodeMetadata> nodesWithGroup = filter(deadNodes, NodePredicates.hasGroup()); Set<RegionAndName> regionAndGroupNames = ImmutableSet.copyOf(filter(transform(nodesWithGroup, new Function<NodeMetadata, RegionAndName>() { @Override public RegionAndName apply(NodeMetadata input) { String regionId = input.getLocation().getScope() == LocationScope.HOST ? input.getLocation() .getParent().getId() : input.getLocation().getId(); return RegionAndName.fromRegionAndName(regionId, input.getGroup()); } }), allNodesInGroupTerminated)); Multimap<String, String> regionToRegionAndGroupNames = Multimaps.transformValues(Multimaps.index(regionAndGroupNames, RegionAndName.REGION_FUNCTION), RegionAndName.NAME_FUNCTION); return regionToRegionAndGroupNames; } }
OrphanedGroupsByRegionId implements Function<Set<? extends NodeMetadata>, Multimap<String, String>> { public Multimap<String, String> apply(Set<? extends NodeMetadata> deadNodes) { Iterable<? extends NodeMetadata> nodesWithGroup = filter(deadNodes, NodePredicates.hasGroup()); Set<RegionAndName> regionAndGroupNames = ImmutableSet.copyOf(filter(transform(nodesWithGroup, new Function<NodeMetadata, RegionAndName>() { @Override public RegionAndName apply(NodeMetadata input) { String regionId = input.getLocation().getScope() == LocationScope.HOST ? input.getLocation() .getParent().getId() : input.getLocation().getId(); return RegionAndName.fromRegionAndName(regionId, input.getGroup()); } }), allNodesInGroupTerminated)); Multimap<String, String> regionToRegionAndGroupNames = Multimaps.transformValues(Multimaps.index(regionAndGroupNames, RegionAndName.REGION_FUNCTION), RegionAndName.NAME_FUNCTION); return regionToRegionAndGroupNames; } @Inject protected OrphanedGroupsByRegionId(ComputeService computeService); @VisibleForTesting OrphanedGroupsByRegionId(Predicate<RegionAndName> allNodesInGroupTerminated); }
OrphanedGroupsByRegionId implements Function<Set<? extends NodeMetadata>, Multimap<String, String>> { public Multimap<String, String> apply(Set<? extends NodeMetadata> deadNodes) { Iterable<? extends NodeMetadata> nodesWithGroup = filter(deadNodes, NodePredicates.hasGroup()); Set<RegionAndName> regionAndGroupNames = ImmutableSet.copyOf(filter(transform(nodesWithGroup, new Function<NodeMetadata, RegionAndName>() { @Override public RegionAndName apply(NodeMetadata input) { String regionId = input.getLocation().getScope() == LocationScope.HOST ? input.getLocation() .getParent().getId() : input.getLocation().getId(); return RegionAndName.fromRegionAndName(regionId, input.getGroup()); } }), allNodesInGroupTerminated)); Multimap<String, String> regionToRegionAndGroupNames = Multimaps.transformValues(Multimaps.index(regionAndGroupNames, RegionAndName.REGION_FUNCTION), RegionAndName.NAME_FUNCTION); return regionToRegionAndGroupNames; } @Inject protected OrphanedGroupsByRegionId(ComputeService computeService); @VisibleForTesting OrphanedGroupsByRegionId(Predicate<RegionAndName> allNodesInGroupTerminated); Multimap<String, String> apply(Set<? extends NodeMetadata> deadNodes); }
OrphanedGroupsByRegionId implements Function<Set<? extends NodeMetadata>, Multimap<String, String>> { public Multimap<String, String> apply(Set<? extends NodeMetadata> deadNodes) { Iterable<? extends NodeMetadata> nodesWithGroup = filter(deadNodes, NodePredicates.hasGroup()); Set<RegionAndName> regionAndGroupNames = ImmutableSet.copyOf(filter(transform(nodesWithGroup, new Function<NodeMetadata, RegionAndName>() { @Override public RegionAndName apply(NodeMetadata input) { String regionId = input.getLocation().getScope() == LocationScope.HOST ? input.getLocation() .getParent().getId() : input.getLocation().getId(); return RegionAndName.fromRegionAndName(regionId, input.getGroup()); } }), allNodesInGroupTerminated)); Multimap<String, String> regionToRegionAndGroupNames = Multimaps.transformValues(Multimaps.index(regionAndGroupNames, RegionAndName.REGION_FUNCTION), RegionAndName.NAME_FUNCTION); return regionToRegionAndGroupNames; } @Inject protected OrphanedGroupsByRegionId(ComputeService computeService); @VisibleForTesting OrphanedGroupsByRegionId(Predicate<RegionAndName> allNodesInGroupTerminated); Multimap<String, String> apply(Set<? extends NodeMetadata> deadNodes); }
@Test public void testWhenComputeServiceSaysAllNodesAreDeadNoGroupsAreReturned() { ServerInRegion withoutHost = new ServerInRegion(new ServerInRegionToNodeMetadataTest().expectedServer(), "az-1.region-a.geo-1"); ServerInRegion withHost = new ServerInRegion(new ParseServerTest().expected(), "az-1.region-a.geo-1"); ServerInRegionToNodeMetadata converter = new ServerInRegionToNodeMetadata( NovaComputeServiceContextModule.toPortableNodeStatus, locationIndex, Suppliers .<Set<? extends Image>> ofInstance(ImmutableSet.<Image> of()), Suppliers .<Set<? extends Hardware>> ofInstance(ImmutableSet.<Hardware> of()), namingConvention); Set<? extends NodeMetadata> set = ImmutableSet.of(converter.apply(withHost), converter.apply(withoutHost)); assertEquals(new OrphanedGroupsByRegionId(Predicates.<RegionAndName> alwaysFalse()).apply(set), ImmutableMultimap .<String, String> of()); }
public Multimap<String, String> apply(Set<? extends NodeMetadata> deadNodes) { Iterable<? extends NodeMetadata> nodesWithGroup = filter(deadNodes, NodePredicates.hasGroup()); Set<RegionAndName> regionAndGroupNames = ImmutableSet.copyOf(filter(transform(nodesWithGroup, new Function<NodeMetadata, RegionAndName>() { @Override public RegionAndName apply(NodeMetadata input) { String regionId = input.getLocation().getScope() == LocationScope.HOST ? input.getLocation() .getParent().getId() : input.getLocation().getId(); return RegionAndName.fromRegionAndName(regionId, input.getGroup()); } }), allNodesInGroupTerminated)); Multimap<String, String> regionToRegionAndGroupNames = Multimaps.transformValues(Multimaps.index(regionAndGroupNames, RegionAndName.REGION_FUNCTION), RegionAndName.NAME_FUNCTION); return regionToRegionAndGroupNames; }
OrphanedGroupsByRegionId implements Function<Set<? extends NodeMetadata>, Multimap<String, String>> { public Multimap<String, String> apply(Set<? extends NodeMetadata> deadNodes) { Iterable<? extends NodeMetadata> nodesWithGroup = filter(deadNodes, NodePredicates.hasGroup()); Set<RegionAndName> regionAndGroupNames = ImmutableSet.copyOf(filter(transform(nodesWithGroup, new Function<NodeMetadata, RegionAndName>() { @Override public RegionAndName apply(NodeMetadata input) { String regionId = input.getLocation().getScope() == LocationScope.HOST ? input.getLocation() .getParent().getId() : input.getLocation().getId(); return RegionAndName.fromRegionAndName(regionId, input.getGroup()); } }), allNodesInGroupTerminated)); Multimap<String, String> regionToRegionAndGroupNames = Multimaps.transformValues(Multimaps.index(regionAndGroupNames, RegionAndName.REGION_FUNCTION), RegionAndName.NAME_FUNCTION); return regionToRegionAndGroupNames; } }
OrphanedGroupsByRegionId implements Function<Set<? extends NodeMetadata>, Multimap<String, String>> { public Multimap<String, String> apply(Set<? extends NodeMetadata> deadNodes) { Iterable<? extends NodeMetadata> nodesWithGroup = filter(deadNodes, NodePredicates.hasGroup()); Set<RegionAndName> regionAndGroupNames = ImmutableSet.copyOf(filter(transform(nodesWithGroup, new Function<NodeMetadata, RegionAndName>() { @Override public RegionAndName apply(NodeMetadata input) { String regionId = input.getLocation().getScope() == LocationScope.HOST ? input.getLocation() .getParent().getId() : input.getLocation().getId(); return RegionAndName.fromRegionAndName(regionId, input.getGroup()); } }), allNodesInGroupTerminated)); Multimap<String, String> regionToRegionAndGroupNames = Multimaps.transformValues(Multimaps.index(regionAndGroupNames, RegionAndName.REGION_FUNCTION), RegionAndName.NAME_FUNCTION); return regionToRegionAndGroupNames; } @Inject protected OrphanedGroupsByRegionId(ComputeService computeService); @VisibleForTesting OrphanedGroupsByRegionId(Predicate<RegionAndName> allNodesInGroupTerminated); }
OrphanedGroupsByRegionId implements Function<Set<? extends NodeMetadata>, Multimap<String, String>> { public Multimap<String, String> apply(Set<? extends NodeMetadata> deadNodes) { Iterable<? extends NodeMetadata> nodesWithGroup = filter(deadNodes, NodePredicates.hasGroup()); Set<RegionAndName> regionAndGroupNames = ImmutableSet.copyOf(filter(transform(nodesWithGroup, new Function<NodeMetadata, RegionAndName>() { @Override public RegionAndName apply(NodeMetadata input) { String regionId = input.getLocation().getScope() == LocationScope.HOST ? input.getLocation() .getParent().getId() : input.getLocation().getId(); return RegionAndName.fromRegionAndName(regionId, input.getGroup()); } }), allNodesInGroupTerminated)); Multimap<String, String> regionToRegionAndGroupNames = Multimaps.transformValues(Multimaps.index(regionAndGroupNames, RegionAndName.REGION_FUNCTION), RegionAndName.NAME_FUNCTION); return regionToRegionAndGroupNames; } @Inject protected OrphanedGroupsByRegionId(ComputeService computeService); @VisibleForTesting OrphanedGroupsByRegionId(Predicate<RegionAndName> allNodesInGroupTerminated); Multimap<String, String> apply(Set<? extends NodeMetadata> deadNodes); }
OrphanedGroupsByRegionId implements Function<Set<? extends NodeMetadata>, Multimap<String, String>> { public Multimap<String, String> apply(Set<? extends NodeMetadata> deadNodes) { Iterable<? extends NodeMetadata> nodesWithGroup = filter(deadNodes, NodePredicates.hasGroup()); Set<RegionAndName> regionAndGroupNames = ImmutableSet.copyOf(filter(transform(nodesWithGroup, new Function<NodeMetadata, RegionAndName>() { @Override public RegionAndName apply(NodeMetadata input) { String regionId = input.getLocation().getScope() == LocationScope.HOST ? input.getLocation() .getParent().getId() : input.getLocation().getId(); return RegionAndName.fromRegionAndName(regionId, input.getGroup()); } }), allNodesInGroupTerminated)); Multimap<String, String> regionToRegionAndGroupNames = Multimaps.transformValues(Multimaps.index(regionAndGroupNames, RegionAndName.REGION_FUNCTION), RegionAndName.NAME_FUNCTION); return regionToRegionAndGroupNames; } @Inject protected OrphanedGroupsByRegionId(ComputeService computeService); @VisibleForTesting OrphanedGroupsByRegionId(Predicate<RegionAndName> allNodesInGroupTerminated); Multimap<String, String> apply(Set<? extends NodeMetadata> deadNodes); }
@Test(dataProvider = "getOsFamilyValues") public void testOsFamilyValues(OsFamily family) { Image imageToConvert = Image.builder().id("id-" + family.name()).name(family.name()).build(); ImageToOperatingSystem converter = new ImageToOperatingSystem( new HashMap<OsFamily, Map<String, String>>()); OperatingSystem convertedOs = converter.apply(imageToConvert); assertEquals(convertedOs.getName(), imageToConvert.getName()); assertEquals(convertedOs.getFamily(), family); assertEquals(convertedOs.getDescription(), imageToConvert.getName()); assertEquals(convertedOs.getVersion(), null); assertEquals(convertedOs.getArch(), null); assertTrue(convertedOs.is64Bit()); }
public OperatingSystem apply(final Image from) { OsFamily osFamily = null; String osVersion = null; String imageName = MoreObjects.firstNonNull(from.getName(), "unspecified"); boolean is64Bit = true; if (imageName.indexOf("Windows") != -1) { osFamily = OsFamily.WINDOWS; Matcher matcher = WINDOWS_PATTERN.matcher(from.getName()); if (matcher.find()) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(1), osVersionMap); is64Bit = matcher.group(2).equals("x64"); } } else { if (imageName.contains("Red Hat")) { osFamily = OsFamily.RHEL; } else if (imageName.contains("Oracle")) { osFamily = OsFamily.OEL; } else { final Iterable<String> imageNameParts = Splitter.on(CharMatcher.WHITESPACE).trimResults().split( imageName.toLowerCase()); try { osFamily = find(Arrays.asList(OsFamily.values()), new Predicate<OsFamily>() { @Override public boolean apply(OsFamily osFamily) { return any(imageNameParts, equalTo(osFamily.name().toLowerCase())); } }); } catch (NoSuchElementException e) { String ubuntuVersion = startsWithUbuntuVersion(imageNameParts); if (ubuntuVersion != null) { osFamily = OsFamily.UBUNTU; osVersion = ubuntuVersion; } else { logger.trace("could not parse operating system family for image(%s): %s", from.getId(), imageNameParts); osFamily = OsFamily.UNRECOGNIZED; } } } Matcher matcher = DEFAULT_PATTERN.matcher(imageName); if (matcher.find() && matcher.groupCount() >= 3) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(3), osVersionMap); } } return new OperatingSystem(osFamily, imageName, osVersion, null, imageName, is64Bit); }
ImageToOperatingSystem implements Function<Image, OperatingSystem> { public OperatingSystem apply(final Image from) { OsFamily osFamily = null; String osVersion = null; String imageName = MoreObjects.firstNonNull(from.getName(), "unspecified"); boolean is64Bit = true; if (imageName.indexOf("Windows") != -1) { osFamily = OsFamily.WINDOWS; Matcher matcher = WINDOWS_PATTERN.matcher(from.getName()); if (matcher.find()) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(1), osVersionMap); is64Bit = matcher.group(2).equals("x64"); } } else { if (imageName.contains("Red Hat")) { osFamily = OsFamily.RHEL; } else if (imageName.contains("Oracle")) { osFamily = OsFamily.OEL; } else { final Iterable<String> imageNameParts = Splitter.on(CharMatcher.WHITESPACE).trimResults().split( imageName.toLowerCase()); try { osFamily = find(Arrays.asList(OsFamily.values()), new Predicate<OsFamily>() { @Override public boolean apply(OsFamily osFamily) { return any(imageNameParts, equalTo(osFamily.name().toLowerCase())); } }); } catch (NoSuchElementException e) { String ubuntuVersion = startsWithUbuntuVersion(imageNameParts); if (ubuntuVersion != null) { osFamily = OsFamily.UBUNTU; osVersion = ubuntuVersion; } else { logger.trace("could not parse operating system family for image(%s): %s", from.getId(), imageNameParts); osFamily = OsFamily.UNRECOGNIZED; } } } Matcher matcher = DEFAULT_PATTERN.matcher(imageName); if (matcher.find() && matcher.groupCount() >= 3) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(3), osVersionMap); } } return new OperatingSystem(osFamily, imageName, osVersion, null, imageName, is64Bit); } }
ImageToOperatingSystem implements Function<Image, OperatingSystem> { public OperatingSystem apply(final Image from) { OsFamily osFamily = null; String osVersion = null; String imageName = MoreObjects.firstNonNull(from.getName(), "unspecified"); boolean is64Bit = true; if (imageName.indexOf("Windows") != -1) { osFamily = OsFamily.WINDOWS; Matcher matcher = WINDOWS_PATTERN.matcher(from.getName()); if (matcher.find()) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(1), osVersionMap); is64Bit = matcher.group(2).equals("x64"); } } else { if (imageName.contains("Red Hat")) { osFamily = OsFamily.RHEL; } else if (imageName.contains("Oracle")) { osFamily = OsFamily.OEL; } else { final Iterable<String> imageNameParts = Splitter.on(CharMatcher.WHITESPACE).trimResults().split( imageName.toLowerCase()); try { osFamily = find(Arrays.asList(OsFamily.values()), new Predicate<OsFamily>() { @Override public boolean apply(OsFamily osFamily) { return any(imageNameParts, equalTo(osFamily.name().toLowerCase())); } }); } catch (NoSuchElementException e) { String ubuntuVersion = startsWithUbuntuVersion(imageNameParts); if (ubuntuVersion != null) { osFamily = OsFamily.UBUNTU; osVersion = ubuntuVersion; } else { logger.trace("could not parse operating system family for image(%s): %s", from.getId(), imageNameParts); osFamily = OsFamily.UNRECOGNIZED; } } } Matcher matcher = DEFAULT_PATTERN.matcher(imageName); if (matcher.find() && matcher.groupCount() >= 3) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(3), osVersionMap); } } return new OperatingSystem(osFamily, imageName, osVersion, null, imageName, is64Bit); } @Inject ImageToOperatingSystem(Map<OsFamily, Map<String, String>> osVersionMap); }
ImageToOperatingSystem implements Function<Image, OperatingSystem> { public OperatingSystem apply(final Image from) { OsFamily osFamily = null; String osVersion = null; String imageName = MoreObjects.firstNonNull(from.getName(), "unspecified"); boolean is64Bit = true; if (imageName.indexOf("Windows") != -1) { osFamily = OsFamily.WINDOWS; Matcher matcher = WINDOWS_PATTERN.matcher(from.getName()); if (matcher.find()) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(1), osVersionMap); is64Bit = matcher.group(2).equals("x64"); } } else { if (imageName.contains("Red Hat")) { osFamily = OsFamily.RHEL; } else if (imageName.contains("Oracle")) { osFamily = OsFamily.OEL; } else { final Iterable<String> imageNameParts = Splitter.on(CharMatcher.WHITESPACE).trimResults().split( imageName.toLowerCase()); try { osFamily = find(Arrays.asList(OsFamily.values()), new Predicate<OsFamily>() { @Override public boolean apply(OsFamily osFamily) { return any(imageNameParts, equalTo(osFamily.name().toLowerCase())); } }); } catch (NoSuchElementException e) { String ubuntuVersion = startsWithUbuntuVersion(imageNameParts); if (ubuntuVersion != null) { osFamily = OsFamily.UBUNTU; osVersion = ubuntuVersion; } else { logger.trace("could not parse operating system family for image(%s): %s", from.getId(), imageNameParts); osFamily = OsFamily.UNRECOGNIZED; } } } Matcher matcher = DEFAULT_PATTERN.matcher(imageName); if (matcher.find() && matcher.groupCount() >= 3) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(3), osVersionMap); } } return new OperatingSystem(osFamily, imageName, osVersion, null, imageName, is64Bit); } @Inject ImageToOperatingSystem(Map<OsFamily, Map<String, String>> osVersionMap); OperatingSystem apply(final Image from); }
ImageToOperatingSystem implements Function<Image, OperatingSystem> { public OperatingSystem apply(final Image from) { OsFamily osFamily = null; String osVersion = null; String imageName = MoreObjects.firstNonNull(from.getName(), "unspecified"); boolean is64Bit = true; if (imageName.indexOf("Windows") != -1) { osFamily = OsFamily.WINDOWS; Matcher matcher = WINDOWS_PATTERN.matcher(from.getName()); if (matcher.find()) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(1), osVersionMap); is64Bit = matcher.group(2).equals("x64"); } } else { if (imageName.contains("Red Hat")) { osFamily = OsFamily.RHEL; } else if (imageName.contains("Oracle")) { osFamily = OsFamily.OEL; } else { final Iterable<String> imageNameParts = Splitter.on(CharMatcher.WHITESPACE).trimResults().split( imageName.toLowerCase()); try { osFamily = find(Arrays.asList(OsFamily.values()), new Predicate<OsFamily>() { @Override public boolean apply(OsFamily osFamily) { return any(imageNameParts, equalTo(osFamily.name().toLowerCase())); } }); } catch (NoSuchElementException e) { String ubuntuVersion = startsWithUbuntuVersion(imageNameParts); if (ubuntuVersion != null) { osFamily = OsFamily.UBUNTU; osVersion = ubuntuVersion; } else { logger.trace("could not parse operating system family for image(%s): %s", from.getId(), imageNameParts); osFamily = OsFamily.UNRECOGNIZED; } } } Matcher matcher = DEFAULT_PATTERN.matcher(imageName); if (matcher.find() && matcher.groupCount() >= 3) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(3), osVersionMap); } } return new OperatingSystem(osFamily, imageName, osVersion, null, imageName, is64Bit); } @Inject ImageToOperatingSystem(Map<OsFamily, Map<String, String>> osVersionMap); OperatingSystem apply(final Image from); static final Pattern DEFAULT_PATTERN; static final Pattern WINDOWS_PATTERN; }
@Test public void testWindowsServer2008R2x64() { String name = "Windows Server 2008 R2 x64"; Image imageToConvert = Image.builder().id("id-" + name).name(name).build(); Map<OsFamily, Map<String, String>> osFamilyMap = Maps.newHashMap(); osFamilyMap.put(OsFamily.WINDOWS, ImmutableMap.of("Server 2008 R2", "Server-2008-R2")); ImageToOperatingSystem converter = new ImageToOperatingSystem(osFamilyMap); OperatingSystem convertedOs = converter.apply(imageToConvert); assertEquals(convertedOs.getName(), imageToConvert.getName()); assertEquals(convertedOs.getFamily(), OsFamily.WINDOWS); assertEquals(convertedOs.getDescription(), imageToConvert.getName()); assertEquals(convertedOs.getVersion(), "Server-2008-R2"); assertEquals(convertedOs.getArch(), null); assertTrue(convertedOs.is64Bit()); }
public OperatingSystem apply(final Image from) { OsFamily osFamily = null; String osVersion = null; String imageName = MoreObjects.firstNonNull(from.getName(), "unspecified"); boolean is64Bit = true; if (imageName.indexOf("Windows") != -1) { osFamily = OsFamily.WINDOWS; Matcher matcher = WINDOWS_PATTERN.matcher(from.getName()); if (matcher.find()) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(1), osVersionMap); is64Bit = matcher.group(2).equals("x64"); } } else { if (imageName.contains("Red Hat")) { osFamily = OsFamily.RHEL; } else if (imageName.contains("Oracle")) { osFamily = OsFamily.OEL; } else { final Iterable<String> imageNameParts = Splitter.on(CharMatcher.WHITESPACE).trimResults().split( imageName.toLowerCase()); try { osFamily = find(Arrays.asList(OsFamily.values()), new Predicate<OsFamily>() { @Override public boolean apply(OsFamily osFamily) { return any(imageNameParts, equalTo(osFamily.name().toLowerCase())); } }); } catch (NoSuchElementException e) { String ubuntuVersion = startsWithUbuntuVersion(imageNameParts); if (ubuntuVersion != null) { osFamily = OsFamily.UBUNTU; osVersion = ubuntuVersion; } else { logger.trace("could not parse operating system family for image(%s): %s", from.getId(), imageNameParts); osFamily = OsFamily.UNRECOGNIZED; } } } Matcher matcher = DEFAULT_PATTERN.matcher(imageName); if (matcher.find() && matcher.groupCount() >= 3) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(3), osVersionMap); } } return new OperatingSystem(osFamily, imageName, osVersion, null, imageName, is64Bit); }
ImageToOperatingSystem implements Function<Image, OperatingSystem> { public OperatingSystem apply(final Image from) { OsFamily osFamily = null; String osVersion = null; String imageName = MoreObjects.firstNonNull(from.getName(), "unspecified"); boolean is64Bit = true; if (imageName.indexOf("Windows") != -1) { osFamily = OsFamily.WINDOWS; Matcher matcher = WINDOWS_PATTERN.matcher(from.getName()); if (matcher.find()) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(1), osVersionMap); is64Bit = matcher.group(2).equals("x64"); } } else { if (imageName.contains("Red Hat")) { osFamily = OsFamily.RHEL; } else if (imageName.contains("Oracle")) { osFamily = OsFamily.OEL; } else { final Iterable<String> imageNameParts = Splitter.on(CharMatcher.WHITESPACE).trimResults().split( imageName.toLowerCase()); try { osFamily = find(Arrays.asList(OsFamily.values()), new Predicate<OsFamily>() { @Override public boolean apply(OsFamily osFamily) { return any(imageNameParts, equalTo(osFamily.name().toLowerCase())); } }); } catch (NoSuchElementException e) { String ubuntuVersion = startsWithUbuntuVersion(imageNameParts); if (ubuntuVersion != null) { osFamily = OsFamily.UBUNTU; osVersion = ubuntuVersion; } else { logger.trace("could not parse operating system family for image(%s): %s", from.getId(), imageNameParts); osFamily = OsFamily.UNRECOGNIZED; } } } Matcher matcher = DEFAULT_PATTERN.matcher(imageName); if (matcher.find() && matcher.groupCount() >= 3) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(3), osVersionMap); } } return new OperatingSystem(osFamily, imageName, osVersion, null, imageName, is64Bit); } }
ImageToOperatingSystem implements Function<Image, OperatingSystem> { public OperatingSystem apply(final Image from) { OsFamily osFamily = null; String osVersion = null; String imageName = MoreObjects.firstNonNull(from.getName(), "unspecified"); boolean is64Bit = true; if (imageName.indexOf("Windows") != -1) { osFamily = OsFamily.WINDOWS; Matcher matcher = WINDOWS_PATTERN.matcher(from.getName()); if (matcher.find()) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(1), osVersionMap); is64Bit = matcher.group(2).equals("x64"); } } else { if (imageName.contains("Red Hat")) { osFamily = OsFamily.RHEL; } else if (imageName.contains("Oracle")) { osFamily = OsFamily.OEL; } else { final Iterable<String> imageNameParts = Splitter.on(CharMatcher.WHITESPACE).trimResults().split( imageName.toLowerCase()); try { osFamily = find(Arrays.asList(OsFamily.values()), new Predicate<OsFamily>() { @Override public boolean apply(OsFamily osFamily) { return any(imageNameParts, equalTo(osFamily.name().toLowerCase())); } }); } catch (NoSuchElementException e) { String ubuntuVersion = startsWithUbuntuVersion(imageNameParts); if (ubuntuVersion != null) { osFamily = OsFamily.UBUNTU; osVersion = ubuntuVersion; } else { logger.trace("could not parse operating system family for image(%s): %s", from.getId(), imageNameParts); osFamily = OsFamily.UNRECOGNIZED; } } } Matcher matcher = DEFAULT_PATTERN.matcher(imageName); if (matcher.find() && matcher.groupCount() >= 3) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(3), osVersionMap); } } return new OperatingSystem(osFamily, imageName, osVersion, null, imageName, is64Bit); } @Inject ImageToOperatingSystem(Map<OsFamily, Map<String, String>> osVersionMap); }
ImageToOperatingSystem implements Function<Image, OperatingSystem> { public OperatingSystem apply(final Image from) { OsFamily osFamily = null; String osVersion = null; String imageName = MoreObjects.firstNonNull(from.getName(), "unspecified"); boolean is64Bit = true; if (imageName.indexOf("Windows") != -1) { osFamily = OsFamily.WINDOWS; Matcher matcher = WINDOWS_PATTERN.matcher(from.getName()); if (matcher.find()) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(1), osVersionMap); is64Bit = matcher.group(2).equals("x64"); } } else { if (imageName.contains("Red Hat")) { osFamily = OsFamily.RHEL; } else if (imageName.contains("Oracle")) { osFamily = OsFamily.OEL; } else { final Iterable<String> imageNameParts = Splitter.on(CharMatcher.WHITESPACE).trimResults().split( imageName.toLowerCase()); try { osFamily = find(Arrays.asList(OsFamily.values()), new Predicate<OsFamily>() { @Override public boolean apply(OsFamily osFamily) { return any(imageNameParts, equalTo(osFamily.name().toLowerCase())); } }); } catch (NoSuchElementException e) { String ubuntuVersion = startsWithUbuntuVersion(imageNameParts); if (ubuntuVersion != null) { osFamily = OsFamily.UBUNTU; osVersion = ubuntuVersion; } else { logger.trace("could not parse operating system family for image(%s): %s", from.getId(), imageNameParts); osFamily = OsFamily.UNRECOGNIZED; } } } Matcher matcher = DEFAULT_PATTERN.matcher(imageName); if (matcher.find() && matcher.groupCount() >= 3) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(3), osVersionMap); } } return new OperatingSystem(osFamily, imageName, osVersion, null, imageName, is64Bit); } @Inject ImageToOperatingSystem(Map<OsFamily, Map<String, String>> osVersionMap); OperatingSystem apply(final Image from); }
ImageToOperatingSystem implements Function<Image, OperatingSystem> { public OperatingSystem apply(final Image from) { OsFamily osFamily = null; String osVersion = null; String imageName = MoreObjects.firstNonNull(from.getName(), "unspecified"); boolean is64Bit = true; if (imageName.indexOf("Windows") != -1) { osFamily = OsFamily.WINDOWS; Matcher matcher = WINDOWS_PATTERN.matcher(from.getName()); if (matcher.find()) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(1), osVersionMap); is64Bit = matcher.group(2).equals("x64"); } } else { if (imageName.contains("Red Hat")) { osFamily = OsFamily.RHEL; } else if (imageName.contains("Oracle")) { osFamily = OsFamily.OEL; } else { final Iterable<String> imageNameParts = Splitter.on(CharMatcher.WHITESPACE).trimResults().split( imageName.toLowerCase()); try { osFamily = find(Arrays.asList(OsFamily.values()), new Predicate<OsFamily>() { @Override public boolean apply(OsFamily osFamily) { return any(imageNameParts, equalTo(osFamily.name().toLowerCase())); } }); } catch (NoSuchElementException e) { String ubuntuVersion = startsWithUbuntuVersion(imageNameParts); if (ubuntuVersion != null) { osFamily = OsFamily.UBUNTU; osVersion = ubuntuVersion; } else { logger.trace("could not parse operating system family for image(%s): %s", from.getId(), imageNameParts); osFamily = OsFamily.UNRECOGNIZED; } } } Matcher matcher = DEFAULT_PATTERN.matcher(imageName); if (matcher.find() && matcher.groupCount() >= 3) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(3), osVersionMap); } } return new OperatingSystem(osFamily, imageName, osVersion, null, imageName, is64Bit); } @Inject ImageToOperatingSystem(Map<OsFamily, Map<String, String>> osVersionMap); OperatingSystem apply(final Image from); static final Pattern DEFAULT_PATTERN; static final Pattern WINDOWS_PATTERN; }
@Test public void testWindows98x86() { String name = "Windows 98 x86"; Image imageToConvert = Image.builder().id("id-" + name).name(name).build(); Map<OsFamily, Map<String, String>> osFamilyMap = Maps.newHashMap(); osFamilyMap.put(OsFamily.WINDOWS, ImmutableMap.of("98", "98")); ImageToOperatingSystem converter = new ImageToOperatingSystem(osFamilyMap); OperatingSystem convertedOs = converter.apply(imageToConvert); assertEquals(convertedOs.getName(), imageToConvert.getName()); assertEquals(convertedOs.getFamily(), OsFamily.WINDOWS); assertEquals(convertedOs.getDescription(), imageToConvert.getName()); assertEquals(convertedOs.getVersion(), "98"); assertEquals(convertedOs.getArch(), null); assertFalse(convertedOs.is64Bit()); }
public OperatingSystem apply(final Image from) { OsFamily osFamily = null; String osVersion = null; String imageName = MoreObjects.firstNonNull(from.getName(), "unspecified"); boolean is64Bit = true; if (imageName.indexOf("Windows") != -1) { osFamily = OsFamily.WINDOWS; Matcher matcher = WINDOWS_PATTERN.matcher(from.getName()); if (matcher.find()) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(1), osVersionMap); is64Bit = matcher.group(2).equals("x64"); } } else { if (imageName.contains("Red Hat")) { osFamily = OsFamily.RHEL; } else if (imageName.contains("Oracle")) { osFamily = OsFamily.OEL; } else { final Iterable<String> imageNameParts = Splitter.on(CharMatcher.WHITESPACE).trimResults().split( imageName.toLowerCase()); try { osFamily = find(Arrays.asList(OsFamily.values()), new Predicate<OsFamily>() { @Override public boolean apply(OsFamily osFamily) { return any(imageNameParts, equalTo(osFamily.name().toLowerCase())); } }); } catch (NoSuchElementException e) { String ubuntuVersion = startsWithUbuntuVersion(imageNameParts); if (ubuntuVersion != null) { osFamily = OsFamily.UBUNTU; osVersion = ubuntuVersion; } else { logger.trace("could not parse operating system family for image(%s): %s", from.getId(), imageNameParts); osFamily = OsFamily.UNRECOGNIZED; } } } Matcher matcher = DEFAULT_PATTERN.matcher(imageName); if (matcher.find() && matcher.groupCount() >= 3) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(3), osVersionMap); } } return new OperatingSystem(osFamily, imageName, osVersion, null, imageName, is64Bit); }
ImageToOperatingSystem implements Function<Image, OperatingSystem> { public OperatingSystem apply(final Image from) { OsFamily osFamily = null; String osVersion = null; String imageName = MoreObjects.firstNonNull(from.getName(), "unspecified"); boolean is64Bit = true; if (imageName.indexOf("Windows") != -1) { osFamily = OsFamily.WINDOWS; Matcher matcher = WINDOWS_PATTERN.matcher(from.getName()); if (matcher.find()) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(1), osVersionMap); is64Bit = matcher.group(2).equals("x64"); } } else { if (imageName.contains("Red Hat")) { osFamily = OsFamily.RHEL; } else if (imageName.contains("Oracle")) { osFamily = OsFamily.OEL; } else { final Iterable<String> imageNameParts = Splitter.on(CharMatcher.WHITESPACE).trimResults().split( imageName.toLowerCase()); try { osFamily = find(Arrays.asList(OsFamily.values()), new Predicate<OsFamily>() { @Override public boolean apply(OsFamily osFamily) { return any(imageNameParts, equalTo(osFamily.name().toLowerCase())); } }); } catch (NoSuchElementException e) { String ubuntuVersion = startsWithUbuntuVersion(imageNameParts); if (ubuntuVersion != null) { osFamily = OsFamily.UBUNTU; osVersion = ubuntuVersion; } else { logger.trace("could not parse operating system family for image(%s): %s", from.getId(), imageNameParts); osFamily = OsFamily.UNRECOGNIZED; } } } Matcher matcher = DEFAULT_PATTERN.matcher(imageName); if (matcher.find() && matcher.groupCount() >= 3) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(3), osVersionMap); } } return new OperatingSystem(osFamily, imageName, osVersion, null, imageName, is64Bit); } }
ImageToOperatingSystem implements Function<Image, OperatingSystem> { public OperatingSystem apply(final Image from) { OsFamily osFamily = null; String osVersion = null; String imageName = MoreObjects.firstNonNull(from.getName(), "unspecified"); boolean is64Bit = true; if (imageName.indexOf("Windows") != -1) { osFamily = OsFamily.WINDOWS; Matcher matcher = WINDOWS_PATTERN.matcher(from.getName()); if (matcher.find()) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(1), osVersionMap); is64Bit = matcher.group(2).equals("x64"); } } else { if (imageName.contains("Red Hat")) { osFamily = OsFamily.RHEL; } else if (imageName.contains("Oracle")) { osFamily = OsFamily.OEL; } else { final Iterable<String> imageNameParts = Splitter.on(CharMatcher.WHITESPACE).trimResults().split( imageName.toLowerCase()); try { osFamily = find(Arrays.asList(OsFamily.values()), new Predicate<OsFamily>() { @Override public boolean apply(OsFamily osFamily) { return any(imageNameParts, equalTo(osFamily.name().toLowerCase())); } }); } catch (NoSuchElementException e) { String ubuntuVersion = startsWithUbuntuVersion(imageNameParts); if (ubuntuVersion != null) { osFamily = OsFamily.UBUNTU; osVersion = ubuntuVersion; } else { logger.trace("could not parse operating system family for image(%s): %s", from.getId(), imageNameParts); osFamily = OsFamily.UNRECOGNIZED; } } } Matcher matcher = DEFAULT_PATTERN.matcher(imageName); if (matcher.find() && matcher.groupCount() >= 3) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(3), osVersionMap); } } return new OperatingSystem(osFamily, imageName, osVersion, null, imageName, is64Bit); } @Inject ImageToOperatingSystem(Map<OsFamily, Map<String, String>> osVersionMap); }
ImageToOperatingSystem implements Function<Image, OperatingSystem> { public OperatingSystem apply(final Image from) { OsFamily osFamily = null; String osVersion = null; String imageName = MoreObjects.firstNonNull(from.getName(), "unspecified"); boolean is64Bit = true; if (imageName.indexOf("Windows") != -1) { osFamily = OsFamily.WINDOWS; Matcher matcher = WINDOWS_PATTERN.matcher(from.getName()); if (matcher.find()) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(1), osVersionMap); is64Bit = matcher.group(2).equals("x64"); } } else { if (imageName.contains("Red Hat")) { osFamily = OsFamily.RHEL; } else if (imageName.contains("Oracle")) { osFamily = OsFamily.OEL; } else { final Iterable<String> imageNameParts = Splitter.on(CharMatcher.WHITESPACE).trimResults().split( imageName.toLowerCase()); try { osFamily = find(Arrays.asList(OsFamily.values()), new Predicate<OsFamily>() { @Override public boolean apply(OsFamily osFamily) { return any(imageNameParts, equalTo(osFamily.name().toLowerCase())); } }); } catch (NoSuchElementException e) { String ubuntuVersion = startsWithUbuntuVersion(imageNameParts); if (ubuntuVersion != null) { osFamily = OsFamily.UBUNTU; osVersion = ubuntuVersion; } else { logger.trace("could not parse operating system family for image(%s): %s", from.getId(), imageNameParts); osFamily = OsFamily.UNRECOGNIZED; } } } Matcher matcher = DEFAULT_PATTERN.matcher(imageName); if (matcher.find() && matcher.groupCount() >= 3) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(3), osVersionMap); } } return new OperatingSystem(osFamily, imageName, osVersion, null, imageName, is64Bit); } @Inject ImageToOperatingSystem(Map<OsFamily, Map<String, String>> osVersionMap); OperatingSystem apply(final Image from); }
ImageToOperatingSystem implements Function<Image, OperatingSystem> { public OperatingSystem apply(final Image from) { OsFamily osFamily = null; String osVersion = null; String imageName = MoreObjects.firstNonNull(from.getName(), "unspecified"); boolean is64Bit = true; if (imageName.indexOf("Windows") != -1) { osFamily = OsFamily.WINDOWS; Matcher matcher = WINDOWS_PATTERN.matcher(from.getName()); if (matcher.find()) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(1), osVersionMap); is64Bit = matcher.group(2).equals("x64"); } } else { if (imageName.contains("Red Hat")) { osFamily = OsFamily.RHEL; } else if (imageName.contains("Oracle")) { osFamily = OsFamily.OEL; } else { final Iterable<String> imageNameParts = Splitter.on(CharMatcher.WHITESPACE).trimResults().split( imageName.toLowerCase()); try { osFamily = find(Arrays.asList(OsFamily.values()), new Predicate<OsFamily>() { @Override public boolean apply(OsFamily osFamily) { return any(imageNameParts, equalTo(osFamily.name().toLowerCase())); } }); } catch (NoSuchElementException e) { String ubuntuVersion = startsWithUbuntuVersion(imageNameParts); if (ubuntuVersion != null) { osFamily = OsFamily.UBUNTU; osVersion = ubuntuVersion; } else { logger.trace("could not parse operating system family for image(%s): %s", from.getId(), imageNameParts); osFamily = OsFamily.UNRECOGNIZED; } } } Matcher matcher = DEFAULT_PATTERN.matcher(imageName); if (matcher.find() && matcher.groupCount() >= 3) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(3), osVersionMap); } } return new OperatingSystem(osFamily, imageName, osVersion, null, imageName, is64Bit); } @Inject ImageToOperatingSystem(Map<OsFamily, Map<String, String>> osVersionMap); OperatingSystem apply(final Image from); static final Pattern DEFAULT_PATTERN; static final Pattern WINDOWS_PATTERN; }
@Test public void testRHEL() { String name = "Red Hat EL"; Image imageToConvert = Image.builder().id("id-" + name).name(name).build(); ImageToOperatingSystem converter = new ImageToOperatingSystem( new HashMap<OsFamily, Map<String, String>>()); OperatingSystem convertedOs = converter.apply(imageToConvert); assertEquals(convertedOs.getName(), imageToConvert.getName()); assertEquals(convertedOs.getFamily(), OsFamily.RHEL); assertEquals(convertedOs.getDescription(), imageToConvert.getName()); assertEquals(convertedOs.getVersion(), null); assertEquals(convertedOs.getArch(), null); assertTrue(convertedOs.is64Bit()); }
public OperatingSystem apply(final Image from) { OsFamily osFamily = null; String osVersion = null; String imageName = MoreObjects.firstNonNull(from.getName(), "unspecified"); boolean is64Bit = true; if (imageName.indexOf("Windows") != -1) { osFamily = OsFamily.WINDOWS; Matcher matcher = WINDOWS_PATTERN.matcher(from.getName()); if (matcher.find()) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(1), osVersionMap); is64Bit = matcher.group(2).equals("x64"); } } else { if (imageName.contains("Red Hat")) { osFamily = OsFamily.RHEL; } else if (imageName.contains("Oracle")) { osFamily = OsFamily.OEL; } else { final Iterable<String> imageNameParts = Splitter.on(CharMatcher.WHITESPACE).trimResults().split( imageName.toLowerCase()); try { osFamily = find(Arrays.asList(OsFamily.values()), new Predicate<OsFamily>() { @Override public boolean apply(OsFamily osFamily) { return any(imageNameParts, equalTo(osFamily.name().toLowerCase())); } }); } catch (NoSuchElementException e) { String ubuntuVersion = startsWithUbuntuVersion(imageNameParts); if (ubuntuVersion != null) { osFamily = OsFamily.UBUNTU; osVersion = ubuntuVersion; } else { logger.trace("could not parse operating system family for image(%s): %s", from.getId(), imageNameParts); osFamily = OsFamily.UNRECOGNIZED; } } } Matcher matcher = DEFAULT_PATTERN.matcher(imageName); if (matcher.find() && matcher.groupCount() >= 3) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(3), osVersionMap); } } return new OperatingSystem(osFamily, imageName, osVersion, null, imageName, is64Bit); }
ImageToOperatingSystem implements Function<Image, OperatingSystem> { public OperatingSystem apply(final Image from) { OsFamily osFamily = null; String osVersion = null; String imageName = MoreObjects.firstNonNull(from.getName(), "unspecified"); boolean is64Bit = true; if (imageName.indexOf("Windows") != -1) { osFamily = OsFamily.WINDOWS; Matcher matcher = WINDOWS_PATTERN.matcher(from.getName()); if (matcher.find()) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(1), osVersionMap); is64Bit = matcher.group(2).equals("x64"); } } else { if (imageName.contains("Red Hat")) { osFamily = OsFamily.RHEL; } else if (imageName.contains("Oracle")) { osFamily = OsFamily.OEL; } else { final Iterable<String> imageNameParts = Splitter.on(CharMatcher.WHITESPACE).trimResults().split( imageName.toLowerCase()); try { osFamily = find(Arrays.asList(OsFamily.values()), new Predicate<OsFamily>() { @Override public boolean apply(OsFamily osFamily) { return any(imageNameParts, equalTo(osFamily.name().toLowerCase())); } }); } catch (NoSuchElementException e) { String ubuntuVersion = startsWithUbuntuVersion(imageNameParts); if (ubuntuVersion != null) { osFamily = OsFamily.UBUNTU; osVersion = ubuntuVersion; } else { logger.trace("could not parse operating system family for image(%s): %s", from.getId(), imageNameParts); osFamily = OsFamily.UNRECOGNIZED; } } } Matcher matcher = DEFAULT_PATTERN.matcher(imageName); if (matcher.find() && matcher.groupCount() >= 3) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(3), osVersionMap); } } return new OperatingSystem(osFamily, imageName, osVersion, null, imageName, is64Bit); } }
ImageToOperatingSystem implements Function<Image, OperatingSystem> { public OperatingSystem apply(final Image from) { OsFamily osFamily = null; String osVersion = null; String imageName = MoreObjects.firstNonNull(from.getName(), "unspecified"); boolean is64Bit = true; if (imageName.indexOf("Windows") != -1) { osFamily = OsFamily.WINDOWS; Matcher matcher = WINDOWS_PATTERN.matcher(from.getName()); if (matcher.find()) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(1), osVersionMap); is64Bit = matcher.group(2).equals("x64"); } } else { if (imageName.contains("Red Hat")) { osFamily = OsFamily.RHEL; } else if (imageName.contains("Oracle")) { osFamily = OsFamily.OEL; } else { final Iterable<String> imageNameParts = Splitter.on(CharMatcher.WHITESPACE).trimResults().split( imageName.toLowerCase()); try { osFamily = find(Arrays.asList(OsFamily.values()), new Predicate<OsFamily>() { @Override public boolean apply(OsFamily osFamily) { return any(imageNameParts, equalTo(osFamily.name().toLowerCase())); } }); } catch (NoSuchElementException e) { String ubuntuVersion = startsWithUbuntuVersion(imageNameParts); if (ubuntuVersion != null) { osFamily = OsFamily.UBUNTU; osVersion = ubuntuVersion; } else { logger.trace("could not parse operating system family for image(%s): %s", from.getId(), imageNameParts); osFamily = OsFamily.UNRECOGNIZED; } } } Matcher matcher = DEFAULT_PATTERN.matcher(imageName); if (matcher.find() && matcher.groupCount() >= 3) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(3), osVersionMap); } } return new OperatingSystem(osFamily, imageName, osVersion, null, imageName, is64Bit); } @Inject ImageToOperatingSystem(Map<OsFamily, Map<String, String>> osVersionMap); }
ImageToOperatingSystem implements Function<Image, OperatingSystem> { public OperatingSystem apply(final Image from) { OsFamily osFamily = null; String osVersion = null; String imageName = MoreObjects.firstNonNull(from.getName(), "unspecified"); boolean is64Bit = true; if (imageName.indexOf("Windows") != -1) { osFamily = OsFamily.WINDOWS; Matcher matcher = WINDOWS_PATTERN.matcher(from.getName()); if (matcher.find()) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(1), osVersionMap); is64Bit = matcher.group(2).equals("x64"); } } else { if (imageName.contains("Red Hat")) { osFamily = OsFamily.RHEL; } else if (imageName.contains("Oracle")) { osFamily = OsFamily.OEL; } else { final Iterable<String> imageNameParts = Splitter.on(CharMatcher.WHITESPACE).trimResults().split( imageName.toLowerCase()); try { osFamily = find(Arrays.asList(OsFamily.values()), new Predicate<OsFamily>() { @Override public boolean apply(OsFamily osFamily) { return any(imageNameParts, equalTo(osFamily.name().toLowerCase())); } }); } catch (NoSuchElementException e) { String ubuntuVersion = startsWithUbuntuVersion(imageNameParts); if (ubuntuVersion != null) { osFamily = OsFamily.UBUNTU; osVersion = ubuntuVersion; } else { logger.trace("could not parse operating system family for image(%s): %s", from.getId(), imageNameParts); osFamily = OsFamily.UNRECOGNIZED; } } } Matcher matcher = DEFAULT_PATTERN.matcher(imageName); if (matcher.find() && matcher.groupCount() >= 3) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(3), osVersionMap); } } return new OperatingSystem(osFamily, imageName, osVersion, null, imageName, is64Bit); } @Inject ImageToOperatingSystem(Map<OsFamily, Map<String, String>> osVersionMap); OperatingSystem apply(final Image from); }
ImageToOperatingSystem implements Function<Image, OperatingSystem> { public OperatingSystem apply(final Image from) { OsFamily osFamily = null; String osVersion = null; String imageName = MoreObjects.firstNonNull(from.getName(), "unspecified"); boolean is64Bit = true; if (imageName.indexOf("Windows") != -1) { osFamily = OsFamily.WINDOWS; Matcher matcher = WINDOWS_PATTERN.matcher(from.getName()); if (matcher.find()) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(1), osVersionMap); is64Bit = matcher.group(2).equals("x64"); } } else { if (imageName.contains("Red Hat")) { osFamily = OsFamily.RHEL; } else if (imageName.contains("Oracle")) { osFamily = OsFamily.OEL; } else { final Iterable<String> imageNameParts = Splitter.on(CharMatcher.WHITESPACE).trimResults().split( imageName.toLowerCase()); try { osFamily = find(Arrays.asList(OsFamily.values()), new Predicate<OsFamily>() { @Override public boolean apply(OsFamily osFamily) { return any(imageNameParts, equalTo(osFamily.name().toLowerCase())); } }); } catch (NoSuchElementException e) { String ubuntuVersion = startsWithUbuntuVersion(imageNameParts); if (ubuntuVersion != null) { osFamily = OsFamily.UBUNTU; osVersion = ubuntuVersion; } else { logger.trace("could not parse operating system family for image(%s): %s", from.getId(), imageNameParts); osFamily = OsFamily.UNRECOGNIZED; } } } Matcher matcher = DEFAULT_PATTERN.matcher(imageName); if (matcher.find() && matcher.groupCount() >= 3) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(3), osVersionMap); } } return new OperatingSystem(osFamily, imageName, osVersion, null, imageName, is64Bit); } @Inject ImageToOperatingSystem(Map<OsFamily, Map<String, String>> osVersionMap); OperatingSystem apply(final Image from); static final Pattern DEFAULT_PATTERN; static final Pattern WINDOWS_PATTERN; }
@Test public void testOEL() { String name = "Oracle EL"; Image imageToConvert = Image.builder().id("id-" + name).name(name).build(); ImageToOperatingSystem converter = new ImageToOperatingSystem( new HashMap<OsFamily, Map<String, String>>()); OperatingSystem convertedOs = converter.apply(imageToConvert); assertEquals(convertedOs.getName(), imageToConvert.getName()); assertEquals(convertedOs.getFamily(), OsFamily.OEL); assertEquals(convertedOs.getDescription(), imageToConvert.getName()); assertEquals(convertedOs.getVersion(), null); assertEquals(convertedOs.getArch(), null); assertTrue(convertedOs.is64Bit()); }
public OperatingSystem apply(final Image from) { OsFamily osFamily = null; String osVersion = null; String imageName = MoreObjects.firstNonNull(from.getName(), "unspecified"); boolean is64Bit = true; if (imageName.indexOf("Windows") != -1) { osFamily = OsFamily.WINDOWS; Matcher matcher = WINDOWS_PATTERN.matcher(from.getName()); if (matcher.find()) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(1), osVersionMap); is64Bit = matcher.group(2).equals("x64"); } } else { if (imageName.contains("Red Hat")) { osFamily = OsFamily.RHEL; } else if (imageName.contains("Oracle")) { osFamily = OsFamily.OEL; } else { final Iterable<String> imageNameParts = Splitter.on(CharMatcher.WHITESPACE).trimResults().split( imageName.toLowerCase()); try { osFamily = find(Arrays.asList(OsFamily.values()), new Predicate<OsFamily>() { @Override public boolean apply(OsFamily osFamily) { return any(imageNameParts, equalTo(osFamily.name().toLowerCase())); } }); } catch (NoSuchElementException e) { String ubuntuVersion = startsWithUbuntuVersion(imageNameParts); if (ubuntuVersion != null) { osFamily = OsFamily.UBUNTU; osVersion = ubuntuVersion; } else { logger.trace("could not parse operating system family for image(%s): %s", from.getId(), imageNameParts); osFamily = OsFamily.UNRECOGNIZED; } } } Matcher matcher = DEFAULT_PATTERN.matcher(imageName); if (matcher.find() && matcher.groupCount() >= 3) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(3), osVersionMap); } } return new OperatingSystem(osFamily, imageName, osVersion, null, imageName, is64Bit); }
ImageToOperatingSystem implements Function<Image, OperatingSystem> { public OperatingSystem apply(final Image from) { OsFamily osFamily = null; String osVersion = null; String imageName = MoreObjects.firstNonNull(from.getName(), "unspecified"); boolean is64Bit = true; if (imageName.indexOf("Windows") != -1) { osFamily = OsFamily.WINDOWS; Matcher matcher = WINDOWS_PATTERN.matcher(from.getName()); if (matcher.find()) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(1), osVersionMap); is64Bit = matcher.group(2).equals("x64"); } } else { if (imageName.contains("Red Hat")) { osFamily = OsFamily.RHEL; } else if (imageName.contains("Oracle")) { osFamily = OsFamily.OEL; } else { final Iterable<String> imageNameParts = Splitter.on(CharMatcher.WHITESPACE).trimResults().split( imageName.toLowerCase()); try { osFamily = find(Arrays.asList(OsFamily.values()), new Predicate<OsFamily>() { @Override public boolean apply(OsFamily osFamily) { return any(imageNameParts, equalTo(osFamily.name().toLowerCase())); } }); } catch (NoSuchElementException e) { String ubuntuVersion = startsWithUbuntuVersion(imageNameParts); if (ubuntuVersion != null) { osFamily = OsFamily.UBUNTU; osVersion = ubuntuVersion; } else { logger.trace("could not parse operating system family for image(%s): %s", from.getId(), imageNameParts); osFamily = OsFamily.UNRECOGNIZED; } } } Matcher matcher = DEFAULT_PATTERN.matcher(imageName); if (matcher.find() && matcher.groupCount() >= 3) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(3), osVersionMap); } } return new OperatingSystem(osFamily, imageName, osVersion, null, imageName, is64Bit); } }
ImageToOperatingSystem implements Function<Image, OperatingSystem> { public OperatingSystem apply(final Image from) { OsFamily osFamily = null; String osVersion = null; String imageName = MoreObjects.firstNonNull(from.getName(), "unspecified"); boolean is64Bit = true; if (imageName.indexOf("Windows") != -1) { osFamily = OsFamily.WINDOWS; Matcher matcher = WINDOWS_PATTERN.matcher(from.getName()); if (matcher.find()) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(1), osVersionMap); is64Bit = matcher.group(2).equals("x64"); } } else { if (imageName.contains("Red Hat")) { osFamily = OsFamily.RHEL; } else if (imageName.contains("Oracle")) { osFamily = OsFamily.OEL; } else { final Iterable<String> imageNameParts = Splitter.on(CharMatcher.WHITESPACE).trimResults().split( imageName.toLowerCase()); try { osFamily = find(Arrays.asList(OsFamily.values()), new Predicate<OsFamily>() { @Override public boolean apply(OsFamily osFamily) { return any(imageNameParts, equalTo(osFamily.name().toLowerCase())); } }); } catch (NoSuchElementException e) { String ubuntuVersion = startsWithUbuntuVersion(imageNameParts); if (ubuntuVersion != null) { osFamily = OsFamily.UBUNTU; osVersion = ubuntuVersion; } else { logger.trace("could not parse operating system family for image(%s): %s", from.getId(), imageNameParts); osFamily = OsFamily.UNRECOGNIZED; } } } Matcher matcher = DEFAULT_PATTERN.matcher(imageName); if (matcher.find() && matcher.groupCount() >= 3) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(3), osVersionMap); } } return new OperatingSystem(osFamily, imageName, osVersion, null, imageName, is64Bit); } @Inject ImageToOperatingSystem(Map<OsFamily, Map<String, String>> osVersionMap); }
ImageToOperatingSystem implements Function<Image, OperatingSystem> { public OperatingSystem apply(final Image from) { OsFamily osFamily = null; String osVersion = null; String imageName = MoreObjects.firstNonNull(from.getName(), "unspecified"); boolean is64Bit = true; if (imageName.indexOf("Windows") != -1) { osFamily = OsFamily.WINDOWS; Matcher matcher = WINDOWS_PATTERN.matcher(from.getName()); if (matcher.find()) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(1), osVersionMap); is64Bit = matcher.group(2).equals("x64"); } } else { if (imageName.contains("Red Hat")) { osFamily = OsFamily.RHEL; } else if (imageName.contains("Oracle")) { osFamily = OsFamily.OEL; } else { final Iterable<String> imageNameParts = Splitter.on(CharMatcher.WHITESPACE).trimResults().split( imageName.toLowerCase()); try { osFamily = find(Arrays.asList(OsFamily.values()), new Predicate<OsFamily>() { @Override public boolean apply(OsFamily osFamily) { return any(imageNameParts, equalTo(osFamily.name().toLowerCase())); } }); } catch (NoSuchElementException e) { String ubuntuVersion = startsWithUbuntuVersion(imageNameParts); if (ubuntuVersion != null) { osFamily = OsFamily.UBUNTU; osVersion = ubuntuVersion; } else { logger.trace("could not parse operating system family for image(%s): %s", from.getId(), imageNameParts); osFamily = OsFamily.UNRECOGNIZED; } } } Matcher matcher = DEFAULT_PATTERN.matcher(imageName); if (matcher.find() && matcher.groupCount() >= 3) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(3), osVersionMap); } } return new OperatingSystem(osFamily, imageName, osVersion, null, imageName, is64Bit); } @Inject ImageToOperatingSystem(Map<OsFamily, Map<String, String>> osVersionMap); OperatingSystem apply(final Image from); }
ImageToOperatingSystem implements Function<Image, OperatingSystem> { public OperatingSystem apply(final Image from) { OsFamily osFamily = null; String osVersion = null; String imageName = MoreObjects.firstNonNull(from.getName(), "unspecified"); boolean is64Bit = true; if (imageName.indexOf("Windows") != -1) { osFamily = OsFamily.WINDOWS; Matcher matcher = WINDOWS_PATTERN.matcher(from.getName()); if (matcher.find()) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(1), osVersionMap); is64Bit = matcher.group(2).equals("x64"); } } else { if (imageName.contains("Red Hat")) { osFamily = OsFamily.RHEL; } else if (imageName.contains("Oracle")) { osFamily = OsFamily.OEL; } else { final Iterable<String> imageNameParts = Splitter.on(CharMatcher.WHITESPACE).trimResults().split( imageName.toLowerCase()); try { osFamily = find(Arrays.asList(OsFamily.values()), new Predicate<OsFamily>() { @Override public boolean apply(OsFamily osFamily) { return any(imageNameParts, equalTo(osFamily.name().toLowerCase())); } }); } catch (NoSuchElementException e) { String ubuntuVersion = startsWithUbuntuVersion(imageNameParts); if (ubuntuVersion != null) { osFamily = OsFamily.UBUNTU; osVersion = ubuntuVersion; } else { logger.trace("could not parse operating system family for image(%s): %s", from.getId(), imageNameParts); osFamily = OsFamily.UNRECOGNIZED; } } } Matcher matcher = DEFAULT_PATTERN.matcher(imageName); if (matcher.find() && matcher.groupCount() >= 3) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(3), osVersionMap); } } return new OperatingSystem(osFamily, imageName, osVersion, null, imageName, is64Bit); } @Inject ImageToOperatingSystem(Map<OsFamily, Map<String, String>> osVersionMap); OperatingSystem apply(final Image from); static final Pattern DEFAULT_PATTERN; static final Pattern WINDOWS_PATTERN; }
@Test public void testTryStackOneric() { String name = "oneiric-server-cloudimg-amd64"; Image imageToConvert = Image.builder().id("id-" + name).name(name).build(); OperatingSystem convertedOs = converterForUbuntu.apply(imageToConvert); assertEquals(convertedOs.getName(), imageToConvert.getName()); assertEquals(convertedOs.getFamily(), OsFamily.UBUNTU); assertEquals(convertedOs.getDescription(), imageToConvert.getName()); assertEquals(convertedOs.getVersion(), "11.10"); assertEquals(convertedOs.getArch(), null); assertTrue(convertedOs.is64Bit()); }
public OperatingSystem apply(final Image from) { OsFamily osFamily = null; String osVersion = null; String imageName = MoreObjects.firstNonNull(from.getName(), "unspecified"); boolean is64Bit = true; if (imageName.indexOf("Windows") != -1) { osFamily = OsFamily.WINDOWS; Matcher matcher = WINDOWS_PATTERN.matcher(from.getName()); if (matcher.find()) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(1), osVersionMap); is64Bit = matcher.group(2).equals("x64"); } } else { if (imageName.contains("Red Hat")) { osFamily = OsFamily.RHEL; } else if (imageName.contains("Oracle")) { osFamily = OsFamily.OEL; } else { final Iterable<String> imageNameParts = Splitter.on(CharMatcher.WHITESPACE).trimResults().split( imageName.toLowerCase()); try { osFamily = find(Arrays.asList(OsFamily.values()), new Predicate<OsFamily>() { @Override public boolean apply(OsFamily osFamily) { return any(imageNameParts, equalTo(osFamily.name().toLowerCase())); } }); } catch (NoSuchElementException e) { String ubuntuVersion = startsWithUbuntuVersion(imageNameParts); if (ubuntuVersion != null) { osFamily = OsFamily.UBUNTU; osVersion = ubuntuVersion; } else { logger.trace("could not parse operating system family for image(%s): %s", from.getId(), imageNameParts); osFamily = OsFamily.UNRECOGNIZED; } } } Matcher matcher = DEFAULT_PATTERN.matcher(imageName); if (matcher.find() && matcher.groupCount() >= 3) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(3), osVersionMap); } } return new OperatingSystem(osFamily, imageName, osVersion, null, imageName, is64Bit); }
ImageToOperatingSystem implements Function<Image, OperatingSystem> { public OperatingSystem apply(final Image from) { OsFamily osFamily = null; String osVersion = null; String imageName = MoreObjects.firstNonNull(from.getName(), "unspecified"); boolean is64Bit = true; if (imageName.indexOf("Windows") != -1) { osFamily = OsFamily.WINDOWS; Matcher matcher = WINDOWS_PATTERN.matcher(from.getName()); if (matcher.find()) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(1), osVersionMap); is64Bit = matcher.group(2).equals("x64"); } } else { if (imageName.contains("Red Hat")) { osFamily = OsFamily.RHEL; } else if (imageName.contains("Oracle")) { osFamily = OsFamily.OEL; } else { final Iterable<String> imageNameParts = Splitter.on(CharMatcher.WHITESPACE).trimResults().split( imageName.toLowerCase()); try { osFamily = find(Arrays.asList(OsFamily.values()), new Predicate<OsFamily>() { @Override public boolean apply(OsFamily osFamily) { return any(imageNameParts, equalTo(osFamily.name().toLowerCase())); } }); } catch (NoSuchElementException e) { String ubuntuVersion = startsWithUbuntuVersion(imageNameParts); if (ubuntuVersion != null) { osFamily = OsFamily.UBUNTU; osVersion = ubuntuVersion; } else { logger.trace("could not parse operating system family for image(%s): %s", from.getId(), imageNameParts); osFamily = OsFamily.UNRECOGNIZED; } } } Matcher matcher = DEFAULT_PATTERN.matcher(imageName); if (matcher.find() && matcher.groupCount() >= 3) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(3), osVersionMap); } } return new OperatingSystem(osFamily, imageName, osVersion, null, imageName, is64Bit); } }
ImageToOperatingSystem implements Function<Image, OperatingSystem> { public OperatingSystem apply(final Image from) { OsFamily osFamily = null; String osVersion = null; String imageName = MoreObjects.firstNonNull(from.getName(), "unspecified"); boolean is64Bit = true; if (imageName.indexOf("Windows") != -1) { osFamily = OsFamily.WINDOWS; Matcher matcher = WINDOWS_PATTERN.matcher(from.getName()); if (matcher.find()) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(1), osVersionMap); is64Bit = matcher.group(2).equals("x64"); } } else { if (imageName.contains("Red Hat")) { osFamily = OsFamily.RHEL; } else if (imageName.contains("Oracle")) { osFamily = OsFamily.OEL; } else { final Iterable<String> imageNameParts = Splitter.on(CharMatcher.WHITESPACE).trimResults().split( imageName.toLowerCase()); try { osFamily = find(Arrays.asList(OsFamily.values()), new Predicate<OsFamily>() { @Override public boolean apply(OsFamily osFamily) { return any(imageNameParts, equalTo(osFamily.name().toLowerCase())); } }); } catch (NoSuchElementException e) { String ubuntuVersion = startsWithUbuntuVersion(imageNameParts); if (ubuntuVersion != null) { osFamily = OsFamily.UBUNTU; osVersion = ubuntuVersion; } else { logger.trace("could not parse operating system family for image(%s): %s", from.getId(), imageNameParts); osFamily = OsFamily.UNRECOGNIZED; } } } Matcher matcher = DEFAULT_PATTERN.matcher(imageName); if (matcher.find() && matcher.groupCount() >= 3) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(3), osVersionMap); } } return new OperatingSystem(osFamily, imageName, osVersion, null, imageName, is64Bit); } @Inject ImageToOperatingSystem(Map<OsFamily, Map<String, String>> osVersionMap); }
ImageToOperatingSystem implements Function<Image, OperatingSystem> { public OperatingSystem apply(final Image from) { OsFamily osFamily = null; String osVersion = null; String imageName = MoreObjects.firstNonNull(from.getName(), "unspecified"); boolean is64Bit = true; if (imageName.indexOf("Windows") != -1) { osFamily = OsFamily.WINDOWS; Matcher matcher = WINDOWS_PATTERN.matcher(from.getName()); if (matcher.find()) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(1), osVersionMap); is64Bit = matcher.group(2).equals("x64"); } } else { if (imageName.contains("Red Hat")) { osFamily = OsFamily.RHEL; } else if (imageName.contains("Oracle")) { osFamily = OsFamily.OEL; } else { final Iterable<String> imageNameParts = Splitter.on(CharMatcher.WHITESPACE).trimResults().split( imageName.toLowerCase()); try { osFamily = find(Arrays.asList(OsFamily.values()), new Predicate<OsFamily>() { @Override public boolean apply(OsFamily osFamily) { return any(imageNameParts, equalTo(osFamily.name().toLowerCase())); } }); } catch (NoSuchElementException e) { String ubuntuVersion = startsWithUbuntuVersion(imageNameParts); if (ubuntuVersion != null) { osFamily = OsFamily.UBUNTU; osVersion = ubuntuVersion; } else { logger.trace("could not parse operating system family for image(%s): %s", from.getId(), imageNameParts); osFamily = OsFamily.UNRECOGNIZED; } } } Matcher matcher = DEFAULT_PATTERN.matcher(imageName); if (matcher.find() && matcher.groupCount() >= 3) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(3), osVersionMap); } } return new OperatingSystem(osFamily, imageName, osVersion, null, imageName, is64Bit); } @Inject ImageToOperatingSystem(Map<OsFamily, Map<String, String>> osVersionMap); OperatingSystem apply(final Image from); }
ImageToOperatingSystem implements Function<Image, OperatingSystem> { public OperatingSystem apply(final Image from) { OsFamily osFamily = null; String osVersion = null; String imageName = MoreObjects.firstNonNull(from.getName(), "unspecified"); boolean is64Bit = true; if (imageName.indexOf("Windows") != -1) { osFamily = OsFamily.WINDOWS; Matcher matcher = WINDOWS_PATTERN.matcher(from.getName()); if (matcher.find()) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(1), osVersionMap); is64Bit = matcher.group(2).equals("x64"); } } else { if (imageName.contains("Red Hat")) { osFamily = OsFamily.RHEL; } else if (imageName.contains("Oracle")) { osFamily = OsFamily.OEL; } else { final Iterable<String> imageNameParts = Splitter.on(CharMatcher.WHITESPACE).trimResults().split( imageName.toLowerCase()); try { osFamily = find(Arrays.asList(OsFamily.values()), new Predicate<OsFamily>() { @Override public boolean apply(OsFamily osFamily) { return any(imageNameParts, equalTo(osFamily.name().toLowerCase())); } }); } catch (NoSuchElementException e) { String ubuntuVersion = startsWithUbuntuVersion(imageNameParts); if (ubuntuVersion != null) { osFamily = OsFamily.UBUNTU; osVersion = ubuntuVersion; } else { logger.trace("could not parse operating system family for image(%s): %s", from.getId(), imageNameParts); osFamily = OsFamily.UNRECOGNIZED; } } } Matcher matcher = DEFAULT_PATTERN.matcher(imageName); if (matcher.find() && matcher.groupCount() >= 3) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(3), osVersionMap); } } return new OperatingSystem(osFamily, imageName, osVersion, null, imageName, is64Bit); } @Inject ImageToOperatingSystem(Map<OsFamily, Map<String, String>> osVersionMap); OperatingSystem apply(final Image from); static final Pattern DEFAULT_PATTERN; static final Pattern WINDOWS_PATTERN; }
@Test public void testTryStackNatty() { String name = "natty-server-cloudimg-amd64"; Image imageToConvert = Image.builder().id("id-" + name).name(name).build(); OperatingSystem convertedOs = converterForUbuntu.apply(imageToConvert); assertEquals(convertedOs.getName(), imageToConvert.getName()); assertEquals(convertedOs.getFamily(), OsFamily.UBUNTU); assertEquals(convertedOs.getDescription(), imageToConvert.getName()); assertEquals(convertedOs.getVersion(), "11.04"); assertEquals(convertedOs.getArch(), null); assertTrue(convertedOs.is64Bit()); }
public OperatingSystem apply(final Image from) { OsFamily osFamily = null; String osVersion = null; String imageName = MoreObjects.firstNonNull(from.getName(), "unspecified"); boolean is64Bit = true; if (imageName.indexOf("Windows") != -1) { osFamily = OsFamily.WINDOWS; Matcher matcher = WINDOWS_PATTERN.matcher(from.getName()); if (matcher.find()) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(1), osVersionMap); is64Bit = matcher.group(2).equals("x64"); } } else { if (imageName.contains("Red Hat")) { osFamily = OsFamily.RHEL; } else if (imageName.contains("Oracle")) { osFamily = OsFamily.OEL; } else { final Iterable<String> imageNameParts = Splitter.on(CharMatcher.WHITESPACE).trimResults().split( imageName.toLowerCase()); try { osFamily = find(Arrays.asList(OsFamily.values()), new Predicate<OsFamily>() { @Override public boolean apply(OsFamily osFamily) { return any(imageNameParts, equalTo(osFamily.name().toLowerCase())); } }); } catch (NoSuchElementException e) { String ubuntuVersion = startsWithUbuntuVersion(imageNameParts); if (ubuntuVersion != null) { osFamily = OsFamily.UBUNTU; osVersion = ubuntuVersion; } else { logger.trace("could not parse operating system family for image(%s): %s", from.getId(), imageNameParts); osFamily = OsFamily.UNRECOGNIZED; } } } Matcher matcher = DEFAULT_PATTERN.matcher(imageName); if (matcher.find() && matcher.groupCount() >= 3) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(3), osVersionMap); } } return new OperatingSystem(osFamily, imageName, osVersion, null, imageName, is64Bit); }
ImageToOperatingSystem implements Function<Image, OperatingSystem> { public OperatingSystem apply(final Image from) { OsFamily osFamily = null; String osVersion = null; String imageName = MoreObjects.firstNonNull(from.getName(), "unspecified"); boolean is64Bit = true; if (imageName.indexOf("Windows") != -1) { osFamily = OsFamily.WINDOWS; Matcher matcher = WINDOWS_PATTERN.matcher(from.getName()); if (matcher.find()) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(1), osVersionMap); is64Bit = matcher.group(2).equals("x64"); } } else { if (imageName.contains("Red Hat")) { osFamily = OsFamily.RHEL; } else if (imageName.contains("Oracle")) { osFamily = OsFamily.OEL; } else { final Iterable<String> imageNameParts = Splitter.on(CharMatcher.WHITESPACE).trimResults().split( imageName.toLowerCase()); try { osFamily = find(Arrays.asList(OsFamily.values()), new Predicate<OsFamily>() { @Override public boolean apply(OsFamily osFamily) { return any(imageNameParts, equalTo(osFamily.name().toLowerCase())); } }); } catch (NoSuchElementException e) { String ubuntuVersion = startsWithUbuntuVersion(imageNameParts); if (ubuntuVersion != null) { osFamily = OsFamily.UBUNTU; osVersion = ubuntuVersion; } else { logger.trace("could not parse operating system family for image(%s): %s", from.getId(), imageNameParts); osFamily = OsFamily.UNRECOGNIZED; } } } Matcher matcher = DEFAULT_PATTERN.matcher(imageName); if (matcher.find() && matcher.groupCount() >= 3) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(3), osVersionMap); } } return new OperatingSystem(osFamily, imageName, osVersion, null, imageName, is64Bit); } }
ImageToOperatingSystem implements Function<Image, OperatingSystem> { public OperatingSystem apply(final Image from) { OsFamily osFamily = null; String osVersion = null; String imageName = MoreObjects.firstNonNull(from.getName(), "unspecified"); boolean is64Bit = true; if (imageName.indexOf("Windows") != -1) { osFamily = OsFamily.WINDOWS; Matcher matcher = WINDOWS_PATTERN.matcher(from.getName()); if (matcher.find()) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(1), osVersionMap); is64Bit = matcher.group(2).equals("x64"); } } else { if (imageName.contains("Red Hat")) { osFamily = OsFamily.RHEL; } else if (imageName.contains("Oracle")) { osFamily = OsFamily.OEL; } else { final Iterable<String> imageNameParts = Splitter.on(CharMatcher.WHITESPACE).trimResults().split( imageName.toLowerCase()); try { osFamily = find(Arrays.asList(OsFamily.values()), new Predicate<OsFamily>() { @Override public boolean apply(OsFamily osFamily) { return any(imageNameParts, equalTo(osFamily.name().toLowerCase())); } }); } catch (NoSuchElementException e) { String ubuntuVersion = startsWithUbuntuVersion(imageNameParts); if (ubuntuVersion != null) { osFamily = OsFamily.UBUNTU; osVersion = ubuntuVersion; } else { logger.trace("could not parse operating system family for image(%s): %s", from.getId(), imageNameParts); osFamily = OsFamily.UNRECOGNIZED; } } } Matcher matcher = DEFAULT_PATTERN.matcher(imageName); if (matcher.find() && matcher.groupCount() >= 3) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(3), osVersionMap); } } return new OperatingSystem(osFamily, imageName, osVersion, null, imageName, is64Bit); } @Inject ImageToOperatingSystem(Map<OsFamily, Map<String, String>> osVersionMap); }
ImageToOperatingSystem implements Function<Image, OperatingSystem> { public OperatingSystem apply(final Image from) { OsFamily osFamily = null; String osVersion = null; String imageName = MoreObjects.firstNonNull(from.getName(), "unspecified"); boolean is64Bit = true; if (imageName.indexOf("Windows") != -1) { osFamily = OsFamily.WINDOWS; Matcher matcher = WINDOWS_PATTERN.matcher(from.getName()); if (matcher.find()) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(1), osVersionMap); is64Bit = matcher.group(2).equals("x64"); } } else { if (imageName.contains("Red Hat")) { osFamily = OsFamily.RHEL; } else if (imageName.contains("Oracle")) { osFamily = OsFamily.OEL; } else { final Iterable<String> imageNameParts = Splitter.on(CharMatcher.WHITESPACE).trimResults().split( imageName.toLowerCase()); try { osFamily = find(Arrays.asList(OsFamily.values()), new Predicate<OsFamily>() { @Override public boolean apply(OsFamily osFamily) { return any(imageNameParts, equalTo(osFamily.name().toLowerCase())); } }); } catch (NoSuchElementException e) { String ubuntuVersion = startsWithUbuntuVersion(imageNameParts); if (ubuntuVersion != null) { osFamily = OsFamily.UBUNTU; osVersion = ubuntuVersion; } else { logger.trace("could not parse operating system family for image(%s): %s", from.getId(), imageNameParts); osFamily = OsFamily.UNRECOGNIZED; } } } Matcher matcher = DEFAULT_PATTERN.matcher(imageName); if (matcher.find() && matcher.groupCount() >= 3) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(3), osVersionMap); } } return new OperatingSystem(osFamily, imageName, osVersion, null, imageName, is64Bit); } @Inject ImageToOperatingSystem(Map<OsFamily, Map<String, String>> osVersionMap); OperatingSystem apply(final Image from); }
ImageToOperatingSystem implements Function<Image, OperatingSystem> { public OperatingSystem apply(final Image from) { OsFamily osFamily = null; String osVersion = null; String imageName = MoreObjects.firstNonNull(from.getName(), "unspecified"); boolean is64Bit = true; if (imageName.indexOf("Windows") != -1) { osFamily = OsFamily.WINDOWS; Matcher matcher = WINDOWS_PATTERN.matcher(from.getName()); if (matcher.find()) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(1), osVersionMap); is64Bit = matcher.group(2).equals("x64"); } } else { if (imageName.contains("Red Hat")) { osFamily = OsFamily.RHEL; } else if (imageName.contains("Oracle")) { osFamily = OsFamily.OEL; } else { final Iterable<String> imageNameParts = Splitter.on(CharMatcher.WHITESPACE).trimResults().split( imageName.toLowerCase()); try { osFamily = find(Arrays.asList(OsFamily.values()), new Predicate<OsFamily>() { @Override public boolean apply(OsFamily osFamily) { return any(imageNameParts, equalTo(osFamily.name().toLowerCase())); } }); } catch (NoSuchElementException e) { String ubuntuVersion = startsWithUbuntuVersion(imageNameParts); if (ubuntuVersion != null) { osFamily = OsFamily.UBUNTU; osVersion = ubuntuVersion; } else { logger.trace("could not parse operating system family for image(%s): %s", from.getId(), imageNameParts); osFamily = OsFamily.UNRECOGNIZED; } } } Matcher matcher = DEFAULT_PATTERN.matcher(imageName); if (matcher.find() && matcher.groupCount() >= 3) { osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(3), osVersionMap); } } return new OperatingSystem(osFamily, imageName, osVersion, null, imageName, is64Bit); } @Inject ImageToOperatingSystem(Map<OsFamily, Map<String, String>> osVersionMap); OperatingSystem apply(final Image from); static final Pattern DEFAULT_PATTERN; static final Pattern WINDOWS_PATTERN; }
@Test public void testProvision() throws IOException { ProvisioningManager manager = new ProvisioningManager(); AtomicInteger completedJobs = new AtomicInteger(0); try { for (int i = 0; i < 5; i++) { manager.provision(new MockJob(200, "slow", completedJobs)); manager.provision(new MockJob(0, "fast", completedJobs)); manager.provision(new MockJob(100, "normal", completedJobs)); } } finally { manager.close(); } assertEquals(completedJobs.get(), 15); }
public Object provision(ProvisioningJob job) { if (terminated.get()) { logger.warn("Job(%s) submitted but the provisioning manager is already closed", job); return null; } logger.debug("Job(%s) submitted to group '%s'", job, job.getGroup()); ListeningExecutorService workerGroup = getWorkerGroup(job.getGroup()); return getUnchecked(workerGroup.submit(job)); }
ProvisioningManager implements Closeable { public Object provision(ProvisioningJob job) { if (terminated.get()) { logger.warn("Job(%s) submitted but the provisioning manager is already closed", job); return null; } logger.debug("Job(%s) submitted to group '%s'", job, job.getGroup()); ListeningExecutorService workerGroup = getWorkerGroup(job.getGroup()); return getUnchecked(workerGroup.submit(job)); } }
ProvisioningManager implements Closeable { public Object provision(ProvisioningJob job) { if (terminated.get()) { logger.warn("Job(%s) submitted but the provisioning manager is already closed", job); return null; } logger.debug("Job(%s) submitted to group '%s'", job, job.getGroup()); ListeningExecutorService workerGroup = getWorkerGroup(job.getGroup()); return getUnchecked(workerGroup.submit(job)); } }
ProvisioningManager implements Closeable { public Object provision(ProvisioningJob job) { if (terminated.get()) { logger.warn("Job(%s) submitted but the provisioning manager is already closed", job); return null; } logger.debug("Job(%s) submitted to group '%s'", job, job.getGroup()); ListeningExecutorService workerGroup = getWorkerGroup(job.getGroup()); return getUnchecked(workerGroup.submit(job)); } Object provision(ProvisioningJob job); @Override void close(); }
ProvisioningManager implements Closeable { public Object provision(ProvisioningJob job) { if (terminated.get()) { logger.warn("Job(%s) submitted but the provisioning manager is already closed", job); return null; } logger.debug("Job(%s) submitted to group '%s'", job, job.getGroup()); ListeningExecutorService workerGroup = getWorkerGroup(job.getGroup()); return getUnchecked(workerGroup.submit(job)); } Object provision(ProvisioningJob job); @Override void close(); }
@Test public void testApplyWithGroup() { NovaSecurityGroupInRegionToSecurityGroup parser = createGroupParser(); final org.jclouds.openstack.nova.v2_0.domain.SecurityGroup otherGroup = securityGroupWithCidr(); SecurityGroupInRegion origGroup = new SecurityGroupInRegion(securityGroupWithGroup(), region.getId(), allGroups); SecurityGroup newGroup = parser.apply(origGroup); assertEquals(newGroup.getId(), origGroup.getRegion() + "/" + origGroup.getSecurityGroup().getId()); assertEquals(newGroup.getProviderId(), origGroup.getSecurityGroup().getId()); assertEquals(newGroup.getName(), origGroup.getSecurityGroup().getName()); assertEquals(newGroup.getOwnerId(), origGroup.getSecurityGroup().getTenantId()); final IpPermission permission = Iterables.getOnlyElement(newGroup.getIpPermissions()); assertEquals(Iterables.getOnlyElement(permission.getGroupIds()), region.getId() + "/" + otherGroup.getId()); assertEquals(permission.getFromPort(), 10); assertEquals(permission.getToPort(), 20); assertTrue(permission.getCidrBlocks().isEmpty()); assertEquals(newGroup.getLocation().getId(), origGroup.getRegion()); }
@Override public SecurityGroup apply(final SecurityGroupInRegion groupInRegion) { SecurityGroupBuilder builder = new SecurityGroupBuilder(); final org.jclouds.openstack.nova.v2_0.domain.SecurityGroup group = groupInRegion.getSecurityGroup(); builder.id(group.getId()); builder.providerId(group.getId()); builder.ownerId(group.getTenantId()); builder.name(group.getName()); if (group.getRules() != null) { builder.ipPermissions(filter(transform(group.getRules(), new Function<SecurityGroupRule, IpPermission>() { @Override public IpPermission apply(SecurityGroupRule input) { return securityGroupRuleToIpPermission(groupInRegion, input); } }), Predicates.notNull())); } final String regionId = groupInRegion.getRegion(); Location region = locationIndex.get().get(regionId); checkState(region != null, "location %s not in locationIndex: %s", regionId, locationIndex.get()); builder.location(region); builder.id(regionId + "/" + group.getId()); return builder.build(); }
NovaSecurityGroupInRegionToSecurityGroup implements Function<SecurityGroupInRegion, SecurityGroup> { @Override public SecurityGroup apply(final SecurityGroupInRegion groupInRegion) { SecurityGroupBuilder builder = new SecurityGroupBuilder(); final org.jclouds.openstack.nova.v2_0.domain.SecurityGroup group = groupInRegion.getSecurityGroup(); builder.id(group.getId()); builder.providerId(group.getId()); builder.ownerId(group.getTenantId()); builder.name(group.getName()); if (group.getRules() != null) { builder.ipPermissions(filter(transform(group.getRules(), new Function<SecurityGroupRule, IpPermission>() { @Override public IpPermission apply(SecurityGroupRule input) { return securityGroupRuleToIpPermission(groupInRegion, input); } }), Predicates.notNull())); } final String regionId = groupInRegion.getRegion(); Location region = locationIndex.get().get(regionId); checkState(region != null, "location %s not in locationIndex: %s", regionId, locationIndex.get()); builder.location(region); builder.id(regionId + "/" + group.getId()); return builder.build(); } }
NovaSecurityGroupInRegionToSecurityGroup implements Function<SecurityGroupInRegion, SecurityGroup> { @Override public SecurityGroup apply(final SecurityGroupInRegion groupInRegion) { SecurityGroupBuilder builder = new SecurityGroupBuilder(); final org.jclouds.openstack.nova.v2_0.domain.SecurityGroup group = groupInRegion.getSecurityGroup(); builder.id(group.getId()); builder.providerId(group.getId()); builder.ownerId(group.getTenantId()); builder.name(group.getName()); if (group.getRules() != null) { builder.ipPermissions(filter(transform(group.getRules(), new Function<SecurityGroupRule, IpPermission>() { @Override public IpPermission apply(SecurityGroupRule input) { return securityGroupRuleToIpPermission(groupInRegion, input); } }), Predicates.notNull())); } final String regionId = groupInRegion.getRegion(); Location region = locationIndex.get().get(regionId); checkState(region != null, "location %s not in locationIndex: %s", regionId, locationIndex.get()); builder.location(region); builder.id(regionId + "/" + group.getId()); return builder.build(); } @Inject NovaSecurityGroupInRegionToSecurityGroup(Supplier<Map<String, Location>> locationIndex); }
NovaSecurityGroupInRegionToSecurityGroup implements Function<SecurityGroupInRegion, SecurityGroup> { @Override public SecurityGroup apply(final SecurityGroupInRegion groupInRegion) { SecurityGroupBuilder builder = new SecurityGroupBuilder(); final org.jclouds.openstack.nova.v2_0.domain.SecurityGroup group = groupInRegion.getSecurityGroup(); builder.id(group.getId()); builder.providerId(group.getId()); builder.ownerId(group.getTenantId()); builder.name(group.getName()); if (group.getRules() != null) { builder.ipPermissions(filter(transform(group.getRules(), new Function<SecurityGroupRule, IpPermission>() { @Override public IpPermission apply(SecurityGroupRule input) { return securityGroupRuleToIpPermission(groupInRegion, input); } }), Predicates.notNull())); } final String regionId = groupInRegion.getRegion(); Location region = locationIndex.get().get(regionId); checkState(region != null, "location %s not in locationIndex: %s", regionId, locationIndex.get()); builder.location(region); builder.id(regionId + "/" + group.getId()); return builder.build(); } @Inject NovaSecurityGroupInRegionToSecurityGroup(Supplier<Map<String, Location>> locationIndex); @Override SecurityGroup apply(final SecurityGroupInRegion groupInRegion); }
NovaSecurityGroupInRegionToSecurityGroup implements Function<SecurityGroupInRegion, SecurityGroup> { @Override public SecurityGroup apply(final SecurityGroupInRegion groupInRegion) { SecurityGroupBuilder builder = new SecurityGroupBuilder(); final org.jclouds.openstack.nova.v2_0.domain.SecurityGroup group = groupInRegion.getSecurityGroup(); builder.id(group.getId()); builder.providerId(group.getId()); builder.ownerId(group.getTenantId()); builder.name(group.getName()); if (group.getRules() != null) { builder.ipPermissions(filter(transform(group.getRules(), new Function<SecurityGroupRule, IpPermission>() { @Override public IpPermission apply(SecurityGroupRule input) { return securityGroupRuleToIpPermission(groupInRegion, input); } }), Predicates.notNull())); } final String regionId = groupInRegion.getRegion(); Location region = locationIndex.get().get(regionId); checkState(region != null, "location %s not in locationIndex: %s", regionId, locationIndex.get()); builder.location(region); builder.id(regionId + "/" + group.getId()); return builder.build(); } @Inject NovaSecurityGroupInRegionToSecurityGroup(Supplier<Map<String, Location>> locationIndex); @Override SecurityGroup apply(final SecurityGroupInRegion groupInRegion); }
@Test public void testApplyWithCidr() { NovaSecurityGroupInRegionToSecurityGroup parser = createGroupParser(); SecurityGroupInRegion origGroup = new SecurityGroupInRegion(securityGroupWithCidr(), region.getId(), allGroups); SecurityGroup newGroup = parser.apply(origGroup); assertEquals(newGroup.getId(), origGroup.getRegion() + "/" + origGroup.getSecurityGroup().getId()); assertEquals(newGroup.getProviderId(), origGroup.getSecurityGroup().getId()); assertEquals(newGroup.getName(), origGroup.getSecurityGroup().getName()); assertEquals(newGroup.getOwnerId(), origGroup.getSecurityGroup().getTenantId()); final IpPermission permission = Iterables.getOnlyElement(newGroup.getIpPermissions()); assertEquals(permission.getFromPort(), 10); assertEquals(permission.getToPort(), 20); assertEquals(Iterables.getOnlyElement(permission.getCidrBlocks()), IP_RANGE); assertTrue(permission.getGroupIds().isEmpty()); assertEquals(newGroup.getLocation().getId(), origGroup.getRegion()); }
@Override public SecurityGroup apply(final SecurityGroupInRegion groupInRegion) { SecurityGroupBuilder builder = new SecurityGroupBuilder(); final org.jclouds.openstack.nova.v2_0.domain.SecurityGroup group = groupInRegion.getSecurityGroup(); builder.id(group.getId()); builder.providerId(group.getId()); builder.ownerId(group.getTenantId()); builder.name(group.getName()); if (group.getRules() != null) { builder.ipPermissions(filter(transform(group.getRules(), new Function<SecurityGroupRule, IpPermission>() { @Override public IpPermission apply(SecurityGroupRule input) { return securityGroupRuleToIpPermission(groupInRegion, input); } }), Predicates.notNull())); } final String regionId = groupInRegion.getRegion(); Location region = locationIndex.get().get(regionId); checkState(region != null, "location %s not in locationIndex: %s", regionId, locationIndex.get()); builder.location(region); builder.id(regionId + "/" + group.getId()); return builder.build(); }
NovaSecurityGroupInRegionToSecurityGroup implements Function<SecurityGroupInRegion, SecurityGroup> { @Override public SecurityGroup apply(final SecurityGroupInRegion groupInRegion) { SecurityGroupBuilder builder = new SecurityGroupBuilder(); final org.jclouds.openstack.nova.v2_0.domain.SecurityGroup group = groupInRegion.getSecurityGroup(); builder.id(group.getId()); builder.providerId(group.getId()); builder.ownerId(group.getTenantId()); builder.name(group.getName()); if (group.getRules() != null) { builder.ipPermissions(filter(transform(group.getRules(), new Function<SecurityGroupRule, IpPermission>() { @Override public IpPermission apply(SecurityGroupRule input) { return securityGroupRuleToIpPermission(groupInRegion, input); } }), Predicates.notNull())); } final String regionId = groupInRegion.getRegion(); Location region = locationIndex.get().get(regionId); checkState(region != null, "location %s not in locationIndex: %s", regionId, locationIndex.get()); builder.location(region); builder.id(regionId + "/" + group.getId()); return builder.build(); } }
NovaSecurityGroupInRegionToSecurityGroup implements Function<SecurityGroupInRegion, SecurityGroup> { @Override public SecurityGroup apply(final SecurityGroupInRegion groupInRegion) { SecurityGroupBuilder builder = new SecurityGroupBuilder(); final org.jclouds.openstack.nova.v2_0.domain.SecurityGroup group = groupInRegion.getSecurityGroup(); builder.id(group.getId()); builder.providerId(group.getId()); builder.ownerId(group.getTenantId()); builder.name(group.getName()); if (group.getRules() != null) { builder.ipPermissions(filter(transform(group.getRules(), new Function<SecurityGroupRule, IpPermission>() { @Override public IpPermission apply(SecurityGroupRule input) { return securityGroupRuleToIpPermission(groupInRegion, input); } }), Predicates.notNull())); } final String regionId = groupInRegion.getRegion(); Location region = locationIndex.get().get(regionId); checkState(region != null, "location %s not in locationIndex: %s", regionId, locationIndex.get()); builder.location(region); builder.id(regionId + "/" + group.getId()); return builder.build(); } @Inject NovaSecurityGroupInRegionToSecurityGroup(Supplier<Map<String, Location>> locationIndex); }
NovaSecurityGroupInRegionToSecurityGroup implements Function<SecurityGroupInRegion, SecurityGroup> { @Override public SecurityGroup apply(final SecurityGroupInRegion groupInRegion) { SecurityGroupBuilder builder = new SecurityGroupBuilder(); final org.jclouds.openstack.nova.v2_0.domain.SecurityGroup group = groupInRegion.getSecurityGroup(); builder.id(group.getId()); builder.providerId(group.getId()); builder.ownerId(group.getTenantId()); builder.name(group.getName()); if (group.getRules() != null) { builder.ipPermissions(filter(transform(group.getRules(), new Function<SecurityGroupRule, IpPermission>() { @Override public IpPermission apply(SecurityGroupRule input) { return securityGroupRuleToIpPermission(groupInRegion, input); } }), Predicates.notNull())); } final String regionId = groupInRegion.getRegion(); Location region = locationIndex.get().get(regionId); checkState(region != null, "location %s not in locationIndex: %s", regionId, locationIndex.get()); builder.location(region); builder.id(regionId + "/" + group.getId()); return builder.build(); } @Inject NovaSecurityGroupInRegionToSecurityGroup(Supplier<Map<String, Location>> locationIndex); @Override SecurityGroup apply(final SecurityGroupInRegion groupInRegion); }
NovaSecurityGroupInRegionToSecurityGroup implements Function<SecurityGroupInRegion, SecurityGroup> { @Override public SecurityGroup apply(final SecurityGroupInRegion groupInRegion) { SecurityGroupBuilder builder = new SecurityGroupBuilder(); final org.jclouds.openstack.nova.v2_0.domain.SecurityGroup group = groupInRegion.getSecurityGroup(); builder.id(group.getId()); builder.providerId(group.getId()); builder.ownerId(group.getTenantId()); builder.name(group.getName()); if (group.getRules() != null) { builder.ipPermissions(filter(transform(group.getRules(), new Function<SecurityGroupRule, IpPermission>() { @Override public IpPermission apply(SecurityGroupRule input) { return securityGroupRuleToIpPermission(groupInRegion, input); } }), Predicates.notNull())); } final String regionId = groupInRegion.getRegion(); Location region = locationIndex.get().get(regionId); checkState(region != null, "location %s not in locationIndex: %s", regionId, locationIndex.get()); builder.location(region); builder.id(regionId + "/" + group.getId()); return builder.build(); } @Inject NovaSecurityGroupInRegionToSecurityGroup(Supplier<Map<String, Location>> locationIndex); @Override SecurityGroup apply(final SecurityGroupInRegion groupInRegion); }
@Test public void testConversionWhereLocationFound() { UUID id = UUID.randomUUID(); FlavorInRegion flavorInRegionToConvert = new FlavorInRegion(Flavor.builder().id(id.toString()) .name("Test Flavor " + id).ram(262144).disk(10000).vcpus(16).build(), "az-1.region-a.geo-1"); Hardware converted = new FlavorInRegionToHardware(locationIndex).apply(flavorInRegionToConvert); Flavor flavorToConvert = flavorInRegionToConvert.getFlavor(); assertEquals(converted.getName(), flavorToConvert.getName()); assertEquals(converted.getId(), flavorInRegionToConvert.slashEncode()); assertEquals(converted.getProviderId(), flavorToConvert.getId()); assertEquals(converted.getLocation(), locationIndex.get().get("az-1.region-a.geo-1")); assertEquals(converted.getRam(), flavorToConvert.getRam()); assertNotNull(converted.getProcessors()); assertFalse(converted.getProcessors().isEmpty()); assertEquals(converted.getProcessors().iterator().next().getCores(), (double) flavorToConvert.getVcpus()); assertNotNull(converted.getVolumes()); assertFalse(converted.getVolumes().isEmpty()); assertEquals(converted.getVolumes().iterator().next().getSize(), Float.valueOf(flavorToConvert.getDisk())); }
@Override public Hardware apply(FlavorInRegion flavorInRegion) { Location location = locationIndex.get().get(flavorInRegion.getRegion()); checkState(location != null, "location %s not in locationIndex: %s", flavorInRegion.getRegion(), locationIndex.get()); Flavor flavor = flavorInRegion.getFlavor(); return new HardwareBuilder().id(flavorInRegion.slashEncode()).providerId(flavor.getId()).name(flavor.getName()) .ram(flavor.getRam()).processor(new Processor(flavor.getVcpus(), 1.0)).volume( new VolumeImpl(Float.valueOf(flavor.getDisk()), true, true)).location(location).build(); }
FlavorInRegionToHardware implements Function<FlavorInRegion, Hardware> { @Override public Hardware apply(FlavorInRegion flavorInRegion) { Location location = locationIndex.get().get(flavorInRegion.getRegion()); checkState(location != null, "location %s not in locationIndex: %s", flavorInRegion.getRegion(), locationIndex.get()); Flavor flavor = flavorInRegion.getFlavor(); return new HardwareBuilder().id(flavorInRegion.slashEncode()).providerId(flavor.getId()).name(flavor.getName()) .ram(flavor.getRam()).processor(new Processor(flavor.getVcpus(), 1.0)).volume( new VolumeImpl(Float.valueOf(flavor.getDisk()), true, true)).location(location).build(); } }
FlavorInRegionToHardware implements Function<FlavorInRegion, Hardware> { @Override public Hardware apply(FlavorInRegion flavorInRegion) { Location location = locationIndex.get().get(flavorInRegion.getRegion()); checkState(location != null, "location %s not in locationIndex: %s", flavorInRegion.getRegion(), locationIndex.get()); Flavor flavor = flavorInRegion.getFlavor(); return new HardwareBuilder().id(flavorInRegion.slashEncode()).providerId(flavor.getId()).name(flavor.getName()) .ram(flavor.getRam()).processor(new Processor(flavor.getVcpus(), 1.0)).volume( new VolumeImpl(Float.valueOf(flavor.getDisk()), true, true)).location(location).build(); } @Inject FlavorInRegionToHardware(Supplier<Map<String, Location>> locationIndex); }
FlavorInRegionToHardware implements Function<FlavorInRegion, Hardware> { @Override public Hardware apply(FlavorInRegion flavorInRegion) { Location location = locationIndex.get().get(flavorInRegion.getRegion()); checkState(location != null, "location %s not in locationIndex: %s", flavorInRegion.getRegion(), locationIndex.get()); Flavor flavor = flavorInRegion.getFlavor(); return new HardwareBuilder().id(flavorInRegion.slashEncode()).providerId(flavor.getId()).name(flavor.getName()) .ram(flavor.getRam()).processor(new Processor(flavor.getVcpus(), 1.0)).volume( new VolumeImpl(Float.valueOf(flavor.getDisk()), true, true)).location(location).build(); } @Inject FlavorInRegionToHardware(Supplier<Map<String, Location>> locationIndex); @Override Hardware apply(FlavorInRegion flavorInRegion); }
FlavorInRegionToHardware implements Function<FlavorInRegion, Hardware> { @Override public Hardware apply(FlavorInRegion flavorInRegion) { Location location = locationIndex.get().get(flavorInRegion.getRegion()); checkState(location != null, "location %s not in locationIndex: %s", flavorInRegion.getRegion(), locationIndex.get()); Flavor flavor = flavorInRegion.getFlavor(); return new HardwareBuilder().id(flavorInRegion.slashEncode()).providerId(flavor.getId()).name(flavor.getName()) .ram(flavor.getRam()).processor(new Processor(flavor.getVcpus(), 1.0)).volume( new VolumeImpl(Float.valueOf(flavor.getDisk()), true, true)).location(location).build(); } @Inject FlavorInRegionToHardware(Supplier<Map<String, Location>> locationIndex); @Override Hardware apply(FlavorInRegion flavorInRegion); }
@Test(expectedExceptions = IllegalStateException.class) public void testConversionWhereLocationNotFound() { UUID id = UUID.randomUUID(); FlavorInRegion flavorInRegionToConvert = new FlavorInRegion(Flavor.builder().id(id.toString()) .name("Test Flavor " + id).ram(262144).disk(10000).vcpus(16).build(), "South"); new FlavorInRegionToHardware(locationIndex).apply(flavorInRegionToConvert); }
@Override public Hardware apply(FlavorInRegion flavorInRegion) { Location location = locationIndex.get().get(flavorInRegion.getRegion()); checkState(location != null, "location %s not in locationIndex: %s", flavorInRegion.getRegion(), locationIndex.get()); Flavor flavor = flavorInRegion.getFlavor(); return new HardwareBuilder().id(flavorInRegion.slashEncode()).providerId(flavor.getId()).name(flavor.getName()) .ram(flavor.getRam()).processor(new Processor(flavor.getVcpus(), 1.0)).volume( new VolumeImpl(Float.valueOf(flavor.getDisk()), true, true)).location(location).build(); }
FlavorInRegionToHardware implements Function<FlavorInRegion, Hardware> { @Override public Hardware apply(FlavorInRegion flavorInRegion) { Location location = locationIndex.get().get(flavorInRegion.getRegion()); checkState(location != null, "location %s not in locationIndex: %s", flavorInRegion.getRegion(), locationIndex.get()); Flavor flavor = flavorInRegion.getFlavor(); return new HardwareBuilder().id(flavorInRegion.slashEncode()).providerId(flavor.getId()).name(flavor.getName()) .ram(flavor.getRam()).processor(new Processor(flavor.getVcpus(), 1.0)).volume( new VolumeImpl(Float.valueOf(flavor.getDisk()), true, true)).location(location).build(); } }
FlavorInRegionToHardware implements Function<FlavorInRegion, Hardware> { @Override public Hardware apply(FlavorInRegion flavorInRegion) { Location location = locationIndex.get().get(flavorInRegion.getRegion()); checkState(location != null, "location %s not in locationIndex: %s", flavorInRegion.getRegion(), locationIndex.get()); Flavor flavor = flavorInRegion.getFlavor(); return new HardwareBuilder().id(flavorInRegion.slashEncode()).providerId(flavor.getId()).name(flavor.getName()) .ram(flavor.getRam()).processor(new Processor(flavor.getVcpus(), 1.0)).volume( new VolumeImpl(Float.valueOf(flavor.getDisk()), true, true)).location(location).build(); } @Inject FlavorInRegionToHardware(Supplier<Map<String, Location>> locationIndex); }
FlavorInRegionToHardware implements Function<FlavorInRegion, Hardware> { @Override public Hardware apply(FlavorInRegion flavorInRegion) { Location location = locationIndex.get().get(flavorInRegion.getRegion()); checkState(location != null, "location %s not in locationIndex: %s", flavorInRegion.getRegion(), locationIndex.get()); Flavor flavor = flavorInRegion.getFlavor(); return new HardwareBuilder().id(flavorInRegion.slashEncode()).providerId(flavor.getId()).name(flavor.getName()) .ram(flavor.getRam()).processor(new Processor(flavor.getVcpus(), 1.0)).volume( new VolumeImpl(Float.valueOf(flavor.getDisk()), true, true)).location(location).build(); } @Inject FlavorInRegionToHardware(Supplier<Map<String, Location>> locationIndex); @Override Hardware apply(FlavorInRegion flavorInRegion); }
FlavorInRegionToHardware implements Function<FlavorInRegion, Hardware> { @Override public Hardware apply(FlavorInRegion flavorInRegion) { Location location = locationIndex.get().get(flavorInRegion.getRegion()); checkState(location != null, "location %s not in locationIndex: %s", flavorInRegion.getRegion(), locationIndex.get()); Flavor flavor = flavorInRegion.getFlavor(); return new HardwareBuilder().id(flavorInRegion.slashEncode()).providerId(flavor.getId()).name(flavor.getName()) .ram(flavor.getRam()).processor(new Processor(flavor.getVcpus(), 1.0)).volume( new VolumeImpl(Float.valueOf(flavor.getDisk()), true, true)).location(location).build(); } @Inject FlavorInRegionToHardware(Supplier<Map<String, Location>> locationIndex); @Override Hardware apply(FlavorInRegion flavorInRegion); }
@Test public void testNullAccessIPs() { Hardware existingHardware = new HardwareBuilder().id("az-1.region-a.geo-1/52415800-8b69-11e0-9b19-734f216543fd") .providerId("52415800-8b69-11e0-9b19-734f216543fd").location(region).build(); Image existingImage = new ImageBuilder().id("az-1.region-a.geo-1/52415800-8b69-11e0-9b19-734f6f006e54") .operatingSystem(OperatingSystem.builder().family(OsFamily.LINUX).description("foobuntu").build()) .providerId("52415800-8b69-11e0-9b19-734f6f006e54").description("foobuntu").status(Image.Status.AVAILABLE) .location(region).build(); Set<Image> images = existingImage == null ? ImmutableSet.<Image> of() : ImmutableSet.of(existingImage); Set<Hardware> hardwares = existingHardware == null ? ImmutableSet.<Hardware> of() : ImmutableSet .of(existingHardware); Server serverToConvert = new ParseServerTest().expected().toBuilder() .accessIPv4(null) .accessIPv6(null) .build(); ServerInRegion serverInRegionToConvert = new ServerInRegion(serverToConvert, "az-1.region-a.geo-1"); ServerInRegionToNodeMetadata converter = new ServerInRegionToNodeMetadata( NovaComputeServiceContextModule.toPortableNodeStatus, locationIndex, Suppliers .<Set<? extends Image>> ofInstance(images), Suppliers .<Set<? extends Hardware>> ofInstance(hardwares), namingConvention); NodeMetadata convertedNodeMetadata = converter.apply(serverInRegionToConvert); assertNotNull(convertedNodeMetadata.getPrivateAddresses()); assertEquals(convertedNodeMetadata.getPrivateAddresses(), ImmutableSet.of("10.176.42.16")); assertNotNull(convertedNodeMetadata.getPublicAddresses()); assertEquals(convertedNodeMetadata.getPublicAddresses(), ImmutableSet.of("67.23.10.132", "67.23.10.131")); }
@Override public NodeMetadata apply(ServerInRegion serverInRegion) { Location region = locationIndex.get().get(serverInRegion.getRegion()); checkState(region != null, "location %s not in locationIndex: %s", serverInRegion.getRegion(), locationIndex.get()); Server from = serverInRegion.getServer(); NodeMetadataBuilder builder = new NodeMetadataBuilder(); builder.id(serverInRegion.slashEncode()); builder.providerId(from.getId()); builder.name(from.getName()); builder.hostname(from.getName()); builder.location(from.getHostId() != null ? new LocationBuilder().scope(LocationScope.HOST).id(from.getHostId()) .description(from.getHostId()).parent(region).build() : region); builder.group(groupFromMapOrName(from.getMetadata(), from.getName(), nodeNamingConvention)); addMetadataAndParseTagsFromCommaDelimitedValue(builder, from.getMetadata()); if (from.getImage() != null) { builder.imageId(RegionAndId.fromRegionAndId(serverInRegion.getRegion(), from.getImage().getId()).slashEncode()); } builder.operatingSystem(findOperatingSystemForServerOrNull(serverInRegion)); builder.hardware(findHardwareForServerOrNull(serverInRegion)); builder.status(toPortableNodeStatus.get(from.getStatus())); Set<Address> addresses = newHashSet(from.getAddresses().values()); if (from.getAccessIPv4() != null) { addresses.add(createV4(from.getAccessIPv4())); } if (from.getAccessIPv6() != null) { addresses.add(createV6(from.getAccessIPv6())); } builder.publicAddresses( filter( transform( filter(addresses, or(isFloatingAddress, not(isPrivateAddress))), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); builder.privateAddresses( filter( transform( filter(addresses, and(not(isFloatingAddress), isPrivateAddress)), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); for (Link link : from.getLinks()) { if (link.getRelation().equals(Link.Relation.SELF)) { builder.uri(link.getHref()); } } return builder.build(); }
ServerInRegionToNodeMetadata implements Function<ServerInRegion, NodeMetadata> { @Override public NodeMetadata apply(ServerInRegion serverInRegion) { Location region = locationIndex.get().get(serverInRegion.getRegion()); checkState(region != null, "location %s not in locationIndex: %s", serverInRegion.getRegion(), locationIndex.get()); Server from = serverInRegion.getServer(); NodeMetadataBuilder builder = new NodeMetadataBuilder(); builder.id(serverInRegion.slashEncode()); builder.providerId(from.getId()); builder.name(from.getName()); builder.hostname(from.getName()); builder.location(from.getHostId() != null ? new LocationBuilder().scope(LocationScope.HOST).id(from.getHostId()) .description(from.getHostId()).parent(region).build() : region); builder.group(groupFromMapOrName(from.getMetadata(), from.getName(), nodeNamingConvention)); addMetadataAndParseTagsFromCommaDelimitedValue(builder, from.getMetadata()); if (from.getImage() != null) { builder.imageId(RegionAndId.fromRegionAndId(serverInRegion.getRegion(), from.getImage().getId()).slashEncode()); } builder.operatingSystem(findOperatingSystemForServerOrNull(serverInRegion)); builder.hardware(findHardwareForServerOrNull(serverInRegion)); builder.status(toPortableNodeStatus.get(from.getStatus())); Set<Address> addresses = newHashSet(from.getAddresses().values()); if (from.getAccessIPv4() != null) { addresses.add(createV4(from.getAccessIPv4())); } if (from.getAccessIPv6() != null) { addresses.add(createV6(from.getAccessIPv6())); } builder.publicAddresses( filter( transform( filter(addresses, or(isFloatingAddress, not(isPrivateAddress))), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); builder.privateAddresses( filter( transform( filter(addresses, and(not(isFloatingAddress), isPrivateAddress)), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); for (Link link : from.getLinks()) { if (link.getRelation().equals(Link.Relation.SELF)) { builder.uri(link.getHref()); } } return builder.build(); } }
ServerInRegionToNodeMetadata implements Function<ServerInRegion, NodeMetadata> { @Override public NodeMetadata apply(ServerInRegion serverInRegion) { Location region = locationIndex.get().get(serverInRegion.getRegion()); checkState(region != null, "location %s not in locationIndex: %s", serverInRegion.getRegion(), locationIndex.get()); Server from = serverInRegion.getServer(); NodeMetadataBuilder builder = new NodeMetadataBuilder(); builder.id(serverInRegion.slashEncode()); builder.providerId(from.getId()); builder.name(from.getName()); builder.hostname(from.getName()); builder.location(from.getHostId() != null ? new LocationBuilder().scope(LocationScope.HOST).id(from.getHostId()) .description(from.getHostId()).parent(region).build() : region); builder.group(groupFromMapOrName(from.getMetadata(), from.getName(), nodeNamingConvention)); addMetadataAndParseTagsFromCommaDelimitedValue(builder, from.getMetadata()); if (from.getImage() != null) { builder.imageId(RegionAndId.fromRegionAndId(serverInRegion.getRegion(), from.getImage().getId()).slashEncode()); } builder.operatingSystem(findOperatingSystemForServerOrNull(serverInRegion)); builder.hardware(findHardwareForServerOrNull(serverInRegion)); builder.status(toPortableNodeStatus.get(from.getStatus())); Set<Address> addresses = newHashSet(from.getAddresses().values()); if (from.getAccessIPv4() != null) { addresses.add(createV4(from.getAccessIPv4())); } if (from.getAccessIPv6() != null) { addresses.add(createV6(from.getAccessIPv6())); } builder.publicAddresses( filter( transform( filter(addresses, or(isFloatingAddress, not(isPrivateAddress))), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); builder.privateAddresses( filter( transform( filter(addresses, and(not(isFloatingAddress), isPrivateAddress)), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); for (Link link : from.getLinks()) { if (link.getRelation().equals(Link.Relation.SELF)) { builder.uri(link.getHref()); } } return builder.build(); } @Inject ServerInRegionToNodeMetadata(Map<Server.Status, NodeMetadata.Status> toPortableNodeStatus, Supplier<Map<String, Location>> locationIndex, @Memoized Supplier<Set<? extends Image>> images, @Memoized Supplier<Set<? extends Hardware>> hardwares, GroupNamingConvention.Factory namingConvention); }
ServerInRegionToNodeMetadata implements Function<ServerInRegion, NodeMetadata> { @Override public NodeMetadata apply(ServerInRegion serverInRegion) { Location region = locationIndex.get().get(serverInRegion.getRegion()); checkState(region != null, "location %s not in locationIndex: %s", serverInRegion.getRegion(), locationIndex.get()); Server from = serverInRegion.getServer(); NodeMetadataBuilder builder = new NodeMetadataBuilder(); builder.id(serverInRegion.slashEncode()); builder.providerId(from.getId()); builder.name(from.getName()); builder.hostname(from.getName()); builder.location(from.getHostId() != null ? new LocationBuilder().scope(LocationScope.HOST).id(from.getHostId()) .description(from.getHostId()).parent(region).build() : region); builder.group(groupFromMapOrName(from.getMetadata(), from.getName(), nodeNamingConvention)); addMetadataAndParseTagsFromCommaDelimitedValue(builder, from.getMetadata()); if (from.getImage() != null) { builder.imageId(RegionAndId.fromRegionAndId(serverInRegion.getRegion(), from.getImage().getId()).slashEncode()); } builder.operatingSystem(findOperatingSystemForServerOrNull(serverInRegion)); builder.hardware(findHardwareForServerOrNull(serverInRegion)); builder.status(toPortableNodeStatus.get(from.getStatus())); Set<Address> addresses = newHashSet(from.getAddresses().values()); if (from.getAccessIPv4() != null) { addresses.add(createV4(from.getAccessIPv4())); } if (from.getAccessIPv6() != null) { addresses.add(createV6(from.getAccessIPv6())); } builder.publicAddresses( filter( transform( filter(addresses, or(isFloatingAddress, not(isPrivateAddress))), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); builder.privateAddresses( filter( transform( filter(addresses, and(not(isFloatingAddress), isPrivateAddress)), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); for (Link link : from.getLinks()) { if (link.getRelation().equals(Link.Relation.SELF)) { builder.uri(link.getHref()); } } return builder.build(); } @Inject ServerInRegionToNodeMetadata(Map<Server.Status, NodeMetadata.Status> toPortableNodeStatus, Supplier<Map<String, Location>> locationIndex, @Memoized Supplier<Set<? extends Image>> images, @Memoized Supplier<Set<? extends Hardware>> hardwares, GroupNamingConvention.Factory namingConvention); @Override NodeMetadata apply(ServerInRegion serverInRegion); T findObjectOfTypeForServerOrNull(Set<? extends T> supply, String type, final String objectId, final RegionAndId serverInRegion); }
ServerInRegionToNodeMetadata implements Function<ServerInRegion, NodeMetadata> { @Override public NodeMetadata apply(ServerInRegion serverInRegion) { Location region = locationIndex.get().get(serverInRegion.getRegion()); checkState(region != null, "location %s not in locationIndex: %s", serverInRegion.getRegion(), locationIndex.get()); Server from = serverInRegion.getServer(); NodeMetadataBuilder builder = new NodeMetadataBuilder(); builder.id(serverInRegion.slashEncode()); builder.providerId(from.getId()); builder.name(from.getName()); builder.hostname(from.getName()); builder.location(from.getHostId() != null ? new LocationBuilder().scope(LocationScope.HOST).id(from.getHostId()) .description(from.getHostId()).parent(region).build() : region); builder.group(groupFromMapOrName(from.getMetadata(), from.getName(), nodeNamingConvention)); addMetadataAndParseTagsFromCommaDelimitedValue(builder, from.getMetadata()); if (from.getImage() != null) { builder.imageId(RegionAndId.fromRegionAndId(serverInRegion.getRegion(), from.getImage().getId()).slashEncode()); } builder.operatingSystem(findOperatingSystemForServerOrNull(serverInRegion)); builder.hardware(findHardwareForServerOrNull(serverInRegion)); builder.status(toPortableNodeStatus.get(from.getStatus())); Set<Address> addresses = newHashSet(from.getAddresses().values()); if (from.getAccessIPv4() != null) { addresses.add(createV4(from.getAccessIPv4())); } if (from.getAccessIPv6() != null) { addresses.add(createV6(from.getAccessIPv6())); } builder.publicAddresses( filter( transform( filter(addresses, or(isFloatingAddress, not(isPrivateAddress))), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); builder.privateAddresses( filter( transform( filter(addresses, and(not(isFloatingAddress), isPrivateAddress)), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); for (Link link : from.getLinks()) { if (link.getRelation().equals(Link.Relation.SELF)) { builder.uri(link.getHref()); } } return builder.build(); } @Inject ServerInRegionToNodeMetadata(Map<Server.Status, NodeMetadata.Status> toPortableNodeStatus, Supplier<Map<String, Location>> locationIndex, @Memoized Supplier<Set<? extends Image>> images, @Memoized Supplier<Set<? extends Hardware>> hardwares, GroupNamingConvention.Factory namingConvention); @Override NodeMetadata apply(ServerInRegion serverInRegion); T findObjectOfTypeForServerOrNull(Set<? extends T> supply, String type, final String objectId, final RegionAndId serverInRegion); static final Predicate<Address> isFloatingAddress; static final Predicate<Address> isPrivateAddress; static final Predicate<String> isInet4Address; }
@Test public void testDuplicateAccessIPs() { Hardware existingHardware = new HardwareBuilder().id("az-1.region-a.geo-1/52415800-8b69-11e0-9b19-734f216543fd") .providerId("52415800-8b69-11e0-9b19-734f216543fd").location(region).build(); Image existingImage = new ImageBuilder().id("az-1.region-a.geo-1/52415800-8b69-11e0-9b19-734f6f006e54") .operatingSystem(OperatingSystem.builder().family(OsFamily.LINUX).description("foobuntu").build()) .providerId("52415800-8b69-11e0-9b19-734f6f006e54").description("foobuntu").status(Image.Status.AVAILABLE) .location(region).build(); Set<Image> images = existingImage == null ? ImmutableSet.<Image> of() : ImmutableSet.of(existingImage); Set<Hardware> hardwares = existingHardware == null ? ImmutableSet.<Hardware> of() : ImmutableSet .of(existingHardware); Server serverToConvert = new ParseServerTest().expected().toBuilder() .accessIPv4("67.23.10.132") .accessIPv6("::babe:67.23.10.132") .build(); ServerInRegion serverInRegionToConvert = new ServerInRegion(serverToConvert, "az-1.region-a.geo-1"); ServerInRegionToNodeMetadata converter = new ServerInRegionToNodeMetadata( NovaComputeServiceContextModule.toPortableNodeStatus, locationIndex, Suppliers .<Set<? extends Image>> ofInstance(images), Suppliers .<Set<? extends Hardware>> ofInstance(hardwares), namingConvention); NodeMetadata convertedNodeMetadata = converter.apply(serverInRegionToConvert); assertNotNull(convertedNodeMetadata.getPrivateAddresses()); assertEquals(convertedNodeMetadata.getPrivateAddresses(), ImmutableSet.of("10.176.42.16")); assertNotNull(convertedNodeMetadata.getPublicAddresses()); assertEquals(convertedNodeMetadata.getPublicAddresses(), ImmutableSet.of("67.23.10.132", "67.23.10.131")); }
@Override public NodeMetadata apply(ServerInRegion serverInRegion) { Location region = locationIndex.get().get(serverInRegion.getRegion()); checkState(region != null, "location %s not in locationIndex: %s", serverInRegion.getRegion(), locationIndex.get()); Server from = serverInRegion.getServer(); NodeMetadataBuilder builder = new NodeMetadataBuilder(); builder.id(serverInRegion.slashEncode()); builder.providerId(from.getId()); builder.name(from.getName()); builder.hostname(from.getName()); builder.location(from.getHostId() != null ? new LocationBuilder().scope(LocationScope.HOST).id(from.getHostId()) .description(from.getHostId()).parent(region).build() : region); builder.group(groupFromMapOrName(from.getMetadata(), from.getName(), nodeNamingConvention)); addMetadataAndParseTagsFromCommaDelimitedValue(builder, from.getMetadata()); if (from.getImage() != null) { builder.imageId(RegionAndId.fromRegionAndId(serverInRegion.getRegion(), from.getImage().getId()).slashEncode()); } builder.operatingSystem(findOperatingSystemForServerOrNull(serverInRegion)); builder.hardware(findHardwareForServerOrNull(serverInRegion)); builder.status(toPortableNodeStatus.get(from.getStatus())); Set<Address> addresses = newHashSet(from.getAddresses().values()); if (from.getAccessIPv4() != null) { addresses.add(createV4(from.getAccessIPv4())); } if (from.getAccessIPv6() != null) { addresses.add(createV6(from.getAccessIPv6())); } builder.publicAddresses( filter( transform( filter(addresses, or(isFloatingAddress, not(isPrivateAddress))), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); builder.privateAddresses( filter( transform( filter(addresses, and(not(isFloatingAddress), isPrivateAddress)), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); for (Link link : from.getLinks()) { if (link.getRelation().equals(Link.Relation.SELF)) { builder.uri(link.getHref()); } } return builder.build(); }
ServerInRegionToNodeMetadata implements Function<ServerInRegion, NodeMetadata> { @Override public NodeMetadata apply(ServerInRegion serverInRegion) { Location region = locationIndex.get().get(serverInRegion.getRegion()); checkState(region != null, "location %s not in locationIndex: %s", serverInRegion.getRegion(), locationIndex.get()); Server from = serverInRegion.getServer(); NodeMetadataBuilder builder = new NodeMetadataBuilder(); builder.id(serverInRegion.slashEncode()); builder.providerId(from.getId()); builder.name(from.getName()); builder.hostname(from.getName()); builder.location(from.getHostId() != null ? new LocationBuilder().scope(LocationScope.HOST).id(from.getHostId()) .description(from.getHostId()).parent(region).build() : region); builder.group(groupFromMapOrName(from.getMetadata(), from.getName(), nodeNamingConvention)); addMetadataAndParseTagsFromCommaDelimitedValue(builder, from.getMetadata()); if (from.getImage() != null) { builder.imageId(RegionAndId.fromRegionAndId(serverInRegion.getRegion(), from.getImage().getId()).slashEncode()); } builder.operatingSystem(findOperatingSystemForServerOrNull(serverInRegion)); builder.hardware(findHardwareForServerOrNull(serverInRegion)); builder.status(toPortableNodeStatus.get(from.getStatus())); Set<Address> addresses = newHashSet(from.getAddresses().values()); if (from.getAccessIPv4() != null) { addresses.add(createV4(from.getAccessIPv4())); } if (from.getAccessIPv6() != null) { addresses.add(createV6(from.getAccessIPv6())); } builder.publicAddresses( filter( transform( filter(addresses, or(isFloatingAddress, not(isPrivateAddress))), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); builder.privateAddresses( filter( transform( filter(addresses, and(not(isFloatingAddress), isPrivateAddress)), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); for (Link link : from.getLinks()) { if (link.getRelation().equals(Link.Relation.SELF)) { builder.uri(link.getHref()); } } return builder.build(); } }
ServerInRegionToNodeMetadata implements Function<ServerInRegion, NodeMetadata> { @Override public NodeMetadata apply(ServerInRegion serverInRegion) { Location region = locationIndex.get().get(serverInRegion.getRegion()); checkState(region != null, "location %s not in locationIndex: %s", serverInRegion.getRegion(), locationIndex.get()); Server from = serverInRegion.getServer(); NodeMetadataBuilder builder = new NodeMetadataBuilder(); builder.id(serverInRegion.slashEncode()); builder.providerId(from.getId()); builder.name(from.getName()); builder.hostname(from.getName()); builder.location(from.getHostId() != null ? new LocationBuilder().scope(LocationScope.HOST).id(from.getHostId()) .description(from.getHostId()).parent(region).build() : region); builder.group(groupFromMapOrName(from.getMetadata(), from.getName(), nodeNamingConvention)); addMetadataAndParseTagsFromCommaDelimitedValue(builder, from.getMetadata()); if (from.getImage() != null) { builder.imageId(RegionAndId.fromRegionAndId(serverInRegion.getRegion(), from.getImage().getId()).slashEncode()); } builder.operatingSystem(findOperatingSystemForServerOrNull(serverInRegion)); builder.hardware(findHardwareForServerOrNull(serverInRegion)); builder.status(toPortableNodeStatus.get(from.getStatus())); Set<Address> addresses = newHashSet(from.getAddresses().values()); if (from.getAccessIPv4() != null) { addresses.add(createV4(from.getAccessIPv4())); } if (from.getAccessIPv6() != null) { addresses.add(createV6(from.getAccessIPv6())); } builder.publicAddresses( filter( transform( filter(addresses, or(isFloatingAddress, not(isPrivateAddress))), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); builder.privateAddresses( filter( transform( filter(addresses, and(not(isFloatingAddress), isPrivateAddress)), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); for (Link link : from.getLinks()) { if (link.getRelation().equals(Link.Relation.SELF)) { builder.uri(link.getHref()); } } return builder.build(); } @Inject ServerInRegionToNodeMetadata(Map<Server.Status, NodeMetadata.Status> toPortableNodeStatus, Supplier<Map<String, Location>> locationIndex, @Memoized Supplier<Set<? extends Image>> images, @Memoized Supplier<Set<? extends Hardware>> hardwares, GroupNamingConvention.Factory namingConvention); }
ServerInRegionToNodeMetadata implements Function<ServerInRegion, NodeMetadata> { @Override public NodeMetadata apply(ServerInRegion serverInRegion) { Location region = locationIndex.get().get(serverInRegion.getRegion()); checkState(region != null, "location %s not in locationIndex: %s", serverInRegion.getRegion(), locationIndex.get()); Server from = serverInRegion.getServer(); NodeMetadataBuilder builder = new NodeMetadataBuilder(); builder.id(serverInRegion.slashEncode()); builder.providerId(from.getId()); builder.name(from.getName()); builder.hostname(from.getName()); builder.location(from.getHostId() != null ? new LocationBuilder().scope(LocationScope.HOST).id(from.getHostId()) .description(from.getHostId()).parent(region).build() : region); builder.group(groupFromMapOrName(from.getMetadata(), from.getName(), nodeNamingConvention)); addMetadataAndParseTagsFromCommaDelimitedValue(builder, from.getMetadata()); if (from.getImage() != null) { builder.imageId(RegionAndId.fromRegionAndId(serverInRegion.getRegion(), from.getImage().getId()).slashEncode()); } builder.operatingSystem(findOperatingSystemForServerOrNull(serverInRegion)); builder.hardware(findHardwareForServerOrNull(serverInRegion)); builder.status(toPortableNodeStatus.get(from.getStatus())); Set<Address> addresses = newHashSet(from.getAddresses().values()); if (from.getAccessIPv4() != null) { addresses.add(createV4(from.getAccessIPv4())); } if (from.getAccessIPv6() != null) { addresses.add(createV6(from.getAccessIPv6())); } builder.publicAddresses( filter( transform( filter(addresses, or(isFloatingAddress, not(isPrivateAddress))), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); builder.privateAddresses( filter( transform( filter(addresses, and(not(isFloatingAddress), isPrivateAddress)), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); for (Link link : from.getLinks()) { if (link.getRelation().equals(Link.Relation.SELF)) { builder.uri(link.getHref()); } } return builder.build(); } @Inject ServerInRegionToNodeMetadata(Map<Server.Status, NodeMetadata.Status> toPortableNodeStatus, Supplier<Map<String, Location>> locationIndex, @Memoized Supplier<Set<? extends Image>> images, @Memoized Supplier<Set<? extends Hardware>> hardwares, GroupNamingConvention.Factory namingConvention); @Override NodeMetadata apply(ServerInRegion serverInRegion); T findObjectOfTypeForServerOrNull(Set<? extends T> supply, String type, final String objectId, final RegionAndId serverInRegion); }
ServerInRegionToNodeMetadata implements Function<ServerInRegion, NodeMetadata> { @Override public NodeMetadata apply(ServerInRegion serverInRegion) { Location region = locationIndex.get().get(serverInRegion.getRegion()); checkState(region != null, "location %s not in locationIndex: %s", serverInRegion.getRegion(), locationIndex.get()); Server from = serverInRegion.getServer(); NodeMetadataBuilder builder = new NodeMetadataBuilder(); builder.id(serverInRegion.slashEncode()); builder.providerId(from.getId()); builder.name(from.getName()); builder.hostname(from.getName()); builder.location(from.getHostId() != null ? new LocationBuilder().scope(LocationScope.HOST).id(from.getHostId()) .description(from.getHostId()).parent(region).build() : region); builder.group(groupFromMapOrName(from.getMetadata(), from.getName(), nodeNamingConvention)); addMetadataAndParseTagsFromCommaDelimitedValue(builder, from.getMetadata()); if (from.getImage() != null) { builder.imageId(RegionAndId.fromRegionAndId(serverInRegion.getRegion(), from.getImage().getId()).slashEncode()); } builder.operatingSystem(findOperatingSystemForServerOrNull(serverInRegion)); builder.hardware(findHardwareForServerOrNull(serverInRegion)); builder.status(toPortableNodeStatus.get(from.getStatus())); Set<Address> addresses = newHashSet(from.getAddresses().values()); if (from.getAccessIPv4() != null) { addresses.add(createV4(from.getAccessIPv4())); } if (from.getAccessIPv6() != null) { addresses.add(createV6(from.getAccessIPv6())); } builder.publicAddresses( filter( transform( filter(addresses, or(isFloatingAddress, not(isPrivateAddress))), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); builder.privateAddresses( filter( transform( filter(addresses, and(not(isFloatingAddress), isPrivateAddress)), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); for (Link link : from.getLinks()) { if (link.getRelation().equals(Link.Relation.SELF)) { builder.uri(link.getHref()); } } return builder.build(); } @Inject ServerInRegionToNodeMetadata(Map<Server.Status, NodeMetadata.Status> toPortableNodeStatus, Supplier<Map<String, Location>> locationIndex, @Memoized Supplier<Set<? extends Image>> images, @Memoized Supplier<Set<? extends Hardware>> hardwares, GroupNamingConvention.Factory namingConvention); @Override NodeMetadata apply(ServerInRegion serverInRegion); T findObjectOfTypeForServerOrNull(Set<? extends T> supply, String type, final String objectId, final RegionAndId serverInRegion); static final Predicate<Address> isFloatingAddress; static final Predicate<Address> isPrivateAddress; static final Predicate<String> isInet4Address; }
@Test public void testAlternateAccessIPs() { Hardware existingHardware = new HardwareBuilder().id("az-1.region-a.geo-1/52415800-8b69-11e0-9b19-734f216543fd") .providerId("52415800-8b69-11e0-9b19-734f216543fd").location(region).build(); Image existingImage = new ImageBuilder().id("az-1.region-a.geo-1/52415800-8b69-11e0-9b19-734f6f006e54") .operatingSystem(OperatingSystem.builder().family(OsFamily.LINUX).description("foobuntu").build()) .providerId("52415800-8b69-11e0-9b19-734f6f006e54").description("foobuntu").status(Image.Status.AVAILABLE) .location(region).build(); Set<Image> images = existingImage == null ? ImmutableSet.<Image> of() : ImmutableSet.of(existingImage); Set<Hardware> hardwares = existingHardware == null ? ImmutableSet.<Hardware> of() : ImmutableSet .of(existingHardware); Server serverToConvert = new ParseServerTest().expected().toBuilder() .accessIPv4("76.32.1.231") .accessIPv6("::babe:76.32.1.231") .build(); ServerInRegion serverInRegionToConvert = new ServerInRegion(serverToConvert, "az-1.region-a.geo-1"); ServerInRegionToNodeMetadata converter = new ServerInRegionToNodeMetadata( NovaComputeServiceContextModule.toPortableNodeStatus, locationIndex, Suppliers .<Set<? extends Image>> ofInstance(images), Suppliers .<Set<? extends Hardware>> ofInstance(hardwares), namingConvention); NodeMetadata convertedNodeMetadata = converter.apply(serverInRegionToConvert); assertNotNull(convertedNodeMetadata.getPrivateAddresses()); assertEquals(convertedNodeMetadata.getPrivateAddresses(), ImmutableSet.of("10.176.42.16")); assertNotNull(convertedNodeMetadata.getPublicAddresses()); assertEquals(convertedNodeMetadata.getPublicAddresses(), ImmutableSet.of("67.23.10.132", "67.23.10.131", "76.32.1.231")); }
@Override public NodeMetadata apply(ServerInRegion serverInRegion) { Location region = locationIndex.get().get(serverInRegion.getRegion()); checkState(region != null, "location %s not in locationIndex: %s", serverInRegion.getRegion(), locationIndex.get()); Server from = serverInRegion.getServer(); NodeMetadataBuilder builder = new NodeMetadataBuilder(); builder.id(serverInRegion.slashEncode()); builder.providerId(from.getId()); builder.name(from.getName()); builder.hostname(from.getName()); builder.location(from.getHostId() != null ? new LocationBuilder().scope(LocationScope.HOST).id(from.getHostId()) .description(from.getHostId()).parent(region).build() : region); builder.group(groupFromMapOrName(from.getMetadata(), from.getName(), nodeNamingConvention)); addMetadataAndParseTagsFromCommaDelimitedValue(builder, from.getMetadata()); if (from.getImage() != null) { builder.imageId(RegionAndId.fromRegionAndId(serverInRegion.getRegion(), from.getImage().getId()).slashEncode()); } builder.operatingSystem(findOperatingSystemForServerOrNull(serverInRegion)); builder.hardware(findHardwareForServerOrNull(serverInRegion)); builder.status(toPortableNodeStatus.get(from.getStatus())); Set<Address> addresses = newHashSet(from.getAddresses().values()); if (from.getAccessIPv4() != null) { addresses.add(createV4(from.getAccessIPv4())); } if (from.getAccessIPv6() != null) { addresses.add(createV6(from.getAccessIPv6())); } builder.publicAddresses( filter( transform( filter(addresses, or(isFloatingAddress, not(isPrivateAddress))), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); builder.privateAddresses( filter( transform( filter(addresses, and(not(isFloatingAddress), isPrivateAddress)), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); for (Link link : from.getLinks()) { if (link.getRelation().equals(Link.Relation.SELF)) { builder.uri(link.getHref()); } } return builder.build(); }
ServerInRegionToNodeMetadata implements Function<ServerInRegion, NodeMetadata> { @Override public NodeMetadata apply(ServerInRegion serverInRegion) { Location region = locationIndex.get().get(serverInRegion.getRegion()); checkState(region != null, "location %s not in locationIndex: %s", serverInRegion.getRegion(), locationIndex.get()); Server from = serverInRegion.getServer(); NodeMetadataBuilder builder = new NodeMetadataBuilder(); builder.id(serverInRegion.slashEncode()); builder.providerId(from.getId()); builder.name(from.getName()); builder.hostname(from.getName()); builder.location(from.getHostId() != null ? new LocationBuilder().scope(LocationScope.HOST).id(from.getHostId()) .description(from.getHostId()).parent(region).build() : region); builder.group(groupFromMapOrName(from.getMetadata(), from.getName(), nodeNamingConvention)); addMetadataAndParseTagsFromCommaDelimitedValue(builder, from.getMetadata()); if (from.getImage() != null) { builder.imageId(RegionAndId.fromRegionAndId(serverInRegion.getRegion(), from.getImage().getId()).slashEncode()); } builder.operatingSystem(findOperatingSystemForServerOrNull(serverInRegion)); builder.hardware(findHardwareForServerOrNull(serverInRegion)); builder.status(toPortableNodeStatus.get(from.getStatus())); Set<Address> addresses = newHashSet(from.getAddresses().values()); if (from.getAccessIPv4() != null) { addresses.add(createV4(from.getAccessIPv4())); } if (from.getAccessIPv6() != null) { addresses.add(createV6(from.getAccessIPv6())); } builder.publicAddresses( filter( transform( filter(addresses, or(isFloatingAddress, not(isPrivateAddress))), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); builder.privateAddresses( filter( transform( filter(addresses, and(not(isFloatingAddress), isPrivateAddress)), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); for (Link link : from.getLinks()) { if (link.getRelation().equals(Link.Relation.SELF)) { builder.uri(link.getHref()); } } return builder.build(); } }
ServerInRegionToNodeMetadata implements Function<ServerInRegion, NodeMetadata> { @Override public NodeMetadata apply(ServerInRegion serverInRegion) { Location region = locationIndex.get().get(serverInRegion.getRegion()); checkState(region != null, "location %s not in locationIndex: %s", serverInRegion.getRegion(), locationIndex.get()); Server from = serverInRegion.getServer(); NodeMetadataBuilder builder = new NodeMetadataBuilder(); builder.id(serverInRegion.slashEncode()); builder.providerId(from.getId()); builder.name(from.getName()); builder.hostname(from.getName()); builder.location(from.getHostId() != null ? new LocationBuilder().scope(LocationScope.HOST).id(from.getHostId()) .description(from.getHostId()).parent(region).build() : region); builder.group(groupFromMapOrName(from.getMetadata(), from.getName(), nodeNamingConvention)); addMetadataAndParseTagsFromCommaDelimitedValue(builder, from.getMetadata()); if (from.getImage() != null) { builder.imageId(RegionAndId.fromRegionAndId(serverInRegion.getRegion(), from.getImage().getId()).slashEncode()); } builder.operatingSystem(findOperatingSystemForServerOrNull(serverInRegion)); builder.hardware(findHardwareForServerOrNull(serverInRegion)); builder.status(toPortableNodeStatus.get(from.getStatus())); Set<Address> addresses = newHashSet(from.getAddresses().values()); if (from.getAccessIPv4() != null) { addresses.add(createV4(from.getAccessIPv4())); } if (from.getAccessIPv6() != null) { addresses.add(createV6(from.getAccessIPv6())); } builder.publicAddresses( filter( transform( filter(addresses, or(isFloatingAddress, not(isPrivateAddress))), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); builder.privateAddresses( filter( transform( filter(addresses, and(not(isFloatingAddress), isPrivateAddress)), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); for (Link link : from.getLinks()) { if (link.getRelation().equals(Link.Relation.SELF)) { builder.uri(link.getHref()); } } return builder.build(); } @Inject ServerInRegionToNodeMetadata(Map<Server.Status, NodeMetadata.Status> toPortableNodeStatus, Supplier<Map<String, Location>> locationIndex, @Memoized Supplier<Set<? extends Image>> images, @Memoized Supplier<Set<? extends Hardware>> hardwares, GroupNamingConvention.Factory namingConvention); }
ServerInRegionToNodeMetadata implements Function<ServerInRegion, NodeMetadata> { @Override public NodeMetadata apply(ServerInRegion serverInRegion) { Location region = locationIndex.get().get(serverInRegion.getRegion()); checkState(region != null, "location %s not in locationIndex: %s", serverInRegion.getRegion(), locationIndex.get()); Server from = serverInRegion.getServer(); NodeMetadataBuilder builder = new NodeMetadataBuilder(); builder.id(serverInRegion.slashEncode()); builder.providerId(from.getId()); builder.name(from.getName()); builder.hostname(from.getName()); builder.location(from.getHostId() != null ? new LocationBuilder().scope(LocationScope.HOST).id(from.getHostId()) .description(from.getHostId()).parent(region).build() : region); builder.group(groupFromMapOrName(from.getMetadata(), from.getName(), nodeNamingConvention)); addMetadataAndParseTagsFromCommaDelimitedValue(builder, from.getMetadata()); if (from.getImage() != null) { builder.imageId(RegionAndId.fromRegionAndId(serverInRegion.getRegion(), from.getImage().getId()).slashEncode()); } builder.operatingSystem(findOperatingSystemForServerOrNull(serverInRegion)); builder.hardware(findHardwareForServerOrNull(serverInRegion)); builder.status(toPortableNodeStatus.get(from.getStatus())); Set<Address> addresses = newHashSet(from.getAddresses().values()); if (from.getAccessIPv4() != null) { addresses.add(createV4(from.getAccessIPv4())); } if (from.getAccessIPv6() != null) { addresses.add(createV6(from.getAccessIPv6())); } builder.publicAddresses( filter( transform( filter(addresses, or(isFloatingAddress, not(isPrivateAddress))), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); builder.privateAddresses( filter( transform( filter(addresses, and(not(isFloatingAddress), isPrivateAddress)), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); for (Link link : from.getLinks()) { if (link.getRelation().equals(Link.Relation.SELF)) { builder.uri(link.getHref()); } } return builder.build(); } @Inject ServerInRegionToNodeMetadata(Map<Server.Status, NodeMetadata.Status> toPortableNodeStatus, Supplier<Map<String, Location>> locationIndex, @Memoized Supplier<Set<? extends Image>> images, @Memoized Supplier<Set<? extends Hardware>> hardwares, GroupNamingConvention.Factory namingConvention); @Override NodeMetadata apply(ServerInRegion serverInRegion); T findObjectOfTypeForServerOrNull(Set<? extends T> supply, String type, final String objectId, final RegionAndId serverInRegion); }
ServerInRegionToNodeMetadata implements Function<ServerInRegion, NodeMetadata> { @Override public NodeMetadata apply(ServerInRegion serverInRegion) { Location region = locationIndex.get().get(serverInRegion.getRegion()); checkState(region != null, "location %s not in locationIndex: %s", serverInRegion.getRegion(), locationIndex.get()); Server from = serverInRegion.getServer(); NodeMetadataBuilder builder = new NodeMetadataBuilder(); builder.id(serverInRegion.slashEncode()); builder.providerId(from.getId()); builder.name(from.getName()); builder.hostname(from.getName()); builder.location(from.getHostId() != null ? new LocationBuilder().scope(LocationScope.HOST).id(from.getHostId()) .description(from.getHostId()).parent(region).build() : region); builder.group(groupFromMapOrName(from.getMetadata(), from.getName(), nodeNamingConvention)); addMetadataAndParseTagsFromCommaDelimitedValue(builder, from.getMetadata()); if (from.getImage() != null) { builder.imageId(RegionAndId.fromRegionAndId(serverInRegion.getRegion(), from.getImage().getId()).slashEncode()); } builder.operatingSystem(findOperatingSystemForServerOrNull(serverInRegion)); builder.hardware(findHardwareForServerOrNull(serverInRegion)); builder.status(toPortableNodeStatus.get(from.getStatus())); Set<Address> addresses = newHashSet(from.getAddresses().values()); if (from.getAccessIPv4() != null) { addresses.add(createV4(from.getAccessIPv4())); } if (from.getAccessIPv6() != null) { addresses.add(createV6(from.getAccessIPv6())); } builder.publicAddresses( filter( transform( filter(addresses, or(isFloatingAddress, not(isPrivateAddress))), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); builder.privateAddresses( filter( transform( filter(addresses, and(not(isFloatingAddress), isPrivateAddress)), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); for (Link link : from.getLinks()) { if (link.getRelation().equals(Link.Relation.SELF)) { builder.uri(link.getHref()); } } return builder.build(); } @Inject ServerInRegionToNodeMetadata(Map<Server.Status, NodeMetadata.Status> toPortableNodeStatus, Supplier<Map<String, Location>> locationIndex, @Memoized Supplier<Set<? extends Image>> images, @Memoized Supplier<Set<? extends Hardware>> hardwares, GroupNamingConvention.Factory namingConvention); @Override NodeMetadata apply(ServerInRegion serverInRegion); T findObjectOfTypeForServerOrNull(Set<? extends T> supply, String type, final String objectId, final RegionAndId serverInRegion); static final Predicate<Address> isFloatingAddress; static final Predicate<Address> isPrivateAddress; static final Predicate<String> isInet4Address; }
@Test public void testServerWithoutImage() { Hardware existingHardware = new HardwareBuilder().id("az-1.region-a.geo-1/52415800-8b69-11e0-9b19-734f216543fd") .providerId("52415800-8b69-11e0-9b19-734f216543fd").location(region).build(); Image existingImage = new ImageBuilder().id("az-1.region-a.geo-1/52415800-8b69-11e0-9b19-734f6f006e54") .operatingSystem(OperatingSystem.builder().family(OsFamily.LINUX).description("foobuntu").build()) .providerId("52415800-8b69-11e0-9b19-734f6f006e54").description("foobuntu").status(Image.Status.AVAILABLE) .location(region).build(); Server serverToConvert = new ParseServerWithoutImageTest().expected(); ServerInRegion serverInRegionToConvert = new ServerInRegion(serverToConvert, "az-1.region-a.geo-1"); ServerInRegionToNodeMetadata converter = new ServerInRegionToNodeMetadata( NovaComputeServiceContextModule.toPortableNodeStatus, locationIndex, Suppliers.<Set<? extends Image>> ofInstance(ImmutableSet.of(existingImage)), Suppliers.<Set<? extends Hardware>> ofInstance(ImmutableSet.of(existingHardware)), namingConvention); NodeMetadata convertedNodeMetadata = converter.apply(serverInRegionToConvert); assertNull(convertedNodeMetadata.getImageId()); }
@Override public NodeMetadata apply(ServerInRegion serverInRegion) { Location region = locationIndex.get().get(serverInRegion.getRegion()); checkState(region != null, "location %s not in locationIndex: %s", serverInRegion.getRegion(), locationIndex.get()); Server from = serverInRegion.getServer(); NodeMetadataBuilder builder = new NodeMetadataBuilder(); builder.id(serverInRegion.slashEncode()); builder.providerId(from.getId()); builder.name(from.getName()); builder.hostname(from.getName()); builder.location(from.getHostId() != null ? new LocationBuilder().scope(LocationScope.HOST).id(from.getHostId()) .description(from.getHostId()).parent(region).build() : region); builder.group(groupFromMapOrName(from.getMetadata(), from.getName(), nodeNamingConvention)); addMetadataAndParseTagsFromCommaDelimitedValue(builder, from.getMetadata()); if (from.getImage() != null) { builder.imageId(RegionAndId.fromRegionAndId(serverInRegion.getRegion(), from.getImage().getId()).slashEncode()); } builder.operatingSystem(findOperatingSystemForServerOrNull(serverInRegion)); builder.hardware(findHardwareForServerOrNull(serverInRegion)); builder.status(toPortableNodeStatus.get(from.getStatus())); Set<Address> addresses = newHashSet(from.getAddresses().values()); if (from.getAccessIPv4() != null) { addresses.add(createV4(from.getAccessIPv4())); } if (from.getAccessIPv6() != null) { addresses.add(createV6(from.getAccessIPv6())); } builder.publicAddresses( filter( transform( filter(addresses, or(isFloatingAddress, not(isPrivateAddress))), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); builder.privateAddresses( filter( transform( filter(addresses, and(not(isFloatingAddress), isPrivateAddress)), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); for (Link link : from.getLinks()) { if (link.getRelation().equals(Link.Relation.SELF)) { builder.uri(link.getHref()); } } return builder.build(); }
ServerInRegionToNodeMetadata implements Function<ServerInRegion, NodeMetadata> { @Override public NodeMetadata apply(ServerInRegion serverInRegion) { Location region = locationIndex.get().get(serverInRegion.getRegion()); checkState(region != null, "location %s not in locationIndex: %s", serverInRegion.getRegion(), locationIndex.get()); Server from = serverInRegion.getServer(); NodeMetadataBuilder builder = new NodeMetadataBuilder(); builder.id(serverInRegion.slashEncode()); builder.providerId(from.getId()); builder.name(from.getName()); builder.hostname(from.getName()); builder.location(from.getHostId() != null ? new LocationBuilder().scope(LocationScope.HOST).id(from.getHostId()) .description(from.getHostId()).parent(region).build() : region); builder.group(groupFromMapOrName(from.getMetadata(), from.getName(), nodeNamingConvention)); addMetadataAndParseTagsFromCommaDelimitedValue(builder, from.getMetadata()); if (from.getImage() != null) { builder.imageId(RegionAndId.fromRegionAndId(serverInRegion.getRegion(), from.getImage().getId()).slashEncode()); } builder.operatingSystem(findOperatingSystemForServerOrNull(serverInRegion)); builder.hardware(findHardwareForServerOrNull(serverInRegion)); builder.status(toPortableNodeStatus.get(from.getStatus())); Set<Address> addresses = newHashSet(from.getAddresses().values()); if (from.getAccessIPv4() != null) { addresses.add(createV4(from.getAccessIPv4())); } if (from.getAccessIPv6() != null) { addresses.add(createV6(from.getAccessIPv6())); } builder.publicAddresses( filter( transform( filter(addresses, or(isFloatingAddress, not(isPrivateAddress))), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); builder.privateAddresses( filter( transform( filter(addresses, and(not(isFloatingAddress), isPrivateAddress)), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); for (Link link : from.getLinks()) { if (link.getRelation().equals(Link.Relation.SELF)) { builder.uri(link.getHref()); } } return builder.build(); } }
ServerInRegionToNodeMetadata implements Function<ServerInRegion, NodeMetadata> { @Override public NodeMetadata apply(ServerInRegion serverInRegion) { Location region = locationIndex.get().get(serverInRegion.getRegion()); checkState(region != null, "location %s not in locationIndex: %s", serverInRegion.getRegion(), locationIndex.get()); Server from = serverInRegion.getServer(); NodeMetadataBuilder builder = new NodeMetadataBuilder(); builder.id(serverInRegion.slashEncode()); builder.providerId(from.getId()); builder.name(from.getName()); builder.hostname(from.getName()); builder.location(from.getHostId() != null ? new LocationBuilder().scope(LocationScope.HOST).id(from.getHostId()) .description(from.getHostId()).parent(region).build() : region); builder.group(groupFromMapOrName(from.getMetadata(), from.getName(), nodeNamingConvention)); addMetadataAndParseTagsFromCommaDelimitedValue(builder, from.getMetadata()); if (from.getImage() != null) { builder.imageId(RegionAndId.fromRegionAndId(serverInRegion.getRegion(), from.getImage().getId()).slashEncode()); } builder.operatingSystem(findOperatingSystemForServerOrNull(serverInRegion)); builder.hardware(findHardwareForServerOrNull(serverInRegion)); builder.status(toPortableNodeStatus.get(from.getStatus())); Set<Address> addresses = newHashSet(from.getAddresses().values()); if (from.getAccessIPv4() != null) { addresses.add(createV4(from.getAccessIPv4())); } if (from.getAccessIPv6() != null) { addresses.add(createV6(from.getAccessIPv6())); } builder.publicAddresses( filter( transform( filter(addresses, or(isFloatingAddress, not(isPrivateAddress))), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); builder.privateAddresses( filter( transform( filter(addresses, and(not(isFloatingAddress), isPrivateAddress)), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); for (Link link : from.getLinks()) { if (link.getRelation().equals(Link.Relation.SELF)) { builder.uri(link.getHref()); } } return builder.build(); } @Inject ServerInRegionToNodeMetadata(Map<Server.Status, NodeMetadata.Status> toPortableNodeStatus, Supplier<Map<String, Location>> locationIndex, @Memoized Supplier<Set<? extends Image>> images, @Memoized Supplier<Set<? extends Hardware>> hardwares, GroupNamingConvention.Factory namingConvention); }
ServerInRegionToNodeMetadata implements Function<ServerInRegion, NodeMetadata> { @Override public NodeMetadata apply(ServerInRegion serverInRegion) { Location region = locationIndex.get().get(serverInRegion.getRegion()); checkState(region != null, "location %s not in locationIndex: %s", serverInRegion.getRegion(), locationIndex.get()); Server from = serverInRegion.getServer(); NodeMetadataBuilder builder = new NodeMetadataBuilder(); builder.id(serverInRegion.slashEncode()); builder.providerId(from.getId()); builder.name(from.getName()); builder.hostname(from.getName()); builder.location(from.getHostId() != null ? new LocationBuilder().scope(LocationScope.HOST).id(from.getHostId()) .description(from.getHostId()).parent(region).build() : region); builder.group(groupFromMapOrName(from.getMetadata(), from.getName(), nodeNamingConvention)); addMetadataAndParseTagsFromCommaDelimitedValue(builder, from.getMetadata()); if (from.getImage() != null) { builder.imageId(RegionAndId.fromRegionAndId(serverInRegion.getRegion(), from.getImage().getId()).slashEncode()); } builder.operatingSystem(findOperatingSystemForServerOrNull(serverInRegion)); builder.hardware(findHardwareForServerOrNull(serverInRegion)); builder.status(toPortableNodeStatus.get(from.getStatus())); Set<Address> addresses = newHashSet(from.getAddresses().values()); if (from.getAccessIPv4() != null) { addresses.add(createV4(from.getAccessIPv4())); } if (from.getAccessIPv6() != null) { addresses.add(createV6(from.getAccessIPv6())); } builder.publicAddresses( filter( transform( filter(addresses, or(isFloatingAddress, not(isPrivateAddress))), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); builder.privateAddresses( filter( transform( filter(addresses, and(not(isFloatingAddress), isPrivateAddress)), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); for (Link link : from.getLinks()) { if (link.getRelation().equals(Link.Relation.SELF)) { builder.uri(link.getHref()); } } return builder.build(); } @Inject ServerInRegionToNodeMetadata(Map<Server.Status, NodeMetadata.Status> toPortableNodeStatus, Supplier<Map<String, Location>> locationIndex, @Memoized Supplier<Set<? extends Image>> images, @Memoized Supplier<Set<? extends Hardware>> hardwares, GroupNamingConvention.Factory namingConvention); @Override NodeMetadata apply(ServerInRegion serverInRegion); T findObjectOfTypeForServerOrNull(Set<? extends T> supply, String type, final String objectId, final RegionAndId serverInRegion); }
ServerInRegionToNodeMetadata implements Function<ServerInRegion, NodeMetadata> { @Override public NodeMetadata apply(ServerInRegion serverInRegion) { Location region = locationIndex.get().get(serverInRegion.getRegion()); checkState(region != null, "location %s not in locationIndex: %s", serverInRegion.getRegion(), locationIndex.get()); Server from = serverInRegion.getServer(); NodeMetadataBuilder builder = new NodeMetadataBuilder(); builder.id(serverInRegion.slashEncode()); builder.providerId(from.getId()); builder.name(from.getName()); builder.hostname(from.getName()); builder.location(from.getHostId() != null ? new LocationBuilder().scope(LocationScope.HOST).id(from.getHostId()) .description(from.getHostId()).parent(region).build() : region); builder.group(groupFromMapOrName(from.getMetadata(), from.getName(), nodeNamingConvention)); addMetadataAndParseTagsFromCommaDelimitedValue(builder, from.getMetadata()); if (from.getImage() != null) { builder.imageId(RegionAndId.fromRegionAndId(serverInRegion.getRegion(), from.getImage().getId()).slashEncode()); } builder.operatingSystem(findOperatingSystemForServerOrNull(serverInRegion)); builder.hardware(findHardwareForServerOrNull(serverInRegion)); builder.status(toPortableNodeStatus.get(from.getStatus())); Set<Address> addresses = newHashSet(from.getAddresses().values()); if (from.getAccessIPv4() != null) { addresses.add(createV4(from.getAccessIPv4())); } if (from.getAccessIPv6() != null) { addresses.add(createV6(from.getAccessIPv6())); } builder.publicAddresses( filter( transform( filter(addresses, or(isFloatingAddress, not(isPrivateAddress))), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); builder.privateAddresses( filter( transform( filter(addresses, and(not(isFloatingAddress), isPrivateAddress)), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); for (Link link : from.getLinks()) { if (link.getRelation().equals(Link.Relation.SELF)) { builder.uri(link.getHref()); } } return builder.build(); } @Inject ServerInRegionToNodeMetadata(Map<Server.Status, NodeMetadata.Status> toPortableNodeStatus, Supplier<Map<String, Location>> locationIndex, @Memoized Supplier<Set<? extends Image>> images, @Memoized Supplier<Set<? extends Hardware>> hardwares, GroupNamingConvention.Factory namingConvention); @Override NodeMetadata apply(ServerInRegion serverInRegion); T findObjectOfTypeForServerOrNull(Set<? extends T> supply, String type, final String objectId, final RegionAndId serverInRegion); static final Predicate<Address> isFloatingAddress; static final Predicate<Address> isPrivateAddress; static final Predicate<String> isInet4Address; }
@Test public void testFloatingIp() { Hardware existingHardware = new HardwareBuilder().id("az-1.region-a.geo-1/52415800-8b69-11e0-9b19-734f216543fd") .providerId("52415800-8b69-11e0-9b19-734f216543fd").location(region).build(); Image existingImage = new ImageBuilder().id("az-1.region-a.geo-1/52415800-8b69-11e0-9b19-734f6f006e54") .operatingSystem(OperatingSystem.builder().family(OsFamily.LINUX).description("foobuntu").build()) .providerId("52415800-8b69-11e0-9b19-734f6f006e54").description("foobuntu").status(Image.Status.AVAILABLE) .location(region).build(); Server serverToConvert = new ParseServerWithAddressExtensionsTest().expected(); ServerInRegion serverInRegionToConvert = new ServerInRegion(serverToConvert, "az-1.region-a.geo-1"); ServerInRegionToNodeMetadata converter = new ServerInRegionToNodeMetadata( NovaComputeServiceContextModule.toPortableNodeStatus, locationIndex, Suppliers.<Set<? extends Image>> ofInstance(ImmutableSet.of(existingImage)), Suppliers.<Set<? extends Hardware>> ofInstance(ImmutableSet.of(existingHardware)), namingConvention); NodeMetadata convertedNodeMetadata = converter.apply(serverInRegionToConvert); assertEquals(convertedNodeMetadata.getPrivateAddresses(), ImmutableSet.of("172.16.130.24")); assertEquals(convertedNodeMetadata.getPublicAddresses(), ImmutableSet.of("10.8.54.75")); }
@Override public NodeMetadata apply(ServerInRegion serverInRegion) { Location region = locationIndex.get().get(serverInRegion.getRegion()); checkState(region != null, "location %s not in locationIndex: %s", serverInRegion.getRegion(), locationIndex.get()); Server from = serverInRegion.getServer(); NodeMetadataBuilder builder = new NodeMetadataBuilder(); builder.id(serverInRegion.slashEncode()); builder.providerId(from.getId()); builder.name(from.getName()); builder.hostname(from.getName()); builder.location(from.getHostId() != null ? new LocationBuilder().scope(LocationScope.HOST).id(from.getHostId()) .description(from.getHostId()).parent(region).build() : region); builder.group(groupFromMapOrName(from.getMetadata(), from.getName(), nodeNamingConvention)); addMetadataAndParseTagsFromCommaDelimitedValue(builder, from.getMetadata()); if (from.getImage() != null) { builder.imageId(RegionAndId.fromRegionAndId(serverInRegion.getRegion(), from.getImage().getId()).slashEncode()); } builder.operatingSystem(findOperatingSystemForServerOrNull(serverInRegion)); builder.hardware(findHardwareForServerOrNull(serverInRegion)); builder.status(toPortableNodeStatus.get(from.getStatus())); Set<Address> addresses = newHashSet(from.getAddresses().values()); if (from.getAccessIPv4() != null) { addresses.add(createV4(from.getAccessIPv4())); } if (from.getAccessIPv6() != null) { addresses.add(createV6(from.getAccessIPv6())); } builder.publicAddresses( filter( transform( filter(addresses, or(isFloatingAddress, not(isPrivateAddress))), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); builder.privateAddresses( filter( transform( filter(addresses, and(not(isFloatingAddress), isPrivateAddress)), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); for (Link link : from.getLinks()) { if (link.getRelation().equals(Link.Relation.SELF)) { builder.uri(link.getHref()); } } return builder.build(); }
ServerInRegionToNodeMetadata implements Function<ServerInRegion, NodeMetadata> { @Override public NodeMetadata apply(ServerInRegion serverInRegion) { Location region = locationIndex.get().get(serverInRegion.getRegion()); checkState(region != null, "location %s not in locationIndex: %s", serverInRegion.getRegion(), locationIndex.get()); Server from = serverInRegion.getServer(); NodeMetadataBuilder builder = new NodeMetadataBuilder(); builder.id(serverInRegion.slashEncode()); builder.providerId(from.getId()); builder.name(from.getName()); builder.hostname(from.getName()); builder.location(from.getHostId() != null ? new LocationBuilder().scope(LocationScope.HOST).id(from.getHostId()) .description(from.getHostId()).parent(region).build() : region); builder.group(groupFromMapOrName(from.getMetadata(), from.getName(), nodeNamingConvention)); addMetadataAndParseTagsFromCommaDelimitedValue(builder, from.getMetadata()); if (from.getImage() != null) { builder.imageId(RegionAndId.fromRegionAndId(serverInRegion.getRegion(), from.getImage().getId()).slashEncode()); } builder.operatingSystem(findOperatingSystemForServerOrNull(serverInRegion)); builder.hardware(findHardwareForServerOrNull(serverInRegion)); builder.status(toPortableNodeStatus.get(from.getStatus())); Set<Address> addresses = newHashSet(from.getAddresses().values()); if (from.getAccessIPv4() != null) { addresses.add(createV4(from.getAccessIPv4())); } if (from.getAccessIPv6() != null) { addresses.add(createV6(from.getAccessIPv6())); } builder.publicAddresses( filter( transform( filter(addresses, or(isFloatingAddress, not(isPrivateAddress))), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); builder.privateAddresses( filter( transform( filter(addresses, and(not(isFloatingAddress), isPrivateAddress)), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); for (Link link : from.getLinks()) { if (link.getRelation().equals(Link.Relation.SELF)) { builder.uri(link.getHref()); } } return builder.build(); } }
ServerInRegionToNodeMetadata implements Function<ServerInRegion, NodeMetadata> { @Override public NodeMetadata apply(ServerInRegion serverInRegion) { Location region = locationIndex.get().get(serverInRegion.getRegion()); checkState(region != null, "location %s not in locationIndex: %s", serverInRegion.getRegion(), locationIndex.get()); Server from = serverInRegion.getServer(); NodeMetadataBuilder builder = new NodeMetadataBuilder(); builder.id(serverInRegion.slashEncode()); builder.providerId(from.getId()); builder.name(from.getName()); builder.hostname(from.getName()); builder.location(from.getHostId() != null ? new LocationBuilder().scope(LocationScope.HOST).id(from.getHostId()) .description(from.getHostId()).parent(region).build() : region); builder.group(groupFromMapOrName(from.getMetadata(), from.getName(), nodeNamingConvention)); addMetadataAndParseTagsFromCommaDelimitedValue(builder, from.getMetadata()); if (from.getImage() != null) { builder.imageId(RegionAndId.fromRegionAndId(serverInRegion.getRegion(), from.getImage().getId()).slashEncode()); } builder.operatingSystem(findOperatingSystemForServerOrNull(serverInRegion)); builder.hardware(findHardwareForServerOrNull(serverInRegion)); builder.status(toPortableNodeStatus.get(from.getStatus())); Set<Address> addresses = newHashSet(from.getAddresses().values()); if (from.getAccessIPv4() != null) { addresses.add(createV4(from.getAccessIPv4())); } if (from.getAccessIPv6() != null) { addresses.add(createV6(from.getAccessIPv6())); } builder.publicAddresses( filter( transform( filter(addresses, or(isFloatingAddress, not(isPrivateAddress))), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); builder.privateAddresses( filter( transform( filter(addresses, and(not(isFloatingAddress), isPrivateAddress)), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); for (Link link : from.getLinks()) { if (link.getRelation().equals(Link.Relation.SELF)) { builder.uri(link.getHref()); } } return builder.build(); } @Inject ServerInRegionToNodeMetadata(Map<Server.Status, NodeMetadata.Status> toPortableNodeStatus, Supplier<Map<String, Location>> locationIndex, @Memoized Supplier<Set<? extends Image>> images, @Memoized Supplier<Set<? extends Hardware>> hardwares, GroupNamingConvention.Factory namingConvention); }
ServerInRegionToNodeMetadata implements Function<ServerInRegion, NodeMetadata> { @Override public NodeMetadata apply(ServerInRegion serverInRegion) { Location region = locationIndex.get().get(serverInRegion.getRegion()); checkState(region != null, "location %s not in locationIndex: %s", serverInRegion.getRegion(), locationIndex.get()); Server from = serverInRegion.getServer(); NodeMetadataBuilder builder = new NodeMetadataBuilder(); builder.id(serverInRegion.slashEncode()); builder.providerId(from.getId()); builder.name(from.getName()); builder.hostname(from.getName()); builder.location(from.getHostId() != null ? new LocationBuilder().scope(LocationScope.HOST).id(from.getHostId()) .description(from.getHostId()).parent(region).build() : region); builder.group(groupFromMapOrName(from.getMetadata(), from.getName(), nodeNamingConvention)); addMetadataAndParseTagsFromCommaDelimitedValue(builder, from.getMetadata()); if (from.getImage() != null) { builder.imageId(RegionAndId.fromRegionAndId(serverInRegion.getRegion(), from.getImage().getId()).slashEncode()); } builder.operatingSystem(findOperatingSystemForServerOrNull(serverInRegion)); builder.hardware(findHardwareForServerOrNull(serverInRegion)); builder.status(toPortableNodeStatus.get(from.getStatus())); Set<Address> addresses = newHashSet(from.getAddresses().values()); if (from.getAccessIPv4() != null) { addresses.add(createV4(from.getAccessIPv4())); } if (from.getAccessIPv6() != null) { addresses.add(createV6(from.getAccessIPv6())); } builder.publicAddresses( filter( transform( filter(addresses, or(isFloatingAddress, not(isPrivateAddress))), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); builder.privateAddresses( filter( transform( filter(addresses, and(not(isFloatingAddress), isPrivateAddress)), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); for (Link link : from.getLinks()) { if (link.getRelation().equals(Link.Relation.SELF)) { builder.uri(link.getHref()); } } return builder.build(); } @Inject ServerInRegionToNodeMetadata(Map<Server.Status, NodeMetadata.Status> toPortableNodeStatus, Supplier<Map<String, Location>> locationIndex, @Memoized Supplier<Set<? extends Image>> images, @Memoized Supplier<Set<? extends Hardware>> hardwares, GroupNamingConvention.Factory namingConvention); @Override NodeMetadata apply(ServerInRegion serverInRegion); T findObjectOfTypeForServerOrNull(Set<? extends T> supply, String type, final String objectId, final RegionAndId serverInRegion); }
ServerInRegionToNodeMetadata implements Function<ServerInRegion, NodeMetadata> { @Override public NodeMetadata apply(ServerInRegion serverInRegion) { Location region = locationIndex.get().get(serverInRegion.getRegion()); checkState(region != null, "location %s not in locationIndex: %s", serverInRegion.getRegion(), locationIndex.get()); Server from = serverInRegion.getServer(); NodeMetadataBuilder builder = new NodeMetadataBuilder(); builder.id(serverInRegion.slashEncode()); builder.providerId(from.getId()); builder.name(from.getName()); builder.hostname(from.getName()); builder.location(from.getHostId() != null ? new LocationBuilder().scope(LocationScope.HOST).id(from.getHostId()) .description(from.getHostId()).parent(region).build() : region); builder.group(groupFromMapOrName(from.getMetadata(), from.getName(), nodeNamingConvention)); addMetadataAndParseTagsFromCommaDelimitedValue(builder, from.getMetadata()); if (from.getImage() != null) { builder.imageId(RegionAndId.fromRegionAndId(serverInRegion.getRegion(), from.getImage().getId()).slashEncode()); } builder.operatingSystem(findOperatingSystemForServerOrNull(serverInRegion)); builder.hardware(findHardwareForServerOrNull(serverInRegion)); builder.status(toPortableNodeStatus.get(from.getStatus())); Set<Address> addresses = newHashSet(from.getAddresses().values()); if (from.getAccessIPv4() != null) { addresses.add(createV4(from.getAccessIPv4())); } if (from.getAccessIPv6() != null) { addresses.add(createV6(from.getAccessIPv6())); } builder.publicAddresses( filter( transform( filter(addresses, or(isFloatingAddress, not(isPrivateAddress))), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); builder.privateAddresses( filter( transform( filter(addresses, and(not(isFloatingAddress), isPrivateAddress)), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); for (Link link : from.getLinks()) { if (link.getRelation().equals(Link.Relation.SELF)) { builder.uri(link.getHref()); } } return builder.build(); } @Inject ServerInRegionToNodeMetadata(Map<Server.Status, NodeMetadata.Status> toPortableNodeStatus, Supplier<Map<String, Location>> locationIndex, @Memoized Supplier<Set<? extends Image>> images, @Memoized Supplier<Set<? extends Hardware>> hardwares, GroupNamingConvention.Factory namingConvention); @Override NodeMetadata apply(ServerInRegion serverInRegion); T findObjectOfTypeForServerOrNull(Set<? extends T> supply, String type, final String objectId, final RegionAndId serverInRegion); static final Predicate<Address> isFloatingAddress; static final Predicate<Address> isPrivateAddress; static final Predicate<String> isInet4Address; }
@Test public void testNewServerWithoutHostIdSetsRegionAsLocation() { Set<Image> images = ImmutableSet.<Image> of(); Set<Hardware> hardwares = ImmutableSet.<Hardware> of(); Server serverToConvert = expectedServer(); ServerInRegion serverInRegionToConvert = new ServerInRegion(serverToConvert, "az-1.region-a.geo-1"); ServerInRegionToNodeMetadata converter = new ServerInRegionToNodeMetadata( NovaComputeServiceContextModule.toPortableNodeStatus, locationIndex, Suppliers .<Set<? extends Image>> ofInstance(images), Suppliers .<Set<? extends Hardware>> ofInstance(hardwares), namingConvention); NodeMetadata convertedNodeMetadata = converter.apply(serverInRegionToConvert); assertEquals(serverInRegionToConvert.slashEncode(), convertedNodeMetadata.getId()); assertEquals(serverToConvert.getId(), convertedNodeMetadata.getProviderId()); assertEquals(convertedNodeMetadata.getLocation(), region); URI expectedURI = URI.create("https: assertEquals(convertedNodeMetadata.getUri(), expectedURI); }
@Override public NodeMetadata apply(ServerInRegion serverInRegion) { Location region = locationIndex.get().get(serverInRegion.getRegion()); checkState(region != null, "location %s not in locationIndex: %s", serverInRegion.getRegion(), locationIndex.get()); Server from = serverInRegion.getServer(); NodeMetadataBuilder builder = new NodeMetadataBuilder(); builder.id(serverInRegion.slashEncode()); builder.providerId(from.getId()); builder.name(from.getName()); builder.hostname(from.getName()); builder.location(from.getHostId() != null ? new LocationBuilder().scope(LocationScope.HOST).id(from.getHostId()) .description(from.getHostId()).parent(region).build() : region); builder.group(groupFromMapOrName(from.getMetadata(), from.getName(), nodeNamingConvention)); addMetadataAndParseTagsFromCommaDelimitedValue(builder, from.getMetadata()); if (from.getImage() != null) { builder.imageId(RegionAndId.fromRegionAndId(serverInRegion.getRegion(), from.getImage().getId()).slashEncode()); } builder.operatingSystem(findOperatingSystemForServerOrNull(serverInRegion)); builder.hardware(findHardwareForServerOrNull(serverInRegion)); builder.status(toPortableNodeStatus.get(from.getStatus())); Set<Address> addresses = newHashSet(from.getAddresses().values()); if (from.getAccessIPv4() != null) { addresses.add(createV4(from.getAccessIPv4())); } if (from.getAccessIPv6() != null) { addresses.add(createV6(from.getAccessIPv6())); } builder.publicAddresses( filter( transform( filter(addresses, or(isFloatingAddress, not(isPrivateAddress))), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); builder.privateAddresses( filter( transform( filter(addresses, and(not(isFloatingAddress), isPrivateAddress)), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); for (Link link : from.getLinks()) { if (link.getRelation().equals(Link.Relation.SELF)) { builder.uri(link.getHref()); } } return builder.build(); }
ServerInRegionToNodeMetadata implements Function<ServerInRegion, NodeMetadata> { @Override public NodeMetadata apply(ServerInRegion serverInRegion) { Location region = locationIndex.get().get(serverInRegion.getRegion()); checkState(region != null, "location %s not in locationIndex: %s", serverInRegion.getRegion(), locationIndex.get()); Server from = serverInRegion.getServer(); NodeMetadataBuilder builder = new NodeMetadataBuilder(); builder.id(serverInRegion.slashEncode()); builder.providerId(from.getId()); builder.name(from.getName()); builder.hostname(from.getName()); builder.location(from.getHostId() != null ? new LocationBuilder().scope(LocationScope.HOST).id(from.getHostId()) .description(from.getHostId()).parent(region).build() : region); builder.group(groupFromMapOrName(from.getMetadata(), from.getName(), nodeNamingConvention)); addMetadataAndParseTagsFromCommaDelimitedValue(builder, from.getMetadata()); if (from.getImage() != null) { builder.imageId(RegionAndId.fromRegionAndId(serverInRegion.getRegion(), from.getImage().getId()).slashEncode()); } builder.operatingSystem(findOperatingSystemForServerOrNull(serverInRegion)); builder.hardware(findHardwareForServerOrNull(serverInRegion)); builder.status(toPortableNodeStatus.get(from.getStatus())); Set<Address> addresses = newHashSet(from.getAddresses().values()); if (from.getAccessIPv4() != null) { addresses.add(createV4(from.getAccessIPv4())); } if (from.getAccessIPv6() != null) { addresses.add(createV6(from.getAccessIPv6())); } builder.publicAddresses( filter( transform( filter(addresses, or(isFloatingAddress, not(isPrivateAddress))), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); builder.privateAddresses( filter( transform( filter(addresses, and(not(isFloatingAddress), isPrivateAddress)), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); for (Link link : from.getLinks()) { if (link.getRelation().equals(Link.Relation.SELF)) { builder.uri(link.getHref()); } } return builder.build(); } }
ServerInRegionToNodeMetadata implements Function<ServerInRegion, NodeMetadata> { @Override public NodeMetadata apply(ServerInRegion serverInRegion) { Location region = locationIndex.get().get(serverInRegion.getRegion()); checkState(region != null, "location %s not in locationIndex: %s", serverInRegion.getRegion(), locationIndex.get()); Server from = serverInRegion.getServer(); NodeMetadataBuilder builder = new NodeMetadataBuilder(); builder.id(serverInRegion.slashEncode()); builder.providerId(from.getId()); builder.name(from.getName()); builder.hostname(from.getName()); builder.location(from.getHostId() != null ? new LocationBuilder().scope(LocationScope.HOST).id(from.getHostId()) .description(from.getHostId()).parent(region).build() : region); builder.group(groupFromMapOrName(from.getMetadata(), from.getName(), nodeNamingConvention)); addMetadataAndParseTagsFromCommaDelimitedValue(builder, from.getMetadata()); if (from.getImage() != null) { builder.imageId(RegionAndId.fromRegionAndId(serverInRegion.getRegion(), from.getImage().getId()).slashEncode()); } builder.operatingSystem(findOperatingSystemForServerOrNull(serverInRegion)); builder.hardware(findHardwareForServerOrNull(serverInRegion)); builder.status(toPortableNodeStatus.get(from.getStatus())); Set<Address> addresses = newHashSet(from.getAddresses().values()); if (from.getAccessIPv4() != null) { addresses.add(createV4(from.getAccessIPv4())); } if (from.getAccessIPv6() != null) { addresses.add(createV6(from.getAccessIPv6())); } builder.publicAddresses( filter( transform( filter(addresses, or(isFloatingAddress, not(isPrivateAddress))), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); builder.privateAddresses( filter( transform( filter(addresses, and(not(isFloatingAddress), isPrivateAddress)), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); for (Link link : from.getLinks()) { if (link.getRelation().equals(Link.Relation.SELF)) { builder.uri(link.getHref()); } } return builder.build(); } @Inject ServerInRegionToNodeMetadata(Map<Server.Status, NodeMetadata.Status> toPortableNodeStatus, Supplier<Map<String, Location>> locationIndex, @Memoized Supplier<Set<? extends Image>> images, @Memoized Supplier<Set<? extends Hardware>> hardwares, GroupNamingConvention.Factory namingConvention); }
ServerInRegionToNodeMetadata implements Function<ServerInRegion, NodeMetadata> { @Override public NodeMetadata apply(ServerInRegion serverInRegion) { Location region = locationIndex.get().get(serverInRegion.getRegion()); checkState(region != null, "location %s not in locationIndex: %s", serverInRegion.getRegion(), locationIndex.get()); Server from = serverInRegion.getServer(); NodeMetadataBuilder builder = new NodeMetadataBuilder(); builder.id(serverInRegion.slashEncode()); builder.providerId(from.getId()); builder.name(from.getName()); builder.hostname(from.getName()); builder.location(from.getHostId() != null ? new LocationBuilder().scope(LocationScope.HOST).id(from.getHostId()) .description(from.getHostId()).parent(region).build() : region); builder.group(groupFromMapOrName(from.getMetadata(), from.getName(), nodeNamingConvention)); addMetadataAndParseTagsFromCommaDelimitedValue(builder, from.getMetadata()); if (from.getImage() != null) { builder.imageId(RegionAndId.fromRegionAndId(serverInRegion.getRegion(), from.getImage().getId()).slashEncode()); } builder.operatingSystem(findOperatingSystemForServerOrNull(serverInRegion)); builder.hardware(findHardwareForServerOrNull(serverInRegion)); builder.status(toPortableNodeStatus.get(from.getStatus())); Set<Address> addresses = newHashSet(from.getAddresses().values()); if (from.getAccessIPv4() != null) { addresses.add(createV4(from.getAccessIPv4())); } if (from.getAccessIPv6() != null) { addresses.add(createV6(from.getAccessIPv6())); } builder.publicAddresses( filter( transform( filter(addresses, or(isFloatingAddress, not(isPrivateAddress))), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); builder.privateAddresses( filter( transform( filter(addresses, and(not(isFloatingAddress), isPrivateAddress)), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); for (Link link : from.getLinks()) { if (link.getRelation().equals(Link.Relation.SELF)) { builder.uri(link.getHref()); } } return builder.build(); } @Inject ServerInRegionToNodeMetadata(Map<Server.Status, NodeMetadata.Status> toPortableNodeStatus, Supplier<Map<String, Location>> locationIndex, @Memoized Supplier<Set<? extends Image>> images, @Memoized Supplier<Set<? extends Hardware>> hardwares, GroupNamingConvention.Factory namingConvention); @Override NodeMetadata apply(ServerInRegion serverInRegion); T findObjectOfTypeForServerOrNull(Set<? extends T> supply, String type, final String objectId, final RegionAndId serverInRegion); }
ServerInRegionToNodeMetadata implements Function<ServerInRegion, NodeMetadata> { @Override public NodeMetadata apply(ServerInRegion serverInRegion) { Location region = locationIndex.get().get(serverInRegion.getRegion()); checkState(region != null, "location %s not in locationIndex: %s", serverInRegion.getRegion(), locationIndex.get()); Server from = serverInRegion.getServer(); NodeMetadataBuilder builder = new NodeMetadataBuilder(); builder.id(serverInRegion.slashEncode()); builder.providerId(from.getId()); builder.name(from.getName()); builder.hostname(from.getName()); builder.location(from.getHostId() != null ? new LocationBuilder().scope(LocationScope.HOST).id(from.getHostId()) .description(from.getHostId()).parent(region).build() : region); builder.group(groupFromMapOrName(from.getMetadata(), from.getName(), nodeNamingConvention)); addMetadataAndParseTagsFromCommaDelimitedValue(builder, from.getMetadata()); if (from.getImage() != null) { builder.imageId(RegionAndId.fromRegionAndId(serverInRegion.getRegion(), from.getImage().getId()).slashEncode()); } builder.operatingSystem(findOperatingSystemForServerOrNull(serverInRegion)); builder.hardware(findHardwareForServerOrNull(serverInRegion)); builder.status(toPortableNodeStatus.get(from.getStatus())); Set<Address> addresses = newHashSet(from.getAddresses().values()); if (from.getAccessIPv4() != null) { addresses.add(createV4(from.getAccessIPv4())); } if (from.getAccessIPv6() != null) { addresses.add(createV6(from.getAccessIPv6())); } builder.publicAddresses( filter( transform( filter(addresses, or(isFloatingAddress, not(isPrivateAddress))), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); builder.privateAddresses( filter( transform( filter(addresses, and(not(isFloatingAddress), isPrivateAddress)), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); for (Link link : from.getLinks()) { if (link.getRelation().equals(Link.Relation.SELF)) { builder.uri(link.getHref()); } } return builder.build(); } @Inject ServerInRegionToNodeMetadata(Map<Server.Status, NodeMetadata.Status> toPortableNodeStatus, Supplier<Map<String, Location>> locationIndex, @Memoized Supplier<Set<? extends Image>> images, @Memoized Supplier<Set<? extends Hardware>> hardwares, GroupNamingConvention.Factory namingConvention); @Override NodeMetadata apply(ServerInRegion serverInRegion); T findObjectOfTypeForServerOrNull(Set<? extends T> supply, String type, final String objectId, final RegionAndId serverInRegion); static final Predicate<Address> isFloatingAddress; static final Predicate<Address> isPrivateAddress; static final Predicate<String> isInet4Address; }
@Test public void testProvisionInterrupted() { ProvisioningManager manager = new ProvisioningManager(); AtomicInteger completedJobs = new AtomicInteger(0); manager.provision(new ShutdownExecutorJob(manager, completedJobs)); manager.provision(new MockJob(0, "rejected", completedJobs)); assertEquals(completedJobs.get(), 1); }
public Object provision(ProvisioningJob job) { if (terminated.get()) { logger.warn("Job(%s) submitted but the provisioning manager is already closed", job); return null; } logger.debug("Job(%s) submitted to group '%s'", job, job.getGroup()); ListeningExecutorService workerGroup = getWorkerGroup(job.getGroup()); return getUnchecked(workerGroup.submit(job)); }
ProvisioningManager implements Closeable { public Object provision(ProvisioningJob job) { if (terminated.get()) { logger.warn("Job(%s) submitted but the provisioning manager is already closed", job); return null; } logger.debug("Job(%s) submitted to group '%s'", job, job.getGroup()); ListeningExecutorService workerGroup = getWorkerGroup(job.getGroup()); return getUnchecked(workerGroup.submit(job)); } }
ProvisioningManager implements Closeable { public Object provision(ProvisioningJob job) { if (terminated.get()) { logger.warn("Job(%s) submitted but the provisioning manager is already closed", job); return null; } logger.debug("Job(%s) submitted to group '%s'", job, job.getGroup()); ListeningExecutorService workerGroup = getWorkerGroup(job.getGroup()); return getUnchecked(workerGroup.submit(job)); } }
ProvisioningManager implements Closeable { public Object provision(ProvisioningJob job) { if (terminated.get()) { logger.warn("Job(%s) submitted but the provisioning manager is already closed", job); return null; } logger.debug("Job(%s) submitted to group '%s'", job, job.getGroup()); ListeningExecutorService workerGroup = getWorkerGroup(job.getGroup()); return getUnchecked(workerGroup.submit(job)); } Object provision(ProvisioningJob job); @Override void close(); }
ProvisioningManager implements Closeable { public Object provision(ProvisioningJob job) { if (terminated.get()) { logger.warn("Job(%s) submitted but the provisioning manager is already closed", job); return null; } logger.debug("Job(%s) submitted to group '%s'", job, job.getGroup()); ListeningExecutorService workerGroup = getWorkerGroup(job.getGroup()); return getUnchecked(workerGroup.submit(job)); } Object provision(ProvisioningJob job); @Override void close(); }
@Test public void testReturnsPublicIpOnMatch() throws Exception { NovaApi api = createMock(NovaApi.class); FloatingIPApi ipApi = createMock(FloatingIPApi.class); FloatingIP testIp = FloatingIP.builder().id("1").ip("1.1.1.1").fixedIp("10.1.1.1").instanceId("i-blah").build(); expect(api.getFloatingIPApi("RegionOne")).andReturn((Optional) Optional.of(ipApi)).atLeastOnce(); expect(ipApi.list()).andReturn((FluentIterable) FluentIterable.from(ImmutableSet.<FloatingIP> of(testIp))) .atLeastOnce(); replay(api); replay(ipApi); LoadFloatingIpsForInstance parser = new LoadFloatingIpsForInstance(api); FloatingIpForServer floatingIpForServer = FloatingIpForServer.create(RegionAndId.fromRegionAndId("RegionOne", "i-blah"), "1", "1.1.1.1"); assertEquals(ImmutableSet.copyOf(parser.load(RegionAndId.fromRegionAndId("RegionOne", "i-blah"))), ImmutableSet.of(floatingIpForServer)); verify(api); verify(ipApi); }
@Override public Iterable<? extends FloatingIpForServer> load(final RegionAndId key) throws Exception { String region = key.getRegion(); Optional<? extends FloatingIPApi> ipApiOptional = api.getFloatingIPApi(region); if (ipApiOptional.isPresent()) { return ipApiOptional.get().list().filter( new Predicate<FloatingIP>() { @Override public boolean apply(FloatingIP input) { return key.getId().equals(input.getInstanceId()); } }) .transform(new Function<FloatingIP, FloatingIpForServer>() { @Override public FloatingIpForServer apply(FloatingIP input) { return FloatingIpForServer.create(key, input.getId(), input.getIp()); } }); } return ImmutableSet.of(); }
LoadFloatingIpsForInstance extends CacheLoader<RegionAndId, Iterable<? extends FloatingIpForServer>> { @Override public Iterable<? extends FloatingIpForServer> load(final RegionAndId key) throws Exception { String region = key.getRegion(); Optional<? extends FloatingIPApi> ipApiOptional = api.getFloatingIPApi(region); if (ipApiOptional.isPresent()) { return ipApiOptional.get().list().filter( new Predicate<FloatingIP>() { @Override public boolean apply(FloatingIP input) { return key.getId().equals(input.getInstanceId()); } }) .transform(new Function<FloatingIP, FloatingIpForServer>() { @Override public FloatingIpForServer apply(FloatingIP input) { return FloatingIpForServer.create(key, input.getId(), input.getIp()); } }); } return ImmutableSet.of(); } }
LoadFloatingIpsForInstance extends CacheLoader<RegionAndId, Iterable<? extends FloatingIpForServer>> { @Override public Iterable<? extends FloatingIpForServer> load(final RegionAndId key) throws Exception { String region = key.getRegion(); Optional<? extends FloatingIPApi> ipApiOptional = api.getFloatingIPApi(region); if (ipApiOptional.isPresent()) { return ipApiOptional.get().list().filter( new Predicate<FloatingIP>() { @Override public boolean apply(FloatingIP input) { return key.getId().equals(input.getInstanceId()); } }) .transform(new Function<FloatingIP, FloatingIpForServer>() { @Override public FloatingIpForServer apply(FloatingIP input) { return FloatingIpForServer.create(key, input.getId(), input.getIp()); } }); } return ImmutableSet.of(); } @Inject LoadFloatingIpsForInstance(NovaApi api); }
LoadFloatingIpsForInstance extends CacheLoader<RegionAndId, Iterable<? extends FloatingIpForServer>> { @Override public Iterable<? extends FloatingIpForServer> load(final RegionAndId key) throws Exception { String region = key.getRegion(); Optional<? extends FloatingIPApi> ipApiOptional = api.getFloatingIPApi(region); if (ipApiOptional.isPresent()) { return ipApiOptional.get().list().filter( new Predicate<FloatingIP>() { @Override public boolean apply(FloatingIP input) { return key.getId().equals(input.getInstanceId()); } }) .transform(new Function<FloatingIP, FloatingIpForServer>() { @Override public FloatingIpForServer apply(FloatingIP input) { return FloatingIpForServer.create(key, input.getId(), input.getIp()); } }); } return ImmutableSet.of(); } @Inject LoadFloatingIpsForInstance(NovaApi api); @Override Iterable<? extends FloatingIpForServer> load(final RegionAndId key); }
LoadFloatingIpsForInstance extends CacheLoader<RegionAndId, Iterable<? extends FloatingIpForServer>> { @Override public Iterable<? extends FloatingIpForServer> load(final RegionAndId key) throws Exception { String region = key.getRegion(); Optional<? extends FloatingIPApi> ipApiOptional = api.getFloatingIPApi(region); if (ipApiOptional.isPresent()) { return ipApiOptional.get().list().filter( new Predicate<FloatingIP>() { @Override public boolean apply(FloatingIP input) { return key.getId().equals(input.getInstanceId()); } }) .transform(new Function<FloatingIP, FloatingIpForServer>() { @Override public FloatingIpForServer apply(FloatingIP input) { return FloatingIpForServer.create(key, input.getId(), input.getIp()); } }); } return ImmutableSet.of(); } @Inject LoadFloatingIpsForInstance(NovaApi api); @Override Iterable<? extends FloatingIpForServer> load(final RegionAndId key); }
@Test public void testReturnsNullWhenNotFound() throws Exception { NovaApi api = createMock(NovaApi.class); FloatingIPApi ipApi = createMock(FloatingIPApi.class); expect(api.getFloatingIPApi("region")).andReturn((Optional) Optional.of(ipApi)).atLeastOnce(); expect(ipApi.list()).andReturn((FluentIterable) FluentIterable.from(ImmutableSet.<FloatingIP> of())) .atLeastOnce(); replay(api); replay(ipApi); LoadFloatingIpsForInstance parser = new LoadFloatingIpsForInstance(api); assertFalse(parser.load(RegionAndId.fromRegionAndId("region", "i-blah")).iterator().hasNext()); verify(api); verify(ipApi); }
@Override public Iterable<? extends FloatingIpForServer> load(final RegionAndId key) throws Exception { String region = key.getRegion(); Optional<? extends FloatingIPApi> ipApiOptional = api.getFloatingIPApi(region); if (ipApiOptional.isPresent()) { return ipApiOptional.get().list().filter( new Predicate<FloatingIP>() { @Override public boolean apply(FloatingIP input) { return key.getId().equals(input.getInstanceId()); } }) .transform(new Function<FloatingIP, FloatingIpForServer>() { @Override public FloatingIpForServer apply(FloatingIP input) { return FloatingIpForServer.create(key, input.getId(), input.getIp()); } }); } return ImmutableSet.of(); }
LoadFloatingIpsForInstance extends CacheLoader<RegionAndId, Iterable<? extends FloatingIpForServer>> { @Override public Iterable<? extends FloatingIpForServer> load(final RegionAndId key) throws Exception { String region = key.getRegion(); Optional<? extends FloatingIPApi> ipApiOptional = api.getFloatingIPApi(region); if (ipApiOptional.isPresent()) { return ipApiOptional.get().list().filter( new Predicate<FloatingIP>() { @Override public boolean apply(FloatingIP input) { return key.getId().equals(input.getInstanceId()); } }) .transform(new Function<FloatingIP, FloatingIpForServer>() { @Override public FloatingIpForServer apply(FloatingIP input) { return FloatingIpForServer.create(key, input.getId(), input.getIp()); } }); } return ImmutableSet.of(); } }
LoadFloatingIpsForInstance extends CacheLoader<RegionAndId, Iterable<? extends FloatingIpForServer>> { @Override public Iterable<? extends FloatingIpForServer> load(final RegionAndId key) throws Exception { String region = key.getRegion(); Optional<? extends FloatingIPApi> ipApiOptional = api.getFloatingIPApi(region); if (ipApiOptional.isPresent()) { return ipApiOptional.get().list().filter( new Predicate<FloatingIP>() { @Override public boolean apply(FloatingIP input) { return key.getId().equals(input.getInstanceId()); } }) .transform(new Function<FloatingIP, FloatingIpForServer>() { @Override public FloatingIpForServer apply(FloatingIP input) { return FloatingIpForServer.create(key, input.getId(), input.getIp()); } }); } return ImmutableSet.of(); } @Inject LoadFloatingIpsForInstance(NovaApi api); }
LoadFloatingIpsForInstance extends CacheLoader<RegionAndId, Iterable<? extends FloatingIpForServer>> { @Override public Iterable<? extends FloatingIpForServer> load(final RegionAndId key) throws Exception { String region = key.getRegion(); Optional<? extends FloatingIPApi> ipApiOptional = api.getFloatingIPApi(region); if (ipApiOptional.isPresent()) { return ipApiOptional.get().list().filter( new Predicate<FloatingIP>() { @Override public boolean apply(FloatingIP input) { return key.getId().equals(input.getInstanceId()); } }) .transform(new Function<FloatingIP, FloatingIpForServer>() { @Override public FloatingIpForServer apply(FloatingIP input) { return FloatingIpForServer.create(key, input.getId(), input.getIp()); } }); } return ImmutableSet.of(); } @Inject LoadFloatingIpsForInstance(NovaApi api); @Override Iterable<? extends FloatingIpForServer> load(final RegionAndId key); }
LoadFloatingIpsForInstance extends CacheLoader<RegionAndId, Iterable<? extends FloatingIpForServer>> { @Override public Iterable<? extends FloatingIpForServer> load(final RegionAndId key) throws Exception { String region = key.getRegion(); Optional<? extends FloatingIPApi> ipApiOptional = api.getFloatingIPApi(region); if (ipApiOptional.isPresent()) { return ipApiOptional.get().list().filter( new Predicate<FloatingIP>() { @Override public boolean apply(FloatingIP input) { return key.getId().equals(input.getInstanceId()); } }) .transform(new Function<FloatingIP, FloatingIpForServer>() { @Override public FloatingIpForServer apply(FloatingIP input) { return FloatingIpForServer.create(key, input.getId(), input.getIp()); } }); } return ImmutableSet.of(); } @Inject LoadFloatingIpsForInstance(NovaApi api); @Override Iterable<? extends FloatingIpForServer> load(final RegionAndId key); }
@Test public void testReturnsNullWhenNotAssigned() throws Exception { NovaApi api = createMock(NovaApi.class); FloatingIPApi ipApi = createMock(FloatingIPApi.class); expect(api.getFloatingIPApi("region")).andReturn((Optional) Optional.of(ipApi)).atLeastOnce(); expect(ipApi.list()).andReturn((FluentIterable) FluentIterable.from(ImmutableSet.<FloatingIP> of(FloatingIP.builder().id("1").ip("1.1.1.1").build()))) .atLeastOnce(); replay(api); replay(ipApi); LoadFloatingIpsForInstance parser = new LoadFloatingIpsForInstance(api); assertFalse(parser.load(RegionAndId.fromRegionAndId("region", "i-blah")).iterator().hasNext()); verify(api); verify(ipApi); }
@Override public Iterable<? extends FloatingIpForServer> load(final RegionAndId key) throws Exception { String region = key.getRegion(); Optional<? extends FloatingIPApi> ipApiOptional = api.getFloatingIPApi(region); if (ipApiOptional.isPresent()) { return ipApiOptional.get().list().filter( new Predicate<FloatingIP>() { @Override public boolean apply(FloatingIP input) { return key.getId().equals(input.getInstanceId()); } }) .transform(new Function<FloatingIP, FloatingIpForServer>() { @Override public FloatingIpForServer apply(FloatingIP input) { return FloatingIpForServer.create(key, input.getId(), input.getIp()); } }); } return ImmutableSet.of(); }
LoadFloatingIpsForInstance extends CacheLoader<RegionAndId, Iterable<? extends FloatingIpForServer>> { @Override public Iterable<? extends FloatingIpForServer> load(final RegionAndId key) throws Exception { String region = key.getRegion(); Optional<? extends FloatingIPApi> ipApiOptional = api.getFloatingIPApi(region); if (ipApiOptional.isPresent()) { return ipApiOptional.get().list().filter( new Predicate<FloatingIP>() { @Override public boolean apply(FloatingIP input) { return key.getId().equals(input.getInstanceId()); } }) .transform(new Function<FloatingIP, FloatingIpForServer>() { @Override public FloatingIpForServer apply(FloatingIP input) { return FloatingIpForServer.create(key, input.getId(), input.getIp()); } }); } return ImmutableSet.of(); } }
LoadFloatingIpsForInstance extends CacheLoader<RegionAndId, Iterable<? extends FloatingIpForServer>> { @Override public Iterable<? extends FloatingIpForServer> load(final RegionAndId key) throws Exception { String region = key.getRegion(); Optional<? extends FloatingIPApi> ipApiOptional = api.getFloatingIPApi(region); if (ipApiOptional.isPresent()) { return ipApiOptional.get().list().filter( new Predicate<FloatingIP>() { @Override public boolean apply(FloatingIP input) { return key.getId().equals(input.getInstanceId()); } }) .transform(new Function<FloatingIP, FloatingIpForServer>() { @Override public FloatingIpForServer apply(FloatingIP input) { return FloatingIpForServer.create(key, input.getId(), input.getIp()); } }); } return ImmutableSet.of(); } @Inject LoadFloatingIpsForInstance(NovaApi api); }
LoadFloatingIpsForInstance extends CacheLoader<RegionAndId, Iterable<? extends FloatingIpForServer>> { @Override public Iterable<? extends FloatingIpForServer> load(final RegionAndId key) throws Exception { String region = key.getRegion(); Optional<? extends FloatingIPApi> ipApiOptional = api.getFloatingIPApi(region); if (ipApiOptional.isPresent()) { return ipApiOptional.get().list().filter( new Predicate<FloatingIP>() { @Override public boolean apply(FloatingIP input) { return key.getId().equals(input.getInstanceId()); } }) .transform(new Function<FloatingIP, FloatingIpForServer>() { @Override public FloatingIpForServer apply(FloatingIP input) { return FloatingIpForServer.create(key, input.getId(), input.getIp()); } }); } return ImmutableSet.of(); } @Inject LoadFloatingIpsForInstance(NovaApi api); @Override Iterable<? extends FloatingIpForServer> load(final RegionAndId key); }
LoadFloatingIpsForInstance extends CacheLoader<RegionAndId, Iterable<? extends FloatingIpForServer>> { @Override public Iterable<? extends FloatingIpForServer> load(final RegionAndId key) throws Exception { String region = key.getRegion(); Optional<? extends FloatingIPApi> ipApiOptional = api.getFloatingIPApi(region); if (ipApiOptional.isPresent()) { return ipApiOptional.get().list().filter( new Predicate<FloatingIP>() { @Override public boolean apply(FloatingIP input) { return key.getId().equals(input.getInstanceId()); } }) .transform(new Function<FloatingIP, FloatingIpForServer>() { @Override public FloatingIpForServer apply(FloatingIP input) { return FloatingIpForServer.create(key, input.getId(), input.getIp()); } }); } return ImmutableSet.of(); } @Inject LoadFloatingIpsForInstance(NovaApi api); @Override Iterable<? extends FloatingIpForServer> load(final RegionAndId key); }
@Test public void testHostname() { TemplateOptions options = DockerTemplateOptions.Builder.hostname("hostname"); assertEquals(options.as(DockerTemplateOptions.class).getHostname(), "hostname"); }
public DockerTemplateOptions hostname(@Nullable String hostname) { this.hostname = hostname; return this; }
DockerTemplateOptions extends TemplateOptions implements Cloneable { public DockerTemplateOptions hostname(@Nullable String hostname) { this.hostname = hostname; return this; } }
DockerTemplateOptions extends TemplateOptions implements Cloneable { public DockerTemplateOptions hostname(@Nullable String hostname) { this.hostname = hostname; return this; } }
DockerTemplateOptions extends TemplateOptions implements Cloneable { public DockerTemplateOptions hostname(@Nullable String hostname) { this.hostname = hostname; return this; } @Override DockerTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); DockerTemplateOptions volumes(Map<String, String> volumes); DockerTemplateOptions dns(Iterable<String> dns); DockerTemplateOptions dns(String...dns); DockerTemplateOptions hostname(@Nullable String hostname); DockerTemplateOptions memory(@Nullable Integer memory); DockerTemplateOptions entrypoint(Iterable<String> entrypoint); DockerTemplateOptions entrypoint(String... entrypoint); DockerTemplateOptions commands(Iterable<String> commands); DockerTemplateOptions commands(String...commands); DockerTemplateOptions cpuShares(@Nullable Integer cpuShares); DockerTemplateOptions env(Iterable<String> env); DockerTemplateOptions env(String...env); DockerTemplateOptions portBindings(Map<Integer, Integer> portBindings); DockerTemplateOptions networkMode(@Nullable String networkMode); DockerTemplateOptions extraHosts(Map<String, String> extraHosts); DockerTemplateOptions volumesFrom(Iterable<String> volumesFrom); DockerTemplateOptions privileged(boolean privileged); DockerTemplateOptions openStdin(boolean openStdin); DockerTemplateOptions configBuilder(Config.Builder configBuilder); Map<String, String> getVolumes(); List<String> getDns(); List<String> getVolumesFrom(); String getHostname(); Integer getMemory(); List<String> getEntrypoint(); List<String> getCommands(); Integer getCpuShares(); List<String> getEnv(); Map<Integer, Integer> getPortBindings(); String getNetworkMode(); Map<String, String> getExtraHosts(); boolean getPrivileged(); boolean getOpenStdin(); Config.Builder getConfigBuilder(); @Override DockerTemplateOptions blockOnPort(int port, int seconds); @Override DockerTemplateOptions inboundPorts(int... ports); @Override DockerTemplateOptions authorizePublicKey(String publicKey); @Override DockerTemplateOptions installPrivateKey(String privateKey); @Override DockerTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override DockerTemplateOptions dontAuthorizePublicKey(); @Override DockerTemplateOptions nameTask(String name); @Override DockerTemplateOptions runAsRoot(boolean runAsRoot); @Override DockerTemplateOptions runScript(Statement script); @Override DockerTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override DockerTemplateOptions overrideLoginPassword(String password); @Override DockerTemplateOptions overrideLoginPrivateKey(String privateKey); @Override DockerTemplateOptions overrideLoginUser(String loginUser); @Override DockerTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override DockerTemplateOptions userMetadata(Map<String, String> userMetadata); @Override DockerTemplateOptions userMetadata(String key, String value); @Override DockerTemplateOptions nodeNames(Iterable<String> nodeNames); @Override DockerTemplateOptions networks(Iterable<String> networks); }
DockerTemplateOptions extends TemplateOptions implements Cloneable { public DockerTemplateOptions hostname(@Nullable String hostname) { this.hostname = hostname; return this; } @Override DockerTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); DockerTemplateOptions volumes(Map<String, String> volumes); DockerTemplateOptions dns(Iterable<String> dns); DockerTemplateOptions dns(String...dns); DockerTemplateOptions hostname(@Nullable String hostname); DockerTemplateOptions memory(@Nullable Integer memory); DockerTemplateOptions entrypoint(Iterable<String> entrypoint); DockerTemplateOptions entrypoint(String... entrypoint); DockerTemplateOptions commands(Iterable<String> commands); DockerTemplateOptions commands(String...commands); DockerTemplateOptions cpuShares(@Nullable Integer cpuShares); DockerTemplateOptions env(Iterable<String> env); DockerTemplateOptions env(String...env); DockerTemplateOptions portBindings(Map<Integer, Integer> portBindings); DockerTemplateOptions networkMode(@Nullable String networkMode); DockerTemplateOptions extraHosts(Map<String, String> extraHosts); DockerTemplateOptions volumesFrom(Iterable<String> volumesFrom); DockerTemplateOptions privileged(boolean privileged); DockerTemplateOptions openStdin(boolean openStdin); DockerTemplateOptions configBuilder(Config.Builder configBuilder); Map<String, String> getVolumes(); List<String> getDns(); List<String> getVolumesFrom(); String getHostname(); Integer getMemory(); List<String> getEntrypoint(); List<String> getCommands(); Integer getCpuShares(); List<String> getEnv(); Map<Integer, Integer> getPortBindings(); String getNetworkMode(); Map<String, String> getExtraHosts(); boolean getPrivileged(); boolean getOpenStdin(); Config.Builder getConfigBuilder(); @Override DockerTemplateOptions blockOnPort(int port, int seconds); @Override DockerTemplateOptions inboundPorts(int... ports); @Override DockerTemplateOptions authorizePublicKey(String publicKey); @Override DockerTemplateOptions installPrivateKey(String privateKey); @Override DockerTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override DockerTemplateOptions dontAuthorizePublicKey(); @Override DockerTemplateOptions nameTask(String name); @Override DockerTemplateOptions runAsRoot(boolean runAsRoot); @Override DockerTemplateOptions runScript(Statement script); @Override DockerTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override DockerTemplateOptions overrideLoginPassword(String password); @Override DockerTemplateOptions overrideLoginPrivateKey(String privateKey); @Override DockerTemplateOptions overrideLoginUser(String loginUser); @Override DockerTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override DockerTemplateOptions userMetadata(Map<String, String> userMetadata); @Override DockerTemplateOptions userMetadata(String key, String value); @Override DockerTemplateOptions nodeNames(Iterable<String> nodeNames); @Override DockerTemplateOptions networks(Iterable<String> networks); }
@Test public void testMemory() { TemplateOptions options = DockerTemplateOptions.Builder.memory(1024); assertEquals(options.as(DockerTemplateOptions.class).getMemory(), Integer.valueOf(1024)); }
public DockerTemplateOptions memory(@Nullable Integer memory) { this.memory = memory; return this; }
DockerTemplateOptions extends TemplateOptions implements Cloneable { public DockerTemplateOptions memory(@Nullable Integer memory) { this.memory = memory; return this; } }
DockerTemplateOptions extends TemplateOptions implements Cloneable { public DockerTemplateOptions memory(@Nullable Integer memory) { this.memory = memory; return this; } }
DockerTemplateOptions extends TemplateOptions implements Cloneable { public DockerTemplateOptions memory(@Nullable Integer memory) { this.memory = memory; return this; } @Override DockerTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); DockerTemplateOptions volumes(Map<String, String> volumes); DockerTemplateOptions dns(Iterable<String> dns); DockerTemplateOptions dns(String...dns); DockerTemplateOptions hostname(@Nullable String hostname); DockerTemplateOptions memory(@Nullable Integer memory); DockerTemplateOptions entrypoint(Iterable<String> entrypoint); DockerTemplateOptions entrypoint(String... entrypoint); DockerTemplateOptions commands(Iterable<String> commands); DockerTemplateOptions commands(String...commands); DockerTemplateOptions cpuShares(@Nullable Integer cpuShares); DockerTemplateOptions env(Iterable<String> env); DockerTemplateOptions env(String...env); DockerTemplateOptions portBindings(Map<Integer, Integer> portBindings); DockerTemplateOptions networkMode(@Nullable String networkMode); DockerTemplateOptions extraHosts(Map<String, String> extraHosts); DockerTemplateOptions volumesFrom(Iterable<String> volumesFrom); DockerTemplateOptions privileged(boolean privileged); DockerTemplateOptions openStdin(boolean openStdin); DockerTemplateOptions configBuilder(Config.Builder configBuilder); Map<String, String> getVolumes(); List<String> getDns(); List<String> getVolumesFrom(); String getHostname(); Integer getMemory(); List<String> getEntrypoint(); List<String> getCommands(); Integer getCpuShares(); List<String> getEnv(); Map<Integer, Integer> getPortBindings(); String getNetworkMode(); Map<String, String> getExtraHosts(); boolean getPrivileged(); boolean getOpenStdin(); Config.Builder getConfigBuilder(); @Override DockerTemplateOptions blockOnPort(int port, int seconds); @Override DockerTemplateOptions inboundPorts(int... ports); @Override DockerTemplateOptions authorizePublicKey(String publicKey); @Override DockerTemplateOptions installPrivateKey(String privateKey); @Override DockerTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override DockerTemplateOptions dontAuthorizePublicKey(); @Override DockerTemplateOptions nameTask(String name); @Override DockerTemplateOptions runAsRoot(boolean runAsRoot); @Override DockerTemplateOptions runScript(Statement script); @Override DockerTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override DockerTemplateOptions overrideLoginPassword(String password); @Override DockerTemplateOptions overrideLoginPrivateKey(String privateKey); @Override DockerTemplateOptions overrideLoginUser(String loginUser); @Override DockerTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override DockerTemplateOptions userMetadata(Map<String, String> userMetadata); @Override DockerTemplateOptions userMetadata(String key, String value); @Override DockerTemplateOptions nodeNames(Iterable<String> nodeNames); @Override DockerTemplateOptions networks(Iterable<String> networks); }
DockerTemplateOptions extends TemplateOptions implements Cloneable { public DockerTemplateOptions memory(@Nullable Integer memory) { this.memory = memory; return this; } @Override DockerTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); DockerTemplateOptions volumes(Map<String, String> volumes); DockerTemplateOptions dns(Iterable<String> dns); DockerTemplateOptions dns(String...dns); DockerTemplateOptions hostname(@Nullable String hostname); DockerTemplateOptions memory(@Nullable Integer memory); DockerTemplateOptions entrypoint(Iterable<String> entrypoint); DockerTemplateOptions entrypoint(String... entrypoint); DockerTemplateOptions commands(Iterable<String> commands); DockerTemplateOptions commands(String...commands); DockerTemplateOptions cpuShares(@Nullable Integer cpuShares); DockerTemplateOptions env(Iterable<String> env); DockerTemplateOptions env(String...env); DockerTemplateOptions portBindings(Map<Integer, Integer> portBindings); DockerTemplateOptions networkMode(@Nullable String networkMode); DockerTemplateOptions extraHosts(Map<String, String> extraHosts); DockerTemplateOptions volumesFrom(Iterable<String> volumesFrom); DockerTemplateOptions privileged(boolean privileged); DockerTemplateOptions openStdin(boolean openStdin); DockerTemplateOptions configBuilder(Config.Builder configBuilder); Map<String, String> getVolumes(); List<String> getDns(); List<String> getVolumesFrom(); String getHostname(); Integer getMemory(); List<String> getEntrypoint(); List<String> getCommands(); Integer getCpuShares(); List<String> getEnv(); Map<Integer, Integer> getPortBindings(); String getNetworkMode(); Map<String, String> getExtraHosts(); boolean getPrivileged(); boolean getOpenStdin(); Config.Builder getConfigBuilder(); @Override DockerTemplateOptions blockOnPort(int port, int seconds); @Override DockerTemplateOptions inboundPorts(int... ports); @Override DockerTemplateOptions authorizePublicKey(String publicKey); @Override DockerTemplateOptions installPrivateKey(String privateKey); @Override DockerTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override DockerTemplateOptions dontAuthorizePublicKey(); @Override DockerTemplateOptions nameTask(String name); @Override DockerTemplateOptions runAsRoot(boolean runAsRoot); @Override DockerTemplateOptions runScript(Statement script); @Override DockerTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override DockerTemplateOptions overrideLoginPassword(String password); @Override DockerTemplateOptions overrideLoginPrivateKey(String privateKey); @Override DockerTemplateOptions overrideLoginUser(String loginUser); @Override DockerTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override DockerTemplateOptions userMetadata(Map<String, String> userMetadata); @Override DockerTemplateOptions userMetadata(String key, String value); @Override DockerTemplateOptions nodeNames(Iterable<String> nodeNames); @Override DockerTemplateOptions networks(Iterable<String> networks); }
@Test public void testCpuShares() { TemplateOptions options = DockerTemplateOptions.Builder.cpuShares(2); assertEquals(options.as(DockerTemplateOptions.class).getCpuShares(), Integer.valueOf(2)); }
public DockerTemplateOptions cpuShares(@Nullable Integer cpuShares) { this.cpuShares = cpuShares; return this; }
DockerTemplateOptions extends TemplateOptions implements Cloneable { public DockerTemplateOptions cpuShares(@Nullable Integer cpuShares) { this.cpuShares = cpuShares; return this; } }
DockerTemplateOptions extends TemplateOptions implements Cloneable { public DockerTemplateOptions cpuShares(@Nullable Integer cpuShares) { this.cpuShares = cpuShares; return this; } }
DockerTemplateOptions extends TemplateOptions implements Cloneable { public DockerTemplateOptions cpuShares(@Nullable Integer cpuShares) { this.cpuShares = cpuShares; return this; } @Override DockerTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); DockerTemplateOptions volumes(Map<String, String> volumes); DockerTemplateOptions dns(Iterable<String> dns); DockerTemplateOptions dns(String...dns); DockerTemplateOptions hostname(@Nullable String hostname); DockerTemplateOptions memory(@Nullable Integer memory); DockerTemplateOptions entrypoint(Iterable<String> entrypoint); DockerTemplateOptions entrypoint(String... entrypoint); DockerTemplateOptions commands(Iterable<String> commands); DockerTemplateOptions commands(String...commands); DockerTemplateOptions cpuShares(@Nullable Integer cpuShares); DockerTemplateOptions env(Iterable<String> env); DockerTemplateOptions env(String...env); DockerTemplateOptions portBindings(Map<Integer, Integer> portBindings); DockerTemplateOptions networkMode(@Nullable String networkMode); DockerTemplateOptions extraHosts(Map<String, String> extraHosts); DockerTemplateOptions volumesFrom(Iterable<String> volumesFrom); DockerTemplateOptions privileged(boolean privileged); DockerTemplateOptions openStdin(boolean openStdin); DockerTemplateOptions configBuilder(Config.Builder configBuilder); Map<String, String> getVolumes(); List<String> getDns(); List<String> getVolumesFrom(); String getHostname(); Integer getMemory(); List<String> getEntrypoint(); List<String> getCommands(); Integer getCpuShares(); List<String> getEnv(); Map<Integer, Integer> getPortBindings(); String getNetworkMode(); Map<String, String> getExtraHosts(); boolean getPrivileged(); boolean getOpenStdin(); Config.Builder getConfigBuilder(); @Override DockerTemplateOptions blockOnPort(int port, int seconds); @Override DockerTemplateOptions inboundPorts(int... ports); @Override DockerTemplateOptions authorizePublicKey(String publicKey); @Override DockerTemplateOptions installPrivateKey(String privateKey); @Override DockerTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override DockerTemplateOptions dontAuthorizePublicKey(); @Override DockerTemplateOptions nameTask(String name); @Override DockerTemplateOptions runAsRoot(boolean runAsRoot); @Override DockerTemplateOptions runScript(Statement script); @Override DockerTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override DockerTemplateOptions overrideLoginPassword(String password); @Override DockerTemplateOptions overrideLoginPrivateKey(String privateKey); @Override DockerTemplateOptions overrideLoginUser(String loginUser); @Override DockerTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override DockerTemplateOptions userMetadata(Map<String, String> userMetadata); @Override DockerTemplateOptions userMetadata(String key, String value); @Override DockerTemplateOptions nodeNames(Iterable<String> nodeNames); @Override DockerTemplateOptions networks(Iterable<String> networks); }
DockerTemplateOptions extends TemplateOptions implements Cloneable { public DockerTemplateOptions cpuShares(@Nullable Integer cpuShares) { this.cpuShares = cpuShares; return this; } @Override DockerTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); DockerTemplateOptions volumes(Map<String, String> volumes); DockerTemplateOptions dns(Iterable<String> dns); DockerTemplateOptions dns(String...dns); DockerTemplateOptions hostname(@Nullable String hostname); DockerTemplateOptions memory(@Nullable Integer memory); DockerTemplateOptions entrypoint(Iterable<String> entrypoint); DockerTemplateOptions entrypoint(String... entrypoint); DockerTemplateOptions commands(Iterable<String> commands); DockerTemplateOptions commands(String...commands); DockerTemplateOptions cpuShares(@Nullable Integer cpuShares); DockerTemplateOptions env(Iterable<String> env); DockerTemplateOptions env(String...env); DockerTemplateOptions portBindings(Map<Integer, Integer> portBindings); DockerTemplateOptions networkMode(@Nullable String networkMode); DockerTemplateOptions extraHosts(Map<String, String> extraHosts); DockerTemplateOptions volumesFrom(Iterable<String> volumesFrom); DockerTemplateOptions privileged(boolean privileged); DockerTemplateOptions openStdin(boolean openStdin); DockerTemplateOptions configBuilder(Config.Builder configBuilder); Map<String, String> getVolumes(); List<String> getDns(); List<String> getVolumesFrom(); String getHostname(); Integer getMemory(); List<String> getEntrypoint(); List<String> getCommands(); Integer getCpuShares(); List<String> getEnv(); Map<Integer, Integer> getPortBindings(); String getNetworkMode(); Map<String, String> getExtraHosts(); boolean getPrivileged(); boolean getOpenStdin(); Config.Builder getConfigBuilder(); @Override DockerTemplateOptions blockOnPort(int port, int seconds); @Override DockerTemplateOptions inboundPorts(int... ports); @Override DockerTemplateOptions authorizePublicKey(String publicKey); @Override DockerTemplateOptions installPrivateKey(String privateKey); @Override DockerTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override DockerTemplateOptions dontAuthorizePublicKey(); @Override DockerTemplateOptions nameTask(String name); @Override DockerTemplateOptions runAsRoot(boolean runAsRoot); @Override DockerTemplateOptions runScript(Statement script); @Override DockerTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override DockerTemplateOptions overrideLoginPassword(String password); @Override DockerTemplateOptions overrideLoginPrivateKey(String privateKey); @Override DockerTemplateOptions overrideLoginUser(String loginUser); @Override DockerTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override DockerTemplateOptions userMetadata(Map<String, String> userMetadata); @Override DockerTemplateOptions userMetadata(String key, String value); @Override DockerTemplateOptions nodeNames(Iterable<String> nodeNames); @Override DockerTemplateOptions networks(Iterable<String> networks); }
@Test public void testVolumes() { TemplateOptions options = DockerTemplateOptions.Builder.volumes(ImmutableMap.of("/tmp", "/tmp")); assertEquals(options.as(DockerTemplateOptions.class).getVolumes(), ImmutableMap.of("/tmp", "/tmp")); }
public DockerTemplateOptions volumes(Map<String, String> volumes) { this.volumes = NullSafeCopies.copyOf(volumes); return this; }
DockerTemplateOptions extends TemplateOptions implements Cloneable { public DockerTemplateOptions volumes(Map<String, String> volumes) { this.volumes = NullSafeCopies.copyOf(volumes); return this; } }
DockerTemplateOptions extends TemplateOptions implements Cloneable { public DockerTemplateOptions volumes(Map<String, String> volumes) { this.volumes = NullSafeCopies.copyOf(volumes); return this; } }
DockerTemplateOptions extends TemplateOptions implements Cloneable { public DockerTemplateOptions volumes(Map<String, String> volumes) { this.volumes = NullSafeCopies.copyOf(volumes); return this; } @Override DockerTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); DockerTemplateOptions volumes(Map<String, String> volumes); DockerTemplateOptions dns(Iterable<String> dns); DockerTemplateOptions dns(String...dns); DockerTemplateOptions hostname(@Nullable String hostname); DockerTemplateOptions memory(@Nullable Integer memory); DockerTemplateOptions entrypoint(Iterable<String> entrypoint); DockerTemplateOptions entrypoint(String... entrypoint); DockerTemplateOptions commands(Iterable<String> commands); DockerTemplateOptions commands(String...commands); DockerTemplateOptions cpuShares(@Nullable Integer cpuShares); DockerTemplateOptions env(Iterable<String> env); DockerTemplateOptions env(String...env); DockerTemplateOptions portBindings(Map<Integer, Integer> portBindings); DockerTemplateOptions networkMode(@Nullable String networkMode); DockerTemplateOptions extraHosts(Map<String, String> extraHosts); DockerTemplateOptions volumesFrom(Iterable<String> volumesFrom); DockerTemplateOptions privileged(boolean privileged); DockerTemplateOptions openStdin(boolean openStdin); DockerTemplateOptions configBuilder(Config.Builder configBuilder); Map<String, String> getVolumes(); List<String> getDns(); List<String> getVolumesFrom(); String getHostname(); Integer getMemory(); List<String> getEntrypoint(); List<String> getCommands(); Integer getCpuShares(); List<String> getEnv(); Map<Integer, Integer> getPortBindings(); String getNetworkMode(); Map<String, String> getExtraHosts(); boolean getPrivileged(); boolean getOpenStdin(); Config.Builder getConfigBuilder(); @Override DockerTemplateOptions blockOnPort(int port, int seconds); @Override DockerTemplateOptions inboundPorts(int... ports); @Override DockerTemplateOptions authorizePublicKey(String publicKey); @Override DockerTemplateOptions installPrivateKey(String privateKey); @Override DockerTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override DockerTemplateOptions dontAuthorizePublicKey(); @Override DockerTemplateOptions nameTask(String name); @Override DockerTemplateOptions runAsRoot(boolean runAsRoot); @Override DockerTemplateOptions runScript(Statement script); @Override DockerTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override DockerTemplateOptions overrideLoginPassword(String password); @Override DockerTemplateOptions overrideLoginPrivateKey(String privateKey); @Override DockerTemplateOptions overrideLoginUser(String loginUser); @Override DockerTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override DockerTemplateOptions userMetadata(Map<String, String> userMetadata); @Override DockerTemplateOptions userMetadata(String key, String value); @Override DockerTemplateOptions nodeNames(Iterable<String> nodeNames); @Override DockerTemplateOptions networks(Iterable<String> networks); }
DockerTemplateOptions extends TemplateOptions implements Cloneable { public DockerTemplateOptions volumes(Map<String, String> volumes) { this.volumes = NullSafeCopies.copyOf(volumes); return this; } @Override DockerTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); DockerTemplateOptions volumes(Map<String, String> volumes); DockerTemplateOptions dns(Iterable<String> dns); DockerTemplateOptions dns(String...dns); DockerTemplateOptions hostname(@Nullable String hostname); DockerTemplateOptions memory(@Nullable Integer memory); DockerTemplateOptions entrypoint(Iterable<String> entrypoint); DockerTemplateOptions entrypoint(String... entrypoint); DockerTemplateOptions commands(Iterable<String> commands); DockerTemplateOptions commands(String...commands); DockerTemplateOptions cpuShares(@Nullable Integer cpuShares); DockerTemplateOptions env(Iterable<String> env); DockerTemplateOptions env(String...env); DockerTemplateOptions portBindings(Map<Integer, Integer> portBindings); DockerTemplateOptions networkMode(@Nullable String networkMode); DockerTemplateOptions extraHosts(Map<String, String> extraHosts); DockerTemplateOptions volumesFrom(Iterable<String> volumesFrom); DockerTemplateOptions privileged(boolean privileged); DockerTemplateOptions openStdin(boolean openStdin); DockerTemplateOptions configBuilder(Config.Builder configBuilder); Map<String, String> getVolumes(); List<String> getDns(); List<String> getVolumesFrom(); String getHostname(); Integer getMemory(); List<String> getEntrypoint(); List<String> getCommands(); Integer getCpuShares(); List<String> getEnv(); Map<Integer, Integer> getPortBindings(); String getNetworkMode(); Map<String, String> getExtraHosts(); boolean getPrivileged(); boolean getOpenStdin(); Config.Builder getConfigBuilder(); @Override DockerTemplateOptions blockOnPort(int port, int seconds); @Override DockerTemplateOptions inboundPorts(int... ports); @Override DockerTemplateOptions authorizePublicKey(String publicKey); @Override DockerTemplateOptions installPrivateKey(String privateKey); @Override DockerTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override DockerTemplateOptions dontAuthorizePublicKey(); @Override DockerTemplateOptions nameTask(String name); @Override DockerTemplateOptions runAsRoot(boolean runAsRoot); @Override DockerTemplateOptions runScript(Statement script); @Override DockerTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override DockerTemplateOptions overrideLoginPassword(String password); @Override DockerTemplateOptions overrideLoginPrivateKey(String privateKey); @Override DockerTemplateOptions overrideLoginUser(String loginUser); @Override DockerTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override DockerTemplateOptions userMetadata(Map<String, String> userMetadata); @Override DockerTemplateOptions userMetadata(String key, String value); @Override DockerTemplateOptions nodeNames(Iterable<String> nodeNames); @Override DockerTemplateOptions networks(Iterable<String> networks); }
@Test public void testDns() { TemplateOptions options = DockerTemplateOptions.Builder.dns("8.8.8.8", "8.8.4.4"); assertEquals(options.as(DockerTemplateOptions.class).getDns(), ImmutableList.of("8.8.8.8", "8.8.4.4")); }
public DockerTemplateOptions dns(Iterable<String> dns) { this.dns = NullSafeCopies.copyOf(dns); return this; }
DockerTemplateOptions extends TemplateOptions implements Cloneable { public DockerTemplateOptions dns(Iterable<String> dns) { this.dns = NullSafeCopies.copyOf(dns); return this; } }
DockerTemplateOptions extends TemplateOptions implements Cloneable { public DockerTemplateOptions dns(Iterable<String> dns) { this.dns = NullSafeCopies.copyOf(dns); return this; } }
DockerTemplateOptions extends TemplateOptions implements Cloneable { public DockerTemplateOptions dns(Iterable<String> dns) { this.dns = NullSafeCopies.copyOf(dns); return this; } @Override DockerTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); DockerTemplateOptions volumes(Map<String, String> volumes); DockerTemplateOptions dns(Iterable<String> dns); DockerTemplateOptions dns(String...dns); DockerTemplateOptions hostname(@Nullable String hostname); DockerTemplateOptions memory(@Nullable Integer memory); DockerTemplateOptions entrypoint(Iterable<String> entrypoint); DockerTemplateOptions entrypoint(String... entrypoint); DockerTemplateOptions commands(Iterable<String> commands); DockerTemplateOptions commands(String...commands); DockerTemplateOptions cpuShares(@Nullable Integer cpuShares); DockerTemplateOptions env(Iterable<String> env); DockerTemplateOptions env(String...env); DockerTemplateOptions portBindings(Map<Integer, Integer> portBindings); DockerTemplateOptions networkMode(@Nullable String networkMode); DockerTemplateOptions extraHosts(Map<String, String> extraHosts); DockerTemplateOptions volumesFrom(Iterable<String> volumesFrom); DockerTemplateOptions privileged(boolean privileged); DockerTemplateOptions openStdin(boolean openStdin); DockerTemplateOptions configBuilder(Config.Builder configBuilder); Map<String, String> getVolumes(); List<String> getDns(); List<String> getVolumesFrom(); String getHostname(); Integer getMemory(); List<String> getEntrypoint(); List<String> getCommands(); Integer getCpuShares(); List<String> getEnv(); Map<Integer, Integer> getPortBindings(); String getNetworkMode(); Map<String, String> getExtraHosts(); boolean getPrivileged(); boolean getOpenStdin(); Config.Builder getConfigBuilder(); @Override DockerTemplateOptions blockOnPort(int port, int seconds); @Override DockerTemplateOptions inboundPorts(int... ports); @Override DockerTemplateOptions authorizePublicKey(String publicKey); @Override DockerTemplateOptions installPrivateKey(String privateKey); @Override DockerTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override DockerTemplateOptions dontAuthorizePublicKey(); @Override DockerTemplateOptions nameTask(String name); @Override DockerTemplateOptions runAsRoot(boolean runAsRoot); @Override DockerTemplateOptions runScript(Statement script); @Override DockerTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override DockerTemplateOptions overrideLoginPassword(String password); @Override DockerTemplateOptions overrideLoginPrivateKey(String privateKey); @Override DockerTemplateOptions overrideLoginUser(String loginUser); @Override DockerTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override DockerTemplateOptions userMetadata(Map<String, String> userMetadata); @Override DockerTemplateOptions userMetadata(String key, String value); @Override DockerTemplateOptions nodeNames(Iterable<String> nodeNames); @Override DockerTemplateOptions networks(Iterable<String> networks); }
DockerTemplateOptions extends TemplateOptions implements Cloneable { public DockerTemplateOptions dns(Iterable<String> dns) { this.dns = NullSafeCopies.copyOf(dns); return this; } @Override DockerTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); DockerTemplateOptions volumes(Map<String, String> volumes); DockerTemplateOptions dns(Iterable<String> dns); DockerTemplateOptions dns(String...dns); DockerTemplateOptions hostname(@Nullable String hostname); DockerTemplateOptions memory(@Nullable Integer memory); DockerTemplateOptions entrypoint(Iterable<String> entrypoint); DockerTemplateOptions entrypoint(String... entrypoint); DockerTemplateOptions commands(Iterable<String> commands); DockerTemplateOptions commands(String...commands); DockerTemplateOptions cpuShares(@Nullable Integer cpuShares); DockerTemplateOptions env(Iterable<String> env); DockerTemplateOptions env(String...env); DockerTemplateOptions portBindings(Map<Integer, Integer> portBindings); DockerTemplateOptions networkMode(@Nullable String networkMode); DockerTemplateOptions extraHosts(Map<String, String> extraHosts); DockerTemplateOptions volumesFrom(Iterable<String> volumesFrom); DockerTemplateOptions privileged(boolean privileged); DockerTemplateOptions openStdin(boolean openStdin); DockerTemplateOptions configBuilder(Config.Builder configBuilder); Map<String, String> getVolumes(); List<String> getDns(); List<String> getVolumesFrom(); String getHostname(); Integer getMemory(); List<String> getEntrypoint(); List<String> getCommands(); Integer getCpuShares(); List<String> getEnv(); Map<Integer, Integer> getPortBindings(); String getNetworkMode(); Map<String, String> getExtraHosts(); boolean getPrivileged(); boolean getOpenStdin(); Config.Builder getConfigBuilder(); @Override DockerTemplateOptions blockOnPort(int port, int seconds); @Override DockerTemplateOptions inboundPorts(int... ports); @Override DockerTemplateOptions authorizePublicKey(String publicKey); @Override DockerTemplateOptions installPrivateKey(String privateKey); @Override DockerTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override DockerTemplateOptions dontAuthorizePublicKey(); @Override DockerTemplateOptions nameTask(String name); @Override DockerTemplateOptions runAsRoot(boolean runAsRoot); @Override DockerTemplateOptions runScript(Statement script); @Override DockerTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override DockerTemplateOptions overrideLoginPassword(String password); @Override DockerTemplateOptions overrideLoginPrivateKey(String privateKey); @Override DockerTemplateOptions overrideLoginUser(String loginUser); @Override DockerTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override DockerTemplateOptions userMetadata(Map<String, String> userMetadata); @Override DockerTemplateOptions userMetadata(String key, String value); @Override DockerTemplateOptions nodeNames(Iterable<String> nodeNames); @Override DockerTemplateOptions networks(Iterable<String> networks); }
@Test public void testEntrypoint() { TemplateOptions options = DockerTemplateOptions.Builder.entrypoint("/bin/sh", "-c"); assertEquals(options.as(DockerTemplateOptions.class).getEntrypoint(), ImmutableList.of("/bin/sh", "-c")); }
public DockerTemplateOptions entrypoint(Iterable<String> entrypoint) { this.entrypoint = NullSafeCopies.copyWithNullOf(entrypoint); return this; }
DockerTemplateOptions extends TemplateOptions implements Cloneable { public DockerTemplateOptions entrypoint(Iterable<String> entrypoint) { this.entrypoint = NullSafeCopies.copyWithNullOf(entrypoint); return this; } }
DockerTemplateOptions extends TemplateOptions implements Cloneable { public DockerTemplateOptions entrypoint(Iterable<String> entrypoint) { this.entrypoint = NullSafeCopies.copyWithNullOf(entrypoint); return this; } }
DockerTemplateOptions extends TemplateOptions implements Cloneable { public DockerTemplateOptions entrypoint(Iterable<String> entrypoint) { this.entrypoint = NullSafeCopies.copyWithNullOf(entrypoint); return this; } @Override DockerTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); DockerTemplateOptions volumes(Map<String, String> volumes); DockerTemplateOptions dns(Iterable<String> dns); DockerTemplateOptions dns(String...dns); DockerTemplateOptions hostname(@Nullable String hostname); DockerTemplateOptions memory(@Nullable Integer memory); DockerTemplateOptions entrypoint(Iterable<String> entrypoint); DockerTemplateOptions entrypoint(String... entrypoint); DockerTemplateOptions commands(Iterable<String> commands); DockerTemplateOptions commands(String...commands); DockerTemplateOptions cpuShares(@Nullable Integer cpuShares); DockerTemplateOptions env(Iterable<String> env); DockerTemplateOptions env(String...env); DockerTemplateOptions portBindings(Map<Integer, Integer> portBindings); DockerTemplateOptions networkMode(@Nullable String networkMode); DockerTemplateOptions extraHosts(Map<String, String> extraHosts); DockerTemplateOptions volumesFrom(Iterable<String> volumesFrom); DockerTemplateOptions privileged(boolean privileged); DockerTemplateOptions openStdin(boolean openStdin); DockerTemplateOptions configBuilder(Config.Builder configBuilder); Map<String, String> getVolumes(); List<String> getDns(); List<String> getVolumesFrom(); String getHostname(); Integer getMemory(); List<String> getEntrypoint(); List<String> getCommands(); Integer getCpuShares(); List<String> getEnv(); Map<Integer, Integer> getPortBindings(); String getNetworkMode(); Map<String, String> getExtraHosts(); boolean getPrivileged(); boolean getOpenStdin(); Config.Builder getConfigBuilder(); @Override DockerTemplateOptions blockOnPort(int port, int seconds); @Override DockerTemplateOptions inboundPorts(int... ports); @Override DockerTemplateOptions authorizePublicKey(String publicKey); @Override DockerTemplateOptions installPrivateKey(String privateKey); @Override DockerTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override DockerTemplateOptions dontAuthorizePublicKey(); @Override DockerTemplateOptions nameTask(String name); @Override DockerTemplateOptions runAsRoot(boolean runAsRoot); @Override DockerTemplateOptions runScript(Statement script); @Override DockerTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override DockerTemplateOptions overrideLoginPassword(String password); @Override DockerTemplateOptions overrideLoginPrivateKey(String privateKey); @Override DockerTemplateOptions overrideLoginUser(String loginUser); @Override DockerTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override DockerTemplateOptions userMetadata(Map<String, String> userMetadata); @Override DockerTemplateOptions userMetadata(String key, String value); @Override DockerTemplateOptions nodeNames(Iterable<String> nodeNames); @Override DockerTemplateOptions networks(Iterable<String> networks); }
DockerTemplateOptions extends TemplateOptions implements Cloneable { public DockerTemplateOptions entrypoint(Iterable<String> entrypoint) { this.entrypoint = NullSafeCopies.copyWithNullOf(entrypoint); return this; } @Override DockerTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); DockerTemplateOptions volumes(Map<String, String> volumes); DockerTemplateOptions dns(Iterable<String> dns); DockerTemplateOptions dns(String...dns); DockerTemplateOptions hostname(@Nullable String hostname); DockerTemplateOptions memory(@Nullable Integer memory); DockerTemplateOptions entrypoint(Iterable<String> entrypoint); DockerTemplateOptions entrypoint(String... entrypoint); DockerTemplateOptions commands(Iterable<String> commands); DockerTemplateOptions commands(String...commands); DockerTemplateOptions cpuShares(@Nullable Integer cpuShares); DockerTemplateOptions env(Iterable<String> env); DockerTemplateOptions env(String...env); DockerTemplateOptions portBindings(Map<Integer, Integer> portBindings); DockerTemplateOptions networkMode(@Nullable String networkMode); DockerTemplateOptions extraHosts(Map<String, String> extraHosts); DockerTemplateOptions volumesFrom(Iterable<String> volumesFrom); DockerTemplateOptions privileged(boolean privileged); DockerTemplateOptions openStdin(boolean openStdin); DockerTemplateOptions configBuilder(Config.Builder configBuilder); Map<String, String> getVolumes(); List<String> getDns(); List<String> getVolumesFrom(); String getHostname(); Integer getMemory(); List<String> getEntrypoint(); List<String> getCommands(); Integer getCpuShares(); List<String> getEnv(); Map<Integer, Integer> getPortBindings(); String getNetworkMode(); Map<String, String> getExtraHosts(); boolean getPrivileged(); boolean getOpenStdin(); Config.Builder getConfigBuilder(); @Override DockerTemplateOptions blockOnPort(int port, int seconds); @Override DockerTemplateOptions inboundPorts(int... ports); @Override DockerTemplateOptions authorizePublicKey(String publicKey); @Override DockerTemplateOptions installPrivateKey(String privateKey); @Override DockerTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override DockerTemplateOptions dontAuthorizePublicKey(); @Override DockerTemplateOptions nameTask(String name); @Override DockerTemplateOptions runAsRoot(boolean runAsRoot); @Override DockerTemplateOptions runScript(Statement script); @Override DockerTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override DockerTemplateOptions overrideLoginPassword(String password); @Override DockerTemplateOptions overrideLoginPrivateKey(String privateKey); @Override DockerTemplateOptions overrideLoginUser(String loginUser); @Override DockerTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override DockerTemplateOptions userMetadata(Map<String, String> userMetadata); @Override DockerTemplateOptions userMetadata(String key, String value); @Override DockerTemplateOptions nodeNames(Iterable<String> nodeNames); @Override DockerTemplateOptions networks(Iterable<String> networks); }
@Test public void testCommands() { TemplateOptions options = DockerTemplateOptions.Builder.commands("chmod 666 /etc/*", "rm -rf /var/run"); assertEquals(options.as(DockerTemplateOptions.class).getCommands(), ImmutableList.of("chmod 666 /etc/*", "rm -rf /var/run")); }
public DockerTemplateOptions commands(Iterable<String> commands) { this.commands = NullSafeCopies.copyWithNullOf(commands); return this; }
DockerTemplateOptions extends TemplateOptions implements Cloneable { public DockerTemplateOptions commands(Iterable<String> commands) { this.commands = NullSafeCopies.copyWithNullOf(commands); return this; } }
DockerTemplateOptions extends TemplateOptions implements Cloneable { public DockerTemplateOptions commands(Iterable<String> commands) { this.commands = NullSafeCopies.copyWithNullOf(commands); return this; } }
DockerTemplateOptions extends TemplateOptions implements Cloneable { public DockerTemplateOptions commands(Iterable<String> commands) { this.commands = NullSafeCopies.copyWithNullOf(commands); return this; } @Override DockerTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); DockerTemplateOptions volumes(Map<String, String> volumes); DockerTemplateOptions dns(Iterable<String> dns); DockerTemplateOptions dns(String...dns); DockerTemplateOptions hostname(@Nullable String hostname); DockerTemplateOptions memory(@Nullable Integer memory); DockerTemplateOptions entrypoint(Iterable<String> entrypoint); DockerTemplateOptions entrypoint(String... entrypoint); DockerTemplateOptions commands(Iterable<String> commands); DockerTemplateOptions commands(String...commands); DockerTemplateOptions cpuShares(@Nullable Integer cpuShares); DockerTemplateOptions env(Iterable<String> env); DockerTemplateOptions env(String...env); DockerTemplateOptions portBindings(Map<Integer, Integer> portBindings); DockerTemplateOptions networkMode(@Nullable String networkMode); DockerTemplateOptions extraHosts(Map<String, String> extraHosts); DockerTemplateOptions volumesFrom(Iterable<String> volumesFrom); DockerTemplateOptions privileged(boolean privileged); DockerTemplateOptions openStdin(boolean openStdin); DockerTemplateOptions configBuilder(Config.Builder configBuilder); Map<String, String> getVolumes(); List<String> getDns(); List<String> getVolumesFrom(); String getHostname(); Integer getMemory(); List<String> getEntrypoint(); List<String> getCommands(); Integer getCpuShares(); List<String> getEnv(); Map<Integer, Integer> getPortBindings(); String getNetworkMode(); Map<String, String> getExtraHosts(); boolean getPrivileged(); boolean getOpenStdin(); Config.Builder getConfigBuilder(); @Override DockerTemplateOptions blockOnPort(int port, int seconds); @Override DockerTemplateOptions inboundPorts(int... ports); @Override DockerTemplateOptions authorizePublicKey(String publicKey); @Override DockerTemplateOptions installPrivateKey(String privateKey); @Override DockerTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override DockerTemplateOptions dontAuthorizePublicKey(); @Override DockerTemplateOptions nameTask(String name); @Override DockerTemplateOptions runAsRoot(boolean runAsRoot); @Override DockerTemplateOptions runScript(Statement script); @Override DockerTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override DockerTemplateOptions overrideLoginPassword(String password); @Override DockerTemplateOptions overrideLoginPrivateKey(String privateKey); @Override DockerTemplateOptions overrideLoginUser(String loginUser); @Override DockerTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override DockerTemplateOptions userMetadata(Map<String, String> userMetadata); @Override DockerTemplateOptions userMetadata(String key, String value); @Override DockerTemplateOptions nodeNames(Iterable<String> nodeNames); @Override DockerTemplateOptions networks(Iterable<String> networks); }
DockerTemplateOptions extends TemplateOptions implements Cloneable { public DockerTemplateOptions commands(Iterable<String> commands) { this.commands = NullSafeCopies.copyWithNullOf(commands); return this; } @Override DockerTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); DockerTemplateOptions volumes(Map<String, String> volumes); DockerTemplateOptions dns(Iterable<String> dns); DockerTemplateOptions dns(String...dns); DockerTemplateOptions hostname(@Nullable String hostname); DockerTemplateOptions memory(@Nullable Integer memory); DockerTemplateOptions entrypoint(Iterable<String> entrypoint); DockerTemplateOptions entrypoint(String... entrypoint); DockerTemplateOptions commands(Iterable<String> commands); DockerTemplateOptions commands(String...commands); DockerTemplateOptions cpuShares(@Nullable Integer cpuShares); DockerTemplateOptions env(Iterable<String> env); DockerTemplateOptions env(String...env); DockerTemplateOptions portBindings(Map<Integer, Integer> portBindings); DockerTemplateOptions networkMode(@Nullable String networkMode); DockerTemplateOptions extraHosts(Map<String, String> extraHosts); DockerTemplateOptions volumesFrom(Iterable<String> volumesFrom); DockerTemplateOptions privileged(boolean privileged); DockerTemplateOptions openStdin(boolean openStdin); DockerTemplateOptions configBuilder(Config.Builder configBuilder); Map<String, String> getVolumes(); List<String> getDns(); List<String> getVolumesFrom(); String getHostname(); Integer getMemory(); List<String> getEntrypoint(); List<String> getCommands(); Integer getCpuShares(); List<String> getEnv(); Map<Integer, Integer> getPortBindings(); String getNetworkMode(); Map<String, String> getExtraHosts(); boolean getPrivileged(); boolean getOpenStdin(); Config.Builder getConfigBuilder(); @Override DockerTemplateOptions blockOnPort(int port, int seconds); @Override DockerTemplateOptions inboundPorts(int... ports); @Override DockerTemplateOptions authorizePublicKey(String publicKey); @Override DockerTemplateOptions installPrivateKey(String privateKey); @Override DockerTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override DockerTemplateOptions dontAuthorizePublicKey(); @Override DockerTemplateOptions nameTask(String name); @Override DockerTemplateOptions runAsRoot(boolean runAsRoot); @Override DockerTemplateOptions runScript(Statement script); @Override DockerTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override DockerTemplateOptions overrideLoginPassword(String password); @Override DockerTemplateOptions overrideLoginPrivateKey(String privateKey); @Override DockerTemplateOptions overrideLoginUser(String loginUser); @Override DockerTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override DockerTemplateOptions userMetadata(Map<String, String> userMetadata); @Override DockerTemplateOptions userMetadata(String key, String value); @Override DockerTemplateOptions nodeNames(Iterable<String> nodeNames); @Override DockerTemplateOptions networks(Iterable<String> networks); }
@Test public void testStorageToVolume() { Storage storage = Storage.builder() .id("qswdefrg-qaws-qaws-defe-rgrgdsvcxbrh") .size(40) .name("hdd-1") .busType(Storage.BusType.VIRTIO) .bootDevice(true) .deviceNumber(1) .build(); Volume actual = fnVolume.apply(storage); Volume expected = new VolumeBuilder() .id(storage.id()) .size(40f) .bootDevice(true) .device("1") .type(Volume.Type.LOCAL) .durable(true) .build(); assertEquals(actual, expected); }
@Override public Volume apply(Storage storage) { checkNotNull(storage, "Null storage"); String device = ""; if (storage.deviceNumber() != null) device = storage.deviceNumber().toString(); return new VolumeBuilder() .id(storage.id()) .size(storage.size()) .bootDevice(storage.bootDevice()) .device(device) .durable(true) .type(Volume.Type.LOCAL) .build(); }
StorageToVolume implements Function<Storage, Volume> { @Override public Volume apply(Storage storage) { checkNotNull(storage, "Null storage"); String device = ""; if (storage.deviceNumber() != null) device = storage.deviceNumber().toString(); return new VolumeBuilder() .id(storage.id()) .size(storage.size()) .bootDevice(storage.bootDevice()) .device(device) .durable(true) .type(Volume.Type.LOCAL) .build(); } }
StorageToVolume implements Function<Storage, Volume> { @Override public Volume apply(Storage storage) { checkNotNull(storage, "Null storage"); String device = ""; if (storage.deviceNumber() != null) device = storage.deviceNumber().toString(); return new VolumeBuilder() .id(storage.id()) .size(storage.size()) .bootDevice(storage.bootDevice()) .device(device) .durable(true) .type(Volume.Type.LOCAL) .build(); } }
StorageToVolume implements Function<Storage, Volume> { @Override public Volume apply(Storage storage) { checkNotNull(storage, "Null storage"); String device = ""; if (storage.deviceNumber() != null) device = storage.deviceNumber().toString(); return new VolumeBuilder() .id(storage.id()) .size(storage.size()) .bootDevice(storage.bootDevice()) .device(device) .durable(true) .type(Volume.Type.LOCAL) .build(); } @Override Volume apply(Storage storage); }
StorageToVolume implements Function<Storage, Volume> { @Override public Volume apply(Storage storage) { checkNotNull(storage, "Null storage"); String device = ""; if (storage.deviceNumber() != null) device = storage.deviceNumber().toString(); return new VolumeBuilder() .id(storage.id()) .size(storage.size()) .bootDevice(storage.bootDevice()) .device(device) .durable(true) .type(Volume.Type.LOCAL) .build(); } @Override Volume apply(Storage storage); }
@Test public void testEnv() { TemplateOptions options = DockerTemplateOptions.Builder.env(ImmutableList.of("HOST=abc", "PORT=1234")); assertEquals(options.as(DockerTemplateOptions.class).getEnv(), ImmutableList.of("HOST=abc", "PORT=1234")); }
public DockerTemplateOptions env(Iterable<String> env) { this.env = NullSafeCopies.copyWithNullOf(env); return this; }
DockerTemplateOptions extends TemplateOptions implements Cloneable { public DockerTemplateOptions env(Iterable<String> env) { this.env = NullSafeCopies.copyWithNullOf(env); return this; } }
DockerTemplateOptions extends TemplateOptions implements Cloneable { public DockerTemplateOptions env(Iterable<String> env) { this.env = NullSafeCopies.copyWithNullOf(env); return this; } }
DockerTemplateOptions extends TemplateOptions implements Cloneable { public DockerTemplateOptions env(Iterable<String> env) { this.env = NullSafeCopies.copyWithNullOf(env); return this; } @Override DockerTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); DockerTemplateOptions volumes(Map<String, String> volumes); DockerTemplateOptions dns(Iterable<String> dns); DockerTemplateOptions dns(String...dns); DockerTemplateOptions hostname(@Nullable String hostname); DockerTemplateOptions memory(@Nullable Integer memory); DockerTemplateOptions entrypoint(Iterable<String> entrypoint); DockerTemplateOptions entrypoint(String... entrypoint); DockerTemplateOptions commands(Iterable<String> commands); DockerTemplateOptions commands(String...commands); DockerTemplateOptions cpuShares(@Nullable Integer cpuShares); DockerTemplateOptions env(Iterable<String> env); DockerTemplateOptions env(String...env); DockerTemplateOptions portBindings(Map<Integer, Integer> portBindings); DockerTemplateOptions networkMode(@Nullable String networkMode); DockerTemplateOptions extraHosts(Map<String, String> extraHosts); DockerTemplateOptions volumesFrom(Iterable<String> volumesFrom); DockerTemplateOptions privileged(boolean privileged); DockerTemplateOptions openStdin(boolean openStdin); DockerTemplateOptions configBuilder(Config.Builder configBuilder); Map<String, String> getVolumes(); List<String> getDns(); List<String> getVolumesFrom(); String getHostname(); Integer getMemory(); List<String> getEntrypoint(); List<String> getCommands(); Integer getCpuShares(); List<String> getEnv(); Map<Integer, Integer> getPortBindings(); String getNetworkMode(); Map<String, String> getExtraHosts(); boolean getPrivileged(); boolean getOpenStdin(); Config.Builder getConfigBuilder(); @Override DockerTemplateOptions blockOnPort(int port, int seconds); @Override DockerTemplateOptions inboundPorts(int... ports); @Override DockerTemplateOptions authorizePublicKey(String publicKey); @Override DockerTemplateOptions installPrivateKey(String privateKey); @Override DockerTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override DockerTemplateOptions dontAuthorizePublicKey(); @Override DockerTemplateOptions nameTask(String name); @Override DockerTemplateOptions runAsRoot(boolean runAsRoot); @Override DockerTemplateOptions runScript(Statement script); @Override DockerTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override DockerTemplateOptions overrideLoginPassword(String password); @Override DockerTemplateOptions overrideLoginPrivateKey(String privateKey); @Override DockerTemplateOptions overrideLoginUser(String loginUser); @Override DockerTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override DockerTemplateOptions userMetadata(Map<String, String> userMetadata); @Override DockerTemplateOptions userMetadata(String key, String value); @Override DockerTemplateOptions nodeNames(Iterable<String> nodeNames); @Override DockerTemplateOptions networks(Iterable<String> networks); }
DockerTemplateOptions extends TemplateOptions implements Cloneable { public DockerTemplateOptions env(Iterable<String> env) { this.env = NullSafeCopies.copyWithNullOf(env); return this; } @Override DockerTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); DockerTemplateOptions volumes(Map<String, String> volumes); DockerTemplateOptions dns(Iterable<String> dns); DockerTemplateOptions dns(String...dns); DockerTemplateOptions hostname(@Nullable String hostname); DockerTemplateOptions memory(@Nullable Integer memory); DockerTemplateOptions entrypoint(Iterable<String> entrypoint); DockerTemplateOptions entrypoint(String... entrypoint); DockerTemplateOptions commands(Iterable<String> commands); DockerTemplateOptions commands(String...commands); DockerTemplateOptions cpuShares(@Nullable Integer cpuShares); DockerTemplateOptions env(Iterable<String> env); DockerTemplateOptions env(String...env); DockerTemplateOptions portBindings(Map<Integer, Integer> portBindings); DockerTemplateOptions networkMode(@Nullable String networkMode); DockerTemplateOptions extraHosts(Map<String, String> extraHosts); DockerTemplateOptions volumesFrom(Iterable<String> volumesFrom); DockerTemplateOptions privileged(boolean privileged); DockerTemplateOptions openStdin(boolean openStdin); DockerTemplateOptions configBuilder(Config.Builder configBuilder); Map<String, String> getVolumes(); List<String> getDns(); List<String> getVolumesFrom(); String getHostname(); Integer getMemory(); List<String> getEntrypoint(); List<String> getCommands(); Integer getCpuShares(); List<String> getEnv(); Map<Integer, Integer> getPortBindings(); String getNetworkMode(); Map<String, String> getExtraHosts(); boolean getPrivileged(); boolean getOpenStdin(); Config.Builder getConfigBuilder(); @Override DockerTemplateOptions blockOnPort(int port, int seconds); @Override DockerTemplateOptions inboundPorts(int... ports); @Override DockerTemplateOptions authorizePublicKey(String publicKey); @Override DockerTemplateOptions installPrivateKey(String privateKey); @Override DockerTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override DockerTemplateOptions dontAuthorizePublicKey(); @Override DockerTemplateOptions nameTask(String name); @Override DockerTemplateOptions runAsRoot(boolean runAsRoot); @Override DockerTemplateOptions runScript(Statement script); @Override DockerTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override DockerTemplateOptions overrideLoginPassword(String password); @Override DockerTemplateOptions overrideLoginPrivateKey(String privateKey); @Override DockerTemplateOptions overrideLoginUser(String loginUser); @Override DockerTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override DockerTemplateOptions userMetadata(Map<String, String> userMetadata); @Override DockerTemplateOptions userMetadata(String key, String value); @Override DockerTemplateOptions nodeNames(Iterable<String> nodeNames); @Override DockerTemplateOptions networks(Iterable<String> networks); }
@Test public void testPortBindings() { TemplateOptions options = DockerTemplateOptions.Builder.portBindings(ImmutableMap.<Integer, Integer>builder().put(8443, 443).put(8080, 80).build()); assertEquals(options.as(DockerTemplateOptions.class).getPortBindings(), ImmutableMap.<Integer, Integer>builder().put(8443, 443).put(8080, 80).build()); }
public DockerTemplateOptions portBindings(Map<Integer, Integer> portBindings) { this.portBindings = NullSafeCopies.copyOf(portBindings); return this; }
DockerTemplateOptions extends TemplateOptions implements Cloneable { public DockerTemplateOptions portBindings(Map<Integer, Integer> portBindings) { this.portBindings = NullSafeCopies.copyOf(portBindings); return this; } }
DockerTemplateOptions extends TemplateOptions implements Cloneable { public DockerTemplateOptions portBindings(Map<Integer, Integer> portBindings) { this.portBindings = NullSafeCopies.copyOf(portBindings); return this; } }
DockerTemplateOptions extends TemplateOptions implements Cloneable { public DockerTemplateOptions portBindings(Map<Integer, Integer> portBindings) { this.portBindings = NullSafeCopies.copyOf(portBindings); return this; } @Override DockerTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); DockerTemplateOptions volumes(Map<String, String> volumes); DockerTemplateOptions dns(Iterable<String> dns); DockerTemplateOptions dns(String...dns); DockerTemplateOptions hostname(@Nullable String hostname); DockerTemplateOptions memory(@Nullable Integer memory); DockerTemplateOptions entrypoint(Iterable<String> entrypoint); DockerTemplateOptions entrypoint(String... entrypoint); DockerTemplateOptions commands(Iterable<String> commands); DockerTemplateOptions commands(String...commands); DockerTemplateOptions cpuShares(@Nullable Integer cpuShares); DockerTemplateOptions env(Iterable<String> env); DockerTemplateOptions env(String...env); DockerTemplateOptions portBindings(Map<Integer, Integer> portBindings); DockerTemplateOptions networkMode(@Nullable String networkMode); DockerTemplateOptions extraHosts(Map<String, String> extraHosts); DockerTemplateOptions volumesFrom(Iterable<String> volumesFrom); DockerTemplateOptions privileged(boolean privileged); DockerTemplateOptions openStdin(boolean openStdin); DockerTemplateOptions configBuilder(Config.Builder configBuilder); Map<String, String> getVolumes(); List<String> getDns(); List<String> getVolumesFrom(); String getHostname(); Integer getMemory(); List<String> getEntrypoint(); List<String> getCommands(); Integer getCpuShares(); List<String> getEnv(); Map<Integer, Integer> getPortBindings(); String getNetworkMode(); Map<String, String> getExtraHosts(); boolean getPrivileged(); boolean getOpenStdin(); Config.Builder getConfigBuilder(); @Override DockerTemplateOptions blockOnPort(int port, int seconds); @Override DockerTemplateOptions inboundPorts(int... ports); @Override DockerTemplateOptions authorizePublicKey(String publicKey); @Override DockerTemplateOptions installPrivateKey(String privateKey); @Override DockerTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override DockerTemplateOptions dontAuthorizePublicKey(); @Override DockerTemplateOptions nameTask(String name); @Override DockerTemplateOptions runAsRoot(boolean runAsRoot); @Override DockerTemplateOptions runScript(Statement script); @Override DockerTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override DockerTemplateOptions overrideLoginPassword(String password); @Override DockerTemplateOptions overrideLoginPrivateKey(String privateKey); @Override DockerTemplateOptions overrideLoginUser(String loginUser); @Override DockerTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override DockerTemplateOptions userMetadata(Map<String, String> userMetadata); @Override DockerTemplateOptions userMetadata(String key, String value); @Override DockerTemplateOptions nodeNames(Iterable<String> nodeNames); @Override DockerTemplateOptions networks(Iterable<String> networks); }
DockerTemplateOptions extends TemplateOptions implements Cloneable { public DockerTemplateOptions portBindings(Map<Integer, Integer> portBindings) { this.portBindings = NullSafeCopies.copyOf(portBindings); return this; } @Override DockerTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); DockerTemplateOptions volumes(Map<String, String> volumes); DockerTemplateOptions dns(Iterable<String> dns); DockerTemplateOptions dns(String...dns); DockerTemplateOptions hostname(@Nullable String hostname); DockerTemplateOptions memory(@Nullable Integer memory); DockerTemplateOptions entrypoint(Iterable<String> entrypoint); DockerTemplateOptions entrypoint(String... entrypoint); DockerTemplateOptions commands(Iterable<String> commands); DockerTemplateOptions commands(String...commands); DockerTemplateOptions cpuShares(@Nullable Integer cpuShares); DockerTemplateOptions env(Iterable<String> env); DockerTemplateOptions env(String...env); DockerTemplateOptions portBindings(Map<Integer, Integer> portBindings); DockerTemplateOptions networkMode(@Nullable String networkMode); DockerTemplateOptions extraHosts(Map<String, String> extraHosts); DockerTemplateOptions volumesFrom(Iterable<String> volumesFrom); DockerTemplateOptions privileged(boolean privileged); DockerTemplateOptions openStdin(boolean openStdin); DockerTemplateOptions configBuilder(Config.Builder configBuilder); Map<String, String> getVolumes(); List<String> getDns(); List<String> getVolumesFrom(); String getHostname(); Integer getMemory(); List<String> getEntrypoint(); List<String> getCommands(); Integer getCpuShares(); List<String> getEnv(); Map<Integer, Integer> getPortBindings(); String getNetworkMode(); Map<String, String> getExtraHosts(); boolean getPrivileged(); boolean getOpenStdin(); Config.Builder getConfigBuilder(); @Override DockerTemplateOptions blockOnPort(int port, int seconds); @Override DockerTemplateOptions inboundPorts(int... ports); @Override DockerTemplateOptions authorizePublicKey(String publicKey); @Override DockerTemplateOptions installPrivateKey(String privateKey); @Override DockerTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override DockerTemplateOptions dontAuthorizePublicKey(); @Override DockerTemplateOptions nameTask(String name); @Override DockerTemplateOptions runAsRoot(boolean runAsRoot); @Override DockerTemplateOptions runScript(Statement script); @Override DockerTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override DockerTemplateOptions overrideLoginPassword(String password); @Override DockerTemplateOptions overrideLoginPrivateKey(String privateKey); @Override DockerTemplateOptions overrideLoginUser(String loginUser); @Override DockerTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override DockerTemplateOptions userMetadata(Map<String, String> userMetadata); @Override DockerTemplateOptions userMetadata(String key, String value); @Override DockerTemplateOptions nodeNames(Iterable<String> nodeNames); @Override DockerTemplateOptions networks(Iterable<String> networks); }
@Test public void testNetworkMode() { TemplateOptions options = DockerTemplateOptions.Builder.networkMode("host"); assertEquals(options.as(DockerTemplateOptions.class).getNetworkMode(), "host"); }
public DockerTemplateOptions networkMode(@Nullable String networkMode) { this.networkMode = networkMode; return this; }
DockerTemplateOptions extends TemplateOptions implements Cloneable { public DockerTemplateOptions networkMode(@Nullable String networkMode) { this.networkMode = networkMode; return this; } }
DockerTemplateOptions extends TemplateOptions implements Cloneable { public DockerTemplateOptions networkMode(@Nullable String networkMode) { this.networkMode = networkMode; return this; } }
DockerTemplateOptions extends TemplateOptions implements Cloneable { public DockerTemplateOptions networkMode(@Nullable String networkMode) { this.networkMode = networkMode; return this; } @Override DockerTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); DockerTemplateOptions volumes(Map<String, String> volumes); DockerTemplateOptions dns(Iterable<String> dns); DockerTemplateOptions dns(String...dns); DockerTemplateOptions hostname(@Nullable String hostname); DockerTemplateOptions memory(@Nullable Integer memory); DockerTemplateOptions entrypoint(Iterable<String> entrypoint); DockerTemplateOptions entrypoint(String... entrypoint); DockerTemplateOptions commands(Iterable<String> commands); DockerTemplateOptions commands(String...commands); DockerTemplateOptions cpuShares(@Nullable Integer cpuShares); DockerTemplateOptions env(Iterable<String> env); DockerTemplateOptions env(String...env); DockerTemplateOptions portBindings(Map<Integer, Integer> portBindings); DockerTemplateOptions networkMode(@Nullable String networkMode); DockerTemplateOptions extraHosts(Map<String, String> extraHosts); DockerTemplateOptions volumesFrom(Iterable<String> volumesFrom); DockerTemplateOptions privileged(boolean privileged); DockerTemplateOptions openStdin(boolean openStdin); DockerTemplateOptions configBuilder(Config.Builder configBuilder); Map<String, String> getVolumes(); List<String> getDns(); List<String> getVolumesFrom(); String getHostname(); Integer getMemory(); List<String> getEntrypoint(); List<String> getCommands(); Integer getCpuShares(); List<String> getEnv(); Map<Integer, Integer> getPortBindings(); String getNetworkMode(); Map<String, String> getExtraHosts(); boolean getPrivileged(); boolean getOpenStdin(); Config.Builder getConfigBuilder(); @Override DockerTemplateOptions blockOnPort(int port, int seconds); @Override DockerTemplateOptions inboundPorts(int... ports); @Override DockerTemplateOptions authorizePublicKey(String publicKey); @Override DockerTemplateOptions installPrivateKey(String privateKey); @Override DockerTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override DockerTemplateOptions dontAuthorizePublicKey(); @Override DockerTemplateOptions nameTask(String name); @Override DockerTemplateOptions runAsRoot(boolean runAsRoot); @Override DockerTemplateOptions runScript(Statement script); @Override DockerTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override DockerTemplateOptions overrideLoginPassword(String password); @Override DockerTemplateOptions overrideLoginPrivateKey(String privateKey); @Override DockerTemplateOptions overrideLoginUser(String loginUser); @Override DockerTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override DockerTemplateOptions userMetadata(Map<String, String> userMetadata); @Override DockerTemplateOptions userMetadata(String key, String value); @Override DockerTemplateOptions nodeNames(Iterable<String> nodeNames); @Override DockerTemplateOptions networks(Iterable<String> networks); }
DockerTemplateOptions extends TemplateOptions implements Cloneable { public DockerTemplateOptions networkMode(@Nullable String networkMode) { this.networkMode = networkMode; return this; } @Override DockerTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); DockerTemplateOptions volumes(Map<String, String> volumes); DockerTemplateOptions dns(Iterable<String> dns); DockerTemplateOptions dns(String...dns); DockerTemplateOptions hostname(@Nullable String hostname); DockerTemplateOptions memory(@Nullable Integer memory); DockerTemplateOptions entrypoint(Iterable<String> entrypoint); DockerTemplateOptions entrypoint(String... entrypoint); DockerTemplateOptions commands(Iterable<String> commands); DockerTemplateOptions commands(String...commands); DockerTemplateOptions cpuShares(@Nullable Integer cpuShares); DockerTemplateOptions env(Iterable<String> env); DockerTemplateOptions env(String...env); DockerTemplateOptions portBindings(Map<Integer, Integer> portBindings); DockerTemplateOptions networkMode(@Nullable String networkMode); DockerTemplateOptions extraHosts(Map<String, String> extraHosts); DockerTemplateOptions volumesFrom(Iterable<String> volumesFrom); DockerTemplateOptions privileged(boolean privileged); DockerTemplateOptions openStdin(boolean openStdin); DockerTemplateOptions configBuilder(Config.Builder configBuilder); Map<String, String> getVolumes(); List<String> getDns(); List<String> getVolumesFrom(); String getHostname(); Integer getMemory(); List<String> getEntrypoint(); List<String> getCommands(); Integer getCpuShares(); List<String> getEnv(); Map<Integer, Integer> getPortBindings(); String getNetworkMode(); Map<String, String> getExtraHosts(); boolean getPrivileged(); boolean getOpenStdin(); Config.Builder getConfigBuilder(); @Override DockerTemplateOptions blockOnPort(int port, int seconds); @Override DockerTemplateOptions inboundPorts(int... ports); @Override DockerTemplateOptions authorizePublicKey(String publicKey); @Override DockerTemplateOptions installPrivateKey(String privateKey); @Override DockerTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override DockerTemplateOptions dontAuthorizePublicKey(); @Override DockerTemplateOptions nameTask(String name); @Override DockerTemplateOptions runAsRoot(boolean runAsRoot); @Override DockerTemplateOptions runScript(Statement script); @Override DockerTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override DockerTemplateOptions overrideLoginPassword(String password); @Override DockerTemplateOptions overrideLoginPrivateKey(String privateKey); @Override DockerTemplateOptions overrideLoginUser(String loginUser); @Override DockerTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override DockerTemplateOptions userMetadata(Map<String, String> userMetadata); @Override DockerTemplateOptions userMetadata(String key, String value); @Override DockerTemplateOptions nodeNames(Iterable<String> nodeNames); @Override DockerTemplateOptions networks(Iterable<String> networks); }
@Test public void testPrivileged() { TemplateOptions options = DockerTemplateOptions.Builder.privileged(true); assertEquals(options.as(DockerTemplateOptions.class).getPrivileged(), true); }
public DockerTemplateOptions privileged(boolean privileged) { this.privileged = privileged; return this; }
DockerTemplateOptions extends TemplateOptions implements Cloneable { public DockerTemplateOptions privileged(boolean privileged) { this.privileged = privileged; return this; } }
DockerTemplateOptions extends TemplateOptions implements Cloneable { public DockerTemplateOptions privileged(boolean privileged) { this.privileged = privileged; return this; } }
DockerTemplateOptions extends TemplateOptions implements Cloneable { public DockerTemplateOptions privileged(boolean privileged) { this.privileged = privileged; return this; } @Override DockerTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); DockerTemplateOptions volumes(Map<String, String> volumes); DockerTemplateOptions dns(Iterable<String> dns); DockerTemplateOptions dns(String...dns); DockerTemplateOptions hostname(@Nullable String hostname); DockerTemplateOptions memory(@Nullable Integer memory); DockerTemplateOptions entrypoint(Iterable<String> entrypoint); DockerTemplateOptions entrypoint(String... entrypoint); DockerTemplateOptions commands(Iterable<String> commands); DockerTemplateOptions commands(String...commands); DockerTemplateOptions cpuShares(@Nullable Integer cpuShares); DockerTemplateOptions env(Iterable<String> env); DockerTemplateOptions env(String...env); DockerTemplateOptions portBindings(Map<Integer, Integer> portBindings); DockerTemplateOptions networkMode(@Nullable String networkMode); DockerTemplateOptions extraHosts(Map<String, String> extraHosts); DockerTemplateOptions volumesFrom(Iterable<String> volumesFrom); DockerTemplateOptions privileged(boolean privileged); DockerTemplateOptions openStdin(boolean openStdin); DockerTemplateOptions configBuilder(Config.Builder configBuilder); Map<String, String> getVolumes(); List<String> getDns(); List<String> getVolumesFrom(); String getHostname(); Integer getMemory(); List<String> getEntrypoint(); List<String> getCommands(); Integer getCpuShares(); List<String> getEnv(); Map<Integer, Integer> getPortBindings(); String getNetworkMode(); Map<String, String> getExtraHosts(); boolean getPrivileged(); boolean getOpenStdin(); Config.Builder getConfigBuilder(); @Override DockerTemplateOptions blockOnPort(int port, int seconds); @Override DockerTemplateOptions inboundPorts(int... ports); @Override DockerTemplateOptions authorizePublicKey(String publicKey); @Override DockerTemplateOptions installPrivateKey(String privateKey); @Override DockerTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override DockerTemplateOptions dontAuthorizePublicKey(); @Override DockerTemplateOptions nameTask(String name); @Override DockerTemplateOptions runAsRoot(boolean runAsRoot); @Override DockerTemplateOptions runScript(Statement script); @Override DockerTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override DockerTemplateOptions overrideLoginPassword(String password); @Override DockerTemplateOptions overrideLoginPrivateKey(String privateKey); @Override DockerTemplateOptions overrideLoginUser(String loginUser); @Override DockerTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override DockerTemplateOptions userMetadata(Map<String, String> userMetadata); @Override DockerTemplateOptions userMetadata(String key, String value); @Override DockerTemplateOptions nodeNames(Iterable<String> nodeNames); @Override DockerTemplateOptions networks(Iterable<String> networks); }
DockerTemplateOptions extends TemplateOptions implements Cloneable { public DockerTemplateOptions privileged(boolean privileged) { this.privileged = privileged; return this; } @Override DockerTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); DockerTemplateOptions volumes(Map<String, String> volumes); DockerTemplateOptions dns(Iterable<String> dns); DockerTemplateOptions dns(String...dns); DockerTemplateOptions hostname(@Nullable String hostname); DockerTemplateOptions memory(@Nullable Integer memory); DockerTemplateOptions entrypoint(Iterable<String> entrypoint); DockerTemplateOptions entrypoint(String... entrypoint); DockerTemplateOptions commands(Iterable<String> commands); DockerTemplateOptions commands(String...commands); DockerTemplateOptions cpuShares(@Nullable Integer cpuShares); DockerTemplateOptions env(Iterable<String> env); DockerTemplateOptions env(String...env); DockerTemplateOptions portBindings(Map<Integer, Integer> portBindings); DockerTemplateOptions networkMode(@Nullable String networkMode); DockerTemplateOptions extraHosts(Map<String, String> extraHosts); DockerTemplateOptions volumesFrom(Iterable<String> volumesFrom); DockerTemplateOptions privileged(boolean privileged); DockerTemplateOptions openStdin(boolean openStdin); DockerTemplateOptions configBuilder(Config.Builder configBuilder); Map<String, String> getVolumes(); List<String> getDns(); List<String> getVolumesFrom(); String getHostname(); Integer getMemory(); List<String> getEntrypoint(); List<String> getCommands(); Integer getCpuShares(); List<String> getEnv(); Map<Integer, Integer> getPortBindings(); String getNetworkMode(); Map<String, String> getExtraHosts(); boolean getPrivileged(); boolean getOpenStdin(); Config.Builder getConfigBuilder(); @Override DockerTemplateOptions blockOnPort(int port, int seconds); @Override DockerTemplateOptions inboundPorts(int... ports); @Override DockerTemplateOptions authorizePublicKey(String publicKey); @Override DockerTemplateOptions installPrivateKey(String privateKey); @Override DockerTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override DockerTemplateOptions dontAuthorizePublicKey(); @Override DockerTemplateOptions nameTask(String name); @Override DockerTemplateOptions runAsRoot(boolean runAsRoot); @Override DockerTemplateOptions runScript(Statement script); @Override DockerTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override DockerTemplateOptions overrideLoginPassword(String password); @Override DockerTemplateOptions overrideLoginPrivateKey(String privateKey); @Override DockerTemplateOptions overrideLoginUser(String loginUser); @Override DockerTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override DockerTemplateOptions userMetadata(Map<String, String> userMetadata); @Override DockerTemplateOptions userMetadata(String key, String value); @Override DockerTemplateOptions nodeNames(Iterable<String> nodeNames); @Override DockerTemplateOptions networks(Iterable<String> networks); }
@Test public void testConfigBuilder() { Builder builder = Config.builder().memory(1024) .cpuShares(100).cmd(ImmutableList.<String> of("/opt/jboss/wildfly/bin/standalone.sh", "-b", "0.0.0.0")) .env(ImmutableList.<String> of("JAVA_HOME=/opt/jdk-1.8", "MGMT_USER=admin", "MGMT_PASSWORD=Schroedinger's Cat")); TemplateOptions options = DockerTemplateOptions.Builder.configBuilder(builder); Builder builderInOpts = options.as(DockerTemplateOptions.class).getConfigBuilder(); assertNotNull(builderInOpts); Config configFromOptions = builderInOpts.build(); assertEquals(configFromOptions, builder.build()); assertEquals(configFromOptions.env(), ImmutableList.<String> of("JAVA_HOME=/opt/jdk-1.8", "MGMT_USER=admin", "MGMT_PASSWORD=Schroedinger's Cat")); }
public DockerTemplateOptions configBuilder(Config.Builder configBuilder) { this.configBuilder = configBuilder != null ? Config.builder().fromConfig(configBuilder.image(NO_IMAGE).build()) : null; return this; }
DockerTemplateOptions extends TemplateOptions implements Cloneable { public DockerTemplateOptions configBuilder(Config.Builder configBuilder) { this.configBuilder = configBuilder != null ? Config.builder().fromConfig(configBuilder.image(NO_IMAGE).build()) : null; return this; } }
DockerTemplateOptions extends TemplateOptions implements Cloneable { public DockerTemplateOptions configBuilder(Config.Builder configBuilder) { this.configBuilder = configBuilder != null ? Config.builder().fromConfig(configBuilder.image(NO_IMAGE).build()) : null; return this; } }
DockerTemplateOptions extends TemplateOptions implements Cloneable { public DockerTemplateOptions configBuilder(Config.Builder configBuilder) { this.configBuilder = configBuilder != null ? Config.builder().fromConfig(configBuilder.image(NO_IMAGE).build()) : null; return this; } @Override DockerTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); DockerTemplateOptions volumes(Map<String, String> volumes); DockerTemplateOptions dns(Iterable<String> dns); DockerTemplateOptions dns(String...dns); DockerTemplateOptions hostname(@Nullable String hostname); DockerTemplateOptions memory(@Nullable Integer memory); DockerTemplateOptions entrypoint(Iterable<String> entrypoint); DockerTemplateOptions entrypoint(String... entrypoint); DockerTemplateOptions commands(Iterable<String> commands); DockerTemplateOptions commands(String...commands); DockerTemplateOptions cpuShares(@Nullable Integer cpuShares); DockerTemplateOptions env(Iterable<String> env); DockerTemplateOptions env(String...env); DockerTemplateOptions portBindings(Map<Integer, Integer> portBindings); DockerTemplateOptions networkMode(@Nullable String networkMode); DockerTemplateOptions extraHosts(Map<String, String> extraHosts); DockerTemplateOptions volumesFrom(Iterable<String> volumesFrom); DockerTemplateOptions privileged(boolean privileged); DockerTemplateOptions openStdin(boolean openStdin); DockerTemplateOptions configBuilder(Config.Builder configBuilder); Map<String, String> getVolumes(); List<String> getDns(); List<String> getVolumesFrom(); String getHostname(); Integer getMemory(); List<String> getEntrypoint(); List<String> getCommands(); Integer getCpuShares(); List<String> getEnv(); Map<Integer, Integer> getPortBindings(); String getNetworkMode(); Map<String, String> getExtraHosts(); boolean getPrivileged(); boolean getOpenStdin(); Config.Builder getConfigBuilder(); @Override DockerTemplateOptions blockOnPort(int port, int seconds); @Override DockerTemplateOptions inboundPorts(int... ports); @Override DockerTemplateOptions authorizePublicKey(String publicKey); @Override DockerTemplateOptions installPrivateKey(String privateKey); @Override DockerTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override DockerTemplateOptions dontAuthorizePublicKey(); @Override DockerTemplateOptions nameTask(String name); @Override DockerTemplateOptions runAsRoot(boolean runAsRoot); @Override DockerTemplateOptions runScript(Statement script); @Override DockerTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override DockerTemplateOptions overrideLoginPassword(String password); @Override DockerTemplateOptions overrideLoginPrivateKey(String privateKey); @Override DockerTemplateOptions overrideLoginUser(String loginUser); @Override DockerTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override DockerTemplateOptions userMetadata(Map<String, String> userMetadata); @Override DockerTemplateOptions userMetadata(String key, String value); @Override DockerTemplateOptions nodeNames(Iterable<String> nodeNames); @Override DockerTemplateOptions networks(Iterable<String> networks); }
DockerTemplateOptions extends TemplateOptions implements Cloneable { public DockerTemplateOptions configBuilder(Config.Builder configBuilder) { this.configBuilder = configBuilder != null ? Config.builder().fromConfig(configBuilder.image(NO_IMAGE).build()) : null; return this; } @Override DockerTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); DockerTemplateOptions volumes(Map<String, String> volumes); DockerTemplateOptions dns(Iterable<String> dns); DockerTemplateOptions dns(String...dns); DockerTemplateOptions hostname(@Nullable String hostname); DockerTemplateOptions memory(@Nullable Integer memory); DockerTemplateOptions entrypoint(Iterable<String> entrypoint); DockerTemplateOptions entrypoint(String... entrypoint); DockerTemplateOptions commands(Iterable<String> commands); DockerTemplateOptions commands(String...commands); DockerTemplateOptions cpuShares(@Nullable Integer cpuShares); DockerTemplateOptions env(Iterable<String> env); DockerTemplateOptions env(String...env); DockerTemplateOptions portBindings(Map<Integer, Integer> portBindings); DockerTemplateOptions networkMode(@Nullable String networkMode); DockerTemplateOptions extraHosts(Map<String, String> extraHosts); DockerTemplateOptions volumesFrom(Iterable<String> volumesFrom); DockerTemplateOptions privileged(boolean privileged); DockerTemplateOptions openStdin(boolean openStdin); DockerTemplateOptions configBuilder(Config.Builder configBuilder); Map<String, String> getVolumes(); List<String> getDns(); List<String> getVolumesFrom(); String getHostname(); Integer getMemory(); List<String> getEntrypoint(); List<String> getCommands(); Integer getCpuShares(); List<String> getEnv(); Map<Integer, Integer> getPortBindings(); String getNetworkMode(); Map<String, String> getExtraHosts(); boolean getPrivileged(); boolean getOpenStdin(); Config.Builder getConfigBuilder(); @Override DockerTemplateOptions blockOnPort(int port, int seconds); @Override DockerTemplateOptions inboundPorts(int... ports); @Override DockerTemplateOptions authorizePublicKey(String publicKey); @Override DockerTemplateOptions installPrivateKey(String privateKey); @Override DockerTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override DockerTemplateOptions dontAuthorizePublicKey(); @Override DockerTemplateOptions nameTask(String name); @Override DockerTemplateOptions runAsRoot(boolean runAsRoot); @Override DockerTemplateOptions runScript(Statement script); @Override DockerTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override DockerTemplateOptions overrideLoginPassword(String password); @Override DockerTemplateOptions overrideLoginPrivateKey(String privateKey); @Override DockerTemplateOptions overrideLoginUser(String loginUser); @Override DockerTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override DockerTemplateOptions userMetadata(Map<String, String> userMetadata); @Override DockerTemplateOptions userMetadata(String key, String value); @Override DockerTemplateOptions nodeNames(Iterable<String> nodeNames); @Override DockerTemplateOptions networks(Iterable<String> networks); }
@Test public void testCopyTo() { DockerTemplateOptions options = DockerTemplateOptions.Builder .memory(512) .cpuShares(4) .entrypoint("entry", "point") .commands("test", "abc") .portBindings( ImmutableMap.<Integer, Integer> builder() .put(8443, 443).build()) .hostname("hostname") .networkMode("host") .userMetadata(ImmutableMap.of("key", "value")) .env(ImmutableList.of("HOST=abc", "PORT=1234")) .dns("8.8.8.8", "8.8.4.4") .volumes(ImmutableMap.of("/tmp", "/tmp")); DockerTemplateOptions optionsCopy = new DockerTemplateOptions(); options.copyTo(optionsCopy); assertEquals(optionsCopy, options); }
@Override public void copyTo(TemplateOptions to) { super.copyTo(to); if (to instanceof DockerTemplateOptions) { DockerTemplateOptions eTo = DockerTemplateOptions.class.cast(to); eTo.volumes(volumes); eTo.hostname(hostname); eTo.dns(dns); eTo.memory(memory); eTo.cpuShares(cpuShares); eTo.entrypoint(entrypoint); eTo.commands(commands); eTo.env(env); eTo.portBindings(portBindings); eTo.networkMode(networkMode); eTo.extraHosts(extraHosts); eTo.volumesFrom(volumesFrom); eTo.privileged(privileged); eTo.openStdin(openStdin); eTo.configBuilder(configBuilder); } }
DockerTemplateOptions extends TemplateOptions implements Cloneable { @Override public void copyTo(TemplateOptions to) { super.copyTo(to); if (to instanceof DockerTemplateOptions) { DockerTemplateOptions eTo = DockerTemplateOptions.class.cast(to); eTo.volumes(volumes); eTo.hostname(hostname); eTo.dns(dns); eTo.memory(memory); eTo.cpuShares(cpuShares); eTo.entrypoint(entrypoint); eTo.commands(commands); eTo.env(env); eTo.portBindings(portBindings); eTo.networkMode(networkMode); eTo.extraHosts(extraHosts); eTo.volumesFrom(volumesFrom); eTo.privileged(privileged); eTo.openStdin(openStdin); eTo.configBuilder(configBuilder); } } }
DockerTemplateOptions extends TemplateOptions implements Cloneable { @Override public void copyTo(TemplateOptions to) { super.copyTo(to); if (to instanceof DockerTemplateOptions) { DockerTemplateOptions eTo = DockerTemplateOptions.class.cast(to); eTo.volumes(volumes); eTo.hostname(hostname); eTo.dns(dns); eTo.memory(memory); eTo.cpuShares(cpuShares); eTo.entrypoint(entrypoint); eTo.commands(commands); eTo.env(env); eTo.portBindings(portBindings); eTo.networkMode(networkMode); eTo.extraHosts(extraHosts); eTo.volumesFrom(volumesFrom); eTo.privileged(privileged); eTo.openStdin(openStdin); eTo.configBuilder(configBuilder); } } }
DockerTemplateOptions extends TemplateOptions implements Cloneable { @Override public void copyTo(TemplateOptions to) { super.copyTo(to); if (to instanceof DockerTemplateOptions) { DockerTemplateOptions eTo = DockerTemplateOptions.class.cast(to); eTo.volumes(volumes); eTo.hostname(hostname); eTo.dns(dns); eTo.memory(memory); eTo.cpuShares(cpuShares); eTo.entrypoint(entrypoint); eTo.commands(commands); eTo.env(env); eTo.portBindings(portBindings); eTo.networkMode(networkMode); eTo.extraHosts(extraHosts); eTo.volumesFrom(volumesFrom); eTo.privileged(privileged); eTo.openStdin(openStdin); eTo.configBuilder(configBuilder); } } @Override DockerTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); DockerTemplateOptions volumes(Map<String, String> volumes); DockerTemplateOptions dns(Iterable<String> dns); DockerTemplateOptions dns(String...dns); DockerTemplateOptions hostname(@Nullable String hostname); DockerTemplateOptions memory(@Nullable Integer memory); DockerTemplateOptions entrypoint(Iterable<String> entrypoint); DockerTemplateOptions entrypoint(String... entrypoint); DockerTemplateOptions commands(Iterable<String> commands); DockerTemplateOptions commands(String...commands); DockerTemplateOptions cpuShares(@Nullable Integer cpuShares); DockerTemplateOptions env(Iterable<String> env); DockerTemplateOptions env(String...env); DockerTemplateOptions portBindings(Map<Integer, Integer> portBindings); DockerTemplateOptions networkMode(@Nullable String networkMode); DockerTemplateOptions extraHosts(Map<String, String> extraHosts); DockerTemplateOptions volumesFrom(Iterable<String> volumesFrom); DockerTemplateOptions privileged(boolean privileged); DockerTemplateOptions openStdin(boolean openStdin); DockerTemplateOptions configBuilder(Config.Builder configBuilder); Map<String, String> getVolumes(); List<String> getDns(); List<String> getVolumesFrom(); String getHostname(); Integer getMemory(); List<String> getEntrypoint(); List<String> getCommands(); Integer getCpuShares(); List<String> getEnv(); Map<Integer, Integer> getPortBindings(); String getNetworkMode(); Map<String, String> getExtraHosts(); boolean getPrivileged(); boolean getOpenStdin(); Config.Builder getConfigBuilder(); @Override DockerTemplateOptions blockOnPort(int port, int seconds); @Override DockerTemplateOptions inboundPorts(int... ports); @Override DockerTemplateOptions authorizePublicKey(String publicKey); @Override DockerTemplateOptions installPrivateKey(String privateKey); @Override DockerTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override DockerTemplateOptions dontAuthorizePublicKey(); @Override DockerTemplateOptions nameTask(String name); @Override DockerTemplateOptions runAsRoot(boolean runAsRoot); @Override DockerTemplateOptions runScript(Statement script); @Override DockerTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override DockerTemplateOptions overrideLoginPassword(String password); @Override DockerTemplateOptions overrideLoginPrivateKey(String privateKey); @Override DockerTemplateOptions overrideLoginUser(String loginUser); @Override DockerTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override DockerTemplateOptions userMetadata(Map<String, String> userMetadata); @Override DockerTemplateOptions userMetadata(String key, String value); @Override DockerTemplateOptions nodeNames(Iterable<String> nodeNames); @Override DockerTemplateOptions networks(Iterable<String> networks); }
DockerTemplateOptions extends TemplateOptions implements Cloneable { @Override public void copyTo(TemplateOptions to) { super.copyTo(to); if (to instanceof DockerTemplateOptions) { DockerTemplateOptions eTo = DockerTemplateOptions.class.cast(to); eTo.volumes(volumes); eTo.hostname(hostname); eTo.dns(dns); eTo.memory(memory); eTo.cpuShares(cpuShares); eTo.entrypoint(entrypoint); eTo.commands(commands); eTo.env(env); eTo.portBindings(portBindings); eTo.networkMode(networkMode); eTo.extraHosts(extraHosts); eTo.volumesFrom(volumesFrom); eTo.privileged(privileged); eTo.openStdin(openStdin); eTo.configBuilder(configBuilder); } } @Override DockerTemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); DockerTemplateOptions volumes(Map<String, String> volumes); DockerTemplateOptions dns(Iterable<String> dns); DockerTemplateOptions dns(String...dns); DockerTemplateOptions hostname(@Nullable String hostname); DockerTemplateOptions memory(@Nullable Integer memory); DockerTemplateOptions entrypoint(Iterable<String> entrypoint); DockerTemplateOptions entrypoint(String... entrypoint); DockerTemplateOptions commands(Iterable<String> commands); DockerTemplateOptions commands(String...commands); DockerTemplateOptions cpuShares(@Nullable Integer cpuShares); DockerTemplateOptions env(Iterable<String> env); DockerTemplateOptions env(String...env); DockerTemplateOptions portBindings(Map<Integer, Integer> portBindings); DockerTemplateOptions networkMode(@Nullable String networkMode); DockerTemplateOptions extraHosts(Map<String, String> extraHosts); DockerTemplateOptions volumesFrom(Iterable<String> volumesFrom); DockerTemplateOptions privileged(boolean privileged); DockerTemplateOptions openStdin(boolean openStdin); DockerTemplateOptions configBuilder(Config.Builder configBuilder); Map<String, String> getVolumes(); List<String> getDns(); List<String> getVolumesFrom(); String getHostname(); Integer getMemory(); List<String> getEntrypoint(); List<String> getCommands(); Integer getCpuShares(); List<String> getEnv(); Map<Integer, Integer> getPortBindings(); String getNetworkMode(); Map<String, String> getExtraHosts(); boolean getPrivileged(); boolean getOpenStdin(); Config.Builder getConfigBuilder(); @Override DockerTemplateOptions blockOnPort(int port, int seconds); @Override DockerTemplateOptions inboundPorts(int... ports); @Override DockerTemplateOptions authorizePublicKey(String publicKey); @Override DockerTemplateOptions installPrivateKey(String privateKey); @Override DockerTemplateOptions blockUntilRunning(boolean blockUntilRunning); @Override DockerTemplateOptions dontAuthorizePublicKey(); @Override DockerTemplateOptions nameTask(String name); @Override DockerTemplateOptions runAsRoot(boolean runAsRoot); @Override DockerTemplateOptions runScript(Statement script); @Override DockerTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override DockerTemplateOptions overrideLoginPassword(String password); @Override DockerTemplateOptions overrideLoginPrivateKey(String privateKey); @Override DockerTemplateOptions overrideLoginUser(String loginUser); @Override DockerTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); @Override DockerTemplateOptions userMetadata(Map<String, String> userMetadata); @Override DockerTemplateOptions userMetadata(String key, String value); @Override DockerTemplateOptions nodeNames(Iterable<String> nodeNames); @Override DockerTemplateOptions networks(Iterable<String> networks); }
@Test public void testImageToImage() { org.jclouds.profitbricks.domain.Image image = org.jclouds.profitbricks.domain.Image.builder() .isBootable(true) .isCpuHotPlug(true) .isCpuHotUnPlug(false) .isDiscVirtioHotPlug(true) .isDiscVirtioHotUnPlug(true) .id("5ad99c9e-9166-11e4-9d74-52540066fee9") .name("Ubuntu-14.04-LTS-server-2015-01-01") .size(2048f) .type(org.jclouds.profitbricks.domain.Image.Type.HDD) .location(US_LAS) .isNicHotPlug(true) .isNicHotUnPlug(true) .osType(OsType.LINUX) .isPublic(true) .isRamHotPlug(true) .isRamHotUnPlug(false) .isWriteable(true) .build(); Image actual = fnImage.apply(image); Image expected = new ImageBuilder() .ids(image.id()) .name(image.name()) .location(location) .status(Image.Status.AVAILABLE) .operatingSystem(OperatingSystem.builder() .description("UBUNTU") .family(OsFamily.UBUNTU) .version("14.04") .is64Bit(false) .build()) .userMetadata(ImmutableMap.of("provisionableType", "image")) .build(); assertEquals(actual, expected); }
@Override public Image apply(Provisionable input) { checkNotNull(input, "Cannot convert null input"); if (input instanceof org.jclouds.profitbricks.domain.Image) return fnImageToImage.apply((org.jclouds.profitbricks.domain.Image) input); else if (input instanceof Snapshot) return fnSnapshotToImage.apply((Snapshot) input); else throw new UnsupportedOperationException("No implementation found for provisionable of concrete type '" + input.getClass().getCanonicalName() + "'"); }
ProvisionableToImage implements Function<Provisionable, Image> { @Override public Image apply(Provisionable input) { checkNotNull(input, "Cannot convert null input"); if (input instanceof org.jclouds.profitbricks.domain.Image) return fnImageToImage.apply((org.jclouds.profitbricks.domain.Image) input); else if (input instanceof Snapshot) return fnSnapshotToImage.apply((Snapshot) input); else throw new UnsupportedOperationException("No implementation found for provisionable of concrete type '" + input.getClass().getCanonicalName() + "'"); } }
ProvisionableToImage implements Function<Provisionable, Image> { @Override public Image apply(Provisionable input) { checkNotNull(input, "Cannot convert null input"); if (input instanceof org.jclouds.profitbricks.domain.Image) return fnImageToImage.apply((org.jclouds.profitbricks.domain.Image) input); else if (input instanceof Snapshot) return fnSnapshotToImage.apply((Snapshot) input); else throw new UnsupportedOperationException("No implementation found for provisionable of concrete type '" + input.getClass().getCanonicalName() + "'"); } @Inject ProvisionableToImage(@Memoized Supplier<Set<? extends Location>> locations); }
ProvisionableToImage implements Function<Provisionable, Image> { @Override public Image apply(Provisionable input) { checkNotNull(input, "Cannot convert null input"); if (input instanceof org.jclouds.profitbricks.domain.Image) return fnImageToImage.apply((org.jclouds.profitbricks.domain.Image) input); else if (input instanceof Snapshot) return fnSnapshotToImage.apply((Snapshot) input); else throw new UnsupportedOperationException("No implementation found for provisionable of concrete type '" + input.getClass().getCanonicalName() + "'"); } @Inject ProvisionableToImage(@Memoized Supplier<Set<? extends Location>> locations); @Override Image apply(Provisionable input); }
ProvisionableToImage implements Function<Provisionable, Image> { @Override public Image apply(Provisionable input) { checkNotNull(input, "Cannot convert null input"); if (input instanceof org.jclouds.profitbricks.domain.Image) return fnImageToImage.apply((org.jclouds.profitbricks.domain.Image) input); else if (input instanceof Snapshot) return fnSnapshotToImage.apply((Snapshot) input); else throw new UnsupportedOperationException("No implementation found for provisionable of concrete type '" + input.getClass().getCanonicalName() + "'"); } @Inject ProvisionableToImage(@Memoized Supplier<Set<? extends Location>> locations); @Override Image apply(Provisionable input); static final String KEY_PROVISIONABLE_TYPE; }
@Test public void testVolumeType() { CreateVolumeOptions options = new CreateVolumeOptions(); options.volumeType("test"); assertEquals(options.buildFormParameters().get("VolumeType"), ImmutableList.of("test")); }
public CreateVolumeOptions volumeType(String volumeType) { formParameters.put("VolumeType", checkNotNull(volumeType, "volumeType")); return this; }
CreateVolumeOptions extends BaseEC2RequestOptions { public CreateVolumeOptions volumeType(String volumeType) { formParameters.put("VolumeType", checkNotNull(volumeType, "volumeType")); return this; } }
CreateVolumeOptions extends BaseEC2RequestOptions { public CreateVolumeOptions volumeType(String volumeType) { formParameters.put("VolumeType", checkNotNull(volumeType, "volumeType")); return this; } }
CreateVolumeOptions extends BaseEC2RequestOptions { public CreateVolumeOptions volumeType(String volumeType) { formParameters.put("VolumeType", checkNotNull(volumeType, "volumeType")); return this; } CreateVolumeOptions withSize(int size); int getSize(); CreateVolumeOptions fromSnapshotId(String snapshotId); String getSnapshotId(); CreateVolumeOptions volumeType(String volumeType); String getVolumeType(); CreateVolumeOptions withIops(Integer iops); Integer getIops(); CreateVolumeOptions isEncrypted(boolean encrypted); boolean getEncrypted(); }
CreateVolumeOptions extends BaseEC2RequestOptions { public CreateVolumeOptions volumeType(String volumeType) { formParameters.put("VolumeType", checkNotNull(volumeType, "volumeType")); return this; } CreateVolumeOptions withSize(int size); int getSize(); CreateVolumeOptions fromSnapshotId(String snapshotId); String getSnapshotId(); CreateVolumeOptions volumeType(String volumeType); String getVolumeType(); CreateVolumeOptions withIops(Integer iops); Integer getIops(); CreateVolumeOptions isEncrypted(boolean encrypted); boolean getEncrypted(); }
@Test public void testImageDescriptionParsing() { org.jclouds.profitbricks.domain.Image image1 = org.jclouds.profitbricks.domain.Image.builder() .id("f4742db0-9160-11e4-9d74-52540066fee9") .name("Fedora-19-server-2015-01-01") .size(2048f) .type(org.jclouds.profitbricks.domain.Image.Type.HDD) .location(US_LAS) .osType(OsType.LINUX) .build(); Image actual1 = fnImage.apply(image1); Image expected1 = new ImageBuilder() .ids(image1.id()) .name(image1.name()) .location(location) .status(Image.Status.AVAILABLE) .operatingSystem(OperatingSystem.builder() .description("FEDORA") .family(OsFamily.FEDORA) .version("7") .is64Bit(true) .build()) .userMetadata(ImmutableMap.of("provisionableType", "image")) .build(); assertEquals(actual1, expected1); org.jclouds.profitbricks.domain.Image image2 = org.jclouds.profitbricks.domain.Image.builder() .id("457bf707-d5d1-11e3-8b4f-52540066fee9") .name("clearos-community-6.5.0-x86_64.iso") .size(2048f) .type(org.jclouds.profitbricks.domain.Image.Type.CDROM) .location(US_LAS) .osType(OsType.LINUX) .build(); Image actual2 = fnImage.apply(image2); Image expected2 = new ImageBuilder() .ids(image2.id()) .name(image2.name()) .location(location) .status(Image.Status.AVAILABLE) .operatingSystem(OperatingSystem.builder() .description("UNRECOGNIZED") .family(OsFamily.UNRECOGNIZED) .version("6.5.0") .is64Bit(true) .build()) .userMetadata(ImmutableMap.of("provisionableType", "image")) .build(); assertEquals(actual2, expected2); org.jclouds.profitbricks.domain.Image image3 = org.jclouds.profitbricks.domain.Image.builder() .id("e54af701-53b8-11e3-8f17-52540066fee9") .name("windows-2008-r2-server-setup.iso") .size(2048f) .type(org.jclouds.profitbricks.domain.Image.Type.CDROM) .location(US_LAS) .osType(OsType.WINDOWS) .build(); Image actual3 = fnImage.apply(image3); Image expected3 = new ImageBuilder() .ids(image3.id()) .name(image3.name()) .location(location) .status(Image.Status.AVAILABLE) .operatingSystem(OperatingSystem.builder() .description("WINDOWS") .family(OsFamily.WINDOWS) .version("2008") .is64Bit(false) .build()) .userMetadata(ImmutableMap.of("provisionableType", "image")) .build(); assertEquals(actual3, expected3); }
@Override public Image apply(Provisionable input) { checkNotNull(input, "Cannot convert null input"); if (input instanceof org.jclouds.profitbricks.domain.Image) return fnImageToImage.apply((org.jclouds.profitbricks.domain.Image) input); else if (input instanceof Snapshot) return fnSnapshotToImage.apply((Snapshot) input); else throw new UnsupportedOperationException("No implementation found for provisionable of concrete type '" + input.getClass().getCanonicalName() + "'"); }
ProvisionableToImage implements Function<Provisionable, Image> { @Override public Image apply(Provisionable input) { checkNotNull(input, "Cannot convert null input"); if (input instanceof org.jclouds.profitbricks.domain.Image) return fnImageToImage.apply((org.jclouds.profitbricks.domain.Image) input); else if (input instanceof Snapshot) return fnSnapshotToImage.apply((Snapshot) input); else throw new UnsupportedOperationException("No implementation found for provisionable of concrete type '" + input.getClass().getCanonicalName() + "'"); } }
ProvisionableToImage implements Function<Provisionable, Image> { @Override public Image apply(Provisionable input) { checkNotNull(input, "Cannot convert null input"); if (input instanceof org.jclouds.profitbricks.domain.Image) return fnImageToImage.apply((org.jclouds.profitbricks.domain.Image) input); else if (input instanceof Snapshot) return fnSnapshotToImage.apply((Snapshot) input); else throw new UnsupportedOperationException("No implementation found for provisionable of concrete type '" + input.getClass().getCanonicalName() + "'"); } @Inject ProvisionableToImage(@Memoized Supplier<Set<? extends Location>> locations); }
ProvisionableToImage implements Function<Provisionable, Image> { @Override public Image apply(Provisionable input) { checkNotNull(input, "Cannot convert null input"); if (input instanceof org.jclouds.profitbricks.domain.Image) return fnImageToImage.apply((org.jclouds.profitbricks.domain.Image) input); else if (input instanceof Snapshot) return fnSnapshotToImage.apply((Snapshot) input); else throw new UnsupportedOperationException("No implementation found for provisionable of concrete type '" + input.getClass().getCanonicalName() + "'"); } @Inject ProvisionableToImage(@Memoized Supplier<Set<? extends Location>> locations); @Override Image apply(Provisionable input); }
ProvisionableToImage implements Function<Provisionable, Image> { @Override public Image apply(Provisionable input) { checkNotNull(input, "Cannot convert null input"); if (input instanceof org.jclouds.profitbricks.domain.Image) return fnImageToImage.apply((org.jclouds.profitbricks.domain.Image) input); else if (input instanceof Snapshot) return fnSnapshotToImage.apply((Snapshot) input); else throw new UnsupportedOperationException("No implementation found for provisionable of concrete type '" + input.getClass().getCanonicalName() + "'"); } @Inject ProvisionableToImage(@Memoized Supplier<Set<? extends Location>> locations); @Override Image apply(Provisionable input); static final String KEY_PROVISIONABLE_TYPE; }
@Test public void testVolumeTypeStatic() { CreateVolumeOptions options = volumeType("test"); assertEquals(options.buildFormParameters().get("VolumeType"), ImmutableList.of("test")); }
public CreateVolumeOptions volumeType(String volumeType) { formParameters.put("VolumeType", checkNotNull(volumeType, "volumeType")); return this; }
CreateVolumeOptions extends BaseEC2RequestOptions { public CreateVolumeOptions volumeType(String volumeType) { formParameters.put("VolumeType", checkNotNull(volumeType, "volumeType")); return this; } }
CreateVolumeOptions extends BaseEC2RequestOptions { public CreateVolumeOptions volumeType(String volumeType) { formParameters.put("VolumeType", checkNotNull(volumeType, "volumeType")); return this; } }
CreateVolumeOptions extends BaseEC2RequestOptions { public CreateVolumeOptions volumeType(String volumeType) { formParameters.put("VolumeType", checkNotNull(volumeType, "volumeType")); return this; } CreateVolumeOptions withSize(int size); int getSize(); CreateVolumeOptions fromSnapshotId(String snapshotId); String getSnapshotId(); CreateVolumeOptions volumeType(String volumeType); String getVolumeType(); CreateVolumeOptions withIops(Integer iops); Integer getIops(); CreateVolumeOptions isEncrypted(boolean encrypted); boolean getEncrypted(); }
CreateVolumeOptions extends BaseEC2RequestOptions { public CreateVolumeOptions volumeType(String volumeType) { formParameters.put("VolumeType", checkNotNull(volumeType, "volumeType")); return this; } CreateVolumeOptions withSize(int size); int getSize(); CreateVolumeOptions fromSnapshotId(String snapshotId); String getSnapshotId(); CreateVolumeOptions volumeType(String volumeType); String getVolumeType(); CreateVolumeOptions withIops(Integer iops); Integer getIops(); CreateVolumeOptions isEncrypted(boolean encrypted); boolean getEncrypted(); }
@Test(expectedExceptions = NullPointerException.class) public void testVolmeTypeNPE() { volumeType(null); }
public CreateVolumeOptions volumeType(String volumeType) { formParameters.put("VolumeType", checkNotNull(volumeType, "volumeType")); return this; }
CreateVolumeOptions extends BaseEC2RequestOptions { public CreateVolumeOptions volumeType(String volumeType) { formParameters.put("VolumeType", checkNotNull(volumeType, "volumeType")); return this; } }
CreateVolumeOptions extends BaseEC2RequestOptions { public CreateVolumeOptions volumeType(String volumeType) { formParameters.put("VolumeType", checkNotNull(volumeType, "volumeType")); return this; } }
CreateVolumeOptions extends BaseEC2RequestOptions { public CreateVolumeOptions volumeType(String volumeType) { formParameters.put("VolumeType", checkNotNull(volumeType, "volumeType")); return this; } CreateVolumeOptions withSize(int size); int getSize(); CreateVolumeOptions fromSnapshotId(String snapshotId); String getSnapshotId(); CreateVolumeOptions volumeType(String volumeType); String getVolumeType(); CreateVolumeOptions withIops(Integer iops); Integer getIops(); CreateVolumeOptions isEncrypted(boolean encrypted); boolean getEncrypted(); }
CreateVolumeOptions extends BaseEC2RequestOptions { public CreateVolumeOptions volumeType(String volumeType) { formParameters.put("VolumeType", checkNotNull(volumeType, "volumeType")); return this; } CreateVolumeOptions withSize(int size); int getSize(); CreateVolumeOptions fromSnapshotId(String snapshotId); String getSnapshotId(); CreateVolumeOptions volumeType(String volumeType); String getVolumeType(); CreateVolumeOptions withIops(Integer iops); Integer getIops(); CreateVolumeOptions isEncrypted(boolean encrypted); boolean getEncrypted(); }
@Test public void testFromSnapshotId() { CreateVolumeOptions options = new CreateVolumeOptions(); options.fromSnapshotId("test"); assertEquals(options.buildFormParameters().get("SnapshotId"), ImmutableList.of("test")); }
public CreateVolumeOptions fromSnapshotId(String snapshotId) { formParameters.put("SnapshotId", checkNotNull(snapshotId, "snapshotId")); return this; }
CreateVolumeOptions extends BaseEC2RequestOptions { public CreateVolumeOptions fromSnapshotId(String snapshotId) { formParameters.put("SnapshotId", checkNotNull(snapshotId, "snapshotId")); return this; } }
CreateVolumeOptions extends BaseEC2RequestOptions { public CreateVolumeOptions fromSnapshotId(String snapshotId) { formParameters.put("SnapshotId", checkNotNull(snapshotId, "snapshotId")); return this; } }
CreateVolumeOptions extends BaseEC2RequestOptions { public CreateVolumeOptions fromSnapshotId(String snapshotId) { formParameters.put("SnapshotId", checkNotNull(snapshotId, "snapshotId")); return this; } CreateVolumeOptions withSize(int size); int getSize(); CreateVolumeOptions fromSnapshotId(String snapshotId); String getSnapshotId(); CreateVolumeOptions volumeType(String volumeType); String getVolumeType(); CreateVolumeOptions withIops(Integer iops); Integer getIops(); CreateVolumeOptions isEncrypted(boolean encrypted); boolean getEncrypted(); }
CreateVolumeOptions extends BaseEC2RequestOptions { public CreateVolumeOptions fromSnapshotId(String snapshotId) { formParameters.put("SnapshotId", checkNotNull(snapshotId, "snapshotId")); return this; } CreateVolumeOptions withSize(int size); int getSize(); CreateVolumeOptions fromSnapshotId(String snapshotId); String getSnapshotId(); CreateVolumeOptions volumeType(String volumeType); String getVolumeType(); CreateVolumeOptions withIops(Integer iops); Integer getIops(); CreateVolumeOptions isEncrypted(boolean encrypted); boolean getEncrypted(); }
@Test public void testWithSnapshotIdStatic() { CreateVolumeOptions options = fromSnapshotId("test"); assertEquals(options.buildFormParameters().get("SnapshotId"), ImmutableList.of("test")); }
public CreateVolumeOptions fromSnapshotId(String snapshotId) { formParameters.put("SnapshotId", checkNotNull(snapshotId, "snapshotId")); return this; }
CreateVolumeOptions extends BaseEC2RequestOptions { public CreateVolumeOptions fromSnapshotId(String snapshotId) { formParameters.put("SnapshotId", checkNotNull(snapshotId, "snapshotId")); return this; } }
CreateVolumeOptions extends BaseEC2RequestOptions { public CreateVolumeOptions fromSnapshotId(String snapshotId) { formParameters.put("SnapshotId", checkNotNull(snapshotId, "snapshotId")); return this; } }
CreateVolumeOptions extends BaseEC2RequestOptions { public CreateVolumeOptions fromSnapshotId(String snapshotId) { formParameters.put("SnapshotId", checkNotNull(snapshotId, "snapshotId")); return this; } CreateVolumeOptions withSize(int size); int getSize(); CreateVolumeOptions fromSnapshotId(String snapshotId); String getSnapshotId(); CreateVolumeOptions volumeType(String volumeType); String getVolumeType(); CreateVolumeOptions withIops(Integer iops); Integer getIops(); CreateVolumeOptions isEncrypted(boolean encrypted); boolean getEncrypted(); }
CreateVolumeOptions extends BaseEC2RequestOptions { public CreateVolumeOptions fromSnapshotId(String snapshotId) { formParameters.put("SnapshotId", checkNotNull(snapshotId, "snapshotId")); return this; } CreateVolumeOptions withSize(int size); int getSize(); CreateVolumeOptions fromSnapshotId(String snapshotId); String getSnapshotId(); CreateVolumeOptions volumeType(String volumeType); String getVolumeType(); CreateVolumeOptions withIops(Integer iops); Integer getIops(); CreateVolumeOptions isEncrypted(boolean encrypted); boolean getEncrypted(); }
@Test(expectedExceptions = NullPointerException.class) public void testFromSnapshotIdNPE() { fromSnapshotId(null); }
public CreateVolumeOptions fromSnapshotId(String snapshotId) { formParameters.put("SnapshotId", checkNotNull(snapshotId, "snapshotId")); return this; }
CreateVolumeOptions extends BaseEC2RequestOptions { public CreateVolumeOptions fromSnapshotId(String snapshotId) { formParameters.put("SnapshotId", checkNotNull(snapshotId, "snapshotId")); return this; } }
CreateVolumeOptions extends BaseEC2RequestOptions { public CreateVolumeOptions fromSnapshotId(String snapshotId) { formParameters.put("SnapshotId", checkNotNull(snapshotId, "snapshotId")); return this; } }
CreateVolumeOptions extends BaseEC2RequestOptions { public CreateVolumeOptions fromSnapshotId(String snapshotId) { formParameters.put("SnapshotId", checkNotNull(snapshotId, "snapshotId")); return this; } CreateVolumeOptions withSize(int size); int getSize(); CreateVolumeOptions fromSnapshotId(String snapshotId); String getSnapshotId(); CreateVolumeOptions volumeType(String volumeType); String getVolumeType(); CreateVolumeOptions withIops(Integer iops); Integer getIops(); CreateVolumeOptions isEncrypted(boolean encrypted); boolean getEncrypted(); }
CreateVolumeOptions extends BaseEC2RequestOptions { public CreateVolumeOptions fromSnapshotId(String snapshotId) { formParameters.put("SnapshotId", checkNotNull(snapshotId, "snapshotId")); return this; } CreateVolumeOptions withSize(int size); int getSize(); CreateVolumeOptions fromSnapshotId(String snapshotId); String getSnapshotId(); CreateVolumeOptions volumeType(String volumeType); String getVolumeType(); CreateVolumeOptions withIops(Integer iops); Integer getIops(); CreateVolumeOptions isEncrypted(boolean encrypted); boolean getEncrypted(); }
@Test public void testWithIops() { CreateVolumeOptions options = new CreateVolumeOptions(); options.withIops(5); assertEquals(options.buildFormParameters().get("Iops"), ImmutableList.of("5")); }
public CreateVolumeOptions withIops(Integer iops) { formParameters.put("Iops", checkNotNull(iops, "iops").toString()); return this; }
CreateVolumeOptions extends BaseEC2RequestOptions { public CreateVolumeOptions withIops(Integer iops) { formParameters.put("Iops", checkNotNull(iops, "iops").toString()); return this; } }
CreateVolumeOptions extends BaseEC2RequestOptions { public CreateVolumeOptions withIops(Integer iops) { formParameters.put("Iops", checkNotNull(iops, "iops").toString()); return this; } }
CreateVolumeOptions extends BaseEC2RequestOptions { public CreateVolumeOptions withIops(Integer iops) { formParameters.put("Iops", checkNotNull(iops, "iops").toString()); return this; } CreateVolumeOptions withSize(int size); int getSize(); CreateVolumeOptions fromSnapshotId(String snapshotId); String getSnapshotId(); CreateVolumeOptions volumeType(String volumeType); String getVolumeType(); CreateVolumeOptions withIops(Integer iops); Integer getIops(); CreateVolumeOptions isEncrypted(boolean encrypted); boolean getEncrypted(); }
CreateVolumeOptions extends BaseEC2RequestOptions { public CreateVolumeOptions withIops(Integer iops) { formParameters.put("Iops", checkNotNull(iops, "iops").toString()); return this; } CreateVolumeOptions withSize(int size); int getSize(); CreateVolumeOptions fromSnapshotId(String snapshotId); String getSnapshotId(); CreateVolumeOptions volumeType(String volumeType); String getVolumeType(); CreateVolumeOptions withIops(Integer iops); Integer getIops(); CreateVolumeOptions isEncrypted(boolean encrypted); boolean getEncrypted(); }
@Test public void testWithIopsStatic() { CreateVolumeOptions options = withIops(5); assertEquals(options.buildFormParameters().get("Iops"), ImmutableList.of("5")); }
public CreateVolumeOptions withIops(Integer iops) { formParameters.put("Iops", checkNotNull(iops, "iops").toString()); return this; }
CreateVolumeOptions extends BaseEC2RequestOptions { public CreateVolumeOptions withIops(Integer iops) { formParameters.put("Iops", checkNotNull(iops, "iops").toString()); return this; } }
CreateVolumeOptions extends BaseEC2RequestOptions { public CreateVolumeOptions withIops(Integer iops) { formParameters.put("Iops", checkNotNull(iops, "iops").toString()); return this; } }
CreateVolumeOptions extends BaseEC2RequestOptions { public CreateVolumeOptions withIops(Integer iops) { formParameters.put("Iops", checkNotNull(iops, "iops").toString()); return this; } CreateVolumeOptions withSize(int size); int getSize(); CreateVolumeOptions fromSnapshotId(String snapshotId); String getSnapshotId(); CreateVolumeOptions volumeType(String volumeType); String getVolumeType(); CreateVolumeOptions withIops(Integer iops); Integer getIops(); CreateVolumeOptions isEncrypted(boolean encrypted); boolean getEncrypted(); }
CreateVolumeOptions extends BaseEC2RequestOptions { public CreateVolumeOptions withIops(Integer iops) { formParameters.put("Iops", checkNotNull(iops, "iops").toString()); return this; } CreateVolumeOptions withSize(int size); int getSize(); CreateVolumeOptions fromSnapshotId(String snapshotId); String getSnapshotId(); CreateVolumeOptions volumeType(String volumeType); String getVolumeType(); CreateVolumeOptions withIops(Integer iops); Integer getIops(); CreateVolumeOptions isEncrypted(boolean encrypted); boolean getEncrypted(); }
@Test public void testWithSize() { CreateVolumeOptions options = new CreateVolumeOptions(); options.withSize(5); assertEquals(options.buildFormParameters().get("Size"), ImmutableList.of("5")); }
public CreateVolumeOptions withSize(int size) { formParameters.put("Size", Integer.toString(size)); return this; }
CreateVolumeOptions extends BaseEC2RequestOptions { public CreateVolumeOptions withSize(int size) { formParameters.put("Size", Integer.toString(size)); return this; } }
CreateVolumeOptions extends BaseEC2RequestOptions { public CreateVolumeOptions withSize(int size) { formParameters.put("Size", Integer.toString(size)); return this; } }
CreateVolumeOptions extends BaseEC2RequestOptions { public CreateVolumeOptions withSize(int size) { formParameters.put("Size", Integer.toString(size)); return this; } CreateVolumeOptions withSize(int size); int getSize(); CreateVolumeOptions fromSnapshotId(String snapshotId); String getSnapshotId(); CreateVolumeOptions volumeType(String volumeType); String getVolumeType(); CreateVolumeOptions withIops(Integer iops); Integer getIops(); CreateVolumeOptions isEncrypted(boolean encrypted); boolean getEncrypted(); }
CreateVolumeOptions extends BaseEC2RequestOptions { public CreateVolumeOptions withSize(int size) { formParameters.put("Size", Integer.toString(size)); return this; } CreateVolumeOptions withSize(int size); int getSize(); CreateVolumeOptions fromSnapshotId(String snapshotId); String getSnapshotId(); CreateVolumeOptions volumeType(String volumeType); String getVolumeType(); CreateVolumeOptions withIops(Integer iops); Integer getIops(); CreateVolumeOptions isEncrypted(boolean encrypted); boolean getEncrypted(); }
@Test public void testWithSizeStatic() { CreateVolumeOptions options = withSize(5); assertEquals(options.buildFormParameters().get("Size"), ImmutableList.of("5")); }
public CreateVolumeOptions withSize(int size) { formParameters.put("Size", Integer.toString(size)); return this; }
CreateVolumeOptions extends BaseEC2RequestOptions { public CreateVolumeOptions withSize(int size) { formParameters.put("Size", Integer.toString(size)); return this; } }
CreateVolumeOptions extends BaseEC2RequestOptions { public CreateVolumeOptions withSize(int size) { formParameters.put("Size", Integer.toString(size)); return this; } }
CreateVolumeOptions extends BaseEC2RequestOptions { public CreateVolumeOptions withSize(int size) { formParameters.put("Size", Integer.toString(size)); return this; } CreateVolumeOptions withSize(int size); int getSize(); CreateVolumeOptions fromSnapshotId(String snapshotId); String getSnapshotId(); CreateVolumeOptions volumeType(String volumeType); String getVolumeType(); CreateVolumeOptions withIops(Integer iops); Integer getIops(); CreateVolumeOptions isEncrypted(boolean encrypted); boolean getEncrypted(); }
CreateVolumeOptions extends BaseEC2RequestOptions { public CreateVolumeOptions withSize(int size) { formParameters.put("Size", Integer.toString(size)); return this; } CreateVolumeOptions withSize(int size); int getSize(); CreateVolumeOptions fromSnapshotId(String snapshotId); String getSnapshotId(); CreateVolumeOptions volumeType(String volumeType); String getVolumeType(); CreateVolumeOptions withIops(Integer iops); Integer getIops(); CreateVolumeOptions isEncrypted(boolean encrypted); boolean getEncrypted(); }
@Test public void testIsEncrypted() { CreateVolumeOptions options = new CreateVolumeOptions(); options.isEncrypted(true); assertEquals(options.buildFormParameters().get("Encrypted"), ImmutableList.of("true")); }
public CreateVolumeOptions isEncrypted(boolean encrypted) { if (encrypted) formParameters.put("Encrypted", "true"); return this; }
CreateVolumeOptions extends BaseEC2RequestOptions { public CreateVolumeOptions isEncrypted(boolean encrypted) { if (encrypted) formParameters.put("Encrypted", "true"); return this; } }
CreateVolumeOptions extends BaseEC2RequestOptions { public CreateVolumeOptions isEncrypted(boolean encrypted) { if (encrypted) formParameters.put("Encrypted", "true"); return this; } }
CreateVolumeOptions extends BaseEC2RequestOptions { public CreateVolumeOptions isEncrypted(boolean encrypted) { if (encrypted) formParameters.put("Encrypted", "true"); return this; } CreateVolumeOptions withSize(int size); int getSize(); CreateVolumeOptions fromSnapshotId(String snapshotId); String getSnapshotId(); CreateVolumeOptions volumeType(String volumeType); String getVolumeType(); CreateVolumeOptions withIops(Integer iops); Integer getIops(); CreateVolumeOptions isEncrypted(boolean encrypted); boolean getEncrypted(); }
CreateVolumeOptions extends BaseEC2RequestOptions { public CreateVolumeOptions isEncrypted(boolean encrypted) { if (encrypted) formParameters.put("Encrypted", "true"); return this; } CreateVolumeOptions withSize(int size); int getSize(); CreateVolumeOptions fromSnapshotId(String snapshotId); String getSnapshotId(); CreateVolumeOptions volumeType(String volumeType); String getVolumeType(); CreateVolumeOptions withIops(Integer iops); Integer getIops(); CreateVolumeOptions isEncrypted(boolean encrypted); boolean getEncrypted(); }
@Test public void testSnapshotToImage() { Calendar calendar = Calendar.getInstance(); calendar.set(2015, 4, 13); Date date = calendar.getTime(); Snapshot snapshot1 = Snapshot.builder() .isBootable(true) .isCpuHotPlug(true) .isCpuHotUnPlug(false) .isDiscVirtioHotPlug(true) .isDiscVirtioHotUnPlug(true) .id("qswdefrg-qaws-qaws-defe-rgrgdsvcxbrh") .name("placeholder-snapshot-04/13/2015") .description("Created from \"placeholder\" in Data Center \"sbx-computeservice\"") .size(2048f) .location(US_LAS) .isNicHotPlug(true) .isNicHotUnPlug(true) .osType(OsType.LINUX) .isRamHotPlug(true) .isRamHotUnPlug(false) .creationTime(date) .lastModificationTime(new Date()) .state(ProvisioningState.AVAILABLE) .build(); Image actual1 = fnImage.apply(snapshot1); Image expected1 = new ImageBuilder() .ids(snapshot1.id()) .name(snapshot1.name()) .location(location) .status(Image.Status.AVAILABLE) .operatingSystem(OperatingSystem.builder() .description(snapshot1.description()) .family(OsFamily.LINUX) .is64Bit(true) .build()) .userMetadata(ImmutableMap.of("provisionableType", "snapshot")) .build(); assertEquals(actual1, expected1); Snapshot snapshot2 = Snapshot.builder() .isBootable(true) .isCpuHotPlug(true) .isCpuHotUnPlug(false) .isDiscVirtioHotPlug(true) .isDiscVirtioHotUnPlug(true) .id("d80bf9c0-ce6e-4283-9ea4-2906635f6137") .name("jclouds-ubuntu14.10-template") .description("Created from \"jclouds-ubuntu14.10 Storage\" in Data Center \"jclouds-computeservice\"") .size(10240f) .location(US_LAS) .isNicHotPlug(true) .isNicHotUnPlug(true) .osType(OsType.LINUX) .isRamHotPlug(true) .isRamHotUnPlug(false) .creationTime(date) .lastModificationTime(new Date()) .state(ProvisioningState.INPROCESS) .build(); Image actual2 = fnImage.apply(snapshot2); Image expected2 = new ImageBuilder() .ids(snapshot2.id()) .name(snapshot2.name()) .location(location) .status(Image.Status.PENDING) .operatingSystem(OperatingSystem.builder() .description("ubuntu") .family(OsFamily.UBUNTU) .is64Bit(true) .version("00.00") .build()) .userMetadata(ImmutableMap.of("provisionableType", "snapshot")) .build(); assertEquals(actual2, expected2); assertEquals(actual2.getOperatingSystem(), expected2.getOperatingSystem()); }
@Override public Image apply(Provisionable input) { checkNotNull(input, "Cannot convert null input"); if (input instanceof org.jclouds.profitbricks.domain.Image) return fnImageToImage.apply((org.jclouds.profitbricks.domain.Image) input); else if (input instanceof Snapshot) return fnSnapshotToImage.apply((Snapshot) input); else throw new UnsupportedOperationException("No implementation found for provisionable of concrete type '" + input.getClass().getCanonicalName() + "'"); }
ProvisionableToImage implements Function<Provisionable, Image> { @Override public Image apply(Provisionable input) { checkNotNull(input, "Cannot convert null input"); if (input instanceof org.jclouds.profitbricks.domain.Image) return fnImageToImage.apply((org.jclouds.profitbricks.domain.Image) input); else if (input instanceof Snapshot) return fnSnapshotToImage.apply((Snapshot) input); else throw new UnsupportedOperationException("No implementation found for provisionable of concrete type '" + input.getClass().getCanonicalName() + "'"); } }
ProvisionableToImage implements Function<Provisionable, Image> { @Override public Image apply(Provisionable input) { checkNotNull(input, "Cannot convert null input"); if (input instanceof org.jclouds.profitbricks.domain.Image) return fnImageToImage.apply((org.jclouds.profitbricks.domain.Image) input); else if (input instanceof Snapshot) return fnSnapshotToImage.apply((Snapshot) input); else throw new UnsupportedOperationException("No implementation found for provisionable of concrete type '" + input.getClass().getCanonicalName() + "'"); } @Inject ProvisionableToImage(@Memoized Supplier<Set<? extends Location>> locations); }
ProvisionableToImage implements Function<Provisionable, Image> { @Override public Image apply(Provisionable input) { checkNotNull(input, "Cannot convert null input"); if (input instanceof org.jclouds.profitbricks.domain.Image) return fnImageToImage.apply((org.jclouds.profitbricks.domain.Image) input); else if (input instanceof Snapshot) return fnSnapshotToImage.apply((Snapshot) input); else throw new UnsupportedOperationException("No implementation found for provisionable of concrete type '" + input.getClass().getCanonicalName() + "'"); } @Inject ProvisionableToImage(@Memoized Supplier<Set<? extends Location>> locations); @Override Image apply(Provisionable input); }
ProvisionableToImage implements Function<Provisionable, Image> { @Override public Image apply(Provisionable input) { checkNotNull(input, "Cannot convert null input"); if (input instanceof org.jclouds.profitbricks.domain.Image) return fnImageToImage.apply((org.jclouds.profitbricks.domain.Image) input); else if (input instanceof Snapshot) return fnSnapshotToImage.apply((Snapshot) input); else throw new UnsupportedOperationException("No implementation found for provisionable of concrete type '" + input.getClass().getCanonicalName() + "'"); } @Inject ProvisionableToImage(@Memoized Supplier<Set<? extends Location>> locations); @Override Image apply(Provisionable input); static final String KEY_PROVISIONABLE_TYPE; }
@Test public void testIsEncryptedStatic() { CreateVolumeOptions options = isEncrypted(true); assertEquals(options.buildFormParameters().get("Encrypted"), ImmutableList.of("true")); }
public CreateVolumeOptions isEncrypted(boolean encrypted) { if (encrypted) formParameters.put("Encrypted", "true"); return this; }
CreateVolumeOptions extends BaseEC2RequestOptions { public CreateVolumeOptions isEncrypted(boolean encrypted) { if (encrypted) formParameters.put("Encrypted", "true"); return this; } }
CreateVolumeOptions extends BaseEC2RequestOptions { public CreateVolumeOptions isEncrypted(boolean encrypted) { if (encrypted) formParameters.put("Encrypted", "true"); return this; } }
CreateVolumeOptions extends BaseEC2RequestOptions { public CreateVolumeOptions isEncrypted(boolean encrypted) { if (encrypted) formParameters.put("Encrypted", "true"); return this; } CreateVolumeOptions withSize(int size); int getSize(); CreateVolumeOptions fromSnapshotId(String snapshotId); String getSnapshotId(); CreateVolumeOptions volumeType(String volumeType); String getVolumeType(); CreateVolumeOptions withIops(Integer iops); Integer getIops(); CreateVolumeOptions isEncrypted(boolean encrypted); boolean getEncrypted(); }
CreateVolumeOptions extends BaseEC2RequestOptions { public CreateVolumeOptions isEncrypted(boolean encrypted) { if (encrypted) formParameters.put("Encrypted", "true"); return this; } CreateVolumeOptions withSize(int size); int getSize(); CreateVolumeOptions fromSnapshotId(String snapshotId); String getSnapshotId(); CreateVolumeOptions volumeType(String volumeType); String getVolumeType(); CreateVolumeOptions withIops(Integer iops); Integer getIops(); CreateVolumeOptions isEncrypted(boolean encrypted); boolean getEncrypted(); }
@Test public void testWithKeyName() { RunInstancesOptions options = new RunInstancesOptions(); options.withKeyName("test"); assertEquals(options.buildFormParameters().get("KeyName"), ImmutableList.of("test")); }
public RunInstancesOptions withKeyName(String keyName) { formParameters.put("KeyName", checkNotNull(keyName, "keyName")); return this; }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withKeyName(String keyName) { formParameters.put("KeyName", checkNotNull(keyName, "keyName")); return this; } }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withKeyName(String keyName) { formParameters.put("KeyName", checkNotNull(keyName, "keyName")); return this; } }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withKeyName(String keyName) { formParameters.put("KeyName", checkNotNull(keyName, "keyName")); return this; } RunInstancesOptions withKeyName(String keyName); RunInstancesOptions withSecurityGroups(String... securityGroups); RunInstancesOptions withSecurityGroups(Iterable<String> securityGroups); RunInstancesOptions withSecurityGroup(String securityGroup); RunInstancesOptions withUserData(byte[] unencodedData); RunInstancesOptions asType(String type); RunInstancesOptions withKernelId(String kernelId); RunInstancesOptions withRamdisk(String ramDiskId); RunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings); RunInstancesOptions withClientToken(String clientToken); }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withKeyName(String keyName) { formParameters.put("KeyName", checkNotNull(keyName, "keyName")); return this; } RunInstancesOptions withKeyName(String keyName); RunInstancesOptions withSecurityGroups(String... securityGroups); RunInstancesOptions withSecurityGroups(Iterable<String> securityGroups); RunInstancesOptions withSecurityGroup(String securityGroup); RunInstancesOptions withUserData(byte[] unencodedData); RunInstancesOptions asType(String type); RunInstancesOptions withKernelId(String kernelId); RunInstancesOptions withRamdisk(String ramDiskId); RunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings); RunInstancesOptions withClientToken(String clientToken); static final RunInstancesOptions NONE; }
@Test public void testWithKeyNameStatic() { RunInstancesOptions options = withKeyName("test"); assertEquals(options.buildFormParameters().get("KeyName"), ImmutableList.of("test")); }
public RunInstancesOptions withKeyName(String keyName) { formParameters.put("KeyName", checkNotNull(keyName, "keyName")); return this; }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withKeyName(String keyName) { formParameters.put("KeyName", checkNotNull(keyName, "keyName")); return this; } }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withKeyName(String keyName) { formParameters.put("KeyName", checkNotNull(keyName, "keyName")); return this; } }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withKeyName(String keyName) { formParameters.put("KeyName", checkNotNull(keyName, "keyName")); return this; } RunInstancesOptions withKeyName(String keyName); RunInstancesOptions withSecurityGroups(String... securityGroups); RunInstancesOptions withSecurityGroups(Iterable<String> securityGroups); RunInstancesOptions withSecurityGroup(String securityGroup); RunInstancesOptions withUserData(byte[] unencodedData); RunInstancesOptions asType(String type); RunInstancesOptions withKernelId(String kernelId); RunInstancesOptions withRamdisk(String ramDiskId); RunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings); RunInstancesOptions withClientToken(String clientToken); }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withKeyName(String keyName) { formParameters.put("KeyName", checkNotNull(keyName, "keyName")); return this; } RunInstancesOptions withKeyName(String keyName); RunInstancesOptions withSecurityGroups(String... securityGroups); RunInstancesOptions withSecurityGroups(Iterable<String> securityGroups); RunInstancesOptions withSecurityGroup(String securityGroup); RunInstancesOptions withUserData(byte[] unencodedData); RunInstancesOptions asType(String type); RunInstancesOptions withKernelId(String kernelId); RunInstancesOptions withRamdisk(String ramDiskId); RunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings); RunInstancesOptions withClientToken(String clientToken); static final RunInstancesOptions NONE; }
@Test(expectedExceptions = NullPointerException.class) public void testWithKeyNameNPE() { withKeyName(null); }
public RunInstancesOptions withKeyName(String keyName) { formParameters.put("KeyName", checkNotNull(keyName, "keyName")); return this; }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withKeyName(String keyName) { formParameters.put("KeyName", checkNotNull(keyName, "keyName")); return this; } }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withKeyName(String keyName) { formParameters.put("KeyName", checkNotNull(keyName, "keyName")); return this; } }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withKeyName(String keyName) { formParameters.put("KeyName", checkNotNull(keyName, "keyName")); return this; } RunInstancesOptions withKeyName(String keyName); RunInstancesOptions withSecurityGroups(String... securityGroups); RunInstancesOptions withSecurityGroups(Iterable<String> securityGroups); RunInstancesOptions withSecurityGroup(String securityGroup); RunInstancesOptions withUserData(byte[] unencodedData); RunInstancesOptions asType(String type); RunInstancesOptions withKernelId(String kernelId); RunInstancesOptions withRamdisk(String ramDiskId); RunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings); RunInstancesOptions withClientToken(String clientToken); }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withKeyName(String keyName) { formParameters.put("KeyName", checkNotNull(keyName, "keyName")); return this; } RunInstancesOptions withKeyName(String keyName); RunInstancesOptions withSecurityGroups(String... securityGroups); RunInstancesOptions withSecurityGroups(Iterable<String> securityGroups); RunInstancesOptions withSecurityGroup(String securityGroup); RunInstancesOptions withUserData(byte[] unencodedData); RunInstancesOptions asType(String type); RunInstancesOptions withKernelId(String kernelId); RunInstancesOptions withRamdisk(String ramDiskId); RunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings); RunInstancesOptions withClientToken(String clientToken); static final RunInstancesOptions NONE; }
@Test public void testWithSecurityGroup() { RunInstancesOptions options = new RunInstancesOptions(); options.withSecurityGroup("test"); assertEquals(options.buildFormParameters().get("SecurityGroup.1"), ImmutableList.of("test")); }
public RunInstancesOptions withSecurityGroup(String securityGroup) { return withSecurityGroups(securityGroup); }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withSecurityGroup(String securityGroup) { return withSecurityGroups(securityGroup); } }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withSecurityGroup(String securityGroup) { return withSecurityGroups(securityGroup); } }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withSecurityGroup(String securityGroup) { return withSecurityGroups(securityGroup); } RunInstancesOptions withKeyName(String keyName); RunInstancesOptions withSecurityGroups(String... securityGroups); RunInstancesOptions withSecurityGroups(Iterable<String> securityGroups); RunInstancesOptions withSecurityGroup(String securityGroup); RunInstancesOptions withUserData(byte[] unencodedData); RunInstancesOptions asType(String type); RunInstancesOptions withKernelId(String kernelId); RunInstancesOptions withRamdisk(String ramDiskId); RunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings); RunInstancesOptions withClientToken(String clientToken); }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withSecurityGroup(String securityGroup) { return withSecurityGroups(securityGroup); } RunInstancesOptions withKeyName(String keyName); RunInstancesOptions withSecurityGroups(String... securityGroups); RunInstancesOptions withSecurityGroups(Iterable<String> securityGroups); RunInstancesOptions withSecurityGroup(String securityGroup); RunInstancesOptions withUserData(byte[] unencodedData); RunInstancesOptions asType(String type); RunInstancesOptions withKernelId(String kernelId); RunInstancesOptions withRamdisk(String ramDiskId); RunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings); RunInstancesOptions withClientToken(String clientToken); static final RunInstancesOptions NONE; }
@Test public void testWithSecurityGroupStatic() { RunInstancesOptions options = withSecurityGroup("test"); assertEquals(options.buildFormParameters().get("SecurityGroup.1"), ImmutableList.of("test")); }
public RunInstancesOptions withSecurityGroup(String securityGroup) { return withSecurityGroups(securityGroup); }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withSecurityGroup(String securityGroup) { return withSecurityGroups(securityGroup); } }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withSecurityGroup(String securityGroup) { return withSecurityGroups(securityGroup); } }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withSecurityGroup(String securityGroup) { return withSecurityGroups(securityGroup); } RunInstancesOptions withKeyName(String keyName); RunInstancesOptions withSecurityGroups(String... securityGroups); RunInstancesOptions withSecurityGroups(Iterable<String> securityGroups); RunInstancesOptions withSecurityGroup(String securityGroup); RunInstancesOptions withUserData(byte[] unencodedData); RunInstancesOptions asType(String type); RunInstancesOptions withKernelId(String kernelId); RunInstancesOptions withRamdisk(String ramDiskId); RunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings); RunInstancesOptions withClientToken(String clientToken); }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withSecurityGroup(String securityGroup) { return withSecurityGroups(securityGroup); } RunInstancesOptions withKeyName(String keyName); RunInstancesOptions withSecurityGroups(String... securityGroups); RunInstancesOptions withSecurityGroups(Iterable<String> securityGroups); RunInstancesOptions withSecurityGroup(String securityGroup); RunInstancesOptions withUserData(byte[] unencodedData); RunInstancesOptions asType(String type); RunInstancesOptions withKernelId(String kernelId); RunInstancesOptions withRamdisk(String ramDiskId); RunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings); RunInstancesOptions withClientToken(String clientToken); static final RunInstancesOptions NONE; }
@Test(expectedExceptions = NullPointerException.class) public void testWithSecurityGroupNPE() { withSecurityGroup(null); }
public RunInstancesOptions withSecurityGroup(String securityGroup) { return withSecurityGroups(securityGroup); }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withSecurityGroup(String securityGroup) { return withSecurityGroups(securityGroup); } }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withSecurityGroup(String securityGroup) { return withSecurityGroups(securityGroup); } }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withSecurityGroup(String securityGroup) { return withSecurityGroups(securityGroup); } RunInstancesOptions withKeyName(String keyName); RunInstancesOptions withSecurityGroups(String... securityGroups); RunInstancesOptions withSecurityGroups(Iterable<String> securityGroups); RunInstancesOptions withSecurityGroup(String securityGroup); RunInstancesOptions withUserData(byte[] unencodedData); RunInstancesOptions asType(String type); RunInstancesOptions withKernelId(String kernelId); RunInstancesOptions withRamdisk(String ramDiskId); RunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings); RunInstancesOptions withClientToken(String clientToken); }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withSecurityGroup(String securityGroup) { return withSecurityGroups(securityGroup); } RunInstancesOptions withKeyName(String keyName); RunInstancesOptions withSecurityGroups(String... securityGroups); RunInstancesOptions withSecurityGroups(Iterable<String> securityGroups); RunInstancesOptions withSecurityGroup(String securityGroup); RunInstancesOptions withUserData(byte[] unencodedData); RunInstancesOptions asType(String type); RunInstancesOptions withKernelId(String kernelId); RunInstancesOptions withRamdisk(String ramDiskId); RunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings); RunInstancesOptions withClientToken(String clientToken); static final RunInstancesOptions NONE; }
@Test public void testWithUserData() { RunInstancesOptions options = new RunInstancesOptions(); options.withUserData("test".getBytes()); assertEquals(options.buildFormParameters().get("UserData"), ImmutableList.of("dGVzdA==")); }
public RunInstancesOptions withUserData(byte[] unencodedData) { int length = checkNotNull(unencodedData, "unencodedData").length; checkArgument(length > 0, "userData cannot be empty"); checkArgument(length <= 16 * 1024, "userData cannot be larger than 16kb"); formParameters.put("UserData", base64().encode(unencodedData)); return this; }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withUserData(byte[] unencodedData) { int length = checkNotNull(unencodedData, "unencodedData").length; checkArgument(length > 0, "userData cannot be empty"); checkArgument(length <= 16 * 1024, "userData cannot be larger than 16kb"); formParameters.put("UserData", base64().encode(unencodedData)); return this; } }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withUserData(byte[] unencodedData) { int length = checkNotNull(unencodedData, "unencodedData").length; checkArgument(length > 0, "userData cannot be empty"); checkArgument(length <= 16 * 1024, "userData cannot be larger than 16kb"); formParameters.put("UserData", base64().encode(unencodedData)); return this; } }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withUserData(byte[] unencodedData) { int length = checkNotNull(unencodedData, "unencodedData").length; checkArgument(length > 0, "userData cannot be empty"); checkArgument(length <= 16 * 1024, "userData cannot be larger than 16kb"); formParameters.put("UserData", base64().encode(unencodedData)); return this; } RunInstancesOptions withKeyName(String keyName); RunInstancesOptions withSecurityGroups(String... securityGroups); RunInstancesOptions withSecurityGroups(Iterable<String> securityGroups); RunInstancesOptions withSecurityGroup(String securityGroup); RunInstancesOptions withUserData(byte[] unencodedData); RunInstancesOptions asType(String type); RunInstancesOptions withKernelId(String kernelId); RunInstancesOptions withRamdisk(String ramDiskId); RunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings); RunInstancesOptions withClientToken(String clientToken); }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withUserData(byte[] unencodedData) { int length = checkNotNull(unencodedData, "unencodedData").length; checkArgument(length > 0, "userData cannot be empty"); checkArgument(length <= 16 * 1024, "userData cannot be larger than 16kb"); formParameters.put("UserData", base64().encode(unencodedData)); return this; } RunInstancesOptions withKeyName(String keyName); RunInstancesOptions withSecurityGroups(String... securityGroups); RunInstancesOptions withSecurityGroups(Iterable<String> securityGroups); RunInstancesOptions withSecurityGroup(String securityGroup); RunInstancesOptions withUserData(byte[] unencodedData); RunInstancesOptions asType(String type); RunInstancesOptions withKernelId(String kernelId); RunInstancesOptions withRamdisk(String ramDiskId); RunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings); RunInstancesOptions withClientToken(String clientToken); static final RunInstancesOptions NONE; }
@Test public void testWithUserDataStatic() { RunInstancesOptions options = withUserData("test".getBytes()); assertEquals(options.buildFormParameters().get("UserData"), ImmutableList.of("dGVzdA==")); }
public RunInstancesOptions withUserData(byte[] unencodedData) { int length = checkNotNull(unencodedData, "unencodedData").length; checkArgument(length > 0, "userData cannot be empty"); checkArgument(length <= 16 * 1024, "userData cannot be larger than 16kb"); formParameters.put("UserData", base64().encode(unencodedData)); return this; }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withUserData(byte[] unencodedData) { int length = checkNotNull(unencodedData, "unencodedData").length; checkArgument(length > 0, "userData cannot be empty"); checkArgument(length <= 16 * 1024, "userData cannot be larger than 16kb"); formParameters.put("UserData", base64().encode(unencodedData)); return this; } }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withUserData(byte[] unencodedData) { int length = checkNotNull(unencodedData, "unencodedData").length; checkArgument(length > 0, "userData cannot be empty"); checkArgument(length <= 16 * 1024, "userData cannot be larger than 16kb"); formParameters.put("UserData", base64().encode(unencodedData)); return this; } }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withUserData(byte[] unencodedData) { int length = checkNotNull(unencodedData, "unencodedData").length; checkArgument(length > 0, "userData cannot be empty"); checkArgument(length <= 16 * 1024, "userData cannot be larger than 16kb"); formParameters.put("UserData", base64().encode(unencodedData)); return this; } RunInstancesOptions withKeyName(String keyName); RunInstancesOptions withSecurityGroups(String... securityGroups); RunInstancesOptions withSecurityGroups(Iterable<String> securityGroups); RunInstancesOptions withSecurityGroup(String securityGroup); RunInstancesOptions withUserData(byte[] unencodedData); RunInstancesOptions asType(String type); RunInstancesOptions withKernelId(String kernelId); RunInstancesOptions withRamdisk(String ramDiskId); RunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings); RunInstancesOptions withClientToken(String clientToken); }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withUserData(byte[] unencodedData) { int length = checkNotNull(unencodedData, "unencodedData").length; checkArgument(length > 0, "userData cannot be empty"); checkArgument(length <= 16 * 1024, "userData cannot be larger than 16kb"); formParameters.put("UserData", base64().encode(unencodedData)); return this; } RunInstancesOptions withKeyName(String keyName); RunInstancesOptions withSecurityGroups(String... securityGroups); RunInstancesOptions withSecurityGroups(Iterable<String> securityGroups); RunInstancesOptions withSecurityGroup(String securityGroup); RunInstancesOptions withUserData(byte[] unencodedData); RunInstancesOptions asType(String type); RunInstancesOptions withKernelId(String kernelId); RunInstancesOptions withRamdisk(String ramDiskId); RunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings); RunInstancesOptions withClientToken(String clientToken); static final RunInstancesOptions NONE; }
@Test(expectedExceptions = NullPointerException.class) public void testWithUserDataNPE() { withUserData(null); }
public RunInstancesOptions withUserData(byte[] unencodedData) { int length = checkNotNull(unencodedData, "unencodedData").length; checkArgument(length > 0, "userData cannot be empty"); checkArgument(length <= 16 * 1024, "userData cannot be larger than 16kb"); formParameters.put("UserData", base64().encode(unencodedData)); return this; }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withUserData(byte[] unencodedData) { int length = checkNotNull(unencodedData, "unencodedData").length; checkArgument(length > 0, "userData cannot be empty"); checkArgument(length <= 16 * 1024, "userData cannot be larger than 16kb"); formParameters.put("UserData", base64().encode(unencodedData)); return this; } }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withUserData(byte[] unencodedData) { int length = checkNotNull(unencodedData, "unencodedData").length; checkArgument(length > 0, "userData cannot be empty"); checkArgument(length <= 16 * 1024, "userData cannot be larger than 16kb"); formParameters.put("UserData", base64().encode(unencodedData)); return this; } }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withUserData(byte[] unencodedData) { int length = checkNotNull(unencodedData, "unencodedData").length; checkArgument(length > 0, "userData cannot be empty"); checkArgument(length <= 16 * 1024, "userData cannot be larger than 16kb"); formParameters.put("UserData", base64().encode(unencodedData)); return this; } RunInstancesOptions withKeyName(String keyName); RunInstancesOptions withSecurityGroups(String... securityGroups); RunInstancesOptions withSecurityGroups(Iterable<String> securityGroups); RunInstancesOptions withSecurityGroup(String securityGroup); RunInstancesOptions withUserData(byte[] unencodedData); RunInstancesOptions asType(String type); RunInstancesOptions withKernelId(String kernelId); RunInstancesOptions withRamdisk(String ramDiskId); RunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings); RunInstancesOptions withClientToken(String clientToken); }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withUserData(byte[] unencodedData) { int length = checkNotNull(unencodedData, "unencodedData").length; checkArgument(length > 0, "userData cannot be empty"); checkArgument(length <= 16 * 1024, "userData cannot be larger than 16kb"); formParameters.put("UserData", base64().encode(unencodedData)); return this; } RunInstancesOptions withKeyName(String keyName); RunInstancesOptions withSecurityGroups(String... securityGroups); RunInstancesOptions withSecurityGroups(Iterable<String> securityGroups); RunInstancesOptions withSecurityGroup(String securityGroup); RunInstancesOptions withUserData(byte[] unencodedData); RunInstancesOptions asType(String type); RunInstancesOptions withKernelId(String kernelId); RunInstancesOptions withRamdisk(String ramDiskId); RunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings); RunInstancesOptions withClientToken(String clientToken); static final RunInstancesOptions NONE; }
@Test public void testServerToNodeMetadata() { Server server = Server.builder() .dataCenter(DataCenter.builder() .id("mock") .version(10) .location(org.jclouds.profitbricks.domain.Location.DE_FRA) .build()) .id("qwertyui-qwer-qwer-qwer-qwertyyuiiop") .name("mock-facebook-node") .cores(4) .ram(4096) .hasInternetAccess(true) .state(ProvisioningState.AVAILABLE) .status(Server.Status.RUNNING) .osType(OsType.LINUX) .availabilityZone(AvailabilityZone.AUTO) .isCpuHotPlug(true) .isRamHotPlug(true) .isNicHotPlug(true) .isNicHotUnPlug(true) .isDiscVirtioHotPlug(true) .isDiscVirtioHotUnPlug(true) .storages(ImmutableList.<Storage>of( Storage.builder() .bootDevice(true) .busType(Storage.BusType.VIRTIO) .deviceNumber(1) .size(40f) .id("qswdefrg-qaws-qaws-defe-rgrgdsvcxbrh") .name("facebook-storage") .build() ) ) .nics(ImmutableList.<Nic>of( Nic.builder() .id("qwqwqwqw-wewe-erer-rtrt-tytytytytyty") .lanId(1) .dataCenterId("12345678-abcd-efgh-ijkl-987654321000") .internetAccess(true) .serverId("qwertyui-qwer-qwer-qwer-qwertyyuiiop") .macAddress("02:01:09:cd:f0:b0") .ips( ImmutableList.<String>of("173.252.120.6")) .build() ) ) .build(); NodeMetadata expected = fnNodeMetadata.apply(server); assertNotNull(expected); NodeMetadata actual = new NodeMetadataBuilder() .group("mock") .ids(server.id()) .name(server.name()) .backendStatus("AVAILABLE") .status(NodeMetadata.Status.RUNNING) .hardware(new HardwareBuilder() .ids("cpu=4,ram=4096,disk=40") .name("cpu=4,ram=4096,disk=40") .ram(server.ram()) .processor(new Processor(server.cores(), 1d)) .hypervisor("kvm") .volume(new VolumeBuilder() .bootDevice(true) .size(40f) .id("qswdefrg-qaws-qaws-defe-rgrgdsvcxbrh") .durable(true) .type(Volume.Type.LOCAL) .build()) .build()) .operatingSystem(new OperatingSystem.Builder() .description(OsFamily.LINUX.value()) .family(OsFamily.LINUX) .build()) .location(new LocationBuilder() .id("de/fra") .description("de/fra") .scope(LocationScope.ZONE) .parent(new LocationBuilder() .id("de") .description("de") .scope(LocationScope.REGION) .build()) .build()) .publicAddresses(ImmutableList.<String>of("173.252.120.6")) .build(); assertEquals(actual, expected); }
@Inject ServerToNodeMetadata(Function<Storage, Volume> fnVolume, @Memoized Supplier<Set<? extends Location>> locations, ProfitBricksApi api, GroupNamingConvention.Factory groupNamingConvention) { this.fnVolume = fnVolume; this.locations = locations; this.api = api; this.groupNamingConvention = groupNamingConvention.createWithoutPrefix(); this.fnCollectIps = new Function<List<Nic>, List<String>>() { @Override public List<String> apply(List<Nic> in) { List<String> ips = Lists.newArrayListWithExpectedSize(in.size()); for (Nic nic : in) ips.addAll(nic.ips()); return ips; } }; }
ServerToNodeMetadata implements Function<Server, NodeMetadata> { @Inject ServerToNodeMetadata(Function<Storage, Volume> fnVolume, @Memoized Supplier<Set<? extends Location>> locations, ProfitBricksApi api, GroupNamingConvention.Factory groupNamingConvention) { this.fnVolume = fnVolume; this.locations = locations; this.api = api; this.groupNamingConvention = groupNamingConvention.createWithoutPrefix(); this.fnCollectIps = new Function<List<Nic>, List<String>>() { @Override public List<String> apply(List<Nic> in) { List<String> ips = Lists.newArrayListWithExpectedSize(in.size()); for (Nic nic : in) ips.addAll(nic.ips()); return ips; } }; } }
ServerToNodeMetadata implements Function<Server, NodeMetadata> { @Inject ServerToNodeMetadata(Function<Storage, Volume> fnVolume, @Memoized Supplier<Set<? extends Location>> locations, ProfitBricksApi api, GroupNamingConvention.Factory groupNamingConvention) { this.fnVolume = fnVolume; this.locations = locations; this.api = api; this.groupNamingConvention = groupNamingConvention.createWithoutPrefix(); this.fnCollectIps = new Function<List<Nic>, List<String>>() { @Override public List<String> apply(List<Nic> in) { List<String> ips = Lists.newArrayListWithExpectedSize(in.size()); for (Nic nic : in) ips.addAll(nic.ips()); return ips; } }; } @Inject ServerToNodeMetadata(Function<Storage, Volume> fnVolume, @Memoized Supplier<Set<? extends Location>> locations, ProfitBricksApi api, GroupNamingConvention.Factory groupNamingConvention); }
ServerToNodeMetadata implements Function<Server, NodeMetadata> { @Inject ServerToNodeMetadata(Function<Storage, Volume> fnVolume, @Memoized Supplier<Set<? extends Location>> locations, ProfitBricksApi api, GroupNamingConvention.Factory groupNamingConvention) { this.fnVolume = fnVolume; this.locations = locations; this.api = api; this.groupNamingConvention = groupNamingConvention.createWithoutPrefix(); this.fnCollectIps = new Function<List<Nic>, List<String>>() { @Override public List<String> apply(List<Nic> in) { List<String> ips = Lists.newArrayListWithExpectedSize(in.size()); for (Nic nic : in) ips.addAll(nic.ips()); return ips; } }; } @Inject ServerToNodeMetadata(Function<Storage, Volume> fnVolume, @Memoized Supplier<Set<? extends Location>> locations, ProfitBricksApi api, GroupNamingConvention.Factory groupNamingConvention); @Override NodeMetadata apply(final Server server); }
ServerToNodeMetadata implements Function<Server, NodeMetadata> { @Inject ServerToNodeMetadata(Function<Storage, Volume> fnVolume, @Memoized Supplier<Set<? extends Location>> locations, ProfitBricksApi api, GroupNamingConvention.Factory groupNamingConvention) { this.fnVolume = fnVolume; this.locations = locations; this.api = api; this.groupNamingConvention = groupNamingConvention.createWithoutPrefix(); this.fnCollectIps = new Function<List<Nic>, List<String>>() { @Override public List<String> apply(List<Nic> in) { List<String> ips = Lists.newArrayListWithExpectedSize(in.size()); for (Nic nic : in) ips.addAll(nic.ips()); return ips; } }; } @Inject ServerToNodeMetadata(Function<Storage, Volume> fnVolume, @Memoized Supplier<Set<? extends Location>> locations, ProfitBricksApi api, GroupNamingConvention.Factory groupNamingConvention); @Override NodeMetadata apply(final Server server); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testWithUserDataEmpty() { withUserData("".getBytes()); }
public RunInstancesOptions withUserData(byte[] unencodedData) { int length = checkNotNull(unencodedData, "unencodedData").length; checkArgument(length > 0, "userData cannot be empty"); checkArgument(length <= 16 * 1024, "userData cannot be larger than 16kb"); formParameters.put("UserData", base64().encode(unencodedData)); return this; }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withUserData(byte[] unencodedData) { int length = checkNotNull(unencodedData, "unencodedData").length; checkArgument(length > 0, "userData cannot be empty"); checkArgument(length <= 16 * 1024, "userData cannot be larger than 16kb"); formParameters.put("UserData", base64().encode(unencodedData)); return this; } }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withUserData(byte[] unencodedData) { int length = checkNotNull(unencodedData, "unencodedData").length; checkArgument(length > 0, "userData cannot be empty"); checkArgument(length <= 16 * 1024, "userData cannot be larger than 16kb"); formParameters.put("UserData", base64().encode(unencodedData)); return this; } }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withUserData(byte[] unencodedData) { int length = checkNotNull(unencodedData, "unencodedData").length; checkArgument(length > 0, "userData cannot be empty"); checkArgument(length <= 16 * 1024, "userData cannot be larger than 16kb"); formParameters.put("UserData", base64().encode(unencodedData)); return this; } RunInstancesOptions withKeyName(String keyName); RunInstancesOptions withSecurityGroups(String... securityGroups); RunInstancesOptions withSecurityGroups(Iterable<String> securityGroups); RunInstancesOptions withSecurityGroup(String securityGroup); RunInstancesOptions withUserData(byte[] unencodedData); RunInstancesOptions asType(String type); RunInstancesOptions withKernelId(String kernelId); RunInstancesOptions withRamdisk(String ramDiskId); RunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings); RunInstancesOptions withClientToken(String clientToken); }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withUserData(byte[] unencodedData) { int length = checkNotNull(unencodedData, "unencodedData").length; checkArgument(length > 0, "userData cannot be empty"); checkArgument(length <= 16 * 1024, "userData cannot be larger than 16kb"); formParameters.put("UserData", base64().encode(unencodedData)); return this; } RunInstancesOptions withKeyName(String keyName); RunInstancesOptions withSecurityGroups(String... securityGroups); RunInstancesOptions withSecurityGroups(Iterable<String> securityGroups); RunInstancesOptions withSecurityGroup(String securityGroup); RunInstancesOptions withUserData(byte[] unencodedData); RunInstancesOptions asType(String type); RunInstancesOptions withKernelId(String kernelId); RunInstancesOptions withRamdisk(String ramDiskId); RunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings); RunInstancesOptions withClientToken(String clientToken); static final RunInstancesOptions NONE; }
@Test public void testWithInstanceType() { RunInstancesOptions options = new RunInstancesOptions(); options.asType(InstanceType.C1_XLARGE); assertEquals(options.buildFormParameters().get("InstanceType"), ImmutableList.of("c1.xlarge")); }
public RunInstancesOptions asType(String type) { formParameters.put("InstanceType", checkNotNull(type, "type")); return this; }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions asType(String type) { formParameters.put("InstanceType", checkNotNull(type, "type")); return this; } }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions asType(String type) { formParameters.put("InstanceType", checkNotNull(type, "type")); return this; } }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions asType(String type) { formParameters.put("InstanceType", checkNotNull(type, "type")); return this; } RunInstancesOptions withKeyName(String keyName); RunInstancesOptions withSecurityGroups(String... securityGroups); RunInstancesOptions withSecurityGroups(Iterable<String> securityGroups); RunInstancesOptions withSecurityGroup(String securityGroup); RunInstancesOptions withUserData(byte[] unencodedData); RunInstancesOptions asType(String type); RunInstancesOptions withKernelId(String kernelId); RunInstancesOptions withRamdisk(String ramDiskId); RunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings); RunInstancesOptions withClientToken(String clientToken); }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions asType(String type) { formParameters.put("InstanceType", checkNotNull(type, "type")); return this; } RunInstancesOptions withKeyName(String keyName); RunInstancesOptions withSecurityGroups(String... securityGroups); RunInstancesOptions withSecurityGroups(Iterable<String> securityGroups); RunInstancesOptions withSecurityGroup(String securityGroup); RunInstancesOptions withUserData(byte[] unencodedData); RunInstancesOptions asType(String type); RunInstancesOptions withKernelId(String kernelId); RunInstancesOptions withRamdisk(String ramDiskId); RunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings); RunInstancesOptions withClientToken(String clientToken); static final RunInstancesOptions NONE; }
@Test public void testWithInstanceTypeStatic() { RunInstancesOptions options = asType(InstanceType.C1_XLARGE); assertEquals(options.buildFormParameters().get("InstanceType"), ImmutableList.of("c1.xlarge")); }
public RunInstancesOptions asType(String type) { formParameters.put("InstanceType", checkNotNull(type, "type")); return this; }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions asType(String type) { formParameters.put("InstanceType", checkNotNull(type, "type")); return this; } }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions asType(String type) { formParameters.put("InstanceType", checkNotNull(type, "type")); return this; } }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions asType(String type) { formParameters.put("InstanceType", checkNotNull(type, "type")); return this; } RunInstancesOptions withKeyName(String keyName); RunInstancesOptions withSecurityGroups(String... securityGroups); RunInstancesOptions withSecurityGroups(Iterable<String> securityGroups); RunInstancesOptions withSecurityGroup(String securityGroup); RunInstancesOptions withUserData(byte[] unencodedData); RunInstancesOptions asType(String type); RunInstancesOptions withKernelId(String kernelId); RunInstancesOptions withRamdisk(String ramDiskId); RunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings); RunInstancesOptions withClientToken(String clientToken); }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions asType(String type) { formParameters.put("InstanceType", checkNotNull(type, "type")); return this; } RunInstancesOptions withKeyName(String keyName); RunInstancesOptions withSecurityGroups(String... securityGroups); RunInstancesOptions withSecurityGroups(Iterable<String> securityGroups); RunInstancesOptions withSecurityGroup(String securityGroup); RunInstancesOptions withUserData(byte[] unencodedData); RunInstancesOptions asType(String type); RunInstancesOptions withKernelId(String kernelId); RunInstancesOptions withRamdisk(String ramDiskId); RunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings); RunInstancesOptions withClientToken(String clientToken); static final RunInstancesOptions NONE; }
@Test(expectedExceptions = NullPointerException.class) public void testWithInstanceTypeNPE() { asType(null); }
public RunInstancesOptions asType(String type) { formParameters.put("InstanceType", checkNotNull(type, "type")); return this; }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions asType(String type) { formParameters.put("InstanceType", checkNotNull(type, "type")); return this; } }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions asType(String type) { formParameters.put("InstanceType", checkNotNull(type, "type")); return this; } }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions asType(String type) { formParameters.put("InstanceType", checkNotNull(type, "type")); return this; } RunInstancesOptions withKeyName(String keyName); RunInstancesOptions withSecurityGroups(String... securityGroups); RunInstancesOptions withSecurityGroups(Iterable<String> securityGroups); RunInstancesOptions withSecurityGroup(String securityGroup); RunInstancesOptions withUserData(byte[] unencodedData); RunInstancesOptions asType(String type); RunInstancesOptions withKernelId(String kernelId); RunInstancesOptions withRamdisk(String ramDiskId); RunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings); RunInstancesOptions withClientToken(String clientToken); }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions asType(String type) { formParameters.put("InstanceType", checkNotNull(type, "type")); return this; } RunInstancesOptions withKeyName(String keyName); RunInstancesOptions withSecurityGroups(String... securityGroups); RunInstancesOptions withSecurityGroups(Iterable<String> securityGroups); RunInstancesOptions withSecurityGroup(String securityGroup); RunInstancesOptions withUserData(byte[] unencodedData); RunInstancesOptions asType(String type); RunInstancesOptions withKernelId(String kernelId); RunInstancesOptions withRamdisk(String ramDiskId); RunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings); RunInstancesOptions withClientToken(String clientToken); static final RunInstancesOptions NONE; }
@Test public void testWithKernelId() { RunInstancesOptions options = new RunInstancesOptions(); options.withKernelId("test"); assertEquals(options.buildFormParameters().get("KernelId"), ImmutableList.of("test")); }
public RunInstancesOptions withKernelId(String kernelId) { formParameters.put("KernelId", checkNotNull(kernelId, "kernelId")); return this; }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withKernelId(String kernelId) { formParameters.put("KernelId", checkNotNull(kernelId, "kernelId")); return this; } }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withKernelId(String kernelId) { formParameters.put("KernelId", checkNotNull(kernelId, "kernelId")); return this; } }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withKernelId(String kernelId) { formParameters.put("KernelId", checkNotNull(kernelId, "kernelId")); return this; } RunInstancesOptions withKeyName(String keyName); RunInstancesOptions withSecurityGroups(String... securityGroups); RunInstancesOptions withSecurityGroups(Iterable<String> securityGroups); RunInstancesOptions withSecurityGroup(String securityGroup); RunInstancesOptions withUserData(byte[] unencodedData); RunInstancesOptions asType(String type); RunInstancesOptions withKernelId(String kernelId); RunInstancesOptions withRamdisk(String ramDiskId); RunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings); RunInstancesOptions withClientToken(String clientToken); }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withKernelId(String kernelId) { formParameters.put("KernelId", checkNotNull(kernelId, "kernelId")); return this; } RunInstancesOptions withKeyName(String keyName); RunInstancesOptions withSecurityGroups(String... securityGroups); RunInstancesOptions withSecurityGroups(Iterable<String> securityGroups); RunInstancesOptions withSecurityGroup(String securityGroup); RunInstancesOptions withUserData(byte[] unencodedData); RunInstancesOptions asType(String type); RunInstancesOptions withKernelId(String kernelId); RunInstancesOptions withRamdisk(String ramDiskId); RunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings); RunInstancesOptions withClientToken(String clientToken); static final RunInstancesOptions NONE; }
@Test public void testWithKernelIdStatic() { RunInstancesOptions options = withKernelId("test"); assertEquals(options.buildFormParameters().get("KernelId"), ImmutableList.of("test")); }
public RunInstancesOptions withKernelId(String kernelId) { formParameters.put("KernelId", checkNotNull(kernelId, "kernelId")); return this; }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withKernelId(String kernelId) { formParameters.put("KernelId", checkNotNull(kernelId, "kernelId")); return this; } }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withKernelId(String kernelId) { formParameters.put("KernelId", checkNotNull(kernelId, "kernelId")); return this; } }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withKernelId(String kernelId) { formParameters.put("KernelId", checkNotNull(kernelId, "kernelId")); return this; } RunInstancesOptions withKeyName(String keyName); RunInstancesOptions withSecurityGroups(String... securityGroups); RunInstancesOptions withSecurityGroups(Iterable<String> securityGroups); RunInstancesOptions withSecurityGroup(String securityGroup); RunInstancesOptions withUserData(byte[] unencodedData); RunInstancesOptions asType(String type); RunInstancesOptions withKernelId(String kernelId); RunInstancesOptions withRamdisk(String ramDiskId); RunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings); RunInstancesOptions withClientToken(String clientToken); }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withKernelId(String kernelId) { formParameters.put("KernelId", checkNotNull(kernelId, "kernelId")); return this; } RunInstancesOptions withKeyName(String keyName); RunInstancesOptions withSecurityGroups(String... securityGroups); RunInstancesOptions withSecurityGroups(Iterable<String> securityGroups); RunInstancesOptions withSecurityGroup(String securityGroup); RunInstancesOptions withUserData(byte[] unencodedData); RunInstancesOptions asType(String type); RunInstancesOptions withKernelId(String kernelId); RunInstancesOptions withRamdisk(String ramDiskId); RunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings); RunInstancesOptions withClientToken(String clientToken); static final RunInstancesOptions NONE; }
@Test(expectedExceptions = NullPointerException.class) public void testWithKernelIdNPE() { withKernelId(null); }
public RunInstancesOptions withKernelId(String kernelId) { formParameters.put("KernelId", checkNotNull(kernelId, "kernelId")); return this; }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withKernelId(String kernelId) { formParameters.put("KernelId", checkNotNull(kernelId, "kernelId")); return this; } }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withKernelId(String kernelId) { formParameters.put("KernelId", checkNotNull(kernelId, "kernelId")); return this; } }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withKernelId(String kernelId) { formParameters.put("KernelId", checkNotNull(kernelId, "kernelId")); return this; } RunInstancesOptions withKeyName(String keyName); RunInstancesOptions withSecurityGroups(String... securityGroups); RunInstancesOptions withSecurityGroups(Iterable<String> securityGroups); RunInstancesOptions withSecurityGroup(String securityGroup); RunInstancesOptions withUserData(byte[] unencodedData); RunInstancesOptions asType(String type); RunInstancesOptions withKernelId(String kernelId); RunInstancesOptions withRamdisk(String ramDiskId); RunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings); RunInstancesOptions withClientToken(String clientToken); }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withKernelId(String kernelId) { formParameters.put("KernelId", checkNotNull(kernelId, "kernelId")); return this; } RunInstancesOptions withKeyName(String keyName); RunInstancesOptions withSecurityGroups(String... securityGroups); RunInstancesOptions withSecurityGroups(Iterable<String> securityGroups); RunInstancesOptions withSecurityGroup(String securityGroup); RunInstancesOptions withUserData(byte[] unencodedData); RunInstancesOptions asType(String type); RunInstancesOptions withKernelId(String kernelId); RunInstancesOptions withRamdisk(String ramDiskId); RunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings); RunInstancesOptions withClientToken(String clientToken); static final RunInstancesOptions NONE; }
@Test public void testWithRamdisk() { RunInstancesOptions options = new RunInstancesOptions(); options.withRamdisk("test"); assertEquals(options.buildFormParameters().get("RamdiskId"), ImmutableList.of("test")); }
public RunInstancesOptions withRamdisk(String ramDiskId) { formParameters.put("RamdiskId", checkNotNull(ramDiskId, "ramDiskId")); return this; }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withRamdisk(String ramDiskId) { formParameters.put("RamdiskId", checkNotNull(ramDiskId, "ramDiskId")); return this; } }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withRamdisk(String ramDiskId) { formParameters.put("RamdiskId", checkNotNull(ramDiskId, "ramDiskId")); return this; } }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withRamdisk(String ramDiskId) { formParameters.put("RamdiskId", checkNotNull(ramDiskId, "ramDiskId")); return this; } RunInstancesOptions withKeyName(String keyName); RunInstancesOptions withSecurityGroups(String... securityGroups); RunInstancesOptions withSecurityGroups(Iterable<String> securityGroups); RunInstancesOptions withSecurityGroup(String securityGroup); RunInstancesOptions withUserData(byte[] unencodedData); RunInstancesOptions asType(String type); RunInstancesOptions withKernelId(String kernelId); RunInstancesOptions withRamdisk(String ramDiskId); RunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings); RunInstancesOptions withClientToken(String clientToken); }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withRamdisk(String ramDiskId) { formParameters.put("RamdiskId", checkNotNull(ramDiskId, "ramDiskId")); return this; } RunInstancesOptions withKeyName(String keyName); RunInstancesOptions withSecurityGroups(String... securityGroups); RunInstancesOptions withSecurityGroups(Iterable<String> securityGroups); RunInstancesOptions withSecurityGroup(String securityGroup); RunInstancesOptions withUserData(byte[] unencodedData); RunInstancesOptions asType(String type); RunInstancesOptions withKernelId(String kernelId); RunInstancesOptions withRamdisk(String ramDiskId); RunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings); RunInstancesOptions withClientToken(String clientToken); static final RunInstancesOptions NONE; }
@Test public void testWithRamdiskStatic() { RunInstancesOptions options = withRamdisk("test"); assertEquals(options.buildFormParameters().get("RamdiskId"), ImmutableList.of("test")); }
public RunInstancesOptions withRamdisk(String ramDiskId) { formParameters.put("RamdiskId", checkNotNull(ramDiskId, "ramDiskId")); return this; }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withRamdisk(String ramDiskId) { formParameters.put("RamdiskId", checkNotNull(ramDiskId, "ramDiskId")); return this; } }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withRamdisk(String ramDiskId) { formParameters.put("RamdiskId", checkNotNull(ramDiskId, "ramDiskId")); return this; } }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withRamdisk(String ramDiskId) { formParameters.put("RamdiskId", checkNotNull(ramDiskId, "ramDiskId")); return this; } RunInstancesOptions withKeyName(String keyName); RunInstancesOptions withSecurityGroups(String... securityGroups); RunInstancesOptions withSecurityGroups(Iterable<String> securityGroups); RunInstancesOptions withSecurityGroup(String securityGroup); RunInstancesOptions withUserData(byte[] unencodedData); RunInstancesOptions asType(String type); RunInstancesOptions withKernelId(String kernelId); RunInstancesOptions withRamdisk(String ramDiskId); RunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings); RunInstancesOptions withClientToken(String clientToken); }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withRamdisk(String ramDiskId) { formParameters.put("RamdiskId", checkNotNull(ramDiskId, "ramDiskId")); return this; } RunInstancesOptions withKeyName(String keyName); RunInstancesOptions withSecurityGroups(String... securityGroups); RunInstancesOptions withSecurityGroups(Iterable<String> securityGroups); RunInstancesOptions withSecurityGroup(String securityGroup); RunInstancesOptions withUserData(byte[] unencodedData); RunInstancesOptions asType(String type); RunInstancesOptions withKernelId(String kernelId); RunInstancesOptions withRamdisk(String ramDiskId); RunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings); RunInstancesOptions withClientToken(String clientToken); static final RunInstancesOptions NONE; }
@Test(expectedExceptions = NullPointerException.class) public void testWithRamdiskNPE() { withRamdisk(null); }
public RunInstancesOptions withRamdisk(String ramDiskId) { formParameters.put("RamdiskId", checkNotNull(ramDiskId, "ramDiskId")); return this; }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withRamdisk(String ramDiskId) { formParameters.put("RamdiskId", checkNotNull(ramDiskId, "ramDiskId")); return this; } }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withRamdisk(String ramDiskId) { formParameters.put("RamdiskId", checkNotNull(ramDiskId, "ramDiskId")); return this; } }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withRamdisk(String ramDiskId) { formParameters.put("RamdiskId", checkNotNull(ramDiskId, "ramDiskId")); return this; } RunInstancesOptions withKeyName(String keyName); RunInstancesOptions withSecurityGroups(String... securityGroups); RunInstancesOptions withSecurityGroups(Iterable<String> securityGroups); RunInstancesOptions withSecurityGroup(String securityGroup); RunInstancesOptions withUserData(byte[] unencodedData); RunInstancesOptions asType(String type); RunInstancesOptions withKernelId(String kernelId); RunInstancesOptions withRamdisk(String ramDiskId); RunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings); RunInstancesOptions withClientToken(String clientToken); }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withRamdisk(String ramDiskId) { formParameters.put("RamdiskId", checkNotNull(ramDiskId, "ramDiskId")); return this; } RunInstancesOptions withKeyName(String keyName); RunInstancesOptions withSecurityGroups(String... securityGroups); RunInstancesOptions withSecurityGroups(Iterable<String> securityGroups); RunInstancesOptions withSecurityGroup(String securityGroup); RunInstancesOptions withUserData(byte[] unencodedData); RunInstancesOptions asType(String type); RunInstancesOptions withKernelId(String kernelId); RunInstancesOptions withRamdisk(String ramDiskId); RunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings); RunInstancesOptions withClientToken(String clientToken); static final RunInstancesOptions NONE; }
@Test public void testSShKeyIds() { TemplateOptions options = new DigitalOcean2TemplateOptions().sshKeyIds(ImmutableSet.of(1, 2, 3)); assertEquals(options.as(DigitalOcean2TemplateOptions.class).getSshKeyIds(), ImmutableSet.of(1, 2, 3)); }
public DigitalOcean2TemplateOptions sshKeyIds(Iterable<Integer> sshKeyIds) { this.sshKeyIds = ImmutableSet.copyOf(checkNotNull(sshKeyIds, "sshKeyIds cannot be null")); return this; }
DigitalOcean2TemplateOptions extends TemplateOptions implements Cloneable { public DigitalOcean2TemplateOptions sshKeyIds(Iterable<Integer> sshKeyIds) { this.sshKeyIds = ImmutableSet.copyOf(checkNotNull(sshKeyIds, "sshKeyIds cannot be null")); return this; } }
DigitalOcean2TemplateOptions extends TemplateOptions implements Cloneable { public DigitalOcean2TemplateOptions sshKeyIds(Iterable<Integer> sshKeyIds) { this.sshKeyIds = ImmutableSet.copyOf(checkNotNull(sshKeyIds, "sshKeyIds cannot be null")); return this; } }
DigitalOcean2TemplateOptions extends TemplateOptions implements Cloneable { public DigitalOcean2TemplateOptions sshKeyIds(Iterable<Integer> sshKeyIds) { this.sshKeyIds = ImmutableSet.copyOf(checkNotNull(sshKeyIds, "sshKeyIds cannot be null")); return this; } DigitalOcean2TemplateOptions privateNetworking(boolean privateNetworking); DigitalOcean2TemplateOptions backupsEnabled(boolean backupsEnabled); DigitalOcean2TemplateOptions sshKeyIds(Iterable<Integer> sshKeyIds); DigitalOcean2TemplateOptions autoCreateKeyPair(boolean autoCreateKeyPair); DigitalOcean2TemplateOptions userData(byte[] userData); @Deprecated @Override TemplateOptions userMetadata(Map<String, String> userMetadata); @Deprecated @Override TemplateOptions userMetadata(String key, String value); @Deprecated @Override Map<String, String> getUserMetadata(); Set<Integer> getSshKeyIds(); boolean getPrivateNetworking(); boolean getBackupsEnabled(); boolean getAutoCreateKeyPair(); byte[] getUserData(); @Override DigitalOcean2TemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override int hashCode(); @Override boolean equals(Object obj); @Override ToStringHelper string(); }
DigitalOcean2TemplateOptions extends TemplateOptions implements Cloneable { public DigitalOcean2TemplateOptions sshKeyIds(Iterable<Integer> sshKeyIds) { this.sshKeyIds = ImmutableSet.copyOf(checkNotNull(sshKeyIds, "sshKeyIds cannot be null")); return this; } DigitalOcean2TemplateOptions privateNetworking(boolean privateNetworking); DigitalOcean2TemplateOptions backupsEnabled(boolean backupsEnabled); DigitalOcean2TemplateOptions sshKeyIds(Iterable<Integer> sshKeyIds); DigitalOcean2TemplateOptions autoCreateKeyPair(boolean autoCreateKeyPair); DigitalOcean2TemplateOptions userData(byte[] userData); @Deprecated @Override TemplateOptions userMetadata(Map<String, String> userMetadata); @Deprecated @Override TemplateOptions userMetadata(String key, String value); @Deprecated @Override Map<String, String> getUserMetadata(); Set<Integer> getSshKeyIds(); boolean getPrivateNetworking(); boolean getBackupsEnabled(); boolean getAutoCreateKeyPair(); byte[] getUserData(); @Override DigitalOcean2TemplateOptions clone(); @Override void copyTo(TemplateOptions to); @Override int hashCode(); @Override boolean equals(Object obj); @Override ToStringHelper string(); }
@Test public void testWithBlockDeviceMapping() { BlockDeviceMapping mapping = new BlockDeviceMapping.MapNewVolumeToDevice("/dev/sda1", 120, true, "gp2", 10, true); RunInstancesOptions options = new RunInstancesOptions().withBlockDeviceMappings(ImmutableSet .<BlockDeviceMapping> of(mapping)); assertEquals(options.buildFormParameters().get("BlockDeviceMapping.1.DeviceName"), ImmutableList.of("/dev/sda1")); assertEquals(options.buildFormParameters().get("BlockDeviceMapping.1.Ebs.VolumeSize"), ImmutableList.of("120")); assertEquals(options.buildFormParameters().get("BlockDeviceMapping.1.Ebs.DeleteOnTermination"), ImmutableList.of("true")); assertEquals(options.buildFormParameters().get("BlockDeviceMapping.1.Ebs.VolumeType"), ImmutableList.of("gp2")); assertEquals(options.buildFormParameters().get("BlockDeviceMapping.1.Ebs.Iops"), ImmutableList.of("10")); assertEquals(options.buildFormParameters().get("BlockDeviceMapping.1.Ebs.Encrypted"), ImmutableList.of("true")); }
public RunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings) { int i = 1; for (BlockDeviceMapping mapping : checkNotNull(mappings, "mappings")) { checkNotNull(mapping.getDeviceName(), "deviceName"); formParameters.put(String.format("BlockDeviceMapping.%d.DeviceName", i), mapping.getDeviceName()); if (mapping.getVirtualName() != null) formParameters.put(String.format("BlockDeviceMapping.%d.VirtualName", i), mapping.getVirtualName()); if (mapping.getEbsSnapshotId() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.SnapshotId", i), mapping.getEbsSnapshotId()); if (mapping.getEbsVolumeSize() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.VolumeSize", i), String.valueOf(mapping.getEbsVolumeSize())); if (mapping.getEbsNoDevice() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.NoDevice", i), String.valueOf(mapping.getEbsNoDevice())); if (mapping.getEbsDeleteOnTermination() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.DeleteOnTermination", i), String.valueOf(mapping.getEbsDeleteOnTermination())); if (mapping.getEbsVolumeType() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.VolumeType", i), mapping.getEbsVolumeType()); if (mapping.getEbsIops() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.Iops", i), String.valueOf(mapping.getEbsIops())); if (mapping.getEbsEncrypted() != null && mapping.getEbsEncrypted()) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.Encrypted", i), String.valueOf(mapping.getEbsEncrypted())); i++; } return this; }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings) { int i = 1; for (BlockDeviceMapping mapping : checkNotNull(mappings, "mappings")) { checkNotNull(mapping.getDeviceName(), "deviceName"); formParameters.put(String.format("BlockDeviceMapping.%d.DeviceName", i), mapping.getDeviceName()); if (mapping.getVirtualName() != null) formParameters.put(String.format("BlockDeviceMapping.%d.VirtualName", i), mapping.getVirtualName()); if (mapping.getEbsSnapshotId() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.SnapshotId", i), mapping.getEbsSnapshotId()); if (mapping.getEbsVolumeSize() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.VolumeSize", i), String.valueOf(mapping.getEbsVolumeSize())); if (mapping.getEbsNoDevice() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.NoDevice", i), String.valueOf(mapping.getEbsNoDevice())); if (mapping.getEbsDeleteOnTermination() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.DeleteOnTermination", i), String.valueOf(mapping.getEbsDeleteOnTermination())); if (mapping.getEbsVolumeType() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.VolumeType", i), mapping.getEbsVolumeType()); if (mapping.getEbsIops() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.Iops", i), String.valueOf(mapping.getEbsIops())); if (mapping.getEbsEncrypted() != null && mapping.getEbsEncrypted()) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.Encrypted", i), String.valueOf(mapping.getEbsEncrypted())); i++; } return this; } }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings) { int i = 1; for (BlockDeviceMapping mapping : checkNotNull(mappings, "mappings")) { checkNotNull(mapping.getDeviceName(), "deviceName"); formParameters.put(String.format("BlockDeviceMapping.%d.DeviceName", i), mapping.getDeviceName()); if (mapping.getVirtualName() != null) formParameters.put(String.format("BlockDeviceMapping.%d.VirtualName", i), mapping.getVirtualName()); if (mapping.getEbsSnapshotId() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.SnapshotId", i), mapping.getEbsSnapshotId()); if (mapping.getEbsVolumeSize() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.VolumeSize", i), String.valueOf(mapping.getEbsVolumeSize())); if (mapping.getEbsNoDevice() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.NoDevice", i), String.valueOf(mapping.getEbsNoDevice())); if (mapping.getEbsDeleteOnTermination() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.DeleteOnTermination", i), String.valueOf(mapping.getEbsDeleteOnTermination())); if (mapping.getEbsVolumeType() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.VolumeType", i), mapping.getEbsVolumeType()); if (mapping.getEbsIops() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.Iops", i), String.valueOf(mapping.getEbsIops())); if (mapping.getEbsEncrypted() != null && mapping.getEbsEncrypted()) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.Encrypted", i), String.valueOf(mapping.getEbsEncrypted())); i++; } return this; } }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings) { int i = 1; for (BlockDeviceMapping mapping : checkNotNull(mappings, "mappings")) { checkNotNull(mapping.getDeviceName(), "deviceName"); formParameters.put(String.format("BlockDeviceMapping.%d.DeviceName", i), mapping.getDeviceName()); if (mapping.getVirtualName() != null) formParameters.put(String.format("BlockDeviceMapping.%d.VirtualName", i), mapping.getVirtualName()); if (mapping.getEbsSnapshotId() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.SnapshotId", i), mapping.getEbsSnapshotId()); if (mapping.getEbsVolumeSize() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.VolumeSize", i), String.valueOf(mapping.getEbsVolumeSize())); if (mapping.getEbsNoDevice() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.NoDevice", i), String.valueOf(mapping.getEbsNoDevice())); if (mapping.getEbsDeleteOnTermination() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.DeleteOnTermination", i), String.valueOf(mapping.getEbsDeleteOnTermination())); if (mapping.getEbsVolumeType() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.VolumeType", i), mapping.getEbsVolumeType()); if (mapping.getEbsIops() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.Iops", i), String.valueOf(mapping.getEbsIops())); if (mapping.getEbsEncrypted() != null && mapping.getEbsEncrypted()) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.Encrypted", i), String.valueOf(mapping.getEbsEncrypted())); i++; } return this; } RunInstancesOptions withKeyName(String keyName); RunInstancesOptions withSecurityGroups(String... securityGroups); RunInstancesOptions withSecurityGroups(Iterable<String> securityGroups); RunInstancesOptions withSecurityGroup(String securityGroup); RunInstancesOptions withUserData(byte[] unencodedData); RunInstancesOptions asType(String type); RunInstancesOptions withKernelId(String kernelId); RunInstancesOptions withRamdisk(String ramDiskId); RunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings); RunInstancesOptions withClientToken(String clientToken); }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings) { int i = 1; for (BlockDeviceMapping mapping : checkNotNull(mappings, "mappings")) { checkNotNull(mapping.getDeviceName(), "deviceName"); formParameters.put(String.format("BlockDeviceMapping.%d.DeviceName", i), mapping.getDeviceName()); if (mapping.getVirtualName() != null) formParameters.put(String.format("BlockDeviceMapping.%d.VirtualName", i), mapping.getVirtualName()); if (mapping.getEbsSnapshotId() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.SnapshotId", i), mapping.getEbsSnapshotId()); if (mapping.getEbsVolumeSize() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.VolumeSize", i), String.valueOf(mapping.getEbsVolumeSize())); if (mapping.getEbsNoDevice() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.NoDevice", i), String.valueOf(mapping.getEbsNoDevice())); if (mapping.getEbsDeleteOnTermination() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.DeleteOnTermination", i), String.valueOf(mapping.getEbsDeleteOnTermination())); if (mapping.getEbsVolumeType() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.VolumeType", i), mapping.getEbsVolumeType()); if (mapping.getEbsIops() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.Iops", i), String.valueOf(mapping.getEbsIops())); if (mapping.getEbsEncrypted() != null && mapping.getEbsEncrypted()) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.Encrypted", i), String.valueOf(mapping.getEbsEncrypted())); i++; } return this; } RunInstancesOptions withKeyName(String keyName); RunInstancesOptions withSecurityGroups(String... securityGroups); RunInstancesOptions withSecurityGroups(Iterable<String> securityGroups); RunInstancesOptions withSecurityGroup(String securityGroup); RunInstancesOptions withUserData(byte[] unencodedData); RunInstancesOptions asType(String type); RunInstancesOptions withKernelId(String kernelId); RunInstancesOptions withRamdisk(String ramDiskId); RunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings); RunInstancesOptions withClientToken(String clientToken); static final RunInstancesOptions NONE; }
@Test public void testWithBlockDeviceMappingStatic() { BlockDeviceMapping mapping = new BlockDeviceMapping.MapNewVolumeToDevice("/dev/sda1", 120, true, null, null, false); RunInstancesOptions options = withBlockDeviceMappings(ImmutableSet .<BlockDeviceMapping> of(mapping)); assertEquals(options.buildFormParameters().get("BlockDeviceMapping.1.DeviceName"), ImmutableList.of("/dev/sda1")); assertEquals(options.buildFormParameters().get("BlockDeviceMapping.1.Ebs.VolumeSize"), ImmutableList.of("120")); assertEquals(options.buildFormParameters().get("BlockDeviceMapping.1.Ebs.DeleteOnTermination"), ImmutableList.of("true")); assertEquals(options.buildFormParameters().get("BlockDeviceMapping.1.Ebs.VolumeType"), ImmutableList.of()); }
public RunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings) { int i = 1; for (BlockDeviceMapping mapping : checkNotNull(mappings, "mappings")) { checkNotNull(mapping.getDeviceName(), "deviceName"); formParameters.put(String.format("BlockDeviceMapping.%d.DeviceName", i), mapping.getDeviceName()); if (mapping.getVirtualName() != null) formParameters.put(String.format("BlockDeviceMapping.%d.VirtualName", i), mapping.getVirtualName()); if (mapping.getEbsSnapshotId() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.SnapshotId", i), mapping.getEbsSnapshotId()); if (mapping.getEbsVolumeSize() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.VolumeSize", i), String.valueOf(mapping.getEbsVolumeSize())); if (mapping.getEbsNoDevice() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.NoDevice", i), String.valueOf(mapping.getEbsNoDevice())); if (mapping.getEbsDeleteOnTermination() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.DeleteOnTermination", i), String.valueOf(mapping.getEbsDeleteOnTermination())); if (mapping.getEbsVolumeType() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.VolumeType", i), mapping.getEbsVolumeType()); if (mapping.getEbsIops() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.Iops", i), String.valueOf(mapping.getEbsIops())); if (mapping.getEbsEncrypted() != null && mapping.getEbsEncrypted()) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.Encrypted", i), String.valueOf(mapping.getEbsEncrypted())); i++; } return this; }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings) { int i = 1; for (BlockDeviceMapping mapping : checkNotNull(mappings, "mappings")) { checkNotNull(mapping.getDeviceName(), "deviceName"); formParameters.put(String.format("BlockDeviceMapping.%d.DeviceName", i), mapping.getDeviceName()); if (mapping.getVirtualName() != null) formParameters.put(String.format("BlockDeviceMapping.%d.VirtualName", i), mapping.getVirtualName()); if (mapping.getEbsSnapshotId() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.SnapshotId", i), mapping.getEbsSnapshotId()); if (mapping.getEbsVolumeSize() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.VolumeSize", i), String.valueOf(mapping.getEbsVolumeSize())); if (mapping.getEbsNoDevice() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.NoDevice", i), String.valueOf(mapping.getEbsNoDevice())); if (mapping.getEbsDeleteOnTermination() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.DeleteOnTermination", i), String.valueOf(mapping.getEbsDeleteOnTermination())); if (mapping.getEbsVolumeType() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.VolumeType", i), mapping.getEbsVolumeType()); if (mapping.getEbsIops() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.Iops", i), String.valueOf(mapping.getEbsIops())); if (mapping.getEbsEncrypted() != null && mapping.getEbsEncrypted()) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.Encrypted", i), String.valueOf(mapping.getEbsEncrypted())); i++; } return this; } }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings) { int i = 1; for (BlockDeviceMapping mapping : checkNotNull(mappings, "mappings")) { checkNotNull(mapping.getDeviceName(), "deviceName"); formParameters.put(String.format("BlockDeviceMapping.%d.DeviceName", i), mapping.getDeviceName()); if (mapping.getVirtualName() != null) formParameters.put(String.format("BlockDeviceMapping.%d.VirtualName", i), mapping.getVirtualName()); if (mapping.getEbsSnapshotId() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.SnapshotId", i), mapping.getEbsSnapshotId()); if (mapping.getEbsVolumeSize() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.VolumeSize", i), String.valueOf(mapping.getEbsVolumeSize())); if (mapping.getEbsNoDevice() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.NoDevice", i), String.valueOf(mapping.getEbsNoDevice())); if (mapping.getEbsDeleteOnTermination() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.DeleteOnTermination", i), String.valueOf(mapping.getEbsDeleteOnTermination())); if (mapping.getEbsVolumeType() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.VolumeType", i), mapping.getEbsVolumeType()); if (mapping.getEbsIops() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.Iops", i), String.valueOf(mapping.getEbsIops())); if (mapping.getEbsEncrypted() != null && mapping.getEbsEncrypted()) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.Encrypted", i), String.valueOf(mapping.getEbsEncrypted())); i++; } return this; } }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings) { int i = 1; for (BlockDeviceMapping mapping : checkNotNull(mappings, "mappings")) { checkNotNull(mapping.getDeviceName(), "deviceName"); formParameters.put(String.format("BlockDeviceMapping.%d.DeviceName", i), mapping.getDeviceName()); if (mapping.getVirtualName() != null) formParameters.put(String.format("BlockDeviceMapping.%d.VirtualName", i), mapping.getVirtualName()); if (mapping.getEbsSnapshotId() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.SnapshotId", i), mapping.getEbsSnapshotId()); if (mapping.getEbsVolumeSize() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.VolumeSize", i), String.valueOf(mapping.getEbsVolumeSize())); if (mapping.getEbsNoDevice() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.NoDevice", i), String.valueOf(mapping.getEbsNoDevice())); if (mapping.getEbsDeleteOnTermination() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.DeleteOnTermination", i), String.valueOf(mapping.getEbsDeleteOnTermination())); if (mapping.getEbsVolumeType() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.VolumeType", i), mapping.getEbsVolumeType()); if (mapping.getEbsIops() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.Iops", i), String.valueOf(mapping.getEbsIops())); if (mapping.getEbsEncrypted() != null && mapping.getEbsEncrypted()) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.Encrypted", i), String.valueOf(mapping.getEbsEncrypted())); i++; } return this; } RunInstancesOptions withKeyName(String keyName); RunInstancesOptions withSecurityGroups(String... securityGroups); RunInstancesOptions withSecurityGroups(Iterable<String> securityGroups); RunInstancesOptions withSecurityGroup(String securityGroup); RunInstancesOptions withUserData(byte[] unencodedData); RunInstancesOptions asType(String type); RunInstancesOptions withKernelId(String kernelId); RunInstancesOptions withRamdisk(String ramDiskId); RunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings); RunInstancesOptions withClientToken(String clientToken); }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings) { int i = 1; for (BlockDeviceMapping mapping : checkNotNull(mappings, "mappings")) { checkNotNull(mapping.getDeviceName(), "deviceName"); formParameters.put(String.format("BlockDeviceMapping.%d.DeviceName", i), mapping.getDeviceName()); if (mapping.getVirtualName() != null) formParameters.put(String.format("BlockDeviceMapping.%d.VirtualName", i), mapping.getVirtualName()); if (mapping.getEbsSnapshotId() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.SnapshotId", i), mapping.getEbsSnapshotId()); if (mapping.getEbsVolumeSize() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.VolumeSize", i), String.valueOf(mapping.getEbsVolumeSize())); if (mapping.getEbsNoDevice() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.NoDevice", i), String.valueOf(mapping.getEbsNoDevice())); if (mapping.getEbsDeleteOnTermination() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.DeleteOnTermination", i), String.valueOf(mapping.getEbsDeleteOnTermination())); if (mapping.getEbsVolumeType() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.VolumeType", i), mapping.getEbsVolumeType()); if (mapping.getEbsIops() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.Iops", i), String.valueOf(mapping.getEbsIops())); if (mapping.getEbsEncrypted() != null && mapping.getEbsEncrypted()) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.Encrypted", i), String.valueOf(mapping.getEbsEncrypted())); i++; } return this; } RunInstancesOptions withKeyName(String keyName); RunInstancesOptions withSecurityGroups(String... securityGroups); RunInstancesOptions withSecurityGroups(Iterable<String> securityGroups); RunInstancesOptions withSecurityGroup(String securityGroup); RunInstancesOptions withUserData(byte[] unencodedData); RunInstancesOptions asType(String type); RunInstancesOptions withKernelId(String kernelId); RunInstancesOptions withRamdisk(String ramDiskId); RunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings); RunInstancesOptions withClientToken(String clientToken); static final RunInstancesOptions NONE; }
@Test(expectedExceptions = NullPointerException.class) public void testWithBlockDeviceMappingNPE() { withBlockDeviceMappings(null); }
public RunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings) { int i = 1; for (BlockDeviceMapping mapping : checkNotNull(mappings, "mappings")) { checkNotNull(mapping.getDeviceName(), "deviceName"); formParameters.put(String.format("BlockDeviceMapping.%d.DeviceName", i), mapping.getDeviceName()); if (mapping.getVirtualName() != null) formParameters.put(String.format("BlockDeviceMapping.%d.VirtualName", i), mapping.getVirtualName()); if (mapping.getEbsSnapshotId() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.SnapshotId", i), mapping.getEbsSnapshotId()); if (mapping.getEbsVolumeSize() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.VolumeSize", i), String.valueOf(mapping.getEbsVolumeSize())); if (mapping.getEbsNoDevice() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.NoDevice", i), String.valueOf(mapping.getEbsNoDevice())); if (mapping.getEbsDeleteOnTermination() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.DeleteOnTermination", i), String.valueOf(mapping.getEbsDeleteOnTermination())); if (mapping.getEbsVolumeType() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.VolumeType", i), mapping.getEbsVolumeType()); if (mapping.getEbsIops() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.Iops", i), String.valueOf(mapping.getEbsIops())); if (mapping.getEbsEncrypted() != null && mapping.getEbsEncrypted()) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.Encrypted", i), String.valueOf(mapping.getEbsEncrypted())); i++; } return this; }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings) { int i = 1; for (BlockDeviceMapping mapping : checkNotNull(mappings, "mappings")) { checkNotNull(mapping.getDeviceName(), "deviceName"); formParameters.put(String.format("BlockDeviceMapping.%d.DeviceName", i), mapping.getDeviceName()); if (mapping.getVirtualName() != null) formParameters.put(String.format("BlockDeviceMapping.%d.VirtualName", i), mapping.getVirtualName()); if (mapping.getEbsSnapshotId() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.SnapshotId", i), mapping.getEbsSnapshotId()); if (mapping.getEbsVolumeSize() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.VolumeSize", i), String.valueOf(mapping.getEbsVolumeSize())); if (mapping.getEbsNoDevice() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.NoDevice", i), String.valueOf(mapping.getEbsNoDevice())); if (mapping.getEbsDeleteOnTermination() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.DeleteOnTermination", i), String.valueOf(mapping.getEbsDeleteOnTermination())); if (mapping.getEbsVolumeType() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.VolumeType", i), mapping.getEbsVolumeType()); if (mapping.getEbsIops() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.Iops", i), String.valueOf(mapping.getEbsIops())); if (mapping.getEbsEncrypted() != null && mapping.getEbsEncrypted()) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.Encrypted", i), String.valueOf(mapping.getEbsEncrypted())); i++; } return this; } }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings) { int i = 1; for (BlockDeviceMapping mapping : checkNotNull(mappings, "mappings")) { checkNotNull(mapping.getDeviceName(), "deviceName"); formParameters.put(String.format("BlockDeviceMapping.%d.DeviceName", i), mapping.getDeviceName()); if (mapping.getVirtualName() != null) formParameters.put(String.format("BlockDeviceMapping.%d.VirtualName", i), mapping.getVirtualName()); if (mapping.getEbsSnapshotId() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.SnapshotId", i), mapping.getEbsSnapshotId()); if (mapping.getEbsVolumeSize() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.VolumeSize", i), String.valueOf(mapping.getEbsVolumeSize())); if (mapping.getEbsNoDevice() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.NoDevice", i), String.valueOf(mapping.getEbsNoDevice())); if (mapping.getEbsDeleteOnTermination() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.DeleteOnTermination", i), String.valueOf(mapping.getEbsDeleteOnTermination())); if (mapping.getEbsVolumeType() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.VolumeType", i), mapping.getEbsVolumeType()); if (mapping.getEbsIops() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.Iops", i), String.valueOf(mapping.getEbsIops())); if (mapping.getEbsEncrypted() != null && mapping.getEbsEncrypted()) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.Encrypted", i), String.valueOf(mapping.getEbsEncrypted())); i++; } return this; } }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings) { int i = 1; for (BlockDeviceMapping mapping : checkNotNull(mappings, "mappings")) { checkNotNull(mapping.getDeviceName(), "deviceName"); formParameters.put(String.format("BlockDeviceMapping.%d.DeviceName", i), mapping.getDeviceName()); if (mapping.getVirtualName() != null) formParameters.put(String.format("BlockDeviceMapping.%d.VirtualName", i), mapping.getVirtualName()); if (mapping.getEbsSnapshotId() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.SnapshotId", i), mapping.getEbsSnapshotId()); if (mapping.getEbsVolumeSize() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.VolumeSize", i), String.valueOf(mapping.getEbsVolumeSize())); if (mapping.getEbsNoDevice() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.NoDevice", i), String.valueOf(mapping.getEbsNoDevice())); if (mapping.getEbsDeleteOnTermination() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.DeleteOnTermination", i), String.valueOf(mapping.getEbsDeleteOnTermination())); if (mapping.getEbsVolumeType() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.VolumeType", i), mapping.getEbsVolumeType()); if (mapping.getEbsIops() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.Iops", i), String.valueOf(mapping.getEbsIops())); if (mapping.getEbsEncrypted() != null && mapping.getEbsEncrypted()) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.Encrypted", i), String.valueOf(mapping.getEbsEncrypted())); i++; } return this; } RunInstancesOptions withKeyName(String keyName); RunInstancesOptions withSecurityGroups(String... securityGroups); RunInstancesOptions withSecurityGroups(Iterable<String> securityGroups); RunInstancesOptions withSecurityGroup(String securityGroup); RunInstancesOptions withUserData(byte[] unencodedData); RunInstancesOptions asType(String type); RunInstancesOptions withKernelId(String kernelId); RunInstancesOptions withRamdisk(String ramDiskId); RunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings); RunInstancesOptions withClientToken(String clientToken); }
RunInstancesOptions extends BaseEC2RequestOptions { public RunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings) { int i = 1; for (BlockDeviceMapping mapping : checkNotNull(mappings, "mappings")) { checkNotNull(mapping.getDeviceName(), "deviceName"); formParameters.put(String.format("BlockDeviceMapping.%d.DeviceName", i), mapping.getDeviceName()); if (mapping.getVirtualName() != null) formParameters.put(String.format("BlockDeviceMapping.%d.VirtualName", i), mapping.getVirtualName()); if (mapping.getEbsSnapshotId() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.SnapshotId", i), mapping.getEbsSnapshotId()); if (mapping.getEbsVolumeSize() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.VolumeSize", i), String.valueOf(mapping.getEbsVolumeSize())); if (mapping.getEbsNoDevice() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.NoDevice", i), String.valueOf(mapping.getEbsNoDevice())); if (mapping.getEbsDeleteOnTermination() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.DeleteOnTermination", i), String.valueOf(mapping.getEbsDeleteOnTermination())); if (mapping.getEbsVolumeType() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.VolumeType", i), mapping.getEbsVolumeType()); if (mapping.getEbsIops() != null) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.Iops", i), String.valueOf(mapping.getEbsIops())); if (mapping.getEbsEncrypted() != null && mapping.getEbsEncrypted()) formParameters.put(String.format("BlockDeviceMapping.%d.Ebs.Encrypted", i), String.valueOf(mapping.getEbsEncrypted())); i++; } return this; } RunInstancesOptions withKeyName(String keyName); RunInstancesOptions withSecurityGroups(String... securityGroups); RunInstancesOptions withSecurityGroups(Iterable<String> securityGroups); RunInstancesOptions withSecurityGroup(String securityGroup); RunInstancesOptions withUserData(byte[] unencodedData); RunInstancesOptions asType(String type); RunInstancesOptions withKernelId(String kernelId); RunInstancesOptions withRamdisk(String ramDiskId); RunInstancesOptions withBlockDeviceMappings(Set<? extends BlockDeviceMapping> mappings); RunInstancesOptions withClientToken(String clientToken); static final RunInstancesOptions NONE; }