示例#1
0
    def deploy_vpcs_remotevpngateways(self, vpcs_data, account):
        for vpc_data in vpcs_data:
            for vpnconnection_data in vpc_data['data']['vpnconnections']:
                vpc = get_vpc(
                    api_client=self.api_client,
                    name=self.dynamic_names['vpcs'][vpc_data['data']['name']])
                vpc_vpngateway = get_vpngateway(api_client=self.api_client,
                                                vpc=vpc)

                remotevpc = get_vpc(
                    api_client=self.api_client,
                    name=self.dynamic_names['vpcs'][vpnconnection_data])
                remotevpc_vpngateway = get_vpngateway(
                    api_client=self.api_client, vpc=remotevpc)

                self.logger.debug(
                    '>>>  VPN CUSTOMER GATEWAY  =>  Creating to VPC "%s"...',
                    vpnconnection_data)
                vpncustomergateway = VpnCustomerGateway.create(
                    api_client=self.api_client,
                    name="remotegateway_to_" + remotevpc.name,
                    gateway=remotevpc_vpngateway.publicip,
                    cidrlist=remotevpc.cidr,
                    presharedkey='notasecret',
                    ikepolicy='aes128-sha256;modp2048',
                    esppolicy='aes128-sha256;modp2048',
                    account=account.name,
                    domainid=account.domainid)

                self.logger.debug(
                    '>>>  VPN CUSTOMER GATEWAY  =>  ID: %s  =>  Name: %s  =>  CIDR List: %s  '
                    '=>  Gateway: %s  =>  Domain: %s', vpncustomergateway.id,
                    vpncustomergateway.name, vpncustomergateway.cidrlist,
                    vpncustomergateway.gateway, vpncustomergateway.domainid)

                self.logger.debug(
                    '>>>  VPN CONNECTION  =>  Creating from VPC "%s" to VPC "%s"...',
                    vpc_data['data']['name'], vpnconnection_data)
                vpnconnection = Vpn.createVpnConnection(
                    api_client=self.api_client,
                    s2svpngatewayid=vpc_vpngateway.id,
                    s2scustomergatewayid=vpncustomergateway.id)

                self.logger.debug(
                    '>>>  VPN CONNECTION  =>  ID: %s  =>  VPN Local Gateway: %s  '
                    '=>  VPN Customer Gateway: %s  =>  State: %s',
                    vpnconnection['id'], vpnconnection['s2svpngatewayid'],
                    vpnconnection['s2scustomergatewayid'],
                    vpnconnection['state'])
    def enable_vpcs_localvpngateway(self, vpcs_data):
        for vpc_data in vpcs_data:
            vpc = get_vpc(api_client=self.api_client, name=self.dynamic_names['vpcs'][vpc_data['data']['name']])
            if vpc_data['data']['vpnconnections']:
                self.logger.debug('>>>  VPN LOCAL GATEWAY  =>  Creating on VPC "%s"...', vpc_data['data']['name'])
                localvpngateway = Vpn.createVpnGateway(api_client=self.api_client, vpc=vpc)

                self.logger.debug('>>>  VPN LOCAL GATEWAY  =>  ID: %s  =>  IP: %s  =>  VPC: %s  =>  Domain: %s',
                                  localvpngateway['id'], localvpngateway['publicip'], localvpngateway['vpcid'],
                                  localvpngateway['domainid'])
    def deploy_vpcs_remotevpngateways(self, vpcs_data, account):
        for vpc_data in vpcs_data:
            for vpnconnection_data in vpc_data['data']['vpnconnections']:
                vpc = get_vpc(api_client=self.api_client, name=self.dynamic_names['vpcs'][vpc_data['data']['name']])
                vpc_vpngateway = get_vpngateway(api_client=self.api_client, vpc=vpc)

                remotevpc = get_vpc(api_client=self.api_client, name=self.dynamic_names['vpcs'][vpnconnection_data])
                remotevpc_vpngateway = get_vpngateway(api_client=self.api_client, vpc=remotevpc)

                self.logger.debug('>>>  VPN CUSTOMER GATEWAY  =>  Creating to VPC "%s"...', vpnconnection_data)
                vpncustomergateway = VpnCustomerGateway.create(
                    api_client=self.api_client,
                    name="remotegateway_to_" + remotevpc.name,
                    gateway=remotevpc_vpngateway.publicip,
                    cidrlist=remotevpc.cidr,
                    presharedkey='notasecret',
                    ikepolicy='aes128-sha256;modp2048',
                    esppolicy='aes128-sha256;modp2048',
                    account=account.name,
                    domainid=account.domainid
                )

                self.logger.debug('>>>  VPN CUSTOMER GATEWAY  =>  ID: %s  =>  Name: %s  =>  CIDR List: %s  '
                                  '=>  Gateway: %s  =>  Domain: %s', vpncustomergateway.id, vpncustomergateway.name,
                                  vpncustomergateway.cidrlist, vpncustomergateway.gateway, vpncustomergateway.domainid)

                self.logger.debug('>>>  VPN CONNECTION  =>  Creating from VPC "%s" to VPC "%s"...',
                                  vpc_data['data']['name'], vpnconnection_data)
                vpnconnection = Vpn.createVpnConnection(
                    api_client=self.api_client,
                    s2svpngatewayid=vpc_vpngateway.id,
                    s2scustomergatewayid=vpncustomergateway.id
                )

                self.logger.debug('>>>  VPN CONNECTION  =>  ID: %s  =>  VPN Local Gateway: %s  '
                                  '=>  VPN Customer Gateway: %s  =>  State: %s', vpnconnection['id'],
                                  vpnconnection['s2svpngatewayid'], vpnconnection['s2scustomergatewayid'],
                                  vpnconnection['state'])
