-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexample.php
63 lines (49 loc) · 1.3 KB
/
example.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
include ('settings.php');
include ('CobblerApiClient.php');
//1. Create client
$client = new CobblerApiClient($cobbler_server['host'], $cobbler_server['port'], $cobbler_server['path'], $cobbler_server['user'], $cobbler_server['password'], false);
//2. List Systems
echo '<h1>SYSTEMS</h1>';
$systems = $client->listSystems();
foreach ($systems as $system){
//var_dump($system);
}
//3. List Distros
echo '<h1>DISTROS</h1>';
$distros = $client->listDistros();
foreach ($distros as $distro){
//var_dump($distro);
}
//4. List Profiles
echo '<h1>PROFILES</h1>';
$profiles = $client->listProfiles();
foreach ($profiles as $profile){
//var_dump($profile);
}
//5. List Images
echo '<h1>IMAGES</h1>';
$images = $client->listImages();
foreach ($images as $image){
//var_dump($image);
}
$name = 'testing';
$hostname = $name.'public.mycompany';
$macaddress = '32:00:17:70:bd:ab';
$profile = 'centos-6.6-x86_64';
$key = 'mysshkey';
$password = 'plainrootpassword';
$params = array();
$params['name'] = $name;
$params['host'] = $hostname;
$params['mac'] = $macaddress;
$params['profile'] = $profile;
try{
//6. Create System
$system_id = $client->createSystem($params);
}finally{
//7. Delete System
//$client->deleteSystem($name);
$client->setSSHKey($name, $key);
$client->setPassword($name,'plainrootpassword');
}