Permalink
Browse files

Fix error when status not defined

  • Loading branch information...
nicolasferry committed Aug 3, 2015
1 parent 4914826 commit abc9576cfc8bc79147cbcf8fab2c6d52779335ee
@@ -62,7 +62,7 @@
private ComputeManagementClient computeManagementClient;
private HostedServiceOperations hostedServicesOperations;
private HashMap<String,String> runtimeInformation;
private HashMap<String,Object> runtimeInformation;
public AzureConnector(String endpoint, String provider,String login,String secretKey){
journal.log(Level.INFO, ">> Connecting to "+provider+" ...");
@@ -98,8 +98,8 @@ public void execCommand(String id, String command, String login, String key) {
}
@Override
public HashMap<String, String> createInstance(VMInstance a) {
runtimeInformation=new HashMap<String, String>();
public HashMap<String, Object> createInstance(VMInstance a) {
runtimeInformation=new HashMap<String, Object>();
VM vm = a.getType();
ComponentInstance.State state = ComponentInstance.State.UNRECOGNIZED;
@@ -199,7 +199,7 @@ public void execCommand(String id, String command, String login, String key) {
}
state = ComponentInstance.State.RUNNING;
runtimeInformation.put("status", state.toString());
runtimeInformation.put("status", state);
return runtimeInformation;
}
@@ -60,7 +60,7 @@
private ComputeServiceContext computeContext;
private ComputeService compute;
private String provider;
private HashMap<String,String> runtimeInformation;
private HashMap<String,Object> runtimeInformation;
private CloudSigma2Api cloudSigmaApi;
@@ -124,9 +124,9 @@ private String readSshKey(String keyPath){
@Override
public HashMap<String, String> createInstance(VMInstance a) {
public HashMap<String, Object> createInstance(VMInstance a) {
VM vm = a.getType();
runtimeInformation=new HashMap<String, String>();
runtimeInformation=new HashMap<String, Object>();
ComponentInstance.State state = ComponentInstance.State.UNRECOGNIZED;
// First try to find the desired template drive in MyDrives
@@ -230,7 +230,7 @@ private String readSshKey(String keyPath){
}
runtimeInformation.put("status", state.toString());
runtimeInformation.put("status", state);
return runtimeInformation;
}
@@ -31,7 +31,7 @@
public void execCommand(String id, String command, String login, String key);
public HashMap<String,String> createInstance(VMInstance a);
public HashMap<String,Object> createInstance(VMInstance a);
public void destroyVM(String id);
@@ -49,7 +49,7 @@
private final String endpoint;
private UserService service;
private BindingProvider portBP;
private HashMap<String,String> runtimeInformation=new HashMap<String, String>();
private HashMap<String,Object> runtimeInformation=new HashMap<String, Object>();
@SuppressWarnings("restriction")
public FlexiantConnector(String endPoint, String login, String secretKey) throws MalformedURLException{
@@ -150,7 +150,7 @@ public FlexiantConnector(String endPoint, String login, String secretKey) throws
}
}
public HashMap<String,String> createInstance(VMInstance a){
public HashMap<String,Object> createInstance(VMInstance a){
ComponentInstance.State state = ComponentInstance.State.UNRECOGNIZED;
try {
Server template = new Server();
@@ -160,7 +160,7 @@ public FlexiantConnector(String endPoint, String login, String secretKey) throws
template.setResourceType(ResourceType.SERVER);
journal.log(Level.INFO, ">> Provisioning a vm ..."+vm.getGroupName());
journal.log(Level.INFO, ">> Provisioning a vm ...");
if (vm.getMinCores() > 0 && vm.getMinRam() > 0)
template.setProductOfferUUID(findProduct(((double) vm.getMinRam()), vm.getMinCores()));
@@ -226,7 +226,7 @@ public FlexiantConnector(String endPoint, String login, String secretKey) throws
//a.setStatusAsError();
state = ComponentInstance.State.ERROR;
}
runtimeInformation.put("status", state.toString());
runtimeInformation.put("status", state);
return runtimeInformation;
}
@@ -237,9 +237,17 @@ public void execCommand(VMInstance n, String command, String login, String keyPa
public void execCommand(String id, String command, String login, String keyPath){
Server temp=(Server)findObjectResourceByID(id, ResourceType.SERVER);
String ip=temp.getNics().get(0).getIpAddresses().get(0).getIpAddress();
SSHConnector sc=new SSHConnector(keyPath, login, ip);
while (!sc.checkConnectivity()){
try {
Thread.sleep(32000);
} catch (InterruptedException e) {
journal.log(Level.SEVERE, e.getMessage());
}
}
try {
Thread.sleep(32000);
} catch (InterruptedException e) {
@@ -81,7 +81,7 @@
private String provider;
private ComputeServiceContext computeContext;
private EC2Api ec2api;
private HashMap<String,String> runtimeInformation;
private HashMap<String,Object> runtimeInformation;
public JCloudsConnector(String provider,String login,String secretKey){
journal.log(Level.INFO, ">> Connecting to "+provider+" ...");
@@ -263,8 +263,8 @@ public void updateVMMetadata(VMInstance a){
* @param a description of the VM to be created
* @return
*/
public HashMap<String,String> createInstance(VMInstance a){
runtimeInformation=new HashMap<String, String>();
public HashMap<String,Object> createInstance(VMInstance a){
runtimeInformation=new HashMap<String, Object>();
VM vm = a.getType();
ComponentInstance.State state = ComponentInstance.State.UNRECOGNIZED;
NodeMetadata cm= (NodeMetadata)getVMByName(a.getName());
@@ -342,7 +342,7 @@ public void updateVMMetadata(VMInstance a){
state = ComponentInstance.State.RUNNING;
}
runtimeInformation.put("status", state.toString());
runtimeInformation.put("status", state);
return runtimeInformation;
}
@@ -73,7 +73,7 @@
private ComputeService novaComputeService;
private final String endpoint;
private NovaApi serverApi;
private HashMap<String,String> runtimeInformation=new HashMap<String, String>();
private HashMap<String,Object> runtimeInformation=new HashMap<String, Object>();
public OpenStackConnector(String endPoint,String provider,String login,String secretKey){
this.endpoint=endPoint;
@@ -338,7 +338,7 @@ public Image checkIfImageExist(String name){
* @param a description of the VM to be created
* @return
*/
public HashMap<String,String> createInstance(VMInstance a){
public HashMap<String,Object> createInstance(VMInstance a){
ComponentInstance.State state = ComponentInstance.State.UNRECOGNIZED;
VM vm = a.getType();
ComputeMetadata cm= getVMByName(a.getName());
@@ -439,7 +439,7 @@ public Image checkIfImageExist(String name){
state = ComponentInstance.State.RUNNING;
}
runtimeInformation.put("status",state.toString());
runtimeInformation.put("status",state);
return runtimeInformation;
}
@@ -140,17 +140,17 @@ public Boolean execCommandSsh(String command){
in = channel.getInputStream();
InputStream extIn=channel.getExtInputStream();
channel.connect();
byte[] tmp=new byte[2048];
byte[] tmp2=new byte[2048];
byte[] tmp=new byte[4096];
byte[] tmp2=new byte[4096];
while(true){
while(in.available()>0 || extIn.available()>0){
if(in.available()>0){
int i=in.read(tmp, 0, 2048);
int i=in.read(tmp, 0, 4096);
if(i<0)break;
journal.log(Level.INFO, ">> "+ new String(tmp, 0, i));
}
if(extIn.available()>0){
int i=extIn.read(tmp2, 0, 2048);
int i=extIn.read(tmp2, 0, 4096);
if(i<0)break;
journal.log(Level.INFO, ">> "+ new String(tmp2, 0, i));
}
@@ -364,7 +364,7 @@ private void prepareAnInternalComponent(InternalComponentInstance instance, Comp
}*/
for(InternalComponentInstance ici: host.hostedComponents()){
coordinator.updateStatus(ici.getName(), InternalComponentInstance.State.RUNNING.toString(), CloudAppDeployer.class.getName());
coordinator.updateStatusInternalComponent(ici.getName(), InternalComponentInstance.State.RUNNING.toString(), CloudAppDeployer.class.getName());
}
coordinator.updateStatusInternalComponent(host.getName(), ComponentInstance.State.RUNNING.toString(), CloudAppDeployer.class.getName());
}
@@ -768,20 +768,21 @@ private void provisionAVM(VMInstance n) {
}
Provider p = n.getType().getProvider();
Connector jc = ConnectorFactory.createIaaSConnector(p);
coordinator.updateStatus(n.getName(), ComponentInstance.State.PENDING.toString(), CloudAppDeployer.class.getName());
HashMap<String,String> runtimeInformation = jc.createInstance(n);
coordinator.updateStatus(n.getName(), ComponentInstance.State.PENDING, CloudAppDeployer.class.getName());
HashMap<String,Object> runtimeInformation = jc.createInstance(n);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
coordinator.updateStatus(n.getName(), runtimeInformation.get("status"), CloudAppDeployer.class.getName());
journal.log(Level.INFO, ">> Status: "+runtimeInformation.get("status"));
coordinator.updateStatus(n.getName(), (ComponentInstance.State)runtimeInformation.get("status"), CloudAppDeployer.class.getName());
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
coordinator.updateIP(n.getName(),runtimeInformation.get("publicAddress"),CloudAppDeployer.class.getName());
coordinator.updateIP(n.getName(),runtimeInformation.get("publicAddress").toString(),CloudAppDeployer.class.getName());
//enable the monitoring of the new machine
if (statusMonitorActive) {
statusMonitor.attachModule(jc);
@@ -822,7 +823,7 @@ private void provisionAPlatform(ExternalComponentInstance n) {
String pa=connector.getDBEndPoint(eci.getName(), 600);
eci.setPublicAddress(pa);
coordinator.updateIP(n.getName(),pa,CloudAppDeployer.class.getName());
coordinator.updateStatus(n.getName(), ComponentInstance.State.RUNNING.toString(), CloudAppDeployer.class.getName());
coordinator.updateStatus(n.getName(), ComponentInstance.State.RUNNING, CloudAppDeployer.class.getName());
//execute the configure command
/*if (!n.getType().getResources().isEmpty()) {
for (Resource r : n.getType().getResources()) {
@@ -837,7 +838,7 @@ private void provisionAPlatform(ExternalComponentInstance n) {
if (ec.getServiceType().toLowerCase().equals("messagequeue")) {
String url = connector.createQueue(n.getName());
eci.setPublicAddress(url);
coordinator.updateStatus(n.getName(), ComponentInstance.State.RUNNING.toString(), CloudAppDeployer.class.getName());
coordinator.updateStatus(n.getName(), ComponentInstance.State.RUNNING, CloudAppDeployer.class.getName());
}
if(ec.getServiceType().toLowerCase().equals("loadbalancer")){
String endpoint = ec.getEndPoint();
@@ -868,7 +869,7 @@ private void provisionAPlatform(ExternalComponentInstance n) {
journal.log(Level.INFO, ">>Add pool:" + pConnector.addPool(eci.getName() + "Back", testPool));
journal.log(Level.INFO, ">> " + pConnector.addGateway(gateway));
coordinator.updateStatus(n.getName(), ComponentInstance.State.RUNNING.toString(), CloudAppDeployer.class.getName());
coordinator.updateStatus(n.getName(), ComponentInstance.State.RUNNING, CloudAppDeployer.class.getName());
}
if (statusMonitorActive) {
statusMonitor.attachModule(connector);
@@ -895,13 +896,13 @@ protected void configureWithRelationships(RelationshipInstanceGroup relationship
if (valet != null)
valet.config();
else if(res.hasProperty("db-binding-alias")){
coordinator.updateStatus(bi.getProvidedEnd().getOwner().get().getName(), ComponentInstance.State.PENDING.toString(), CloudAppDeployer.class.getName());
coordinator.updateStatus(bi.getProvidedEnd().getOwner().get().getName(), ComponentInstance.State.PENDING, CloudAppDeployer.class.getName());
try{
Provider p = ((ExternalComponent) bi.getProvidedEnd().getOwner().get().getType()).getProvider();
PaaSConnector connector = ConnectorFactory.createPaaSConnector(p);
String alias = res.getProperties().valueOf("db-binding-alias");
connector.bindDbToApp(bi.getRequiredEnd().getOwner().getName(), bi.getProvidedEnd().getOwner().getName(), alias);
coordinator.updateStatus(bi.getProvidedEnd().getOwner().get().getName(), ComponentInstance.State.RUNNING.toString(), CloudAppDeployer.class.getName());
coordinator.updateStatus(bi.getProvidedEnd().getOwner().get().getName(), ComponentInstance.State.RUNNING, CloudAppDeployer.class.getName());
}catch(Exception ex){
ex.printStackTrace();
journal.log(Level.INFO, ">> db-binding only works for PaaS databases" );
@@ -988,7 +989,7 @@ else if (serveri.isExternal() && "loadbalancer".equals(((ExternalComponentInstan
journal.log(Level.INFO, ">>Modify backend: "+connector.addPool(serveri.getName()+"Back", backend));
journal.log(Level.INFO, ">>Delete Target: "+connector.deleteTarget(serveri.getName()+"Back", "targetOneHold"));
connector.start();
coordinator.updateStatus(serveri.getName(), ComponentInstance.State.RUNNING.toString(), CloudAppDeployer.class.getName());
coordinator.updateStatus(serveri.getName(), ComponentInstance.State.RUNNING, CloudAppDeployer.class.getName());
}
else if (bi.getRequiredEnd().getType().isRemote()) {
RequiredPortInstance client = bi.getRequiredEnd();
@@ -1154,7 +1155,7 @@ private void terminateVM(VMInstance n) {
Connector jc = ConnectorFactory.createIaaSConnector(p);
jc.destroyVM(n.getId());
jc.closeConnection();
coordinator.updateStatus(n.getName(), ComponentInstance.State.STOPPED.toString(), CloudAppDeployer.class.getName());
coordinator.updateStatus(n.getName(), ComponentInstance.State.STOPPED, CloudAppDeployer.class.getName());
//old way without using mrt
//n.setStatusAsStopped();
}
@@ -91,10 +91,10 @@ private void allConfiguration(Map<InternalComponentInstance, InternalComponentIn
private void provisionVM(VMInstance vmi){
Connector c2=ConnectorFactory.createIaaSConnector(vmi.getType().getProvider());
HashMap<String,String> result=c2.createInstance(ci);
HashMap<String,Object> result=c2.createInstance(ci);
c2.closeConnection();
coordinator.updateStatusInternalComponent(ci.getName(), result.get("status"), CloudAppDeployer.class.getName());
coordinator.updateStatus(vmi.getName(), ComponentInstance.State.RUNNING.toString(), CloudAppDeployer.class.getName());
coordinator.updateIP(ci.getName(),result.get("publicAddress"),CloudAppDeployer.class.getName());
coordinator.updateStatusInternalComponent(ci.getName(), result.get("status").toString(), CloudAppDeployer.class.getName());
coordinator.updateStatus(vmi.getName(), ComponentInstance.State.RUNNING, CloudAppDeployer.class.getName());
coordinator.updateIP(ci.getName(),result.get("publicAddress").toString(),CloudAppDeployer.class.getName());
}
}
@@ -203,11 +203,11 @@ public void scaleOut(VMInstance vmi, int n){
public void run() {
//once this is done we can work in parallel
Connector c2 = ConnectorFactory.createIaaSConnector(vm.getProvider());
HashMap<String, String> result = c2.createInstance(ci);
HashMap<String, Object> result = c2.createInstance(ci);
c2.closeConnection();
coordinator.updateStatusInternalComponent(ci.getName(), result.get("status"), CloudAppDeployer.class.getName());
coordinator.updateStatus(name, ComponentInstance.State.RUNNING.toString(), CloudAppDeployer.class.getName());
coordinator.updateIP(ci.getName(),result.get("publicAddress"),CloudAppDeployer.class.getName());
coordinator.updateStatusInternalComponent(ci.getName(), result.get("status").toString(), CloudAppDeployer.class.getName());
coordinator.updateStatus(name, ComponentInstance.State.RUNNING, CloudAppDeployer.class.getName());
coordinator.updateIP(ci.getName(),result.get("publicAddress").toString(),CloudAppDeployer.class.getName());
dep.setAllEnvVarComponent(currentModel);
@@ -266,12 +266,12 @@ public void scaleOut(VMInstance vmi) {
}
Connector c2=ConnectorFactory.createIaaSConnector(v.getProvider());
HashMap<String,String> result=c2.createInstance(ci);
HashMap<String,Object> result=c2.createInstance(ci);
c2.closeConnection();
coordinator.updateStatusInternalComponent(ci.getName(), result.get("status"), CloudAppDeployer.class.getName());
coordinator.updateStatus(vmi.getName(), ComponentInstance.State.RUNNING.toString(), CloudAppDeployer.class.getName());
coordinator.updateIP(ci.getName(),result.get("publicAddress"),CloudAppDeployer.class.getName());
coordinator.updateStatusInternalComponent(ci.getName(), result.get("status").toString(), CloudAppDeployer.class.getName());
coordinator.updateStatus(vmi.getName(), ComponentInstance.State.RUNNING, CloudAppDeployer.class.getName());
coordinator.updateIP(ci.getName(),result.get("publicAddress").toString(),CloudAppDeployer.class.getName());
dep.setAllEnvVarComponent(currentModel);
@@ -254,7 +254,7 @@ public void run() {
Provider provider = vmi.getType().getProvider();
Connector c = ConnectorFactory.createIaaSConnector(provider);
c.startVM(vmi);
coordinator.updateStatus(vmi.getName(), ComponentInstance.State.RUNNING.toString(), Facade.class.getName());
coordinator.updateStatus(vmi.getName(), ComponentInstance.State.RUNNING, Facade.class.getName());
for(InternalComponentInstance ici : vmi.hostedComponents()){
InternalComponent ic=ici.getType();
for(Resource r : ic.getResources()){
@@ -317,7 +317,7 @@ public void run() {
}
}
c.stopVM(vmi);
coordinator.updateStatus(vmi.getName(), ComponentInstance.State.STOPPED.toString(), Facade.class.getName());
coordinator.updateStatus(vmi.getName(), ComponentInstance.State.STOPPED, Facade.class.getName());
c.closeConnection();
}
}
Oops, something went wrong.

0 comments on commit abc9576

Please sign in to comment.