def main(): util.kill_ssl_warnings(logging, urllib3) args = parse_args() verify_services_are_valid(args.SERVICES) if args.LIST_SERVICES: print_service_name_translation() sys.exit(0) return if not args.SERVICES: print("No services specified") sys.exit(0) return env = util.get_environment(args.BIGIQ_ADDR, username=args.BIGIQ_USERNAME, pwd=args.BIGIQ_PWD) util.poll_for_services_available(env["address"], auth=env["auth"], timeout=360) util.complete() util.print_partial("Retrieving DCD identifier...") dcd_self_link = get_dcd_device_reference(env, args.DCD_IP_ADDRESS) util.complete() util.print_partial("Activating services: " + string.join(args.SERVICES, ", ") + "...") activate_services(env, args.DCD_IP_ADDRESS, dcd_self_link, args.SERVICES) util.complete()
def main(): alb_dns_name = "" try: args = parse_args() time.sleep(480) # Eight minute wait for SSG to settle down client = getResourceClient(args) # Sleep till the time ssg resource group gets created retry_count = 1 while retry_count < UNHEALTHY_THRESHOLD: if azureutils.doesResourceGroupExists(client, args.SSG_NAME) == True: break else: retry_count += 1 time.sleep(30) retry_count = 1 resource_name = getPublicIpResourceName(args.SSG_NAME) while retry_count < UNHEALTHY_THRESHOLD: if doesPublicIpExists(args, resource_name) == True: alb_dns_name = getDnsName(args, resource_name) break else: retry_count += 1 time.sleep(30) except Exception as e: util.print_partial( "Exception occurred while configuring the traffic generator ,failed with error:" + str(e)) print(alb_dns_name) return alb_dns_name
def main(): args = parse_args() util.print_partial("Waiting for SSG to be present...") poll_for_ssg_present() util.complete() util.print_partial("Getting SSG reference...") ssgs = get_ssg_reference() util.complete() # Let this reference be unsafe and tacky so that this fails loudly if the SSG is not present ssg_id = ssgs["items"][0]["id"] util.print_partial("Waiting for SSG to be ready...") poll_for_ssg_ready(ssg_id) util.complete() time.sleep(180) # Three minute wait for SSG to settle down util.print_partial("Getting ALB DNS Name reference...") alb_dns_name = getDnsName(args) util.complete() #TODO: can delete file here azureutils.deleteLockFile() util.print_partial("Deploying application...") deploy_application(ssg_id, args.NODE_IP, alb_dns_name) util.complete()
def sanitizeAndGetDnsName(resource_group_name="", alb_dns_name=""): sanitized_dns_name = "" try: if alb_dns_name.startswith(resource_group_name): index_of = alb_dns_name.index(".") sanitized_dns_name = alb_dns_name[:index_of] sanitized_dns_name = sanitized_dns_name + '-' + config_set_name + alb_dns_name[ index_of:] except Exception as e: util.print_partial("Error occured while fetching dns Name " + resource_group_name + "," + alb_dns_name + " \n error:" + str(e)) return sanitized_dns_name
def getDnsName(args, resource_name): resource_group_name = "" alb_dns_name = "" try: resource_group_name = args.SSG_NAME client = getResourceClient(args) alb_dns_name = azureutils.getDnsName(client, resource_group_name, args.SUBSCRIPTION_ID, resource_name) except Exception as e: util.print_partial( "Exception occurred while fetching azure dns name associated with ssg's resource group " + resource_group_name + " ,failed with error:" + str(e)) return alb_dns_name
def poll_for_ssg_present(timeout=1200): count = 0 while True: result = get_ssg_reference() if count >= timeout: sys.exit(-1) break if not result["items"]: time.sleep(1) else: break util.print_partial(".") count += 1
def poll_for_ssg_ready(ssg_id, timeout=1200): url = "http://localhost:8100/cm/cloud/service-scaling-groups/" + ssg_id count = 0 while True: if count >= timeout: sys.exit(-1) break result = util.req(url, None) status = result.json()["status"] if status == "READY": break else: time.sleep(1) util.print_partial(".") count += 1
def main(): # load vars from parser args = parse_args() # Determine local or remote environment = get_environment(args.BIGIQ_ADDR, username=args.DCD_USERNAME, pwd=args.DCD_PWD) # Test authentication? util.poll_for_services_available(environment['address'], auth=environment['auth']) util.complete() # Wait for DCD available and assume basic auth is enabled util.poll_for_system_setup(args.DCD_IP_ADDRESS, auth=requests.auth.HTTPBasicAuth( args.DCD_USERNAME, args.DCD_PWD), timeout=args.TIMEOUT_SEC) util.complete() # Verify that device is not added already util.print_partial("Checking that device is not already registered...") check_that_device_not_already_registered(environment, args.DCD_IP_ADDRESS) util.complete() # post to add node util.print_partial("Adding node...") node_uuid = add_node(environment, args.DCD_IP_ADDRESS, args.DCD_TRANSPORT_ADDRESS, args.DCD_USERNAME, args.DCD_PWD) util.complete() # poll add until success or failure util.print_partial("Waiting for result...") poll_for_result(environment, node_uuid) util.complete()
def poll_for_result(env, uuid): # Based on a the UUID returned from add_node poll this endpoint until something happens # GET # https://18.232.246.131/mgmt/cm/shared/esmgmt/add-node/0d043d33-7619-404b-b184-58aa5c8ef0cf # Returns something like this in progress # {"address":"35.173.117.194","bigIqPassword":"","bigIqUsername":"******","cluster":{"clusterName":"39d30597-4d09-419b-ad64-450e5ba01edf","primaryMachineId":"1f7b1aa0-8fa6-498a-bae6-9c7bb9318435","clusterIndexCollectionReference":{"link":"https://localhost/mgmt/cm/shared/esmgmt/cluster/3fa8567f-b10d-49d1-8e50-09d8741ada4e/indices","isSubcollection":true},"nodes":[{"machineId":"1f7b1aa0-8fa6-498a-bae6-9c7bb9318435","allowData":false,"allowMaster":true,"httpAddress":"127.0.0.1","httpPort":"9200","transportAddress":"10.1.1.169/24","transportPort":"9300","zone":"default","mlockall":false,"repo":"/var/config/rest/elasticsearch/data","generation":0,"lastUpdateMicros":0}],"numberOfDataNodes":0,"id":"3fa8567f-b10d-49d1-8e50-09d8741ada4e","generation":1,"lastUpdateMicros":1525976702076194,"kind":"cm:shared:esmgmt:cluster:esclusterinstancestate","selfLink":"https://localhost/mgmt/cm/shared/esmgmt/cluster/3fa8567f-b10d-49d1-8e50-09d8741ada4e"},"currentStep":"CHECK_DEVICE_STATUS_ADD","deviceReference":{"link":"https://localhost/mgmt/shared/resolver/device-groups/cm-esmgmt-logging-group/devices/f5258bfe-b583-439e-ab92-1d063e3366d1"},"deviceState":{"uuid":"f5258bfe-b583-439e-ab92-1d063e3366d1","deviceUri":"https://35.173.117.194:443","machineId":"f5258bfe-b583-439e-ab92-1d063e3366d1","state":"PENDING","address":"35.173.117.194","httpsPort":443,"properties":{"isLoggingNode":true},"groupName":"cm-esmgmt-logging-group","generation":1,"lastUpdateMicros":1525977026535394,"kind":"shared:resolver:device-groups:restdeviceresolverdevicestate","selfLink":"https://localhost/mgmt/shared/resolver/device-groups/cm-esmgmt-logging-group/devices/f5258bfe-b583-439e-ab92-1d063e3366d1"},"generation":5,"httpPort":"9200","id":"0d043d33-7619-404b-b184-58aa5c8ef0cf","identityReferences":[{"link":"https://localhost/mgmt/shared/authz/users/admin"}],"kind":"cm:shared:esmgmt:add-node:esaddnodetaskstate","lastUpdateMicros":1525977028708833,"ownerMachineId":"1f7b1aa0-8fa6-498a-bae6-9c7bb9318435","selfLink":"https://localhost/mgmt/cm/shared/esmgmt/add-node/0d043d33-7619-404b-b184-58aa5c8ef0cf","startDateTime":"2018-05-10T11:30:26.360-0700","status":"STARTED","transportAddress":"10.1.1.230","transportPort":"9300","userReference":{"link":"https://localhost/mgmt/shared/authz/users/admin"},"username":"******","zone":"default"} i = 0 while i < 120: add_node_res = util.req( env['base_url'] + "cm/shared/esmgmt/add-node/" + uuid, env['auth']) status = add_node_res.json()['status'] if status == "FINISHED": break elif status == "FAILED": print("") print("Node addition failed with:") print(add_node_res.json()['errorMessage']) sys.exit(1) util.print_partial(".") time.sleep(2) i += 2
def getDnsName(args): resource_group_name = "" alb_dns_name = "" try: resource_group_name = azureutils.getContentsOfResourceGroupLockFile() credentials = azureutils.getCredentials(args.TENANT_ID, args.CLIENT_ID, args.SERVICE_PRINCIPAL_SECRET) client = azureutils.getResourceClient(credentials, args.SUBSCRIPTION_ID) alb_dns_name = azureutils.getDnsName(client, resource_group_name, args.SUBSCRIPTION_ID) # Since public ip is created dynamically after deploy application python script execution # Fetching the sample public ip name without demo application and sanitizing it accordingly # eg: Dns name associated with alb initially would be azure-f5-ssg.eastus.cloudapp.azure.com # After below method invocation:o/p would be azure-f5-ssg-apache-test-application.eastus.cloudapp.azure.com alb_dns_name = sanitizeAndGetDnsName(resource_group_name, alb_dns_name) util.print_partial( 'Application can be accessible through https on dns Name:' + alb_dns_name) except Exception as e: util.print_partial( "Exception occurred while fetching azure dns name associated with ssg's resource group " + resource_group_name + " ,failed with error:" + str(e)) return alb_dns_name
def main(): args = parse_args() util.print_partial("Waiting for SSG to be present...") poll_for_ssg_present() util.complete() util.print_partial("Getting SSG reference...") ssgs = get_ssg_reference() util.complete() # Let this reference be unsafe and tacky so that this fails loudly if the SSG is not present ssg_id = ssgs["items"][0]["id"] util.print_partial("Waiting for SSG to be ready...") poll_for_ssg_ready(ssg_id) util.complete() time.sleep(180) # Three minute wait for SSG to settle down util.print_partial("Deploying application...") deploy_application(ssg_id, args.NODE_IP, args.ELB_NAME, args.ELB_DNS_NAME) util.complete()
def activate_services(env, dcd_ip, dcd_self_link, services): for service in services: activate_service(env, service, dcd_self_link, dcd_ip) util.print_partial(".")
def main(): if not poll_for_services_available(): print(" Timed out") sys.exit(1) else: complete() print_partial("Verifying authentication information...") test_auth() complete() if not SKIP_LICENSING: print_partial("Adding license key...") enter_license_info(LICENSE_KEY) complete() poll_for_licensing_complete() complete() print_partial("Configuring role...") configure_big_iq_type(dcd=(NODE_TYPE == "DCD")) complete() print_partial("Setting management address...") set_management_address() complete() poll_for_services_available() complete() print_partial("Setting masterkey...") set_master_key() complete() if not poll_for_services_available(): print(" Timed out") sys.exit(1) else: complete() print_partial("Setting password status to updated...") set_passwords() complete() print_partial("Configuration complete, restarting services") # Wait for toku to flush everything to disk? Maybe? time.sleep(10) do_restart() complete() util.poll_for_system_down(BIGIQ_ADDR, timeout=TIMEOUT_SEC) complete() poll_for_services_available() set_system_setup() complete()