예제 #1
0
파일: base.py 프로젝트: blkart/fuel-web
    def create_node_group(self, api=True, **kwargs):
        ng_data = {'cluster_id': self.clusters[0].id, 'name': 'test_ng'}
        if kwargs:
            ng_data.update(kwargs)
        if api:
            resp = self.app.post(reverse('NodeGroupCollectionHandler'),
                                 jsonutils.dumps(ng_data),
                                 headers=self.default_headers,
                                 expect_errors=False)

            ng = resp
        else:
            ng = NodeGroup.create(ng_data)
            db().commit()

        return ng
예제 #2
0
파일: base.py 프로젝트: thefuyang/fuel-web
    def create_node_group(self, api=True, **kwargs):
        ng_data = {"cluster_id": self.clusters[0].id, "name": "test_ng"}
        if kwargs:
            ng_data.update(kwargs)
        if api:
            resp = self.app.post(
                reverse("NodeGroupCollectionHandler"),
                jsonutils.dumps(ng_data),
                headers=self.default_headers,
                expect_errors=False,
            )

            ng = resp
        else:
            ng = NodeGroup.create(ng_data)
            db().commit()

        return ng
예제 #3
0
    def apply_network_template(cls, instance, template):
        if template is None:
            instance.network_template = None
            return

        template_body = template["adv_net_template"]
        # Get the correct nic_mapping for this node so we can
        # dynamically replace any interface references in any
        # template for this node.
        from nailgun.objects import NodeGroup

        node_group = NodeGroup.get_by_uid(instance.group_id).name
        if node_group not in template_body:
            node_group = "default"

        node_name = cls.get_slave_name(instance)
        nic_mapping = template_body[node_group]["nic_mapping"]
        if node_name not in nic_mapping:
            node_name = "default"

        nic_mapping = nic_mapping[node_name]

        # Replace interface references and re-parse JSON
        template_object = NetworkTemplate(jsonutils.dumps(template_body))
        node_template = template_object.safe_substitute(nic_mapping)
        parsed_template = jsonutils.loads(node_template)

        output = parsed_template[node_group]
        output["templates"] = output.pop("network_scheme")
        output["roles"] = {}
        output["endpoints"] = {}
        for v in output["templates"].values():
            for endpoint in v["endpoints"]:
                output["endpoints"][endpoint] = {}
            for role, ep in v["roles"].items():
                output["roles"][role] = ep

        instance.network_template = output
        db().flush()

        if instance.cluster:
            nm = Cluster.get_network_manager(instance.cluster)
            nm.assign_networks_by_template(instance)
예제 #4
0
파일: node.py 프로젝트: xglhjk6/fuel-web
    def apply_network_template(cls, instance, template):
        if template is None:
            instance.network_template = None
            return

        template_body = template['adv_net_template']
        # Get the correct nic_mapping for this node so we can
        # dynamically replace any interface references in any
        # template for this node.
        from nailgun.objects import NodeGroup
        node_group = NodeGroup.get_by_uid(instance.group_id).name
        if node_group not in template_body:
            node_group = 'default'

        node_name = cls.get_slave_name(instance)
        nic_mapping = template_body[node_group]['nic_mapping']
        if node_name not in nic_mapping:
            node_name = 'default'

        nic_mapping = nic_mapping[node_name]

        # Replace interface references and re-parse JSON
        template_object = NetworkTemplate(jsonutils.dumps(template_body))
        node_template = template_object.safe_substitute(nic_mapping)
        parsed_template = jsonutils.loads(node_template)

        output = parsed_template[node_group]
        output['templates'] = output.pop('network_scheme')
        output['roles'] = {}
        output['endpoints'] = {}
        for v in output['templates'].values():
            for endpoint in v['endpoints']:
                output['endpoints'][endpoint] = {}
            for role, ep in v['roles'].items():
                output['roles'][role] = ep

        instance.network_template = output
        db().flush()

        if instance.cluster:
            nm = Cluster.get_network_manager(instance.cluster)
            nm.assign_networks_by_template(instance)
예제 #5
0
    def apply_network_template(cls, instance, template):
        if template is None:
            instance.network_template = None
            return

        template_body = template['adv_net_template']
        # Get the correct nic_mapping for this node so we can
        # dynamically replace any interface references in any
        # template for this node.
        from nailgun.objects import NodeGroup
        node_group = NodeGroup.get_by_uid(instance.group_id).name
        if node_group not in template_body:
            node_group = 'default'

        node_name = cls.get_slave_name(instance)
        nic_mapping = template_body[node_group]['nic_mapping']
        if node_name not in nic_mapping:
            node_name = 'default'

        nic_mapping = nic_mapping[node_name]

        # Replace interface references and re-parse JSON
        template_object = NetworkTemplate(jsonutils.dumps(template_body))
        node_template = template_object.safe_substitute(nic_mapping)
        parsed_template = jsonutils.loads(node_template)

        output = parsed_template[node_group]
        output['templates'] = output.pop('network_scheme')
        output['roles'] = {}
        output['endpoints'] = {}
        for v in output['templates'].values():
            for endpoint in v['endpoints']:
                output['endpoints'][endpoint] = {}
            for role, ep in v['roles'].items():
                output['roles'][role] = ep

        instance.network_template = output
예제 #6
0
 def get_controllers_node_group(cls, cluster):
     from nailgun.objects import NodeGroup
     group_id = cls.get_controllers_group_id(cluster)
     return NodeGroup.get_by_uid(group_id)
예제 #7
0
파일: cluster.py 프로젝트: SergK/fuel-web
 def get_controllers_node_group(cls, cluster):
     from nailgun.objects import NodeGroup
     group_id = cls.get_controllers_group_id(cluster)
     return NodeGroup.get_by_uid(group_id)