Difference between revisions of "TricircleHowToReadCode"
Chaoyi Huang (talk | contribs) |
Chaoyi Huang (talk | contribs) |
||
Line 8: | Line 8: | ||
=== Step 1 ~ Step 4: no code of Tricircle will be involved === | === Step 1 ~ Step 4: no code of Tricircle will be involved === | ||
=== Step 5: Create pod instances === | === Step 5: Create pod instances === | ||
+ | |||
+ | Command issued: | ||
+ | |||
+ | curl -X POST http://127.0.0.1:19999/v1.0/pods -H "Content-Type: application/json" \ | ||
+ | -H "X-Auth-Token: $token" -d '{"pod": {"region_name": "CentralRegion"}}' | ||
+ | |||
+ | curl -X POST http://127.0.0.1:19999/v1.0/pods -H "Content-Type: application/json" \ | ||
+ | -H "X-Auth-Token: $token" -d '{"pod": {"region_name": "RegionOne", "az_name": "az1"}}' | ||
+ | |||
* The restful API request will be routed to V1Controller from RootController for the version is 'v1.0': | * The restful API request will be routed to V1Controller from RootController for the version is 'v1.0': | ||
Line 43: | Line 52: | ||
core_plugin = tricircle.network.central_plugin.TricirclePlugin | core_plugin = tricircle.network.central_plugin.TricirclePlugin | ||
+ | |||
+ | Command issued: | ||
+ | |||
+ | neutron --os-region-name=CentralRegion net-create net1 | ||
+ | neutron --os-region-name=CentralRegion subnet-create net1 10.0.1.0/24 | ||
* The request is handled by create_network when net1 is to be created: | * The request is handled by create_network when net1 is to be created: | ||
Line 75: | Line 89: | ||
subnet_data = subnet['subnet'] | subnet_data = subnet['subnet'] | ||
... | ... | ||
+ | |||
+ | === Step 7: Get image ID and flavor ID which will be used in VM booting === | ||
+ | |||
+ | Command issued: | ||
+ | |||
+ | glance --os-region-name=RegionOne image-list | ||
+ | nova --os-region-name=RegionOne flavor-list | ||
+ | |||
+ | No source code of Tricircle will be involved in this step. | ||
+ | |||
+ | === Step 8: Get image ID and flavor ID which will be used in VM booting === | ||
+ | |||
+ | Command issued: | ||
+ | |||
+ | nova --os-region-name=RegionOne boot --flavor 1 --image $image1_id --nic net-id=$net1_id vm1 | ||
+ | nova --os-region-name=RegionTwo boot --flavor 1 --image $image2_id --nic net-id=$net2_id vm2 |
Revision as of 01:57, 20 February 2017
Contents
- 1 (Work in progress)Learn the source code of Tricircle step by step
- 1.1 Experience the multi-region Tricircle networking first
- 1.2 Step 1 ~ Step 4: no code of Tricircle will be involved
- 1.3 Step 5: Create pod instances
- 1.4 Step 6: Create network/subnet in central Neutron server
- 1.5 Step 7: Get image ID and flavor ID which will be used in VM booting
- 1.6 Step 8: Get image ID and flavor ID which will be used in VM booting
(Work in progress)Learn the source code of Tricircle step by step
Experience the multi-region Tricircle networking first
Follow the installation guide: https://github.com/openstack/tricircle/blob/master/doc/source/multi-pod-installation-devstack.rst
Learn the source code will be used in the "How to play":
Step 1 ~ Step 4: no code of Tricircle will be involved
Step 5: Create pod instances
Command issued:
curl -X POST http://127.0.0.1:19999/v1.0/pods -H "Content-Type: application/json" \ -H "X-Auth-Token: $token" -d '{"pod": {"region_name": "CentralRegion"}}'
curl -X POST http://127.0.0.1:19999/v1.0/pods -H "Content-Type: application/json" \ -H "X-Auth-Token: $token" -d '{"pod": {"region_name": "RegionOne", "az_name": "az1"}}'
- The restful API request will be routed to V1Controller from RootController for the version is 'v1.0':
tricircle/tricircle/api/controllers/root.py ... class RootController(object): ... @expose() def _lookup(self, version, *remainder): if version == 'v1.0': return V1Controller(), remainder
- In V1Controller, because the request is to create pod, so the request will be forwarded to the post function in PodsController. Post function will create the pod and az mapping record in pod table:
tricircle/tricircle/api/controllers/pod.py ... class PodsController(rest.RestController): ... @expose(generic=True, template='json') def post(self, **kw): context = t_context.extract_context_from_environ() ... new_pod = core.create_resource( context, models.Pod, {'pod_id': _uuid, 'region_name': region_name, 'pod_az_name': pod_az_name, 'dc_name': dc_name, 'az_name': az_name})
Step 6: Create network/subnet in central Neutron server
The central_plugin.py will be called because the core plugin of central Neutron is configured like this:
core_plugin = tricircle.network.central_plugin.TricirclePlugin
Command issued:
neutron --os-region-name=CentralRegion net-create net1 neutron --os-region-name=CentralRegion subnet-create net1 10.0.1.0/24
- The request is handled by create_network when net1 is to be created:
tricircle/tricircle/network/central_plugin.py ... class TricirclePlugin(db_base_plugin_v2.NeutronDbPluginV2, security_groups.TricircleSecurityGroupMixin, external_net_db.External_net_db_mixin, portbindings_db.PortBindingMixin, extradhcpopt_db.ExtraDhcpOptMixin, l3_db.L3_NAT_dbonly_mixin, l3_attrs_db.ExtraAttributesMixin): ... def create_network(self, context, network): net_data = network[attributes.NETWORK] ...
- The request is handled by create_subnet when 10.0.1.0/24 subnet is created in net1:
tricircle/tricircle/network/central_plugin.py ... class TricirclePlugin(db_base_plugin_v2.NeutronDbPluginV2, security_groups.TricircleSecurityGroupMixin, external_net_db.External_net_db_mixin, portbindings_db.PortBindingMixin, extradhcpopt_db.ExtraDhcpOptMixin, l3_db.L3_NAT_dbonly_mixin, l3_attrs_db.ExtraAttributesMixin): ... def create_subnet(self, context, subnet): subnet_data = subnet['subnet'] ...
Step 7: Get image ID and flavor ID which will be used in VM booting
Command issued:
glance --os-region-name=RegionOne image-list nova --os-region-name=RegionOne flavor-list
No source code of Tricircle will be involved in this step.
Step 8: Get image ID and flavor ID which will be used in VM booting
Command issued:
nova --os-region-name=RegionOne boot --flavor 1 --image $image1_id --nic net-id=$net1_id vm1 nova --os-region-name=RegionTwo boot --flavor 1 --image $image2_id --nic net-id=$net2_id vm2