private void OnImportInstance(string msg, string reply, string subject) { Logger.Debug(Strings.OnImportInstanceDebugLogMessage, ServiceDescription(), msg, reply); object[] credentials = new object[0]; credentials = JsonConvertibleObject.DeserializeFromJsonArray(msg); ProvisionedServicePlanType plan = (ProvisionedServicePlanType)Enum.Parse(typeof(ProvisionedServicePlanType), JsonConvertibleObject.ObjectToValue <string>(credentials[0])); ServiceCredentials prov_cred = new ServiceCredentials(); ServiceCredentials binding_creds = new ServiceCredentials(); prov_cred.FromJsonIntermediateObject(credentials[1]); binding_creds.FromJsonIntermediateObject(credentials[2]); prov_cred.ServiceWorkFactory.StartNew( () => { try { string instance = prov_cred.Name; string file_path = this.GetMigrationFolder(instance); bool result = this.ImportInstance(prov_cred, binding_creds, file_path, plan); NodeNats.Publish(reply, null, result.ToString()); } catch (Exception ex) { Logger.Warning(ex.ToString()); } }); }
private void OnEnableInstance(string msg, string reply, string subject) { Logger.Debug(Strings.OnEnableInstanceDebugMessage, ServiceDescription(), msg, reply); object[] credentials = new object[0]; credentials = JsonConvertibleObject.DeserializeFromJsonArray(msg); ServiceCredentials prov_cred = new ServiceCredentials(); Dictionary <string, object> binding_creds_hash = new Dictionary <string, object>(); prov_cred.FromJsonIntermediateObject(credentials[0]); binding_creds_hash = JsonConvertibleObject.ObjectToValue <Dictionary <string, object> >(credentials[1]); prov_cred.ServiceWorkFactory.StartNew( () => { try { this.EnableInstance(ref prov_cred, ref binding_creds_hash); // Update node_id in provision credentials.. prov_cred.NodeId = this.nodeId; credentials[0] = prov_cred; credentials[1] = binding_creds_hash; NodeNats.Publish(reply, null, JsonConvertibleObject.SerializeToJson(credentials)); } catch (Exception ex) { Logger.Warning(ex.ToString()); } }); }
private void OnCleanupNfs(string msg, string reply, string subject) { Logger.Debug(Strings.CleanupNfsLogMessage, ServiceDescription(), msg, reply); object[] request = new object[0]; request = JsonConvertibleObject.DeserializeFromJsonArray(msg); ServiceCredentials prov_cred = new ServiceCredentials(); ServiceCredentials binding_creds = new ServiceCredentials(); prov_cred.FromJsonIntermediateObject(request[0]); binding_creds.FromJsonIntermediateObject(request[1]); prov_cred.ServiceWorkFactory.StartNew( () => { try { string instance = prov_cred.Name; Directory.Delete(this.GetMigrationFolder(instance), true); NodeNats.Publish(reply, null, "true"); } catch (Exception ex) { Logger.Warning(ex.ToString()); } }); }
private void OnDisableInstance(string msg, string reply, string subject) { Logger.Debug(Strings.OnDisableInstanceDebugLogMessage, ServiceDescription(), msg, reply); object[] credentials = new object[0]; credentials = JsonConvertibleObject.DeserializeFromJsonArray(msg); ServiceCredentials prov_cred = new ServiceCredentials(); ServiceCredentials binding_creds = new ServiceCredentials(); prov_cred.FromJsonIntermediateObject(credentials[0]); binding_creds.FromJsonIntermediateObject(credentials[1]); prov_cred.ServiceWorkFactory.StartNew( () => { try { string instance = prov_cred.Name; string file_path = this.GetMigrationFolder(instance); Directory.CreateDirectory(file_path); bool result = this.DisableInstance(prov_cred, binding_creds); if (result) { result = this.DumpInstance(prov_cred, binding_creds, file_path); } NodeNats.Publish(reply, null, result.ToString()); } catch (Exception ex) { Logger.Warning(ex.ToString()); } }); }
protected override bool EnableInstance(ref ServiceCredentials provisionedCredential, ref Dictionary<string, object> bindingCredentialsHash) { if (provisionedCredential == null) { throw new ArgumentNullException("provisionedCredential"); } if (bindingCredentialsHash == null) { throw new ArgumentNullException("bindingCredentialsHash"); } Logger.Debug("Enabling instance {0}", provisionedCredential.Name); try { provisionedCredential = Bind(provisionedCredential.Name, null, provisionedCredential); foreach (KeyValuePair<string, object> pair in bindingCredentialsHash) { Handle handle = (Handle)pair.Value; ServiceCredentials cred = new ServiceCredentials(); cred.FromJsonIntermediateObject(handle.Credentials); Dictionary<string, object> bindingOptions = handle.Credentials.BindOptions; Bind(cred.Name, bindingOptions, cred); } } catch (Exception ex) { Logger.Warning("Could not enable instance {0}: [{1}]", provisionedCredential.Name, ex.ToString()); return false; } return true; }
private void OnImportInstance(string msg, string reply, string subject) { Logger.Debug(Strings.OnImportInstanceDebugLogMessage, ServiceDescription(), msg, reply); object[] credentials = new object[0]; credentials = JsonConvertibleObject.DeserializeFromJsonArray(msg); ProvisionedServicePlanType plan = (ProvisionedServicePlanType)Enum.Parse(typeof(ProvisionedServicePlanType), JsonConvertibleObject.ObjectToValue<string>(credentials[0])); ServiceCredentials prov_cred = new ServiceCredentials(); ServiceCredentials binding_creds = new ServiceCredentials(); prov_cred.FromJsonIntermediateObject(credentials[1]); binding_creds.FromJsonIntermediateObject(credentials[2]); prov_cred.ServiceWorkFactory.StartNew( () => { try { string instance = prov_cred.Name; string file_path = this.GetMigrationFolder(instance); bool result = this.ImportInstance(prov_cred, binding_creds, file_path, plan); NodeNats.Publish(reply, null, result.ToString()); } catch (Exception ex) { Logger.Warning(ex.ToString()); } }); }
private void OnEnableInstance(string msg, string reply, string subject) { Logger.Debug(Strings.OnEnableInstanceDebugMessage, ServiceDescription(), msg, reply); object[] credentials = new object[0]; credentials = JsonConvertibleObject.DeserializeFromJsonArray(msg); ServiceCredentials prov_cred = new ServiceCredentials(); Dictionary<string, object> binding_creds_hash = new Dictionary<string, object>(); prov_cred.FromJsonIntermediateObject(credentials[0]); binding_creds_hash = JsonConvertibleObject.ObjectToValue<Dictionary<string, object>>(credentials[1]); prov_cred.ServiceWorkFactory.StartNew( () => { try { this.EnableInstance(ref prov_cred, ref binding_creds_hash); // Update node_id in provision credentials.. prov_cred.NodeId = this.nodeId; credentials[0] = prov_cred; credentials[1] = binding_creds_hash; NodeNats.Publish(reply, null, JsonConvertibleObject.SerializeToJson(credentials)); } catch (Exception ex) { Logger.Warning(ex.ToString()); } }); }