示例#1
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            repositoryOptions Options = null;

            SapiClients.CheckConnection();
            if (S3)
            {
                Options = new awsS3RepositoryOptions()
                {
                    accessKey = AccessKey,
                    backet    = Backet,
                    name      = Name,
                    region    = Region,
                    base64    = Base64,
                    secretKey = SecretKey,
                    active    = Default
                };
            }
            else if (File)
            {
                Options = new fileRepositoryOptions()
                {
                    name       = Name,
                    rootFolder = RootFolder,
                    active     = Default
                };
            }

            var actionTask  = SapiClients.client.connectRepositoryAsync(Options);
            var result      = Progress("ConnectRepository", actionTask);
            var finalResult = new SapiConnectRepositoryResult(result);

            WriteObject(finalResult); // This is what actually "returns" output.
        }
示例#2
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            SapiClients.CheckConnection();
            var result = SapiClients.client.getActiveRepository( );

            WriteObject(result); // This is what actually "returns" output.
        }
示例#3
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            SapiClients.CheckConnection();
            var     target = SapiClients.client.setActiveRepository(Name);
            Boolean result = target.state == operationState.SUCCESS;

            WriteObject(result, true); // This is what actually "returns" output.
        }
示例#4
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            SapiClients.CheckConnection();
            var actionTask = SapiClients.client.disconnectRepositoryAsync(Name);


            var result = Progress("ConnectRepository", actionTask);

            WriteObject(result); // This is what actually "returns" output.
        }
示例#5
0
 protected override void ProcessRecord()
 {
     base.ProcessRecord();
     SapiClients.CheckConnection();
     if (Name != null)
     {
         var target = SapiClients.client.getRepository(Name);
         WriteObject(target); // This is what actually "returns" output.
     }
     else
     {
         var targets = SapiClients.client.getRepositories();
         WriteObject(targets); // This is what actually "returns" output.
     }
 }
示例#6
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();

            SapiClients.CheckConnection();
            var ListOptions = new archiveListOptions();

            var ActionTask = SapiClients.client.listArchive(ListOptions);

            var result     = Progress("Archive list", ActionTask);
            var resultList = new SapiArchiveListResult[(result as resultActionArchiveItemsList).items.Length];


            for (int j = 0; j < (result as resultActionArchiveItemsList).items.Length; j++)
            {
                resultList[j] = new SapiArchiveListResult((result as resultActionArchiveItemsList).items[j]);
            }
            WriteObject(resultList, true);
        }
示例#7
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            SapiClients.CheckConnection();

            var Options = new restoreOptions();

            if (TransportMode != null)
            {
                Options.requestedTransportMode = TransportMode;
            }
            if (generationIdSet)
            {
                Options.generationIdSpecified = true;
                Options.generationId          = GenerationId;
            }


            if (Name != null)
            {
                Options.name = Name;
            }
            if (Prefix != null)
            {
                Options.prefix = Prefix;
            }
            if (Postfix != null)
            {
                Options.postfix = Postfix;
            }



            Options.importVmxFile = ImportVmxFile;
            Options.recover       = Recover;
            Options.overwrite     = Overwrite;
            Options.powerOn       = PowerOn;

            if (Datacenter != null)
            {
                Options.datacenter = new searchManagementEntity
                {
                    searchTypeSpecified = true,
                    searchType          = searchManagementEntityInfoType.MOREF,
                    searchValue         = (Datacenter as DatacenterImpl).Id.Replace("Datacenter-", "")
                };
            }
            if (Datastore != null)
            {
                Options.datastore = new searchManagementEntity
                {
                    searchTypeSpecified = true,
                    searchType          = searchManagementEntityInfoType.MOREF,
                    searchValue         = (Datastore as DatastoreImpl).Id.Replace("Datastore-", "")
                };
            }
            if (Folder != null)
            {
                Options.folder = new searchManagementEntity
                {
                    searchTypeSpecified = true,
                    searchType          = searchManagementEntityInfoType.MOREF,
                    searchValue         = (Folder as FolderImpl).Id.Replace("Folder-", "")
                };
            }

            if (VMHost != null)
            {
                Options.host = new searchManagementEntity
                {
                    searchTypeSpecified = true,
                    searchType          = searchManagementEntityInfoType.MOREF,
                    searchValue         = (VMHost as VMHostImpl).Id.Replace("VMHost-", "")
                };
            }

            if (ResourcePool != null)
            {
                Options.resourcePool = new searchManagementEntity
                {
                    searchTypeSpecified = true,
                    searchType          = searchManagementEntityInfoType.MOREF,
                    searchValue         = (ResourcePool as ResourcePoolImpl).Id.Replace("ResourcePool-", "")
                };
            }


            if (Networks != null)
            {
                Options.networks = new searchManagementEntity[Networks.Length];
                for (int i = 0; i < Networks.Length; i++)
                {
                    if (Networks[i] != null)
                    {
                        Options.networks[i] = new searchManagementEntity
                        {
                            searchTypeSpecified = true,
                            searchType          = searchManagementEntityInfoType.MOREF,
                            searchValue         = Networks[i].Id.Replace("DistributedVirtualPortgroup-", "")
                        };
                    }
                }
            }


            if (Disks != null)
            {
                Options.disks = Disks;
            }
            //Vapp setting
            if (AllowDuplicatesSet)
            {
                Options.allowDuplicatedVmNamesInsideVappSpecified = true;
                Options.allowDuplicatedVmNamesInsideVapp          = AllowDuplicatesValue;
            }

            Options.targetList = ProcessTargetList();

            var ActionTask = SapiClients.client.restoreAsync(Options);

            var results = Progress("Restore", ActionTask);


            int index        = 0;
            var returnResult = new SapiRestoreResult[results.Length];

            foreach (var result in results)
            {
                returnResult[index] = new SapiRestoreResult(result);
                if (result is resultActionRestore)
                {
                    returnResult[index].GenerationId = (result as resultActionRestore).generationId;
                    returnResult[index].Item         = (result as resultActionRestore).fcoEntityInfo.name;
                }

                ++index;
            }

            WriteObject(returnResult, true);

            // This is what actually "returns" output.
        }
