Commit 5e78e31c authored by Alain Takoudjou's avatar Alain Takoudjou

Merge branch 'master' into master-dev

parents 3e336d19 4b301bc2
...@@ -140,20 +140,25 @@ ...@@ -140,20 +140,25 @@
);\n );\n
}\n }\n
\n \n
function render_selection(json_field) {\n function render_selection(json_field, default_value) {\n
var input = document.createElement("select"),\n var input = document.createElement("select"),\n
option = document.createElement("option"),\n option = document.createElement("option"),\n
option_index,\n option_index,\n
optionz;\n optionz;\n
input.size = 1;\n input.size = 1;\n
option.selected = "selected";\n
option.value = "";\n option.value = "";\n
if (default_value === undefined) {\n
option.selected = "selected";\n
}\n
input.appendChild(option);\n input.appendChild(option);\n
for (option_index in json_field.enum) {\n for (option_index in json_field.enum) {\n
if (json_field.enum.hasOwnProperty(option_index)) {\n if (json_field.enum.hasOwnProperty(option_index)) {\n
optionz = document.createElement("option");\n optionz = document.createElement("option");\n
optionz.value = json_field.enum[option_index];\n optionz.value = json_field.enum[option_index];\n
optionz.textContent = json_field.enum[option_index];\n optionz.textContent = json_field.enum[option_index];\n
if (json_field.enum[option_index] === default_value) {\n
optionz.selected = "selected";\n
}\n
input.appendChild(optionz);\n input.appendChild(optionz);\n
}\n }\n
}\n }\n
...@@ -163,12 +168,12 @@ ...@@ -163,12 +168,12 @@
function render_field(json_field, default_value) {\n function render_field(json_field, default_value) {\n
\n \n
if (json_field.enum !== undefined) {\n if (json_field.enum !== undefined) {\n
return render_selection(json_field);\n return render_selection(json_field, default_value);\n
}\n }\n
\n \n
if (json_field.type === "boolean") {\n if (json_field.type === "boolean") {\n
json_field.enum = [true, false];\n json_field.enum = [true, false];\n
return render_selection(json_field);\n return render_selection(json_field, default_value);\n
}\n }\n
\n \n
var input = document.createElement("input");\n var input = document.createElement("input");\n
...@@ -238,14 +243,17 @@ ...@@ -238,14 +243,17 @@
for (default_value in default_dict) {\n for (default_value in default_dict) {\n
if (default_dict.hasOwnProperty(default_value)) {\n if (default_dict.hasOwnProperty(default_value)) {\n
default_div = document.createElement("div");\n default_div = document.createElement("div");\n
default_div.setAttribute("class", "slapos-parameter-dict-key");\n
label = document.createElement("label");\n label = document.createElement("label");\n
label.textContent = default_value;\n label.textContent = default_value;\n
label.setAttribute("class", "slapos-parameter-dict-key");\n
default_div.appendChild(label);\n default_div.appendChild(label);\n
default_div = render_subform(\n default_div = render_subform(\n
json_field.patternProperties[\'.*\'],\n json_field.patternProperties[\'.*\'],\n
default_dict[default_value],\n default_dict[default_value],\n
default_div,\n default_div,\n
path + "/" + default_value);\n path + "/" + default_value\n
);\n
div.appendChild(default_div);\n div.appendChild(default_div);\n
}\n }\n
}\n }\n
...@@ -253,10 +261,6 @@ ...@@ -253,10 +261,6 @@
\n \n
\n \n
return div;\n return div;\n
\n
\n
\n
return root;\n
}\n }\n
}\n }\n
\n \n
...@@ -315,7 +319,7 @@ ...@@ -315,7 +319,7 @@
}\n }\n
}\n }\n
});\n });\n
console.log(json_dict);\n // console.log(json_dict);\n
\n \n
function convertOnMultiLevel(key, value, d) {\n function convertOnMultiLevel(key, value, d) {\n
var i,\n var i,\n
...@@ -357,13 +361,16 @@ ...@@ -357,13 +361,16 @@
return false;\n return false;\n
}\n }\n
\n \n
div.setAttribute("class", "slapos-parameter-dict-key");\n
label = document.createElement("label");\n label = document.createElement("label");\n
label.textContent = input_text.value;\n label.textContent = input_text.value;\n
label.setAttribute("class", "slapos-parameter-dict-key");\n
div.appendChild(label);\n div.appendChild(label);\n
\n \n
div = render_subform(subform_json, {}, div, element.name + "/" + input_text.value);\n div = render_subform(subform_json, {}, div, element.name + "/" + input_text.value);\n
\n \n
element.parentNode.parentNode.appendChild(div);\n element.parentNode.parentNode.insertBefore(div, element.parentNode.parentNode.children[1]);\n
// element.parentNode.parentNode.appendChild(div);\n
\n \n
return div;\n return div;\n
}\n }\n
...@@ -375,7 +382,7 @@ ...@@ -375,7 +382,7 @@
i,\n i,\n
promise_list = [];\n promise_list = [];\n
\n \n
console.log("INITIATING A LOOP EVENT LISTENER");\n // console.log("INITIATING A LOOP EVENT LISTENER");\n
\n \n
for (i = 0; i < field_list.length; i = i + 1) {\n for (i = 0; i < field_list.length; i = i + 1) {\n
promise_list.push(loopEventListener(\n promise_list.push(loopEventListener(\n
...@@ -476,7 +483,7 @@ ...@@ -476,7 +483,7 @@
xml_output = jsonDictToParameterXML(json_dict);\n xml_output = jsonDictToParameterXML(json_dict);\n
}\n }\n
parameter_hash_input.value = btoa(xml_output);\n parameter_hash_input.value = btoa(xml_output);\n
console.log(parameter_hash_input.value);\n // console.log(parameter_hash_input.value);\n
if (validation.valid) {\n if (validation.valid) {\n
return xml_output;\n return xml_output;\n
}\n }\n
...@@ -553,7 +560,7 @@ ...@@ -553,7 +560,7 @@
if (options.json_url === undefined) {\n if (options.json_url === undefined) {\n
throw new Error("undefined json_url");\n throw new Error("undefined json_url");\n
}\n }\n
console.log("CALLED RENDER");\n // console.log("CALLED RENDER");\n
var g = this,\n var g = this,\n
softwaretype;\n softwaretype;\n
\n \n
...@@ -640,17 +647,17 @@ ...@@ -640,17 +647,17 @@
prefix = options.json_url.split(json_url_uri.path())[0] + prefix.join("/");\n prefix = options.json_url.split(json_url_uri.path())[0] + prefix.join("/");\n
parameter_json_schema_url = prefix + "/" + parameter_json_schema_url;\n parameter_json_schema_url = prefix + "/" + parameter_json_schema_url;\n
}\n }\n
console.log("GOING TO RENDER FORM");\n // console.log("GOING TO RENDER FORM");\n
return g.renderParameterForm(parameter_json_schema_url, parameter_dict);\n return g.renderParameterForm(parameter_json_schema_url, parameter_dict);\n
})\n })\n
.push(function () {\n .push(function () {\n
console.log("FINISHED TO RENDER, RETURNING THE GADGET");\n // console.log("FINISHED TO RENDER, RETURNING THE GADGET");\n
return g;\n return g;\n
})\n })\n
\n \n
.fail(function (error) {\n .fail(function (error) {\n
var parameter_xml = \'\';\n var parameter_xml = \'\';\n
console.log("FAIL CALLED");\n // console.log("FAIL CALLED");\n
console.log(error.stack);\n console.log(error.stack);\n
if (g.options.parameter.parameter_hash !== undefined) {\n if (g.options.parameter.parameter_hash !== undefined) {\n
parameter_xml = atob(g.options.parameter.parameter_hash);\n parameter_xml = atob(g.options.parameter.parameter_hash);\n
...@@ -678,7 +685,7 @@ ...@@ -678,7 +685,7 @@
});\n });\n
}\n }\n
\n \n
console.log("INITIATING A LOOP EVENT LISTENER FOR OPTION CHANGE");\n // console.log("INITIATING A LOOP EVENT LISTENER FOR OPTION CHANGE");\n
return loopEventListener(\n return loopEventListener(\n
element,\n element,\n
\'change\',\n \'change\',\n
...@@ -691,7 +698,20 @@ ...@@ -691,7 +698,20 @@
})\n })\n
.declareService(function () {\n .declareService(function () {\n
var g = this;\n var g = this;\n
return g.processValidation(g.options.json_url);\n return g.processValidation(g.options.json_url)\n
.fail(function (error) {\n
var parameter_xml = \'\';\n
// console.log("FAIL CALLED");\n
console.log(error.stack);\n
if (g.options.parameter.parameter_hash !== undefined) {\n
parameter_xml = atob(g.options.parameter.parameter_hash);\n
}\n
return g.renderFailoverTextArea(parameter_xml, error.toString())\n
.push(function () {\n
error = undefined;\n
return g;\n
});\n
});\n
});\n });\n
\n \n
}(window, document, rJS, loopEventListener, $, XMLSerializer, jQuery, vkbeautify)); }(window, document, rJS, loopEventListener, $, XMLSerializer, jQuery, vkbeautify));
...@@ -831,7 +851,7 @@ ...@@ -831,7 +851,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>941.58456.37859.54289</string> </value> <value> <string>942.12751.5721.43315</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -849,7 +869,7 @@ ...@@ -849,7 +869,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1427289240.71</float> <float>1428479010.83</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -46,7 +46,6 @@ ...@@ -46,7 +46,6 @@
logo_reference python:here.aq_parent.getWebSiteValue().getLayoutProperty(\'layout_logo_reference\', \'vifib_hosting_image/logo.png\');\n logo_reference python:here.aq_parent.getWebSiteValue().getLayoutProperty(\'layout_logo_reference\', \'vifib_hosting_image/logo.png\');\n
subscribe_button python:here.aq_parent.getWebSiteValue().getLayoutProperty(\'layout_subscribe_button_reference\', \'tiolive-Subscribe.For.Free.Button\');">\n subscribe_button python:here.aq_parent.getWebSiteValue().getLayoutProperty(\'layout_subscribe_button_reference\', \'tiolive-Subscribe.For.Free.Button\');">\n
\n \n
\n
/**********************/\n /**********************/\n
/* Global definitions */\n /* Global definitions */\n
/**********************/\n /**********************/\n
...@@ -242,6 +241,60 @@ div#WebPage_viewAsWeb ul {\n ...@@ -242,6 +241,60 @@ div#WebPage_viewAsWeb ul {\n
div#WebPage_viewAsWeb .section {\n div#WebPage_viewAsWeb .section {\n
border: 0;\n border: 0;\n
}\n }\n
\n
div.subfield {\n
margin-left: 15px;\n
}\n
\n
\n
.subfield {\n
padding-left: 20px;\n
} \n
\n
label.slapos-parameter-dict-key::before {\n
content: "Parameter Entry: ";\n
}\n
\n
label.slapos-parameter-dict-key {\n
font-color: "red";\n
}\n
\n
div.slapos-parameter-dict-key {\n
margin-top: 10px;\n
margin-left: 6px;\n
}\n
\n
.subfield {\n
padding-top: 3px;\n
}\n
\n
.add-sub-form {\n
background: #3498db;\n
background-image: -webkit-linear-gradient(top, #3498db, #2980b9);\n
background-image: -moz-linear-gradient(top, #3498db, #2980b9);\n
background-image: -ms-linear-gradient(top, #3498db, #2980b9);\n
background-image: -o-linear-gradient(top, #3498db, #2980b9);\n
background-image: linear-gradient(to bottom, #3498db, #2980b9);\n
-webkit-border-radius: 28;\n
-moz-border-radius: 28;\n
border-radius: 28px;\n
font-family: Arial;\n
color: #ffffff;\n
font-size: 12px;\n
padding: 5px 20px 5px 20px;\n
text-decoration: none;\n
}\n
\n
.add-sub-form:hover {\n
background: #3cb0fd;\n
background-image: -webkit-linear-gradient(top, #3cb0fd, #3498db);\n
background-image: -moz-linear-gradient(top, #3cb0fd, #3498db);\n
background-image: -ms-linear-gradient(top, #3cb0fd, #3498db);\n
background-image: -o-linear-gradient(top, #3cb0fd, #3498db);\n
background-image: linear-gradient(to bottom, #3cb0fd, #3498db);\n
text-decoration: none;\n
}\n
\n
</tal:block> </tal:block>
]]></unicode> </value> ]]></unicode> </value>
......
...@@ -37,6 +37,7 @@ import logging ...@@ -37,6 +37,7 @@ import logging
import netaddr import netaddr
import netifaces import netifaces
import os import os
import glob
import pwd import pwd
import random import random
import shutil import shutil
...@@ -383,10 +384,11 @@ class Computer(object): ...@@ -383,10 +384,11 @@ class Computer(object):
if partition_dict['tap']: if partition_dict['tap']:
tap = Tap(partition_dict['tap']['name']) tap = Tap(partition_dict['tap']['name'])
tap.ipv4_addr = partition_dict['tap'].get('ipv4_addr', '') if tap_gateway_interface:
tap.ipv4_netmask = partition_dict['tap'].get('ipv4_netmask', '') tap.ipv4_addr = partition_dict['tap'].get('ipv4_addr', '')
tap.ipv4_gateway = partition_dict['tap'].get('ipv4_gateway', '') tap.ipv4_netmask = partition_dict['tap'].get('ipv4_netmask', '')
tap.ipv4_network = partition_dict['tap'].get('ipv4_network', '') tap.ipv4_gateway = partition_dict['tap'].get('ipv4_gateway', '')
tap.ipv4_network = partition_dict['tap'].get('ipv4_network', '')
else: else:
tap = Tap(partition_dict['reference']) tap = Tap(partition_dict['reference'])
...@@ -474,11 +476,13 @@ class Computer(object): ...@@ -474,11 +476,13 @@ class Computer(object):
# get list of instance external storage if exist # get list of instance external storage if exist
instance_external_list = [] instance_external_list = []
if self.instance_storage_home: if self.instance_storage_home:
# XXX - Hard limit for storage number to 4 # get all /XXX/dataN where N is a digit
for i in range(1, 5): data_list = glob.glob(os.path.join(self.instance_storage_home, 'data*'))
storage_path = os.path.join(self.instance_storage_home, 'data%s' % i) for i in range(0, len(data_list)):
if os.path.exists(storage_path): data_path = data_list.pop()
instance_external_list.append(storage_path) the_digit = os.path.basename(data_path).split('data')[-1]
if the_digit.isdigit():
instance_external_list.append(data_path)
tap_address_list = [] tap_address_list = []
if alter_network and self.tap_gateway_interface and create_tap: if alter_network and self.tap_gateway_interface and create_tap:
......
...@@ -344,7 +344,8 @@ class Partition(object): ...@@ -344,7 +344,8 @@ class Partition(object):
certificate_repository_path=None, certificate_repository_path=None,
retention_delay='0', retention_delay='0',
instance_min_free_space=None, instance_min_free_space=None,
instance_storage_home='' instance_storage_home='',
ipv4_global_network='',
): ):
"""Initialisation of class parameters""" """Initialisation of class parameters"""
self.buildout = buildout self.buildout = buildout
...@@ -362,6 +363,7 @@ class Partition(object): ...@@ -362,6 +363,7 @@ class Partition(object):
self.server_url = server_url self.server_url = server_url
self.software_release_url = software_release_url self.software_release_url = software_release_url
self.instance_storage_home = instance_storage_home self.instance_storage_home = instance_storage_home
self.ipv4_global_network = ipv4_global_network
self.key_file = '' self.key_file = ''
self.cert_file = '' self.cert_file = ''
...@@ -517,6 +519,7 @@ class Partition(object): ...@@ -517,6 +519,7 @@ class Partition(object):
'key_file': self.key_file, 'key_file': self.key_file,
'cert_file': self.cert_file, 'cert_file': self.cert_file,
'storage_home': self.instance_storage_home, 'storage_home': self.instance_storage_home,
'global_ipv4_network_prefix': self.ipv4_global_network,
} }
open(config_location, 'w').write(buildout_text) open(config_location, 'w').write(buildout_text)
os.chmod(config_location, 0o640) os.chmod(config_location, 0o640)
......
...@@ -233,7 +233,8 @@ def create_slapgrid_object(options, logger): ...@@ -233,7 +233,8 @@ def create_slapgrid_object(options, logger):
computer_partition_filter_list=op.get('only-cp', op.get('only_cp')), computer_partition_filter_list=op.get('only-cp', op.get('only_cp')),
software_min_free_space=software_min_free_space, software_min_free_space=software_min_free_space,
instance_min_free_space=instance_min_free_space, instance_min_free_space=instance_min_free_space,
instance_storage_home=op.get('instance_storage_home')) instance_storage_home=op.get('instance_storage_home'),
ipv4_global_network=op.get('ipv4_global_network'))
def check_required_only_partitions(existing, required): def check_required_only_partitions(existing, required):
...@@ -288,6 +289,7 @@ class Slapgrid(object): ...@@ -288,6 +289,7 @@ class Slapgrid(object):
software_min_free_space=None, software_min_free_space=None,
instance_min_free_space=None, instance_min_free_space=None,
instance_storage_home=None, instance_storage_home=None,
ipv4_global_network=None,
): ):
"""Makes easy initialisation of class parameters""" """Makes easy initialisation of class parameters"""
# Parses arguments # Parses arguments
...@@ -343,6 +345,10 @@ class Slapgrid(object): ...@@ -343,6 +345,10 @@ class Slapgrid(object):
self.instance_storage_home = os.path.abspath(instance_storage_home) self.instance_storage_home = os.path.abspath(instance_storage_home)
else: else:
self.instance_storage_home = "" self.instance_storage_home = ""
if ipv4_global_network:
self.ipv4_global_network = ipv4_global_network
else:
self.ipv4_global_network= ""
def _getWatchdogLine(self): def _getWatchdogLine(self):
invocation_list = [WATCHDOG_PATH] invocation_list = [WATCHDOG_PATH]
...@@ -651,6 +657,7 @@ class Slapgrid(object): ...@@ -651,6 +657,7 @@ class Slapgrid(object):
retention_delay=retention_delay, retention_delay=retention_delay,
instance_min_free_space=self.instance_min_free_space, instance_min_free_space=self.instance_min_free_space,
instance_storage_home=self.instance_storage_home, instance_storage_home=self.instance_storage_home,
ipv4_global_network=self.ipv4_global_network,
) )
computer_partition_state = computer_partition.getState() computer_partition_state = computer_partition.getState()
...@@ -1110,6 +1117,7 @@ class Slapgrid(object): ...@@ -1110,6 +1117,7 @@ class Slapgrid(object):
buildout=self.buildout, buildout=self.buildout,
logger=self.logger, logger=self.logger,
instance_storage_home=self.instance_storage_home, instance_storage_home=self.instance_storage_home,
ipv4_global_network=self.ipv4_global_network,
) )
local_partition.stop() local_partition.stop()
try: try:
......
...@@ -25,4 +25,7 @@ cert_file = %(cert_file)s ...@@ -25,4 +25,7 @@ cert_file = %(cert_file)s
[storage-configuration] [storage-configuration]
storage-home = %(storage_home)s storage-home = %(storage_home)s
[network-information]
global-ipv4-network = %(global_ipv4_network_prefix)s
# This is end of zc.builodout profile's tail added by slapgrid # This is end of zc.builodout profile's tail added by slapgrid
...@@ -95,11 +95,13 @@ def partitiondict2partition(partition): ...@@ -95,11 +95,13 @@ def partitiondict2partition(partition):
slap_partition._requested_state = partition['requested_state'] slap_partition._requested_state = partition['requested_state']
slap_partition._parameter_dict = xml2dict(partition['xml']) slap_partition._parameter_dict = xml2dict(partition['xml'])
address_list = [] address_list = []
full_address_list = []
for address in execute_db('partition_network', for address in execute_db('partition_network',
'SELECT * FROM %s WHERE partition_reference=? AND computer_reference=?', 'SELECT * FROM %s WHERE partition_reference=? AND computer_reference=?',
[partition['reference'], partition['computer_reference']]): [partition['reference'], partition['computer_reference']]):
address_list.append((address['reference'], address['address'])) address_list.append((address['reference'], address['address']))
slap_partition._parameter_dict['ip_list'] = address_list slap_partition._parameter_dict['ip_list'] = address_list
slap_partition._parameter_dict['full_address_list'] = full_address_list
slap_partition._parameter_dict['slap_software_type'] = \ slap_partition._parameter_dict['slap_software_type'] = \
partition['software_type'] partition['software_type']
if partition['slave_instance_list'] is not None: if partition['slave_instance_list'] is not None:
......
...@@ -26,4 +26,4 @@ ...@@ -26,4 +26,4 @@
# #
############################################################################## ##############################################################################
version = '1.3.10-dev0' version = '1.3.11-dev0'
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment