traffic_replay: Move 'traffic account' flag up a level
authorTim Beale <timbeale@catalyst.net.nz>
Mon, 5 Nov 2018 21:58:56 +0000 (10:58 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 7 Nov 2018 16:55:08 +0000 (17:55 +0100)
We create machine accounts for 2 different purposes:
1). For traffic generation, i.e. testing realistic network packets.
2). For generating a realistic large DB.

Unfortunately, we want to use different userAccountControl flags for
the 2 different cases. Commit 3338a3e257fa9f28 changed the flags used
for case #2, but this breaks case #1.

The problem is generate_users_and_groups() is called in both cases,
so we want the 'traffic account' flag passed into that function.
This ensures that the machine accounts get created with the appropriate
userAccountControl flags for the particular case you want to test.

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
python/samba/emulate/traffic.py
script/traffic_replay

index 8de329b09bbca3043282a9345cb2c6ee49b43189..af99e66823af4aedc669dd91f7534840a397e30c 100644 (file)
@@ -1747,7 +1747,8 @@ def generate_users(ldb, instance_id, number, password):
     return users
 
 
-def generate_machine_accounts(ldb, instance_id, number, password):
+def generate_machine_accounts(ldb, instance_id, number, password,
+                              traffic_account=True):
     """Add machine accounts to the server"""
     existing_objects = search_objectclass(ldb, objectclass='computer')
     added = 0
@@ -1756,7 +1757,7 @@ def generate_machine_accounts(ldb, instance_id, number, password):
         if name not in existing_objects:
             name = "STGM-%d-%d" % (instance_id, i)
             create_machine_account(ldb, instance_id, name, password,
-                                   traffic_account=False)
+                                   traffic_account)
             added += 1
             if added % 50 == 0:
                 LOGGER.info("Created %u/%u machine accounts" % (added, number))
@@ -1798,7 +1799,8 @@ def clean_up_accounts(ldb, instance_id):
 
 def generate_users_and_groups(ldb, instance_id, password,
                               number_of_users, number_of_groups,
-                              group_memberships, machine_accounts=0):
+                              group_memberships, machine_accounts=0,
+                              traffic_accounts=True):
     """Generate the required users and groups, allocating the users to
        those groups."""
     memberships_added = 0
@@ -1813,7 +1815,8 @@ def generate_users_and_groups(ldb, instance_id, password,
     if machine_accounts > 0:
         LOGGER.info("Generating dummy machine accounts")
         computers_added = generate_machine_accounts(ldb, instance_id,
-                                                    machine_accounts, password)
+                                                    machine_accounts, password,
+                                                    traffic_accounts)
 
     if number_of_groups > 0:
         LOGGER.info("Generating dummy groups")
index 2cd84f7a0bbba8815c7a7dfb90fec4cf96a6acc6..e8ba131445a6d909f92924fc3aad0def6b92fd26 100755 (executable)
@@ -333,7 +333,8 @@ def main():
                                           opts.number_of_users,
                                           opts.number_of_groups,
                                           opts.group_memberships,
-                                          machine_accounts=computer_accounts)
+                                          machine_accounts=computer_accounts,
+                                          traffic_accounts=False)
         sys.exit()
 
     tempdir = tempfile.mkdtemp(prefix="samba_tg_")
@@ -344,7 +345,8 @@ def main():
                                       opts.fixed_password,
                                       number_of_users,
                                       opts.number_of_groups,
-                                      opts.group_memberships)
+                                      opts.group_memberships,
+                                      traffic_accounts=True)
 
     accounts = traffic.generate_replay_accounts(ldb,
                                                 opts.instance_id,