if (getKernelId() != null) sb.append("KernelId: ").append(getKernelId()).append(","); if (getKeyName() != null) sb.append("KeyName: ").append(getKeyName()).append(","); if (getLaunchTime() != null) sb.append("LaunchTime: ").append(getLaunchTime()).append(",");
hashCode = prime * hashCode + ((getInstanceType() == null) ? 0 : getInstanceType().hashCode()); hashCode = prime * hashCode + ((getKernelId() == null) ? 0 : getKernelId().hashCode()); hashCode = prime * hashCode + ((getKeyName() == null) ? 0 : getKeyName().hashCode()); hashCode = prime * hashCode + ((getLaunchTime() == null) ? 0 : getLaunchTime().hashCode()); hashCode = prime * hashCode + ((getMonitoring() == null) ? 0 : getMonitoring().hashCode());
/** * Constructs and returns an BasicInstance object, using information from <code>ec2</code> * * @param ec2 * @return */ protected static Instance toInstance( com.amazonaws.services.ec2.model.Instance ec2 ) { Instance instance; BasicInstanceSpec spec; spec = new BasicInstanceSpec(); spec.setImageId( ec2.getImageId() ); spec.setKeyName( ec2.getKeyName() ); spec.setType( ec2.getInstanceType() ); instance = new BasicInstance( ec2.getInstanceId(), spec, InstanceState.fromValue( ec2.getState().getName() ), ec2.getPrivateDnsName(), ec2.getPublicDnsName(), ec2.getPrivateIpAddress(), ec2.getPublicIpAddress() ); return instance; }
if (other.getKernelId() != null && other.getKernelId().equals(this.getKernelId()) == false) return false; if (other.getKeyName() == null ^ this.getKeyName() == null) return false; if (other.getKeyName() != null && other.getKeyName().equals(this.getKeyName()) == false) return false; if (other.getLaunchTime() == null ^ this.getLaunchTime() == null)
if (getPublicDnsName() != null) sb.append("PublicDnsName: " + getPublicDnsName() + ","); if (getStateTransitionReason() != null) sb.append("StateTransitionReason: " + getStateTransitionReason() + ","); if (getKeyName() != null) sb.append("KeyName: " + getKeyName() + ","); if (getAmiLaunchIndex() != null) sb.append("AmiLaunchIndex: " + getAmiLaunchIndex() + ","); if (getProductCodes() != null) sb.append("ProductCodes: " + getProductCodes() + ",");
hashCode = prime * hashCode + ((getPublicDnsName() == null) ? 0 : getPublicDnsName().hashCode()); hashCode = prime * hashCode + ((getStateTransitionReason() == null) ? 0 : getStateTransitionReason().hashCode()); hashCode = prime * hashCode + ((getKeyName() == null) ? 0 : getKeyName().hashCode()); hashCode = prime * hashCode + ((getAmiLaunchIndex() == null) ? 0 : getAmiLaunchIndex().hashCode()); hashCode = prime * hashCode + ((getProductCodes() == null) ? 0 : getProductCodes().hashCode());
private boolean verifyKeyPair(Instance instance) { boolean result = false; String keyName = keyRef; if (instance.getKeyName() != null && keyName != null) { if (instance.getKeyName().equals(keyName)) { result = true; } } return result; }
if (other.getStateTransitionReason() == null ^ this.getStateTransitionReason() == null) return false; if (other.getStateTransitionReason() != null && other.getStateTransitionReason().equals(this.getStateTransitionReason()) == false) return false; if (other.getKeyName() == null ^ this.getKeyName() == null) return false; if (other.getKeyName() != null && other.getKeyName().equals(this.getKeyName()) == false) return false; if (other.getAmiLaunchIndex() == null ^ this.getAmiLaunchIndex() == null) return false; if (other.getAmiLaunchIndex() != null && other.getAmiLaunchIndex().equals(this.getAmiLaunchIndex()) == false) return false;
/** * Generates a ssh login command for *nix to access the given ec2 instance. * * @param instance the ec2 instance * @return ssh login command. */ private String getLoginCommand(Instance instance) { final String privateIpAddress = instance.getPrivateIpAddress(); String publicAddress = instance.getPublicDnsName(); publicAddress = publicAddress == null ? instance.getPublicIpAddress() : publicAddress; final String keyName = instance.getKeyName(); String instanceName = instance.getTags().stream() .filter(t -> t.getKey().equals("Name")) .map(com.amazonaws.services.ec2.model.Tag::getValue) .findAny().orElse(""); instanceName = instanceName.isEmpty() ? "" : "# name: " + instanceName; String platform = instance.getPlatform(); platform = platform == null || platform.isEmpty() ? "" : "# platform: " + platform; String ip; if (publicAddress != null && !publicAddress.isEmpty()) { ip = publicAddress; } else { ip = privateIpAddress; } //root user is assumed. EC2 instances print the actual user name when tried to log-in as the root user. return "ssh -i " + keyName + " root@" + ip + "; " + instanceName + platform; }
if (getKernelId() != null) sb.append("KernelId: ").append(getKernelId()).append(","); if (getKeyName() != null) sb.append("KeyName: ").append(getKeyName()).append(","); if (getLaunchTime() != null) sb.append("LaunchTime: ").append(getLaunchTime()).append(",");
hashCode = prime * hashCode + ((getInstanceType() == null) ? 0 : getInstanceType().hashCode()); hashCode = prime * hashCode + ((getKernelId() == null) ? 0 : getKernelId().hashCode()); hashCode = prime * hashCode + ((getKeyName() == null) ? 0 : getKeyName().hashCode()); hashCode = prime * hashCode + ((getLaunchTime() == null) ? 0 : getLaunchTime().hashCode()); hashCode = prime * hashCode + ((getMonitoring() == null) ? 0 : getMonitoring().hashCode());
if (this.instance.getKeyName() == null || !this.instance.getKeyName().equals(KEY_PAIR_NAME)) throw new GfacException("Keypair for instance:" + ins_id + " is not valid");
/** * @see org.apache.airavata.xbaya.ui.widgets.TableRenderable#getValue(int) */ @Override public Object getValue(int index) { switch (index) { case 0: return this.instance.getInstanceId(); case 1: return this.instance.getImageId(); case 2: return this.instance.getRootDeviceType(); case 3: return this.instance.getInstanceType(); case 4: return this.instance.getState().getName(); case 5: return this.instance.getKeyName(); case 6: return this.instance.getMonitoring().getState(); case 7: return this.instance.getVirtualizationType(); case 8: return this.instance.getPlacement().getGroupName(); default: return null; } }
this.platform = instance.getPlatform(); this.kernel = instance.getKernelId(); this.key = instance.getKeyName(); this.image = instance.getImageId(); this.privateIP = instance.getPrivateIpAddress();
if (other.getKernelId() != null && other.getKernelId().equals(this.getKernelId()) == false) return false; if (other.getKeyName() == null ^ this.getKeyName() == null) return false; if (other.getKeyName() != null && other.getKeyName().equals(this.getKeyName()) == false) return false; if (other.getLaunchTime() == null ^ this.getLaunchTime() == null)