|
57 | 57 | # MAGIC %md |
58 | 58 | # MAGIC ## How to Run |
59 | 59 | # MAGIC |
60 | | -# MAGIC Run the script in the following sequence |
| 60 | + |
| 61 | +# COMMAND ---------- |
| 62 | + |
| 63 | +# MAGIC %md |
61 | 64 | # MAGIC #### Step 1: Initialize the class |
62 | 65 | # MAGIC Import the module WSGroupMigration and initialize the class by passing following attributes: |
63 | 66 | # MAGIC - list of workspace group to be migrated (make sure these are workspace groups and not account level groups) |
|
70 | 73 |
|
71 | 74 | # COMMAND ---------- |
72 | 75 |
|
73 | | -# MAGIC %md ## Installing the package and it's dependencies |
74 | | - |
75 | | -# COMMAND ---------- |
76 | | - |
77 | | -from notebooks.common import install_uc_upgrade_package |
78 | | - |
79 | | -install_uc_upgrade_package() |
80 | | - |
81 | | -# COMMAND ---------- |
82 | | - |
83 | | -# MAGIC %md ## Main process entrypoint |
| 76 | +from uc_upgrade.group_migration import GroupMigration |
84 | 77 |
|
85 | 78 | # COMMAND ---------- |
86 | 79 |
|
87 | 80 | # If autoGenerateList=True then groupL will be ignored and all eliglbe groups will be migrated. |
88 | 81 | autoGenerateList = False |
89 | 82 |
|
90 | | -# please provide groups here, e.g. |
| 83 | +# please provide groups here, e.g. analyst. |
| 84 | +# please provide group names and not ids |
91 | 85 | groupL = ["groupA", "groupB"] |
92 | 86 |
|
93 | 87 |
|
94 | 88 | # Find this in the account console |
95 | 89 | inventoryTableName = "WorkspaceInventory" |
| 90 | +# the script will create two table |
| 91 | +# WorkspaceInventory - to store all the ACL permission |
| 92 | +# WorkspaceInventoryTableACL - to store the table acl permission specifically |
96 | 93 |
|
97 | 94 | # Pull from your browser URL bar. Should start with "https://" and end with ".com" or ".net" |
98 | 95 | workspace_url = "https://<DOMAIN>" |
99 | 96 |
|
100 | 97 |
|
101 | 98 | # Personal Access Token. Create one in "User Settings" |
102 | | -token = "<TOKEN" |
| 99 | +token = "<TOKEN>" |
103 | 100 |
|
104 | 101 | # Should the migration Check the ACL on tables/views as well? |
105 | 102 | checkTableACL = False |
|
111 | 108 | userName = "<UserMailID>" |
112 | 109 |
|
113 | 110 | # Number of threads to issue Databricks API requests with. If you get a lot of errors during the inventory, lower this value. |
114 | | -numThreads = 30 |
| 111 | +numThreads = 10 |
115 | 112 |
|
| 113 | +# The notebook will populate data in the WorkspaceInventory and WorkspaceInventoryTableACL(If applicable). |
| 114 | +# if the notebook is run second time, it will retrieve the data from the table if already captured. |
| 115 | +# Users have the option to do a fresh inventory in which case it will recreate the tables and start again. |
| 116 | +# default set to False |
| 117 | +freshInventory = False |
116 | 118 | # Initialize GroupMigration Class with values supplied above |
117 | 119 | gm = GroupMigration( |
118 | 120 | groupL=groupL, |
|
125 | 127 | checkTableACL=checkTableACL, |
126 | 128 | autoGenerateList=autoGenerateList, |
127 | 129 | numThreads=numThreads, |
| 130 | + freshInventory=freshInventory, |
128 | 131 | ) |
129 | 132 |
|
130 | 133 | # COMMAND ---------- |
|
133 | 136 | # MAGIC #### Step 2: Perform Dry run |
134 | 137 | # MAGIC This steps performs a dry run to verify the current ACL on the supplied workspace groups and print outs the permission. |
135 | 138 | # MAGIC Please verify if all the permissions are covered |
| 139 | +# MAGIC If the inventory was run previously and stored in the table for either Workspace or Account then it will use the same and save time, else it will do a fresh inventory |
| 140 | +# MAGIC If the inventory data in the table is present for only few workspace objects , the dryRun will do the fresh inventory of objects not present in the table |
136 | 141 |
|
137 | 142 | # COMMAND ---------- |
138 | 143 |
|
139 | 144 | gm.dryRun("Workspace") |
140 | 145 |
|
141 | 146 | # COMMAND ---------- |
142 | 147 |
|
| 148 | +# MAGIC %md |
| 149 | +# MAGIC #### Adhoc Step: Selective Inventory |
| 150 | +# MAGIC This is a adhoc step for troubleshooting purpose. Once dryRun is complete and data stored in tables, if the acl of any object is changed in the workspace |
| 151 | +# MAGIC Ex new notebook permission added, User can force a fresh inventory of the selected object instead of doing a full cleanup and running the dryRun |
| 152 | +# MAGIC To save time call gm.performInventory with 3 parameters: |
| 153 | +# MAGIC - mode: Workpace("for workspace local group") or Account ("for workspace back up group") |
| 154 | +# MAGIC - force: setting to True will force fresh inventory capture and updates to the tables |
| 155 | +# MAGIC - objectType: select the list of object for which to do the fresh inventory, options are |
| 156 | +# MAGIC |
| 157 | +# MAGIC "Group"(will do members, group list, entitlement, roles), "Password","Cluster","ClusterPolicy","Warehouse","Dashboard","Query","Job","Folder"(Will do folders, notebook and files),"TableACL","Alert","Pool","Experiment","Model","DLT","Repo","Token","Secret" |
| 158 | +# MAGIC Ex: gm.performInventory('Workspace',force=True,objectType='Cluster') will do: |
| 159 | +# MAGIC - fresh inventory of all cluster objects and updated the data the inventory table |
| 160 | +# MAGIC - run printInventory() to verify all the permission again (including clusters). |
| 161 | + |
| 162 | +# COMMAND ---------- |
| 163 | + |
| 164 | +gm.performInventory("Workspace", force=True, objectType="Cluster") |
| 165 | +gm.printInventory() |
| 166 | + |
| 167 | +# COMMAND ---------- |
| 168 | + |
143 | 169 | # MAGIC %md |
144 | 170 | # MAGIC #### Step 3: Create Back up group |
145 | 171 | # MAGIC This steps creates the back up groups, applies the ACL on the new temp group from the original workspace group. |
|
159 | 185 | # MAGIC - Verify the temp group permissions are as seen in the initial dry run |
160 | 186 | # MAGIC - check randomly if all the ACL are applied correctly |
161 | 187 | # MAGIC - there should be one temp group for every workspace group (Ex: db-temp-analysts and analysts with same ACLs) |
| 188 | +# MAGIC - Similar to dryRun("workspace"), this will also capture inventory for first run and store it in tables, subsequent times inventory will be retrived from the table to save time. |
| 189 | +# MAGIC - if inventory table contains partial workspace objects(ex cluster acl is missing), it will do fresh inventory for the missing object and update table |
162 | 190 |
|
163 | 191 | # COMMAND ---------- |
164 | 192 |
|
|
0 commit comments