Ejemplo n.º 1
0
        private async void btnRpcDelete_Click(object sender, EventArgs e)
        {
            try
            {
                if (vpcPeeringConnection == null)
                {
                    throw new Exception("There is no existing RDS VPC Peering Connection");
                }

                var confirmResult = MessageBox.Show(
                    "Are you sure to delete the VPC Peering Connection?",
                    "Warn: Delete Peering Connection",
                    MessageBoxButtons.YesNo);
                if (confirmResult == DialogResult.Yes)
                {
                    var service = new VpcPeeringConnectionServices();
                    await service.DeletePeeringConnection(
                        vpcPeeringConnection.VpcPeeringConnectionId,
                        lstVpcs.Find(o => o.VpcId == lblRpcReuestVpc.Text),
                        lstVpcs.Find(o => o.VpcId == lblRpcAcceptVpc.Text));

                    WriteNotification($"RDS VPC Peering Connection {vpcPeeringConnection.VpcPeeringConnectionId} is deleted.");
                    await Task.Delay(3000);
                    await PopulatePeeringConnection();
                }
            }
            catch (Exception ex)
            {
                HandleException(ex);
            }
        }
Ejemplo n.º 2
0
        //-----------------------------------------------Peering Connection Tab--------------------------------------------------------------

        private async Task PopulatePeeringConnection()
        {
            var service = new VpcPeeringConnectionServices();

            vpcPeeringConnection = await service.GetRdsPeeringConnection();

            if (vpcPeeringConnection == null || vpcPeeringConnection.Status.ToLower() == "deleted")
            {
                pnlNonExistRpc.Show();
                //pnlExistRpc.Visible = false;
                pnlExistRpc.Hide();
                pnlNonExistRpc.Location = pnlExistRpc.Location;
                //The peering connection which is under status of "deleted",
                //should be considered as null when create a new one.
                vpcPeeringConnection = null;
            }
            else
            {
                pnlNonExistRpc.Hide();
                //pnlVPCPeeringConnection.Visible = false;
                pnlExistRpc.Show();
                pnlExistRpc.Visible  = true;
                lblRpcId.Text        = vpcPeeringConnection.VpcPeeringConnectionId;
                lblRpcReuestVpc.Text = vpcPeeringConnection.RequesterVpc;
                lblRpcAcceptVpc.Text = vpcPeeringConnection.AccepterVpc;
                lblRpcStatus.Text    = vpcPeeringConnection.Status;
            }
        }
Ejemplo n.º 3
0
        private async Task PopulateeeringConnectionVpcDropdownLists()
        {
            ddlRequesterVpc.Items.Clear();
            ddlAccepterVpc.Items.Clear();
            var service = new VpcPeeringConnectionServices();

            lstVpcs = await service.GetAvailablePeeringVpcList();

            foreach (var vpc in lstVpcs)
            {
                ddlRequesterVpc.Items.Add($"{vpc.VpcId}|{vpc.Name}");
                ddlAccepterVpc.Items.Add($"{vpc.VpcId}|{vpc.Name}");
            }
        }
Ejemplo n.º 4
0
        private async void btnRpcCreate_Click(object sender, EventArgs e)
        {
            try
            {
                if (vpcPeeringConnection != null)
                {
                    MessageBox.Show("RDS VPC Peering Connection exists!");
                    return;
                }

                if (ddlAccepterVpc.SelectedItem == null ||
                    ddlRequesterVpc.SelectedItem == null)
                {
                    MessageBox.Show("Both Requester VPC and Accepter VPC are required!");
                    return;
                }

                if (ddlAccepterVpc.SelectedItem.ToString() == ddlRequesterVpc.SelectedItem.ToString())
                {
                    MessageBox.Show("VPC cannot create peering connection to itself, please pick another VPC");
                    return;
                }

                var confirmResult = MessageBox.Show(
                    "Are you sure to create a new RDS VPC Peering Connection?",
                    "Create RDS Peering Connection",
                    MessageBoxButtons.YesNo);
                if (confirmResult == DialogResult.Yes)
                {
                    var services         = new VpcPeeringConnectionServices();
                    var strRequesterItem = ddlRequesterVpc.SelectedItem.ToString()
                                           .Substring(0, ddlRequesterVpc.SelectedItem.ToString().IndexOf("|"));
                    var strAccepterItem = ddlAccepterVpc.SelectedItem.ToString()
                                          .Substring(0, ddlAccepterVpc.SelectedItem.ToString().IndexOf("|"));
                    var response = await services.CreatePeeringConnection(
                        lstVpcs.Find(o => o.VpcId == strRequesterItem),
                        lstVpcs.Find(o => o.VpcId == strAccepterItem));

                    WriteNotification($"RDS VPC Peering Connection {response} is created.");
                    await Task.Delay(3000);
                    await PopulatePeeringConnection();
                }
            }
            catch (Exception ex)
            {
                HandleException(ex);
            }
        }