def create(network, **kwargs): gcp_config = utils.get_gcp_config() network['name'] = utils.get_final_resource_name(network['name']) network = Network(gcp_config, ctx.logger, network=network) utils.create(network) ctx.instance.runtime_properties[constants.NAME] = network.name # will be updated only if the resource is created before ctx.instance.runtime_properties['ip_range'] = network.iprange
def create(name, default_service, **kwargs): name = utils.get_final_resource_name(name) gcp_config = utils.get_gcp_config() url_map = UrlMap(gcp_config, ctx.logger, name, default_service) utils.create(url_map) ctx.instance.runtime_properties[constants.NAME] = name ctx.instance.runtime_properties[constants.SELF_URL] = \ url_map.get_self_url()
def create(image, name, size, **kwargs): name = utils.get_final_resource_name(name) gcp_config = utils.get_gcp_config() disk = Disk(gcp_config, ctx.logger, image=image, name=name, size_gb=size) utils.create(disk) ctx.instance.runtime_properties[constants.NAME] = name ctx.instance.runtime_properties[constants.DISK] = \ disk.disk_to_insert_instance_dict(name)
def create(name, **kwargs): name = utils.get_final_resource_name(name) gcp_config = utils.get_gcp_config() static_ip = StaticIP(gcp_config, ctx.logger, name) utils.create(static_ip) ip_address = get_reserved_ip_address(static_ip) ctx.instance.runtime_properties[constants.NAME] = name ctx.instance.runtime_properties[constants.IP] = ip_address
def create(name, target_proxy, port_range, ip_address, **kwargs): name = utils.get_final_resource_name(name) gcp_config = utils.get_gcp_config() forwarding_rule = GlobalForwardingRule(gcp_config, ctx.logger, name, target_proxy, port_range, ip_address) utils.create(forwarding_rule) ctx.instance.runtime_properties[constants.NAME] = name
def create(name, named_ports, **kwargs): name = utils.get_final_resource_name(name) gcp_config = utils.get_gcp_config() instance_group = InstanceGroup(gcp_config, ctx.logger, name=name, named_ports=named_ports) utils.create(instance_group) ctx.instance.runtime_properties[constants.NAME] = name ctx.instance.runtime_properties[constants.SELF_URL] = \ instance_group.get_self_url()
def create(name, health_check, additional_settings, **kwargs): name = utils.get_final_resource_name(name) gcp_config = utils.get_gcp_config() backend_service = BackendService(gcp_config, ctx.logger, name, health_check, additional_settings) utils.create(backend_service) ctx.instance.runtime_properties[constants.NAME] = name ctx.instance.runtime_properties[constants.SELF_URL] = \ backend_service.get_self_url() ctx.instance.runtime_properties[constants.BACKENDS] = []
def create(name, health_check_type, additional_settings, **kwargs): name = utils.get_final_resource_name(name) gcp_config = utils.get_gcp_config() health_check = health_check_of_type(health_check_type, config=gcp_config, logger=ctx.logger, name=name, additional_settings=additional_settings) utils.create(health_check) ctx.instance.runtime_properties[constants.NAME] = name ctx.instance.runtime_properties[constants.HEALTH_CHECK_TYPE] = \ health_check_type ctx.instance.runtime_properties[constants.SELF_URL] = \ health_check.get_self_url()
def create(name, private_key, certificate, **kwargs): name = utils.get_final_resource_name(name) gcp_config = utils.get_gcp_config() private_key_data = get_pem_data(private_key['type'], private_key['data']) certificate_data = get_pem_data(certificate['type'], certificate['data']) ssl_certificate = SslCertificate(config=gcp_config, logger=ctx.logger, name=name, private_key=private_key_data, certificate=certificate_data) utils.create(ssl_certificate) ctx.instance.runtime_properties[constants.NAME] = name ctx.instance.runtime_properties[constants.SELF_URL] = \ ssl_certificate.get_self_url()
def create(name, target_proxy_type, url_map, ssl_certificate, **kwargs): name = utils.get_final_resource_name(name) gcp_config = utils.get_gcp_config() target_proxy = target_proxy_of_type(target_proxy_type, config=gcp_config, logger=ctx.logger, name=name, url_map=url_map, ssl_certificate=ssl_certificate) utils.create(target_proxy) ctx.instance.runtime_properties[constants.NAME] = name ctx.instance.runtime_properties[constants.TARGET_PROXY_TYPE] = \ target_proxy_type ctx.instance.runtime_properties[constants.SELF_URL] = \ target_proxy.get_self_url()
def create(instance_type, image_id, name, zone, external_ip, startup_script, scopes, user_data, **kwargs): if zone: ctx.instance.runtime_properties[constants.GCP_ZONE] = zone gcp_config = utils.get_gcp_config() gcp_config['network'] = utils.get_gcp_resource_name(gcp_config['network']) script = '' if not startup_script: startup_script = ctx.instance.runtime_properties.get('startup_script') #TODO: make it pythonistic ctx.logger.info('The script is {0}'.format(str(startup_script))) if startup_script and startup_script.get('type') == 'file': script = ctx.get_resource(startup_script.get('script')) elif startup_script and startup_script.get('type') == 'string': script = startup_script.get('script') instance_name = utils.get_final_resource_name(name) instance = Instance(gcp_config, ctx.logger, name=instance_name, image=image_id, machine_type=instance_type, external_ip=external_ip, startup_script=script, scopes=scopes, user_data=user_data) ctx.instance.runtime_properties[constants.NAME] = instance.name if ctx.node.properties['install_agent']: add_to_security_groups(instance) disk = ctx.instance.runtime_properties.get(constants.DISK) if disk: instance.disks = [disk] utils.create(instance) set_ip(instance)
def create(image_name, image_path, **kwargs): gcp_config = utils.get_gcp_config() name = utils.get_final_resource_name(image_name) image = Image(gcp_config, ctx.logger, name) upload_image(image, image_path) ctx.instance.runtime_properties[constants.NAME] = image.name