Пример #1
0
    def _config_net_topology(self, conf):
        """
        Initialize and populate all the network related elements, like
        reserving ips and populating network specs of the given confiiguration
        spec

        Args:
            conf (dict): Configuration spec to initalize

        Returns:
            None
        """
        self._init_net_specs(conf)
        self._check_predefined_subnets(conf)
        allocated_subnets = self._allocate_subnets(conf)
        try:
            self._register_preallocated_ips(conf)
            self._allocate_ips_to_nics(conf)
        except:
            for subnet in allocated_subnets:
                subnet_lease.release(subnet)
            raise
Пример #2
0
    def _allocate_subnets(self, conf):
        """
        Allocate all the subnets needed by the given configuration spec
        Args:
            conf (dict): Configuration spec where to get the nets definitions
                from
        Returns:
            tuple(list, dict): allocated subnets and modified conf
        """
        allocated_subnets = []
        try:
            for net_spec in conf.get('nets', {}).itervalues():
                if 'gw' in net_spec or net_spec['type'] != 'nat':
                    continue
                net_spec['gw'] = subnet_lease.acquire(self.paths.uuid())
                allocated_subnets.append(net_spec['gw'])
        except:
            for subnet in allocated_subnets:
                subnet_lease.release(subnet)
            raise

        return allocated_subnets, conf
Пример #3
0
    def _allocate_subnets(self, conf):
        """
        Allocate all the subnets needed by the given configuration spec

        Args:
            conf (dict): Configuration spec where to get the nets definitions
                from

        Returns:
            tuple(list, dict): allocated subnets and modified conf
        """
        allocated_subnets = []
        try:
            for net_spec in conf.get('nets', {}).itervalues():
                if 'gw' in net_spec or net_spec['type'] != 'nat':
                    continue
                net_spec['gw'] = subnet_lease.acquire(self.paths.uuid())
                allocated_subnets.append(net_spec['gw'])
        except:
            for subnet in allocated_subnets:
                subnet_lease.release(subnet)

        return allocated_subnets, conf
Пример #4
0
    def _config_net_topology(self, conf):
        """
        Initialize and populate all the network related elements, like
        reserving ips and populating network specs of the given confiiguration
        spec

        Args:
            conf (dict): Configuration spec to initalize

        Returns:
            None
        """
        conf = self._init_net_specs(conf)
        self._check_predefined_subnets(conf)
        allocated_subnets, conf = self._allocate_subnets(conf)
        try:
            self._register_preallocated_ips(conf)
            self._allocate_ips_to_nics(conf)
        except:
            for subnet in allocated_subnets:
                subnet_lease.release(subnet)
            raise

        return conf