Add multi region support

This commit is contained in:
Setyo Nugroho 2022-11-01 02:19:44 +07:00
parent c695abbf68
commit deb8b77b49
4 changed files with 63 additions and 3 deletions

28
CHANGELOG.txt Normal file
View file

@ -0,0 +1,28 @@
v1.0.1
---------------------------
- Add multi region support
- Update error message on project cost
v1.0
---------------------------
- Fixing some bugs
- Upload logo for your invoice
- Add currency to overview
- Add description for setting form
v1.0-beta
----------------------------
- Setting company profile
- Send invoice to email
- Notification center
- Update invoice format
v1.0-alpha
----------------------------
- Price Configuration
- Project Overview
- Project Invoice
- Usage Cost
- Billing Settings

View file

@ -22,10 +22,35 @@ pip3 install -r requirements.txt
Add this config to your horizon `local_settings.py` Add this config to your horizon `local_settings.py`
```bash ```python
YUYU_URL="http://yuyu_server_url:8182" YUYU_URL="http://yuyu_server_url:8182"
CURRENCIES = ('IDR',) CURRENCIES = ('IDR',)
DEFAULT_CURRENCY = "IDR" DEFAULT_CURRENCY = "IDR"
``` ```
Then restart Horizon. Then restart Horizon.
## Multi Region
If your openstack using multiple region, and each region have its own Yuyu server, you can specify Yuyu server URL for each region.
To do that, you can add `YUYU_URL_REGION` to horizon `local_settings.py`
`YUYU_URL_REGION` is a list of tuples which define a mapping from region name (as in horizon `AVAILABLE_REGIONS`) to Yuyu URL for each. The tuple format is ***('{{ region_name }}', 'http://{yuyu_url}')***.
For example:
```python
# Example AVAILABLE_REGIONS settings
AVAILABLE_REGIONS = [
("https://172.12.12.10:5000/v3", 'US'),
("https://172.12.12.11:5000/v3", 'Singapore')
]
# Set Yuyu URL for each region
YUYU_URL_REGION = [
('US', 'http://region_a_yuyu_server_url:8182'),
('Singapore', 'http://region_b_yuyu_server_url:8182'),
]
```

View file

@ -7,7 +7,14 @@ def _get_header(request):
def _yuyu_url(request, path): def _yuyu_url(request, path):
return settings.YUYU_URL + "/api/" + path yuyu_url = settings.YUYU_URL
if hasattr(settings, 'YUYU_URL_REGION'):
regions = dict(settings.YUYU_URL_REGION)
region_url = regions.get(request.session['region_name'])
if region_url:
yuyu_url = region_url
return yuyu_url + "/api/" + path
def get(request, path): def get(request, path):

View file

@ -51,7 +51,7 @@
</div> </div>
</div> </div>
{% else %} {% else %}
<h1>Billing not enabled or you don't have any usage yet</h1> <br/> <h1>You don't have any usage yet</h1> <br/>
{% endif %} {% endif %}
{% endblock %} {% endblock %}
{% block js %} {% block js %}