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

Merge branch 'master' into master-dev

parents 3e336d19 4b301bc2
......@@ -140,20 +140,25 @@
);\n
}\n
\n
function render_selection(json_field) {\n
function render_selection(json_field, default_value) {\n
var input = document.createElement("select"),\n
option = document.createElement("option"),\n
option_index,\n
optionz;\n
input.size = 1;\n
option.selected = "selected";\n
option.value = "";\n
if (default_value === undefined) {\n
option.selected = "selected";\n
}\n
input.appendChild(option);\n
for (option_index in json_field.enum) {\n
if (json_field.enum.hasOwnProperty(option_index)) {\n
optionz = document.createElement("option");\n
optionz.value = 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
}\n
}\n
......@@ -163,12 +168,12 @@
function render_field(json_field, default_value) {\n
\n
if (json_field.enum !== undefined) {\n
return render_selection(json_field);\n
return render_selection(json_field, default_value);\n
}\n
\n
if (json_field.type === "boolean") {\n
json_field.enum = [true, false];\n
return render_selection(json_field);\n
return render_selection(json_field, default_value);\n
}\n
\n
var input = document.createElement("input");\n
......@@ -238,14 +243,17 @@
for (default_value in default_dict) {\n
if (default_dict.hasOwnProperty(default_value)) {\n
default_div = document.createElement("div");\n
default_div.setAttribute("class", "slapos-parameter-dict-key");\n
label = document.createElement("label");\n
label.textContent = default_value;\n
label.setAttribute("class", "slapos-parameter-dict-key");\n
default_div.appendChild(label);\n
default_div = render_subform(\n
json_field.patternProperties[\'.*\'],\n
default_dict[default_value],\n
default_div,\n
path + "/" + default_value);\n
path + "/" + default_value\n
);\n
div.appendChild(default_div);\n
}\n
}\n
......@@ -253,10 +261,6 @@
\n
\n
return div;\n
\n
\n
\n
return root;\n
}\n
}\n
\n
......@@ -315,7 +319,7 @@
}\n
}\n
});\n
console.log(json_dict);\n
// console.log(json_dict);\n
\n
function convertOnMultiLevel(key, value, d) {\n
var i,\n
......@@ -357,13 +361,16 @@
return false;\n
}\n
\n
div.setAttribute("class", "slapos-parameter-dict-key");\n
label = document.createElement("label");\n
label.textContent = input_text.value;\n
label.setAttribute("class", "slapos-parameter-dict-key");\n
div.appendChild(label);\n
\n
div = render_subform(subform_json, {}, div, element.name + "/" + input_text.value);\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
return div;\n
}\n
......@@ -375,7 +382,7 @@
i,\n
promise_list = [];\n
\n
console.log("INITIATING A LOOP EVENT LISTENER");\n
// console.log("INITIATING A LOOP EVENT LISTENER");\n
\n
for (i = 0; i < field_list.length; i = i + 1) {\n
promise_list.push(loopEventListener(\n
......@@ -476,7 +483,7 @@
xml_output = jsonDictToParameterXML(json_dict);\n
}\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
return xml_output;\n
}\n
......@@ -553,7 +560,7 @@
if (options.json_url === undefined) {\n
throw new Error("undefined json_url");\n
}\n
console.log("CALLED RENDER");\n
// console.log("CALLED RENDER");\n
var g = this,\n
softwaretype;\n
\n
......@@ -640,17 +647,17 @@
prefix = options.json_url.split(json_url_uri.path())[0] + prefix.join("/");\n
parameter_json_schema_url = prefix + "/" + parameter_json_schema_url;\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
})\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
})\n
\n
.fail(function (error) {\n
var parameter_xml = \'\';\n
console.log("FAIL CALLED");\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
......@@ -678,7 +685,7 @@
});\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
element,\n
\'change\',\n
......@@ -691,7 +698,20 @@
})\n
.declareService(function () {\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
}(window, document, rJS, loopEventListener, $, XMLSerializer, jQuery, vkbeautify));
......@@ -831,7 +851,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>941.58456.37859.54289</string> </value>
<value> <string>942.12751.5721.43315</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -849,7 +869,7 @@
</tuple>
<state>
<tuple>
<float>1427289240.71</float>
<float>1428479010.83</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -46,7 +46,6 @@
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
\n
\n
/**********************/\n
/* Global definitions */\n
/**********************/\n
......@@ -242,6 +241,60 @@ div#WebPage_viewAsWeb ul {\n
div#WebPage_viewAsWeb .section {\n
border: 0;\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>
]]></unicode> </value>
......
......@@ -37,6 +37,7 @@ import logging
import netaddr
import netifaces
import os
import glob
import pwd
import random
import shutil
......@@ -383,10 +384,11 @@ class Computer(object):
if partition_dict['tap']:
tap = Tap(partition_dict['tap']['name'])
tap.ipv4_addr = partition_dict['tap'].get('ipv4_addr', '')
tap.ipv4_netmask = partition_dict['tap'].get('ipv4_netmask', '')
tap.ipv4_gateway = partition_dict['tap'].get('ipv4_gateway', '')
tap.ipv4_network = partition_dict['tap'].get('ipv4_network', '')
if tap_gateway_interface:
tap.ipv4_addr = partition_dict['tap'].get('ipv4_addr', '')
tap.ipv4_netmask = partition_dict['tap'].get('ipv4_netmask', '')
tap.ipv4_gateway = partition_dict['tap'].get('ipv4_gateway', '')
tap.ipv4_network = partition_dict['tap'].get('ipv4_network', '')
else:
tap = Tap(partition_dict['reference'])
......@@ -474,11 +476,13 @@ class Computer(object):
# get list of instance external storage if exist
instance_external_list = []
if self.instance_storage_home:
# XXX - Hard limit for storage number to 4
for i in range(1, 5):
storage_path = os.path.join(self.instance_storage_home, 'data%s' % i)
if os.path.exists(storage_path):
instance_external_list.append(storage_path)
# get all /XXX/dataN where N is a digit
data_list = glob.glob(os.path.join(self.instance_storage_home, 'data*'))
for i in range(0, len(data_list)):
data_path = data_list.pop()
the_digit = os.path.basename(data_path).split('data')[-1]
if the_digit.isdigit():
instance_external_list.append(data_path)
tap_address_list = []
if alter_network and self.tap_gateway_interface and create_tap:
......
......@@ -344,7 +344,8 @@ class Partition(object):
certificate_repository_path=None,
retention_delay='0',
instance_min_free_space=None,
instance_storage_home=''
instance_storage_home='',
ipv4_global_network='',
):
"""Initialisation of class parameters"""
self.buildout = buildout
......@@ -362,6 +363,7 @@ class Partition(object):
self.server_url = server_url
self.software_release_url = software_release_url
self.instance_storage_home = instance_storage_home
self.ipv4_global_network = ipv4_global_network
self.key_file = ''
self.cert_file = ''
......@@ -517,6 +519,7 @@ class Partition(object):
'key_file': self.key_file,
'cert_file': self.cert_file,
'storage_home': self.instance_storage_home,
'global_ipv4_network_prefix': self.ipv4_global_network,
}
open(config_location, 'w').write(buildout_text)
os.chmod(config_location, 0o640)
......
......@@ -233,7 +233,8 @@ def create_slapgrid_object(options, logger):
computer_partition_filter_list=op.get('only-cp', op.get('only_cp')),
software_min_free_space=software_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):
......@@ -288,6 +289,7 @@ class Slapgrid(object):
software_min_free_space=None,
instance_min_free_space=None,
instance_storage_home=None,
ipv4_global_network=None,
):
"""Makes easy initialisation of class parameters"""
# Parses arguments
......@@ -343,6 +345,10 @@ class Slapgrid(object):
self.instance_storage_home = os.path.abspath(instance_storage_home)
else:
self.instance_storage_home = ""
if ipv4_global_network:
self.ipv4_global_network = ipv4_global_network
else:
self.ipv4_global_network= ""
def _getWatchdogLine(self):
invocation_list = [WATCHDOG_PATH]
......@@ -651,6 +657,7 @@ class Slapgrid(object):
retention_delay=retention_delay,
instance_min_free_space=self.instance_min_free_space,
instance_storage_home=self.instance_storage_home,
ipv4_global_network=self.ipv4_global_network,
)
computer_partition_state = computer_partition.getState()
......@@ -1110,6 +1117,7 @@ class Slapgrid(object):
buildout=self.buildout,
logger=self.logger,
instance_storage_home=self.instance_storage_home,
ipv4_global_network=self.ipv4_global_network,
)
local_partition.stop()
try:
......
......@@ -25,4 +25,7 @@ cert_file = %(cert_file)s
[storage-configuration]
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
......@@ -95,11 +95,13 @@ def partitiondict2partition(partition):
slap_partition._requested_state = partition['requested_state']
slap_partition._parameter_dict = xml2dict(partition['xml'])
address_list = []
full_address_list = []
for address in execute_db('partition_network',
'SELECT * FROM %s WHERE partition_reference=? AND computer_reference=?',
[partition['reference'], partition['computer_reference']]):
address_list.append((address['reference'], address['address']))
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'] = \
partition['software_type']
if partition['slave_instance_list'] is not None:
......
......@@ -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