Ejemplo n.º 1
0
        public async Task InitializeDialog(AsmToArmForm parentForm)
        {
            _ParentForm = parentForm;
            await this.azureAsmLoginControl1.BindContext(parentForm.AzureContextSourceASM);

            parentForm.AzureContextSourceASM.AfterAzureSubscriptionChange += AzureContextSourceASM_AfterAzureSubscriptionChange;
        }
Ejemplo n.º 2
0
        private async void PreExportForm_Load(object sender, EventArgs e)
        {
            parentForm = (AsmToArmForm)this.Owner;
            txtDestinationFolder.Text = AppDomain.CurrentDomain.BaseDirectory;

            List <TreeNode> selectedNodes = parentForm.SelectedNodes;

            btnExport.Text = btnExport.Text.Replace("0", selectedNodes.Count().ToString());

            artifacts = new AsmArtifacts();
            foreach (TreeNode selectedNode in selectedNodes)
            {
                Type tagType = selectedNode.Tag.GetType();
                if (tagType == typeof(AsmNetworkSecurityGroup))
                {
                    artifacts.NetworkSecurityGroups.Add((AsmNetworkSecurityGroup)selectedNode.Tag);
                }
                else if (tagType == typeof(AsmVirtualNetwork))
                {
                    artifacts.VirtualNetworks.Add((AsmVirtualNetwork)selectedNode.Tag);
                }
                else if (tagType == typeof(AsmStorageAccount))
                {
                    artifacts.StorageAccounts.Add((AsmStorageAccount)selectedNode.Tag);
                }
                else if (tagType == typeof(AsmVirtualMachine))
                {
                    artifacts.VirtualMachines.Add((AsmVirtualMachine)selectedNode.Tag);
                }
            }
        }
Ejemplo n.º 3
0
        public async void Bind(TreeNode armVirtualMachineNode, AsmToArmForm asmToArmForm)
        {
            _VirtualMachineNode = armVirtualMachineNode;
            _AsmToArmForm       = asmToArmForm;

            TreeNode          asmTreeNode       = (TreeNode)_VirtualMachineNode.Tag;
            AsmVirtualMachine asmVirtualMachine = (AsmVirtualMachine)asmTreeNode.Tag;

            lblRoleSize.Text           = asmVirtualMachine.RoleSize;
            lblOS.Text                 = asmVirtualMachine.OSVirtualHardDiskOS;
            lblVirtualNetworkName.Text = asmVirtualMachine.VirtualNetworkName;
            lblSubnetName.Text         = asmVirtualMachine.SubnetName;
            lblStaticIpAddress.Text    = asmVirtualMachine.StaticVirtualNetworkIPAddress;
            txtARMVMName.Text          = asmVirtualMachine.TargetName;

            this.diskProperties1.Bind(asmToArmForm, asmVirtualMachine.OSVirtualHardDisk);

            if ((asmVirtualMachine.TargetSubnet == null) ||
                (asmVirtualMachine.TargetSubnet.GetType() == typeof(AsmSubnet)))
            {
                rbVNetInMigration.Checked = true;
            }
            else
            {
                rbExistingARMVNet.Checked = true;
            }
        }
Ejemplo n.º 4
0
        internal void Bind(AsmToArmForm asmToArmForm, AsmDisk asmDisk)
        {
            _AsmToArmForm = asmToArmForm;
            _AsmDataDisk  = asmDisk;

            BindCommon();
        }
Ejemplo n.º 5
0
        internal void Bind(AsmToArmForm asmToArmForm, TreeNode armDataDiskNode)
        {
            _AsmToArmForm    = asmToArmForm;
            _ARMDataDiskNode = armDataDiskNode;
            _AsmDataDisk     = (AsmDisk)_ARMDataDiskNode.Tag;

            BindCommon();
        }
