Ejemplo n.º 1
0
        internal async Task <string> PrepForSnapshot(SnapSession session)
        {
            try
            {
                SnapShotPutBody body = new SnapShotPutBody();
                body.RunAsNames = session.RunAsName;
                VolumeMapping vm    = new VolumeMapping();
                VolumeName    vname = new VolumeName();
                vname.Name    = session.VolumeName;
                vm.VolumeName = vname;
                FootPrintObject fp = new FootPrintObject();
                fp.SVMName           = session.SvmName;
                fp.VolAndLunsMapping = new System.Collections.Generic.List <VolumeMapping>();
                fp.VolAndLunsMapping.Add(vm);
                body.FootPrint = new System.Collections.Generic.List <FootPrintObject>();
                body.FootPrint.Add(fp);
                PluginParams pluginParams = new PluginParams();
                pluginParams.Data = new System.Collections.Generic.List <PluginData>();
                PluginData port = new PluginData();
                port.Key   = "PORT";
                port.Value = "3306";
                pluginParams.Data.Add(port);
                PluginData ms = new PluginData();
                ms.Key   = "MASTER_SLAVE";
                ms.Value = "N";
                pluginParams.Data.Add(ms);
                PluginData host = new PluginData();
                host.Key   = "HOST";
                host.Value = session.CloneHostName;
                pluginParams.Data.Add(host);
                PluginData uid = new PluginData();
                uid.Key   = "CLONE_UID";
                uid.Value = SnapSession.BuildCloneName(session.DbName, session.AppName);
                pluginParams.Data.Add(uid);
                body.PluginParams = pluginParams;

                ClientResponse <SnapBackupResponse> response = await this.SendRequestAsync <SnapBackupResponse>(Method.PUT, $"api/3.0/plugins/{session.Plugin}/resources/{session.DbKey}", body, false);

                log.Info($"Payload PUT data Detail: {response.Payload}");

                return(response.Response.StatusCode.ToString());
            }
            catch (Exception ex)
            {
                this.log.Error($"Error executing PUT data for snapshot of clone with key {session.DbKey}: {ex}");
                throw;
            }
        }
Ejemplo n.º 2
0
        internal async Task <string> CreateResource(SnapSession session)
        {
            string answer = string.Empty;

            try
            {
                log.Info($"Token = {this.token}");
                ResourceBody body = new ResourceBody();
                body.ResourceName = session.DbName;
                body.ResourceType = "Database";
                body.HostName     = session.HostName;
                body.RunAsNames   = $"{session.DbName}_{session.Plugin}";
                body.MountPaths   = new System.Collections.Generic.List <MountInfo>();
                MountInfo mi = new MountInfo();
                mi.MountPath = session.MountPath;
                body.MountPaths.Add(mi);
                VolumeMapping vm    = new VolumeMapping();
                VolumeName    vname = new VolumeName();
                vname.Name    = session.VolumeName;
                vm.VolumeName = vname;
                FootPrintObject fp = new FootPrintObject();
                fp.SVMName           = session.SvmName;
                fp.VolAndLunsMapping = new System.Collections.Generic.List <VolumeMapping>();
                fp.VolAndLunsMapping.Add(vm);
                body.FootPrint = new System.Collections.Generic.List <FootPrintObject>();
                body.FootPrint.Add(fp);
                PluginParams pluginParams = new PluginParams();
                pluginParams.Data = new System.Collections.Generic.List <PluginData>();
                PluginData ms = new PluginData();
                ms.Key   = "MASTER_SLAVE";
                ms.Value = "N";
                pluginParams.Data.Add(ms);
                body.PluginParams = pluginParams;

                var response = await this.SendRequestAsync <dynamic>(Method.POST, $"api/3.0/plugins/MySQL/resources", body, false);

                log.Info($"Payload: {response.Payload}");
                string dbKey = string.Empty;
                answer = response.Response.Content.ToString();
            }
            catch (Exception ex)
            {
                this.log.Error($"Error while getting creating resource key: {ex}");
            }
            return(answer);
        }