示例#4
0
    def enable_vpcs_localvpngateway(self, vpcs_data):
        for vpc_data in vpcs_data:
            vpc = get_vpc(
                api_client=self.api_client,
                name=self.dynamic_names['vpcs'][vpc_data['data']['name']])
            if vpc_data['data']['vpnconnections']:
                self.logger.debug(
                    '>>>  VPN LOCAL GATEWAY  =>  Creating on VPC "%s"...',
                    vpc_data['data']['name'])
                localvpngateway = Vpn.createVpnGateway(
                    api_client=self.api_client, vpc=vpc)

                self.logger.debug(
                    '>>>  VPN LOCAL GATEWAY  =>  ID: %s  =>  IP: %s  =>  VPC: %s  =>  Domain: %s',
                    localvpngateway['id'], localvpngateway['publicip'],
                    localvpngateway['vpcid'], localvpngateway['domainid'])
示例#5
0
 def get_vpc(self, name):
     vpc = VPC(get_vpc(api_client=self.api_client, name=name).__dict__,
               api_client=self.api_client)
     return vpc
示例#6
0
 def deploy_vpc_privategateways(self, vpc_data):
     vpc = get_vpc(api_client=self.api_client,
                   name=self.dynamic_names['vpcs'][vpc_data['name']])
     for privategateway in vpc_data['privategateways']:
         self.deploy_privategateway(privategateway['data'], vpc)
示例#7
0
 def deploy_vpc_publicipaddresses(self, vpc_data, virtualmachines_data):
     vpc = get_vpc(api_client=self.api_client,
                   name=self.dynamic_names['vpcs'][vpc_data['name']])
     for publicipaddress in vpc_data['publicipaddresses']:
         self.deploy_publicipaddress(publicipaddress['data'],
                                     virtualmachines_data, vpc)
 def get_vpc(self, name):
     vpc = VPC(get_vpc(api_client=self.api_client, name=name).__dict__, api_client=self.api_client)
     return vpc
 def deploy_vpc_privategateways(self, vpc_data):
     vpc = get_vpc(api_client=self.api_client, name=self.dynamic_names['vpcs'][vpc_data['name']])
     for privategateway in vpc_data['privategateways']:
         self.deploy_privategateway(privategateway['data'], vpc)
 def deploy_vpc_publicipaddresses(self, vpc_data, virtualmachines_data):
     vpc = get_vpc(api_client=self.api_client, name=self.dynamic_names['vpcs'][vpc_data['name']])
     for publicipaddress in vpc_data['publicipaddresses']:
         self.deploy_publicipaddress(publicipaddress['data'], virtualmachines_data, vpc)