Beispiel #1
0
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
Beispiel #2
0
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, 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(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(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(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(firewall_rule, **kwargs):
    gcp_config = utils.get_gcp_config()
    network_name = utils.get_gcp_resource_name(gcp_config['network'])
    set_firewall_rule_name(firewall_rule, network_name)
    firewall = FirewallRule(gcp_config,
                            ctx.logger,
                            firewall=firewall_rule,
                            network=network_name)

    utils.create(firewall)
    ctx.instance.runtime_properties[constants.NAME] = firewall.name
Beispiel #9
0
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
Beispiel #10
0
def create(firewall_rule, **kwargs):
    gcp_config = utils.get_gcp_config()
    network_name = utils.get_gcp_resource_name(gcp_config['network'])
    set_firewall_rule_name(firewall_rule, network_name)
    firewall = FirewallRule(gcp_config,
                            ctx.logger,
                            firewall=firewall_rule,
                            network=network_name)

    utils.create(firewall)
    ctx.instance.runtime_properties[constants.NAME] = firewall.name
Beispiel #11
0
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, 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()
Beispiel #13
0
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()
Beispiel #14
0
def create_security_group(rules, **kwargs):
    gcp_config = utils.get_gcp_config()
    firewall_structure = create_firewall_structure_from_rules(
        gcp_config['network'], rules)
    ctx.instance.runtime_properties[constants.TARGET_TAGS] = \
        firewall_structure[constants.TARGET_TAGS]
    ctx.instance.runtime_properties[constants.SOURCE_TAGS] = \
        firewall_structure[constants.SOURCE_TAGS]
    firewall = FirewallRule(gcp_config, ctx.logger, firewall_structure,
                            gcp_config['network'])
    ctx.instance.runtime_properties[constants.NAME] = firewall.name
    utils.create(firewall)
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] = []
Beispiel #16
0
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_security_group(rules, **kwargs):
    gcp_config = utils.get_gcp_config()
    firewall_structure = create_firewall_structure_from_rules(
        gcp_config['network'],
        rules)
    ctx.instance.runtime_properties[constants.TARGET_TAGS] = \
        firewall_structure[constants.TARGET_TAGS]
    ctx.instance.runtime_properties[constants.SOURCE_TAGS] = \
        firewall_structure[constants.SOURCE_TAGS]
    firewall = FirewallRule(gcp_config,
                            ctx.logger,
                            firewall_structure,
                            gcp_config['network'])
    ctx.instance.runtime_properties[constants.NAME] = firewall.name
    utils.create(firewall)
Beispiel #20
0
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)