How to use the foremast.dns.SpinnakerDns function in foremast

To help you get started, we’ve selected a few foremast examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github foremast / foremast / tests / dns / test_dns.py View on Github external
def test_dns_creation(mock_get_details, mock_properties, mock_find_elb, mock_dns_zones, mock_update_dns):
    # mocked data
    hosted_zones = [500, 501]
    dns_elb = {'elb': 'myapp.dev1.example.com'}

    # mock results
    mock_get_details.return_value.app_name.return_value = 'myapp'
    mock_get_details.return_value.dns.return_value = dns_elb
    mock_properties.return_value = {'dns': {'ttl': 60}}
    mock_find_elb.return_value = 'myapp-internal.domain.external.com'
    mock_dns_zones.return_value = hosted_zones
    mock_update_dns.return_value = True

    d = dns.SpinnakerDns(app='myapp', region='region1', env='dev1', elb_subnet='noexist')
    assert d.domain == 'example.com'
    assert d.region == 'region1'
    assert d.elb_subnet == 'noexist'
    assert d.app_name == 'myapp'

    assert 'myapp.dev1.example.com' == d.create_elb_dns()

    sent_update_data = {
        'dns_name': dns_elb['elb'],
        'dns_name_aws': mock_find_elb.return_value,
        'dns_ttl': mock_properties.return_value['dns']['ttl']
    }

    mock_update_dns.assert_called_with('dev1', 501, **sent_update_data)
    assert mock_update_dns.call_count == 2
github foremast / foremast / src / foremast / runner.py View on Github external
def create_dns(self):
        """Create DNS for the defined app and environment."""
        utils.banner("Creating DNS")
        elb_subnet = self.configs[self.env]['elb']['subnet_purpose']
        regions = self.configs[self.env]['regions']
        failover = self.configs[self.env]['dns']['failover_dns']
        primary_region = self.configs['pipeline']['primary_region']
        regionspecific_dns = self.configs[self.env]['dns']['region_specific']

        dnsobj = dns.SpinnakerDns(
            app=self.app, env=self.env, region=self.region, prop_path=self.json_path, elb_subnet=elb_subnet)

        if len(regions) > 1 and failover:
            dnsobj.create_elb_dns(regionspecific=True)
            dnsobj.create_failover_dns(primary_region=primary_region)
        else:
            if regionspecific_dns:
                dnsobj.create_elb_dns(regionspecific=True)

            if self.region == primary_region:
                dnsobj.create_elb_dns(regionspecific=False)
github foremast / foremast / src / foremast / runner.py View on Github external
def create_dns(self):
        """ Creates DNS for the defined app and environment """
        utils.banner("Creating DNS")
        elb_subnet = self.configs[self.env]['elb']['subnet_purpose']
        dnsobj = dns.SpinnakerDns(app=self.app,
                                  env=self.env,
                                  region=self.region,
                                  elb_subnet=elb_subnet)
        dnsobj.create_elb_dns()