craete seed function phase 2
This commit is contained in:
parent
6380a199b3
commit
c970f0d82a
4 changed files with 59 additions and 66 deletions
|
@ -77,7 +77,8 @@ def dashboard():
|
|||
rrd[cubeid] = {}
|
||||
try:
|
||||
query = contact_proxmaster({}, 'vmrrd', cubeid)
|
||||
except:
|
||||
except Exception as e:
|
||||
current_app.logger.error(e)
|
||||
flash('Deploy #{} unreachable. Support is notified'.format(str(cubeid)))
|
||||
send_email(current_app.config['MAIL_USERNAME'], 'Cube {} is unreachable'.format(cubeid),
|
||||
'vmanager/email/adm_unreachable', user=current_user, cubeid=cubeid)
|
||||
|
|
|
@ -208,15 +208,12 @@ def contact_proxmaster(data, method, cubeid=0):
|
|||
url = current_app.config['PROXMASTER_URL']
|
||||
data['apikey'] = current_app.config['APIKEY']
|
||||
data_json = json.dumps(data)
|
||||
#print('--> {}'.format(data))
|
||||
|
||||
if method == 'vmcreate':
|
||||
url = '{}/{}'.format(url, method)
|
||||
else:
|
||||
url = '{}/{}/{}'.format(url, method, cubeid)
|
||||
|
||||
db_result = requests.post( url, data=data_json, headers={"content-type": "application/json"}, timeout=30 )
|
||||
|
||||
try:
|
||||
proxjson = db_result.json()
|
||||
#print('proxmaster query {}'.format(str(proxjson)))
|
||||
|
|
|
@ -187,60 +187,12 @@ addEventListener("DOMContentLoaded", function() {
|
|||
</table>
|
||||
</div>
|
||||
<!-- Cloud Storage icon by Icons8 -->
|
||||
<button class="btn btn-default" onclick="window.open('{{ url_for('vmanager.createvm') }}','_self')"><img class="icon icons8-Cloud-Storage" width="40" height="40" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAEEklEQVRYhe3Xy0/bBhwHcA6btEMP0077A3boYYdK23EHLiQ0hQBtVC1S9zjs0L069TCkSUWNpgZCshDYItZOI+tKH7Cibgw6Wu2RAXWMYyc8mpAoUAIEp6VuTR5OwAnJd5dBEbYJKDSA1J/0PfjgXz6y5W/ssrKDNm9dYl4+aqYeq00kSpnK5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VjpoTxRfm3mL2In8tBY6ZS60C1icRFJrevojaReAF8bkAykkcqAxDz+W0dFxOlXVsCU///5aYy2NZxMVHadbCv4H7IC+CuA/djyg7C/AeJ36h1J+7ehgAAAABJRU5ErkJggg=="> Create</button>
|
||||
<button class="btn btn-default" onclick="window.open('{{ url_for('vmanager.createvm') }}','_self')"><img class="icon icons8-Cloud-Storage" width="32" height="32" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAEEklEQVRYhe3Xy0/bBhwHcA6btEMP0077A3boYYdK23EHLiQ0hQBtVC1S9zjs0L069TCkSUWNpgZCshDYItZOI+tKH7Cibgw6Wu2RAXWMYyc8mpAoUAIEp6VuTR5OwAnJd5dBEbYJKDSA1J/0PfjgXz6y5W/ssrKDNm9dYl4+aqYeq00kSpnK5pGUusX1WkGgxux+/ePLvmQ4lkcp88nPfkHV6DpcEFhpGnnH2D8XKzXwQv98UtXoqioIVDeRH/1IcKlSAzsIbqXSTJ0tCKy2uNt/uy+slhrYez8JrY25XhCotdKDgzNiSXHhWB5DYRFaK+0tfAWt9Pzow9WSA8cereKYheILAo/bGDHE72z5n8E46rsC0LXR0LXRqO8K4O5kbEc7pvg8TrQxuXKD8xVFnLrJ9canVyYTO1k84FvCe+1eXCcWwPLLYPlldJMsPrg4ipsMtyPkmasBQWUk3twKWGm8PRff7kImsoxT7V5MLwrYPPNP0tDbPfh3KrltoGkgIqgaXbVbAT9zuLi00oIHfA6O4ShOOyZQZaFQZ3Pjbx8nwa3NcPAp1CYSersH529NwcuubAn8iXya0VjcXykCtVa6o9cn5JVwZzr9OHcziNBDAWI2hzCXwmourwgEAF7IgEuI6CJZ6FppMJFlRWCfX0BNq6dLEVjdQlODYfmK6RiK4twvwS0xheYasYCGnpAi8N6sCK2V8SsCq76hFsce5WRPPu2YQIBNFgXkEiL0do8icGIxB42Fisviyg3Ol463MtkpmYoZj4qoslAQs7migACgNpFo7Hsge6unl/I4+Z0nW25wHpIAVY2uw593BiQVMx4V8eGlMVwZjhSNA4B4OgtL/zROfsvIIs/eCAoVRuKIHLC26Y+IBGjqn0GHc25XcBvnh39mcaF3WgK03F1IqZoJnQR41EzVO1xPVjaf8P73o2D55V0HTi8K0LXREmAnxWe1VtogrZgW+sbvPkFygt7uAZcQdx2o9MDcnkyh1sb8KgNkvEMyFXP+1hS6SXbXgd0kK1s5rrkMalqYSQlQY6HichXjZVdwqt2LHioKXsgUDeMSIrpJFnU2N9xzacnv+R7noDFTwuaKOXSizSPKVcwasqEnhDqbu+iPI73dg4aekCwuHMtjZikPvd2TLTc4X10HVhiJI19cDe7oLeZ55suukFDRfO/tZxXTTOhMdxZK/iWnFNtf0bTKRLy7DjxmcX99meLFvYat5RodW61uYZo2PsH9fX5pxexV7gTTqGn1DGzswODwbGbPYWsZiWSgtTGhZxVjpoTxRfm3mL2In8tBY6ZS60C1icRFJrevojaReAF8bkAykkcqAxDz+W0dFxOlXVsCU///5aYy2NZxMVHadbCv4H7IC+CuA/djyg7C/AeJ36h1J+7ehgAAAABJRU5ErkJggg=="> Create</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if inv_services != [] %}
|
||||
<div class="col-md-12">
|
||||
<div class="panel panel-info" id="services">
|
||||
<div class="panel-heading">Services</div>
|
||||
<div class="panel-body"><p>
|
||||
<div id="no-more-tables">
|
||||
<table class="table table-hover table-striped table-condensed cf">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Category</th>
|
||||
<th>Description</th>
|
||||
<th>Last Charged</th>
|
||||
<th>Time Left</th>
|
||||
</tr>
|
||||
<tbody>
|
||||
{% for service in inv_services %}
|
||||
{% if service.enabled == False %}
|
||||
<tr class="danger">
|
||||
{% else %}
|
||||
{% if service.warning == True %}
|
||||
<tr class="warning">
|
||||
{% else %}
|
||||
<tr>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
<td data-title="Category">{{ service.category }}</td>
|
||||
<td data-title="Description" >{{ service.description }}</td>
|
||||
<td data-title="Last Charged">{{ moment(service.date_last_charge).format('lll') }} ({{ moment(service.date_last_charge).fromNow() }})</td>
|
||||
{% if service.enabled == False %}
|
||||
<td data-title="Time Left"><button class="btn btn-default btn-success" onclick="window.open('/smanager/activate/{{ service.pid }}','_self');"><span class="glyphicon glyphicon-bell" aria-hidden="true"></span> Activate</button></td>
|
||||
{% else %}
|
||||
{% if service.warning == True %}
|
||||
<td data-title="Time Left"><button class="btn btn-default btn-success" onclick="window.open('/smanager/activate/{{ service.pid }}','_self');"><span class="glyphicon glyphicon-bell" aria-hidden="true"></span> Renew ({{ service.daysleft }} days left)</button></td>
|
||||
{% else %}
|
||||
<td data-title="Time Left">{{ service.daysleft }} day(s)</td>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</tr >
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<img class="icon icons8-Key-2" width="40" height="40" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAADwUlEQVRYhdXYz0/bVhwA8Bz4I/Yn9A/gwKGHHApxiENwo8IG2rSqh/XUw267cRmJY8dOQpIGOq2cdtguFZNoUQQeiOBnm7h4iB+TRkJwkiJtdZ0GQzPLeTtU0bIQ0qQ8wP1K30sU6X3y/X7fs18cjk89Bsn1fjwEAgQj7nhpQXMFeeilBY1gpV2cFkgsCG7fCAwL8E5fWBQmk7IeX1bNTM6ASrkG83odKuUazOQMGF9WzYmEXPWFxd+xAO+8FphziuvzMRKDkcBKLKt/H2gWzOv1C/NAs2ByRdXdJDD9kc2oc4rru1LcSFj4dTIpn6z9edIR1pqZnAG/mt06GWXExStD+hiJ+SKR1ff/MnvCNVfz69mt1yOMOI8chwV4J0YCq9fKtSZ/aEA3Ccyh6Q0cKdAXFoUUVzJbK8IsFc4IVqoSrFSln+fffWgm83odpriSiVNgDxlukFzvn0zKeuvizFLhzEuL224SDLhJMOClBIlZKpx10+qJhFxBtrPHY9mZaLqgty5EsFLVTYKB5h9CsFK1m1ZH0wX9XlSaRQIkGHEnkzPOLXIZYCZnQIIRd5AAvbSgNQ7h5qSf59/hlCAOkuv9g+R6P06BNWoxf9oNUCnXoJcWNCRAV5C/cJaYFwWjsUmoxfxpN5ukka4gD5EAR8LtK3iZVMo1OBJGVMG7EWmv3QxeJjM5AxKstIsE+Hk8G4+mC29RAqPpo+pYbPMJEiAWBLe/fPyy0st8dXEO1rGQcA8J0OFwOPwRaT+5op47Cz8m51ZLcHwma92NSK+GQ+JnSIBYgHe6SWBedhb5QwN6KAEuKBqcXS1VkCL9kc1ou0deL6395sdt+OinAygfv/8MKdI5xfWNMuLigzmlyh/2Vkn+0IAPn27D737+A26+suDTl9aVIufdJDATK6rWzRv13GoJ4pQAv184gI3vy8f1/yF/WCtbPkYsImv30PTGKE6Bvc53kqI5kZTrY7GstaBo5/CtSOQz6XC83zweCrBtb3UUiLpIcN9LC5UUV2x7AlwL8kMxNL1xy0uLeoorvrE5UtBTvxU12yMfc6q9kZ4Q0FxBHjayExL57u412r1r2qKSnYC2Qg6HwOtPvt2/7P73tIqljyw/Kz2zDbA1t4//gTglnF7pn1AXRad2N+eDJ8obV4C/c+3A5ugEjKXVk7EZed62wPR+BfrCYvlGgZ4Q0GLpI6v1uquUa3A8nn07TPHf3ihwaHrjlp+VnuEUOL0/t6UnllVraVe3B645nFNcnyvA3/FQIOELi2Vb4bqJfwEpWpu91pyNygAAAABJRU5ErkJggg==">
|
||||
<button class="btn btn-default" onclick="window.open('{{ url_for('smanager.requestservice') }}','_self')"><span class="glyphicon glyphicon-plus" aria-hiddent="true"></span> Send Request</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if inv_domains != [] %}
|
||||
<div class="col-md-12">
|
||||
|
@ -317,6 +269,54 @@ addEventListener("DOMContentLoaded", function() {
|
|||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if inv_services != [] %}
|
||||
<div class="col-md-12">
|
||||
<div class="panel panel-info" id="services">
|
||||
<div class="panel-heading">Services</div>
|
||||
<div class="panel-body"><p>
|
||||
<div id="no-more-tables">
|
||||
<table class="table table-hover table-striped table-condensed cf">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Category</th>
|
||||
<th>Description</th>
|
||||
<th>Last Charged</th>
|
||||
<th>Time Left</th>
|
||||
</tr>
|
||||
<tbody>
|
||||
{% for service in inv_services %}
|
||||
{% if service.enabled == False %}
|
||||
<tr class="danger">
|
||||
{% else %}
|
||||
{% if service.warning == True %}
|
||||
<tr class="warning">
|
||||
{% else %}
|
||||
<tr>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
<td data-title="Category">{{ service.category }}</td>
|
||||
<td data-title="Description" >{{ service.description }}</td>
|
||||
<td data-title="Last Charged">{{ moment(service.date_last_charge).format('lll') }} ({{ moment(service.date_last_charge).fromNow() }})</td>
|
||||
{% if service.enabled == False %}
|
||||
<td data-title="Time Left"><button class="btn btn-default btn-success" onclick="window.open('/smanager/activate/{{ service.pid }}','_self');"><span class="glyphicon glyphicon-bell" aria-hidden="true"></span> Activate</button></td>
|
||||
{% else %}
|
||||
{% if service.warning == True %}
|
||||
<td data-title="Time Left"><button class="btn btn-default btn-success" onclick="window.open('/smanager/activate/{{ service.pid }}','_self');"><span class="glyphicon glyphicon-bell" aria-hidden="true"></span> Renew ({{ service.daysleft }} days left)</button></td>
|
||||
{% else %}
|
||||
<td data-title="Time Left">{{ service.daysleft }} day(s)</td>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</tr >
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<button class="btn btn-default" onclick="window.open('{{ url_for('smanager.requestservice') }}','_self')"><img class="icon icons8-Key-2" width="32" height="32" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAADwUlEQVRYhdXYz0/bVhwA8Bz4I/Yn9A/gwKGHHApxiENwo8IG2r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1t4//gTglnF7pn1AXRad2N+eDJ8obV4C/c+3A5ugEjKXVk7EZed62wPR+BfrCYvlGgZ4Q0GLpI6v1uquUa3A8nn07TPHf3ihwaHrjlp+VnuEUOL0/t6UnllVraVe3B645nFNcnyvA3/FQIOELi2Vb4bqJfwEpWpu91pyNygAAAABJRU5ErkJggg==">Request</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
|
|
@ -38,23 +38,18 @@ def createvm():
|
|||
if deployment_seeds != []:
|
||||
flash('Offline deployments exist.')
|
||||
return redirect(url_for('main.dashboard'))
|
||||
|
||||
|
||||
if current_user.confirmed and form.validate_on_submit():
|
||||
client_id = current_user.pid
|
||||
data = { 'clientid': str(client_id),
|
||||
data = { 'clientid': str(current_user.pid),
|
||||
'clientname': str(current_user.name),
|
||||
'clientemail': str(current_user.email),
|
||||
'hostname': str(form.servername.data),
|
||||
'vmpass': form.vmpassword.data,
|
||||
'hostname': str(form.deployname.data),
|
||||
'region': form.region.data,
|
||||
'vps_type': 'kvm',
|
||||
'vps_cpu': form.cpu.data,
|
||||
'vps_mem': form.mem.data,
|
||||
'vps_hdd': form.hdd.data,
|
||||
'vps_ipv4': form.ipv4.data,
|
||||
'vps_mac': form.mac.data }
|
||||
|
||||
'type': 'kvm',
|
||||
'cpu': '1',
|
||||
'mem': '512',
|
||||
'hdd': '20'
|
||||
}
|
||||
try:
|
||||
query = contact_proxmaster(data, 'vmcreate')
|
||||
except:
|
||||
|
@ -137,7 +132,7 @@ def command(cmd=None, vmid=0):
|
|||
current_app.logger.warning(cmd + ' is not a valid command!')
|
||||
abort(404)
|
||||
|
||||
#work with enabled deploys only
|
||||
#work with enabled deploys only that you own.
|
||||
result = current_user.inv_deployments.filter_by(enabled=True)
|
||||
inventory = []
|
||||
for invcls in result:
|
||||
|
|
Loading…
Reference in a new issue