Example #1
0
        protected override void ProcessRecord()
        {
            if (Id == Guid.Empty)
            {
                if (VirtualMachineId == Guid.Empty)
                {
                    GetAll(Connection).ToList().ForEach(WriteObject);
                }
                else
                {
                    var vm = GetVirtualMachine.GetOne(VirtualMachineId, Connection);

                    if (vm != null)
                    {
                        WriteObject(vm.OsDisk);
                        foreach (var netinterface in vm.DataDisks)
                        {
                            WriteObject(netinterface);
                        }
                    }
                }
            }
            else
            {
                WriteObject(GetOne(Id, Connection));
            }
        }
Example #2
0
        public static CoreLibrary.Models.Job RemoveForce(Guid Id, Connection con)
        {
            CoreLibrary.Models.Job job;

            bool IsSuccessfull = true;

            var vms = GetVirtualMachine.GetByvSubNetAll(Id, con);

            foreach (var vm in vms)
            {
                job = RemoveVirtualMachine.Remove(vm.Id, con, true);
                if (job == null)
                {
                    IsSuccessfull = false;
                }
                else if (job.State == "failed")
                {
                    IsSuccessfull = false;
                }
                else
                {
                    IsSuccessfull = true;
                }
            }

            if (IsSuccessfull)
            {
                return(Remove(Id, con, true));
            }

            return(null);
        }