Last active
December 29, 2022 10:36
-
-
Save albermav/70d1e41c12602f79159fadc52416f856 to your computer and use it in GitHub Desktop.
CNM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CNM_BRANCH_NEW=$1 | |
| CNM_BRANCH_ORIGIN=$2 | |
| create_a_branch() | |
| { | |
| git fetch | |
| # It doesn't need to create a local branch! | |
| # Example: Create release_5.2.3 branch from release_5.2.2 | |
| # git push origin origin/release_5.2.2:refs/heads/release_5.2.3 | |
| git push origin origin/$CNM_BRANCH_ORIGIN:refs/heads/$CNM_BRANCH_NEW | |
| } | |
| cd $API_GATEWAY_HOME | |
| create_a_branch | |
| cd $NETMANAGER_WILDFLY_HOME | |
| create_a_branch | |
| cd $AUTH_SERVER_HOME | |
| create_a_branch | |
| cd $DATA_MODEL_MODULES_HOME | |
| create_a_branch | |
| cd $DEVICE_API_GW_HOME | |
| create_a_branch | |
| cd $DOCKERFILES_HOME | |
| create_a_branch | |
| cd $NETWORK_STATUS_MONITOR_HOME | |
| create_a_branch | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const USERNAME = "user"; | |
| const PASSWORD = "password"; | |
| const PROJECT_UUID = "6216912c096c9c92e15282ab"; | |
| fetch("https://" + window.location.hostname + "/authserver/users/token", { | |
| headers: { | |
| accept: "application/json, text/plain, */*", | |
| "accept-language": "en-US,en;q=0.9", | |
| authorization: "Basic Y2xpZW50OnNlY3JldA==", | |
| "content-type": "application/x-www-form-urlencoded", | |
| "sec-fetch-dest": "empty", | |
| "sec-fetch-mode": "cors", | |
| "sec-fetch-site": "same-origin", | |
| "sec-gpc": "1", | |
| "x-requested-with": "XMLHttpRequest", | |
| }, | |
| referrerPolicy: "strict-origin-when-cross-origin", | |
| body: | |
| "grant_type=password&scope=read%3Aconfigurations+read%3Acustomers+read%3Ausers+write%3Aconfigurations+write%3Acustomers+write%3Ausers&username=" + | |
| USERNAME + | |
| "&password=" + | |
| PASSWORD, | |
| method: "POST", | |
| mode: "cors", | |
| credentials: "include", | |
| }) | |
| .then((auth_response) => auth_response.json()) | |
| .then(({ access_token }) => { | |
| fetch( | |
| "https://" + | |
| window.location.hostname + | |
| "/api/v2/controller/projects/" + | |
| PROJECT_UUID + | |
| "?embedded=entities.aaa_servers,entities.access_points,entities.access_providers,entities.access_routers,entities.analytics_profiles,entities.ap_settings,entities.application_categories,entities.application_policies,entities.applications,entities.branch_edges,entities.data_centers,entities.dyn_dns_servers,entities.lan_groups,entities.lan_profiles,entities.leakings,entities.nat_entries,entities.network_controllers,entities.network_global_settings,entities.network_profiles,entities.network_users,entities.networks,entities.port_forwarding_rules,entities.preference_groups,entities.radio_profiles,entities.radius_profiles,entities.security_groups,entities.segments,entities.static_routes,entities.switches,entities.traffic_selector_rules,entities.vlans,entities.wan_profiles", | |
| { | |
| headers: { | |
| accept: "application/json", | |
| "accept-language": "en-US,en;q=0.9", | |
| authorization: "Bearer " + access_token, | |
| "sec-fetch-dest": "empty", | |
| "sec-fetch-mode": "cors", | |
| "sec-fetch-site": "same-origin", | |
| "sec-gpc": "1", | |
| }, | |
| referrerPolicy: "strict-origin-when-cross-origin", | |
| body: null, | |
| method: "GET", | |
| mode: "cors", | |
| credentials: "include", | |
| } | |
| ) | |
| .then((x) => x.json()) | |
| .then((project) => { | |
| project_uuids = []; | |
| delete project["_id"]; | |
| delete project["_created"]; | |
| delete project["_etag"]; | |
| delete project["_updated"]; | |
| delete project["last_index_app"]; // TODO check in future | |
| delete project.entities["external_data_documents"]; // TODO in future | |
| delete project.entities["overwritable_data_records"]; // TODO in future | |
| for (const entities of Object.values(project.entities)) { | |
| for (entity of entities) { | |
| project_uuids.push(entity._id); | |
| delete entity["_created"]; | |
| delete entity["_etag"]; | |
| delete entity["_updated"]; | |
| entity["id"] = entity._id; | |
| delete entity["_id"]; | |
| } | |
| } | |
| project_str = JSON.stringify(project); | |
| for (const uuid of project_uuids) { | |
| project_str = project_str.replaceAll(uuid, "NEW:" + uuid); | |
| } | |
| new_project = JSON.parse(project_str); | |
| console.log(new_project); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment