示例#1
0
function call_api($slug = NULL, $restType, $post = NULL)
{
    $details = getAccessDetails();
    $result = false;
    //Encode the login details
    $password = $details['password'];
    $username = $details['username'];
    $url = $details['url'];
    $string = $username . ":" . $password;
    $hash = "Basic " . base64_encode($string);
    if ($restType == 'get') {
        $result = get_api_resource($url, $hash, $slug);
    } elseif ($restType == 'post') {
        $result = post_api_resource($url, $hash, $slug, $post);
    } elseif ($restType == 'put') {
        $result = put_api_resource($url, $hash, $slug, $post);
    } elseif ($restType == 'delete') {
        $result = delete_api_resource($url, $hash, $slug, $post);
    }
    //    $result = json_decode($result);
    return $result;
}
示例#2
0
    $password = $details['password'];
    $url = $details['url'];
}
//Create cluster
if (isset($_POST['submit'])) {
    //if no cluster exists, create one
    if ($_SESSION['clusterUp'] == 'false') {
        $success = create_cluster($nodes, $nodeSizeM, $nodeSize);
        //if a string is not found, there was an error
        if ($success == false) {
            $_SESSION['clusterUp'] = 'error';
        } elseif ($success == true) {
            $_SESSION['clusterUp'] = 'true';
            //Get access details
            $readCsv = readCsv($nodes);
            $details = getAccessDetails();
            $username = $details['username'];
            $password = $details['password'];
            $url = $details['url'];
        }
    }
}
//Tear it down
if (isset($_POST['kubeDown'])) {
    $old_path = getcwd();
    chdir('/var/www/kubernetes');
    $a = popen('sh down_cluster.sh', 'r');
    while ($b = fgets($a, 2048)) {
        echo "<p style='color:#337ab7; font-size: 12px;'>.{$b}.</p>" . "<br>\n";
        ob_flush();
        flush();