Example #1
0
def nic_to_host(nic):
    assert len(nic.ip_configurations) == 1
    ip_config = nic.ip_configurations[0]
    if ip_config.public_ip_address is None:
        return Host(ip_config.private_ip_address, None)
    return Host(ip_config.private_ip_address,
                ip_config.public_ip_address.ip_address)
Example #2
0
 def get_public_agent_ips(self):
     """ public traffic is routed to public agents via a specific load balancer """
     public_lb_ip = self.public_agent_lb_fqdn
     return [
         Host(nic_to_host(nic).private_ip, public_lb_ip)
         for nic in self.get_scale_set_nics('public')
     ]
Example #3
0
 def get_master_ips(self):
     """ Traffic from abroad is routed to a master wth the public master
     loadbalancer FQDN and the VM index plus 2200 (so the first master will be at 2200)
     """
     public_lb_ip = self.public_master_lb_fqdn
     return [Host(nic_to_host(nic).private_ip, '{}:{}'.format(public_lb_ip, 2200 + int(nic.name[-1])))
             for nic in self.master_nics]
Example #4
0
 def hosts(self):
     """ order of return here determines cluster composition, so make sure its consistent
     """
     output_list = list()
     for name in self.instance_names:
         info = self.gce_wrapper.get_instance_network_properties(
             name, self.zone)
         output_list.append(
             Host(private_ip=info['networkIP'],
                  public_ip=info['accessConfigs'][0]['natIP']))
     return sorted(output_list)
Example #5
0
def instances_to_hosts(instances):
    return [Host(i.private_ip_address, i.public_ip_address) for i in instances]
Example #6
0
                                           'deployments')
        DeploymentFunctionsMock = namedtuple('DeploymentFunctionsMock',
                                             'insert delete get')
        ApiRequestMock = namedtuple('ApiRequestMock', 'execute')
        self.project_id = ''
        api_request_mock = ApiRequestMock(
            lambda: {'operation': {
                'status': 'DONE'
            }})
        self.deployment_manager = DeploymentManagerMock(
            lambda: DeploymentFunctionsMock(stub(api_request_mock),
                                            stub(api_request_mock),
                                            stub(api_request_mock)))


mock_pub_priv_host = Host('127.0.0.1', '12.34.56')
mock_priv_host = Host('127.0.0.1', None)
MOCK_GCE_DEPLOYMENT_INFO = {'operation': {'status': 'DONE'}}
MOCK_GCE_INSTANCE_INFO = {
    'name':
    'mock_instance',
    'networkInterfaces': [{
        'networkIP': 'mock_net_ip',
        'accessConfigs': [{
            'natIP': 'mock_nat_ip'
        }]
    }],
    'metadata': {
        'fingerprint': 'mock_fingerprint'
    }
}
Example #7
0
 def hosts(self):
     for name in self.instance_names:
         info = self.gce_wrapper.get_instance_network_properties(name, self.zone)
         yield Host(private_ip=info['networkIP'], public_ip=info['accessConfigs'][0]['natIP'])