PageRenderTime 56ms CodeModel.GetById 32ms RepoModel.GetById 0ms app.codeStats 0ms

/scalr-2/tags/scalr-2.0.0/app/www/aws_vpc_attach_vpn_gateway.php

http://scalr.googlecode.com/
PHP | 69 lines | 49 code | 18 blank | 2 comment | 8 complexity | 68af552d73c29daaeef975e7191753fc MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0, GPL-3.0
  1. <?php
  2. require("src/prepend.inc.php");
  3. if ($_SESSION["uid"] == 0)
  4. UI::Redirect("index.php");
  5. $Client = Client::Load($_SESSION['uid']);
  6. $display["title"] = _("Tools&nbsp;&raquo;&nbsp;Amazon Web Services&nbsp;&raquo;&nbsp;Amazon VPC&nbsp;&raquo;&nbsp;Create VPN connection");
  7. $AmazonVPCClient = AmazonVPC::GetInstance(AWSRegions::GetAPIURL($_SESSION['aws_region']));
  8. $AmazonVPCClient->SetAuthKeys($Client->AWSPrivateKey, $Client->AWSCertificate);
  9. $display["vpnGatewayId"] = array();
  10. $display["customerGatewayId"] = array();
  11. // Get VPN gateways list
  12. $aws_response = $AmazonVPCClient->DescribeVpnGateways();
  13. $rows = (array)$aws_response->vpnGatewaySet;
  14. if ($rows["item"] instanceof stdClass)
  15. $rows["item"] = array($rows["item"]); // convert along record to array
  16. foreach ($rows['item'] as $row)
  17. {
  18. if (stristr($row->state,'available'))
  19. array_push($display["vpnGatewayId"], (string)$row->vpnGatewayId);
  20. }
  21. // Get Customer gateways list
  22. $aws_response = $AmazonVPCClient->DescribeVpnGateways();
  23. $rows = (array)$aws_response->vpnGatewayId;
  24. if ($rows["item"] instanceof stdClass)
  25. $rows["item"] = array($rows["item"]);
  26. foreach ($rows['item'] as $row)
  27. {
  28. if (stristr($row->state,'available'))
  29. array_push($display["vpnGatewayId"], (string)$row->vpnGatewayId);
  30. }
  31. if($_POST)
  32. {
  33. try
  34. {
  35. if (!$req_aws_vpc_vpn_gateways)
  36. {
  37. $errmsg = "Please create vpn gateway first";
  38. UI::Redirect("aws_vpc_attach_vpn_gateway.php");
  39. }
  40. $AmazonVPCClient->AttachVpnGateway(new AttachVpnGateway($req_id,$req_aws_vpc_vpn_gateways));
  41. $okmsg = "Vpn gateway atteched successfully";
  42. UI::Redirect("aws_vpc_view.php");
  43. }
  44. catch(Exception $e)
  45. {
  46. $err[] = $e->getMessage(); //Can't attach VPN gateway %s to VPC %s : %s
  47. UI::Redirect("aws_vpc_view.php");
  48. }
  49. }
  50. require("src/append.inc.php");
  51. ?>