示例#8
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();

            SapiClients.CheckConnection();

            if (VirtualFull)
            {
                var Options = new virtualBackupOptions();
                if (generationIdSet)
                {
                    Options.generationIdSpecified = true;
                    Options.generationId          = GenerationId;
                }

                Options.targetList = ProcessTargetList();
                var ActionTask = SapiClients.client.virtualBackupAsync(Options);

                var results      = Progress("Virtual Full Backup", ActionTask);
                int index        = 0;
                var returnResult = new SapiVirtualBackupResult[results.Length];
                foreach (var result in results)
                {
                    returnResult[index] = new SapiVirtualBackupResult(result)
                    {
                        BackupMode   = (result as abstractResultActionVirtualBackup).backupMode,
                        GenerationId = (result as abstractResultActionVirtualBackup).generationId,
                        Items        = Item(index)
                    };
                    ++index;
                }
                WriteObject(returnResult, true); // This is what actually "returns" output.
            }
            else
            {
                var Options = new backupOptions();
                if (TransportModeSet)
                {
                    Options.requestedTransportMode       = TransportModeValue;
                    Options.requestedBackupModeSpecified = true;
                }
                if (QueryBlocksOptionSet)
                {
                    Options.queryBlocksOption          = QueryBlocksOptionValue;
                    Options.queryBlocksOptionSpecified = true;
                }
                if (CompressSet)
                {
                    Options.compressionSpecified = true;
                    Options.compression          = CompressValue;
                }
                if (CipherSet)
                {
                    Options.cipherSpecified = true;
                    Options.cipher          = CompressValue;
                }
                if (QuisceSpecs != null)
                {
                    Options.quisceSpec = QuisceSpecs;
                }
                if (Full)
                {
                    Options.requestedBackupMode          = backupMode.FULL;
                    Options.requestedBackupModeSpecified = true;
                }
                if (BlocksQuery != null)
                {
                    switch (BlocksQuery)
                    {
                    case "Allocated":
                        Options.queryBlocksOption = queryBlocksOption.ALLOCATED;
                        break;

                    case "ChangedAreas":
                        Options.queryBlocksOption = queryBlocksOption.CHANGED_AREAS;
                        break;

                    case "Full":
                        Options.queryBlocksOption = queryBlocksOption.FULL;
                        break;

                    default:
                        Options.queryBlocksOption = queryBlocksOption.UNKNOWS;
                        break;
                    }
                    Options.queryBlocksOptionSpecified = true;
                }

                Options.targetList = ProcessTargetList();

                var ActionTask = SapiClients.client.backupAsync(Options);

                var results      = Progress("Backup", ActionTask);
                int index        = 0;
                var returnResult = new SapiBackupResult[results.Length];
                foreach (var result in results)
                {
                    returnResult[index] = new SapiBackupResult(result);

                    if (result is resultActionBackup)
                    {
                        returnResult[index].BackupMode = (result as resultActionBackup).backupMode;

                        returnResult[index].GenerationId = (result as resultActionBackup).generationId;

                        if (returnResult[index].BackupMode == backupMode.INCREMENTAL)
                        {
                            returnResult[index].DependOnGenerationId = (result as resultActionBackup).generationInfo.previousGenerationId;
                        }
                    }
                    returnResult[index].Items = Item(index);
                    ++index;
                }
                WriteObject(returnResult, true); // This is what actually "returns" output.
            }
        }