-
Notifications
You must be signed in to change notification settings - Fork 1
/
rkUserManagement.php
92 lines (77 loc) · 2.48 KB
/
rkUserManagement.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
///////////////////////////////////////////////////////////////////
// Includes section
///////////////////////////////////////////////////////////////////
include_once "rkFramework.php";
$bulkUsers=array(
0 => array(
"username" => "user1",
"password" => "P@ss_0rd123!",
"firstName" => "First",
"lastName" => "Last",
"emailAddress" => "[email protected]"
),
1 => array(
"username" => "user2",
"password" => "P@ss_0rd123!",
"firstName" => "First",
"lastName" => "Last",
"emailAddress" => "[email protected]"
),
2 => array(
"username" => "user3",
"password" => "P@ss_0rd123!",
"firstName" => "First",
"lastName" => "Last",
"emailAddress" => "[email protected]"
)
);
$clusterConnect=array(
0 => array(
"username" => "username",
"password" => "password",
"ip" => "rubrik_ip_1"
),
1 => array(
"username" => "username",
"password" => "password",
"ip" => "rubrik_ip_2"
)
);
//////////////////////////
// Create users
//////////////////////////
// Go through all clusters
print("\nCreating ".rkColorOutput(count($bulkUsers))." user(s) on ".rkColorOutput(count($clusterConnect))." cluster(s) ...\n\n");
for($i=0;$i<count($clusterConnect);$i++)
{
print("Creating users in ".rkColorOutput($clusterConnect[$i]["ip"])."\n");
for($j=0;$j<count($bulkUsers);$j++)
{
$return=rkCreateUser($clusterConnect[$i],$bulkUsers[$j]["username"],$bulkUsers[$j]["password"]);
$id=rkGetUserID($clusterConnect[$i],$bulkUsers[$j]["username"]);
rkMakeAdminUser($clusterConnect[$i],$id);
if(isset($return->message)) print("-> ".rkColorOutput($return->message)."\n");
else print("-> ".rkColorOutput($return->username)." created.\n");
}
}
print("\nUsers have been created, waiting 10 seconds ....");
// Wait 10 sec
sleep(10);
//////////////////////////
// Delete users
//////////////////////////
print("\n\nDeleting ".rkColorOutput(count($bulkUsers))." user(s) on ".rkColorOutput(count($clusterConnect))." cluster(s) ...\n\n");
for($i=0;$i<count($clusterConnect);$i++)
{
print("Deleting users in ".rkColorOutput($clusterConnect[$i]["ip"])."\n");
for($j=0;$j<count($bulkUsers);$j++)
{
$id=rkGetUserID($clusterConnect[$i],$bulkUsers[$j]["username"]);
print("-> Deleting ".rkColorOutput($bulkUsers[$j]["username"])." : ");
$result=rkDeleteUser($clusterConnect[$i],$id);
print(rkColorOutput($result)."\n");
}
}
print("\nScript ended.\n");
?>