示例#1
0
文件: base.py 项目: e0ne/fuel-web
    def _create_interfaces_from_meta(self, node):
        # Create interfaces from meta
        for interface in node.meta['interfaces']:
            interface = NodeNICInterface(
                mac=interface.get('mac'),
                name=interface.get('name'),
                ip_addr=interface.get('ip'),
                netmask=interface.get('netmask'))

            self.db.add(interface)
            node.interfaces.append(interface)

        # If node in a cluster then add
        # allowed_networks for all interfaces
        # and assigned_networks for first interface
        if node.cluster_id:
            ng_ids = [ng.id for ng in
                      self.network_manager.get_all_cluster_networkgroups(node)]
            allowed_networks = list(self.db.query(NetworkGroup).filter(
                NetworkGroup.id.in_(ng_ids)))

            for interface in node.interfaces:
                interface.allowed_networks_list = allowed_networks

            node.interfaces[0].assigned_networks_list = allowed_networks

        self.db.commit()
        # At least one interface should have
        # same ip as mac in meta
        if node.interfaces and not \
           filter(lambda i: node.mac == i.mac, node.interfaces):

            node.interfaces[0].mac = node.mac
            self.db.commit()
示例#2
0
    def _create_interfaces_from_meta(self, node):
        # Create interfaces from meta
        for interface in node.meta['interfaces']:
            interface = NodeNICInterface(mac=interface.get('mac'),
                                         name=interface.get('name'),
                                         ip_addr=interface.get('ip'),
                                         netmask=interface.get('netmask'))
            self.db.add(interface)
            node.nic_interfaces.append(interface)

        self.db.flush()
        # If node in a cluster then assign networks for all interfaces
        if node.cluster_id:
            self.network_manager.assign_networks_by_default(node)
        # At least one interface should have
        # same ip as mac in meta
        if node.nic_interfaces and not \
           filter(lambda i: node.mac == i.mac, node.nic_interfaces):

            node.nic_interfaces[0].mac = node.mac
        self.db.commit()
示例#3
0
    def _create_interfaces_from_meta(self, node):
        # Create interfaces from meta
        for interface in node.meta["interfaces"]:
            interface = NodeNICInterface(
                mac=interface.get("mac"),
                name=interface.get("name"),
                ip_addr=interface.get("ip"),
                netmask=interface.get("netmask"),
            )
            self.db.add(interface)
            node.nic_interfaces.append(interface)

        self.db.flush()
        # If node in a cluster then assign networks for all interfaces
        if node.cluster_id:
            self.network_manager.assign_networks_by_default(node)
        # At least one interface should have
        # same ip as mac in meta
        if node.nic_interfaces and not filter(lambda i: node.mac == i.mac, node.nic_interfaces):

            node.nic_interfaces[0].mac = node.mac
        self.db.commit()
示例#4
0
文件: base.py 项目: e0ne/fuel-web
    def _create_interfaces_from_meta(self, node):
        # Create interfaces from meta
        for interface in node.meta['interfaces']:
            interface = NodeNICInterface(mac=interface.get('mac'),
                                         name=interface.get('name'),
                                         ip_addr=interface.get('ip'),
                                         netmask=interface.get('netmask'))

            self.db.add(interface)
            node.interfaces.append(interface)

        # If node in a cluster then add
        # allowed_networks for all interfaces
        # and assigned_networks for first interface
        if node.cluster_id:
            ng_ids = [
                ng.id for ng in
                self.network_manager.get_all_cluster_networkgroups(node)
            ]
            allowed_networks = list(
                self.db.query(NetworkGroup).filter(
                    NetworkGroup.id.in_(ng_ids)))

            for interface in node.interfaces:
                interface.allowed_networks_list = allowed_networks

            node.interfaces[0].assigned_networks_list = allowed_networks

        self.db.commit()
        # At least one interface should have
        # same ip as mac in meta
        if node.interfaces and not \
           filter(lambda i: node.mac == i.mac, node.interfaces):

            node.interfaces[0].mac = node.mac
            self.db.commit()