Ejemplo n.º 6
0
        internal void Bind(TreeNode networkSecurityGroupNode, AsmToArmForm asmToArmForm)
        {
            _NetworkSecurityGroupNode = networkSecurityGroupNode;

            TreeNode asmNetworkSecurityGroupNode            = (TreeNode)_NetworkSecurityGroupNode.Tag;
            AsmNetworkSecurityGroup asmNetworkSecurityGroup = (AsmNetworkSecurityGroup)asmNetworkSecurityGroupNode.Tag;

            lblSourceName.Text = asmNetworkSecurityGroup.Name;
            txtTargetName.Text = asmNetworkSecurityGroup.TargetName;
        }
Ejemplo n.º 7
0
        internal async Task Bind(AsmToArmForm parentForm, TreeNode resourceGroupNode)
        {
            _ParentForm        = parentForm;
            _ResourceGroupNode = resourceGroupNode;

            ArmResourceGroup armResourceGroup = (ArmResourceGroup)_ResourceGroupNode.Tag;

            txtName.Text = armResourceGroup.Name;

            try
            {
                cboTargetLocation.Items.Clear();
                foreach (ArmLocation armLocation in await _ParentForm.AzureContextTargetARM.AzureRetriever.GetAzureARMLocations())
                {
                    cboTargetLocation.Items.Add(armLocation);
                }
            }
            catch (WebException)
            {
                // We are trying to load the ARM defined subscription locations above first; however, this as of Feb 24 2017, this ARM query
                // does not succeed (503 Forbidden) across all Azure Environments.  For example, it works in Azure Commercial, but Azure US Gov
                // is not yet update to support this call.  In the event the ARM location query fails, we will default to using ASM Location query.

                cboTargetLocation.Items.Clear();
                foreach (AsmLocation asmLocation in await _ParentForm.AzureContextTargetARM.AzureRetriever.GetAzureASMLocations())
                {
                    cboTargetLocation.Items.Add(asmLocation);
                }
            }

            if (armResourceGroup.Location != null)
            {
                foreach (ArmLocation armLocation in cboTargetLocation.Items)
                {
                    if (armLocation.Name == armResourceGroup.Location.Name)
                    {
                        cboTargetLocation.SelectedItem = armLocation;
                    }
                }
            }
        }
Ejemplo n.º 8
0
        private async void btnExport_Click(object sender, EventArgs e)
        {
            if (!Directory.Exists(txtDestinationFolder.Text))
            {
                MessageBox.Show("Export path is required.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                btnChoosePath_Click(this, null);
                return;
            }

            if (TemplateResult.OutputFilesExist(txtDestinationFolder.Text))
            {
                if (MessageBox.Show("The target export path already contains export files.  Do you want proceed and overwrite the existing files?", "Overwrite Existing Export", MessageBoxButtons.YesNo) == DialogResult.No)
                {
                    return;
                }
            }

            btnExport.Enabled = false;
            btnCancel.Enabled = false;

            try
            {
                AsmToArmForm      parentForm        = (AsmToArmForm)this.Owner;
                TemplateGenerator templateGenerator = new TemplateGenerator(parentForm.LogProvider, parentForm.StatusProvider, parentForm.TelemetryProvider, parentForm.AppSettingsProviders);
                TemplateResult    templateResult    = await templateGenerator.GenerateTemplate(parentForm.AzureContextSourceASM.AzureSubscription, parentForm.AzureContextTargetARM.AzureSubscription, artifacts, parentForm.TargetResourceGroup, txtDestinationFolder.Text);

                var exportResults = new ExportResultsDialog(templateResult);
                exportResults.ShowDialog(this);
                this.Close();
            }
            catch (Exception ex)
            {
                parentForm.LogProvider.WriteLog("btnExport_Click", "Error generating template : " + ex.ToString());
                MessageBox.Show("Something went wrong when generating the template. Check the log file for details.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                btnExport.Enabled = true;
                btnCancel.Enabled = true;
            }
        }