Exemplo n.º 1
0
 public function testDescribeAddresses()
 {
     $response = Eip::getInstance()->request('DescribeAddresses', ['query' => ['MaxResults' => 10]], 'cn-beijing-6');
     echo (string) $response->getBody();
     return $this->assertEquals($response->getStatusCode(), 200);
 }
Exemplo n.º 2
0
//查询kec实例信息
$param = array('Filter.1.Name' => 'instance-id', 'Filter.1.Value.1' => $kecInstanceId);
while (true) {
    $response = Kec::getInstance()->request('DescribeInstances', array('query' => $param));
    $kecInstanceInfo = getResponse($response);
    $networkInterfaceId = $kecInstanceInfo['InstancesSet'][0]['NetworkInterfaceSet'][0]['NetworkInterfaceId'];
    if (is_null($networkInterfaceId)) {
        echo "sleeping...\n";
        sleep(5);
        continue;
    } else {
        var_dump("networkInterfaceId is " . $networkInterfaceId);
        break;
    }
}
//获取用户可选链路信息
$response = Eip::getInstance()->request('GetLines');
$lineInfo = getResponse($response);
$lineId = $lineInfo['LineSet'][0]['LineId'];
var_dump("lineId is " . $lineId);
//创建eip
$param = array('LineId' => $lineId, 'BandWidth' => 1, 'ChargeType' => 'Daily');
$response = Eip::getInstance()->request('AllocateAddress', array('query' => $param));
$eipInfo = getResponse($response);
$allocationId = $eipInfo['AllocationId'];
var_dump("allocationId is " . $allocationId);
//绑定eip
$param = array('AllocationId' => $allocationId, 'InstanceType' => 'Ipfwd', 'InstanceId' => $kecInstanceId, 'NetworkInterfaceId' => $networkInterfaceId);
$response = Eip::getInstance()->request('AssociateAddress', array('query' => $param));
$associateInfo = getResponse($response);
var_dump($associateInfo);