Merge "add local repo support in regtest" into dev/experimental
This commit is contained in:
commit
75ae85ae4c
@ -20,6 +20,7 @@ import netaddr
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import requests
|
import requests
|
||||||
|
import simplejson as json
|
||||||
import socket
|
import socket
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
@ -34,6 +35,7 @@ import switch_virtualenv
|
|||||||
from compass.apiclient.restful import Client
|
from compass.apiclient.restful import Client
|
||||||
from compass.utils import flags
|
from compass.utils import flags
|
||||||
from compass.utils import logsetting
|
from compass.utils import logsetting
|
||||||
|
from compass.utils import util
|
||||||
|
|
||||||
|
|
||||||
flags.add('compass_server',
|
flags.add('compass_server',
|
||||||
@ -108,6 +110,9 @@ flags.add('domain',
|
|||||||
flags.add('search_path',
|
flags.add('search_path',
|
||||||
help='search path',
|
help='search path',
|
||||||
default='')
|
default='')
|
||||||
|
flags.add('local_repo_url',
|
||||||
|
help='local repo url',
|
||||||
|
default='')
|
||||||
flags.add('default_gateway',
|
flags.add('default_gateway',
|
||||||
help='default gateway',
|
help='default gateway',
|
||||||
default='')
|
default='')
|
||||||
@ -117,6 +122,9 @@ flags.add('server_credential',
|
|||||||
'<username>=<password>'
|
'<username>=<password>'
|
||||||
),
|
),
|
||||||
default='root=root')
|
default='root=root')
|
||||||
|
flags.add('os_config_json_file',
|
||||||
|
help='json formatted os config file',
|
||||||
|
default='')
|
||||||
flags.add('service_credentials',
|
flags.add('service_credentials',
|
||||||
help=(
|
help=(
|
||||||
'comma seperated service credentials formatted as '
|
'comma seperated service credentials formatted as '
|
||||||
@ -150,6 +158,9 @@ flags.add('network_mapping',
|
|||||||
'<network_type>=<interface_name>'
|
'<network_type>=<interface_name>'
|
||||||
),
|
),
|
||||||
default='')
|
default='')
|
||||||
|
flags.add('package_config_json_file',
|
||||||
|
help='json formatted os config file',
|
||||||
|
default='')
|
||||||
flags.add('host_roles',
|
flags.add('host_roles',
|
||||||
help=(
|
help=(
|
||||||
'semicomma separated host roles '
|
'semicomma separated host roles '
|
||||||
@ -176,6 +187,14 @@ flags.add('dashboard_link_pattern',
|
|||||||
default=r'(?m)(http://\d+\.\d+\.\d+\.\d+:5000/v2\.0)')
|
default=r'(?m)(http://\d+\.\d+\.\d+\.\d+:5000/v2\.0)')
|
||||||
|
|
||||||
|
|
||||||
|
def _load_config(config_filename):
|
||||||
|
if not config_filename:
|
||||||
|
return {}
|
||||||
|
with open(config_filename) as config_file:
|
||||||
|
content = config_file.read()
|
||||||
|
return json.loads(content)
|
||||||
|
|
||||||
|
|
||||||
def _get_client():
|
def _get_client():
|
||||||
"""get apiclient object."""
|
"""get apiclient object."""
|
||||||
return Client(flags.OPTIONS.compass_server)
|
return Client(flags.OPTIONS.compass_server)
|
||||||
@ -617,6 +636,14 @@ def _set_cluster_os_config(client, cluster_id, host_ips):
|
|||||||
os_config['partition'][partition_name] = {
|
os_config['partition'][partition_name] = {
|
||||||
partition_type: partition_value
|
partition_type: partition_value
|
||||||
}
|
}
|
||||||
|
local_repo_url = flags.OPTIONS.local_repo_url
|
||||||
|
if local_repo_url:
|
||||||
|
os_config['general']['local_repo'] = local_repo_url
|
||||||
|
os_config_filename = flags.OPTIONS.os_config_json_file
|
||||||
|
if os_config_filename:
|
||||||
|
util.merge_dict(
|
||||||
|
os_config, _load_config(os_config_filename)
|
||||||
|
)
|
||||||
status, resp = client.update_cluster_config(
|
status, resp = client.update_cluster_config(
|
||||||
cluster_id, os_config=os_config)
|
cluster_id, os_config=os_config)
|
||||||
logging.info(
|
logging.info(
|
||||||
@ -689,12 +716,6 @@ def _set_host_networking(client, host_mapping, subnet_mapping):
|
|||||||
def _set_cluster_package_config(client, cluster_id):
|
def _set_cluster_package_config(client, cluster_id):
|
||||||
"""set cluster package config."""
|
"""set cluster package config."""
|
||||||
package_config = {
|
package_config = {
|
||||||
'security': {
|
|
||||||
'service_credentials': {
|
|
||||||
},
|
|
||||||
'console_credentials': {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
service_credentials = [
|
service_credentials = [
|
||||||
service_credential
|
service_credential
|
||||||
@ -715,7 +736,11 @@ def _set_cluster_package_config(client, cluster_id):
|
|||||||
'there is no = in service %s security' % service_name
|
'there is no = in service %s security' % service_name
|
||||||
)
|
)
|
||||||
username, password = service_pair.split('=', 1)
|
username, password = service_pair.split('=', 1)
|
||||||
package_config['security']['service_credentials'][service_name] = {
|
package_config.setdefault(
|
||||||
|
'security', {}
|
||||||
|
).setdefault(
|
||||||
|
'service_credentials', {}
|
||||||
|
)[service_name] = {
|
||||||
'username': username,
|
'username': username,
|
||||||
'password': password
|
'password': password
|
||||||
}
|
}
|
||||||
@ -738,15 +763,28 @@ def _set_cluster_package_config(client, cluster_id):
|
|||||||
'there is no = in console %s security' % console_name
|
'there is no = in console %s security' % console_name
|
||||||
)
|
)
|
||||||
username, password = console_pair.split('=', 1)
|
username, password = console_pair.split('=', 1)
|
||||||
package_config['security']['console_credentials'][console_name] = {
|
package_config.setdefault(
|
||||||
|
'security', {}
|
||||||
|
).setdefault(
|
||||||
|
'console_credentials', {}
|
||||||
|
)[console_name] = {
|
||||||
'username': username,
|
'username': username,
|
||||||
'password': password
|
'password': password
|
||||||
}
|
}
|
||||||
package_config['network_mapping'] = dict([
|
network_mapping = dict([
|
||||||
network_pair.split('=', 1)
|
network_pair.split('=', 1)
|
||||||
for network_pair in flags.OPTIONS.network_mapping.split(',')
|
for network_pair in flags.OPTIONS.network_mapping.split(',')
|
||||||
if '=' in network_pair
|
if '=' in network_pair
|
||||||
])
|
])
|
||||||
|
for network_type, network in network_mapping.items():
|
||||||
|
package_config.setdefault(
|
||||||
|
'network_mapping', {}
|
||||||
|
)[network_type] = network
|
||||||
|
package_config_filename = flags.OPTIONS.package_config_json_file
|
||||||
|
if package_config_filename:
|
||||||
|
util.merge_dict(
|
||||||
|
package_config, _load_config(package_config_filename)
|
||||||
|
)
|
||||||
status, resp = client.update_cluster_config(
|
status, resp = client.update_cluster_config(
|
||||||
cluster_id, package_config=package_config)
|
cluster_id, package_config=package_config)
|
||||||
logging.info(
|
logging.info(
|
||||||
|
@ -37,6 +37,9 @@ export HOME_PERCENTAGE=${HOME_PERCENTAGE:-'5'}
|
|||||||
export TMP_PERCENTAGE=${TMP_PERCENTAGE:-'5'}
|
export TMP_PERCENTAGE=${TMP_PERCENTAGE:-'5'}
|
||||||
export VAR_PERCENTAGE=${VAR_PERCENTAGE:-'10'}
|
export VAR_PERCENTAGE=${VAR_PERCENTAGE:-'10'}
|
||||||
export PARTITION=${PARTITION:-"/home=${HOME_PERCENTAGE}%,/tmp=${TMP_PERCENTAGE}%,/var=${VAR_PERCENTAGE}%"}
|
export PARTITION=${PARTITION:-"/home=${HOME_PERCENTAGE}%,/tmp=${TMP_PERCENTAGE}%,/var=${VAR_PERCENTAGE}%"}
|
||||||
|
export LOCAL_REPO_URL=${LOCAL_REPO_URL:-}
|
||||||
|
export OS_CONFIG_FILENAME=${OS_CONFIG_FILENAME:-}
|
||||||
|
export PACKAGE_CONFIG_FILENAME=${PACKAGE_CONFIG_FILENAME:-}
|
||||||
|
|
||||||
function ip_subnet {
|
function ip_subnet {
|
||||||
ip_addr=$1
|
ip_addr=$1
|
||||||
|
@ -160,7 +160,7 @@ else
|
|||||||
POLL_SWITCHES_FLAG="poll_switches"
|
POLL_SWITCHES_FLAG="poll_switches"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
${CLIENT_SCRIPT} --logfile= --loglevel=debug --logdir= --compass_server="${COMPASS_SERVER_URL}" --compass_user_email="${COMPASS_USER_EMAIL}" --compass_user_password="${COMPASS_USER_PASSWORD}" --cluster_name="${CLUSTER_NAME}" --language="${LANGUAGE}" --timezone="${TIMEZONE}" --hostnames="${HOSTNAMES}" --partitions="${PARTITIONS}" --subnets="${SUBNETS}" --adapter_os_pattern="${ADAPTER_OS_PATTERN}" --adapter_name="${ADAPTER_NAME}" --adapter_target_system_pattern="${ADAPTER_TARGET_SYSTEM_PATTERN}" --adapter_flavor_pattern="${ADAPTER_FLAVOR_PATTERN}" --http_proxy="${PROXY}" --https_proxy="${PROXY}" --no_proxy="${IGNORE_PROXY}" --ntp_server="${NTP_SERVER}" --dns_servers="${NAMESERVERS}" --domain="${DOMAIN}" --search_path="${SEARCH_PATH}" --default_gateway="${GATEWAY}" --server_credential="${SERVER_CREDENTIAL}" --service_credentials="${SERVICE_CREDENTIALS}" --console_credentials="${CONSOLE_CREDENTIALS}" --host_networks="${HOST_NETWORKS}" --network_mapping="${NETWORK_MAPPING}" --host_roles="${HOST_ROLES}" --default_roles="${DEFAULT_ROLES}" --switch_ips="${SWITCH_IPS}" --machines="${machines}" --switch_credential="${SWITCH_CREDENTIAL}" --deployment_timeout="${DEPLOYMENT_TIMEOUT}" --${POLL_SWITCHES_FLAG} --dashboard_url="${DASHBOARD_URL}"
|
${CLIENT_SCRIPT} --logfile= --loglevel=debug --logdir= --compass_server="${COMPASS_SERVER_URL}" --compass_user_email="${COMPASS_USER_EMAIL}" --compass_user_password="${COMPASS_USER_PASSWORD}" --cluster_name="${CLUSTER_NAME}" --language="${LANGUAGE}" --timezone="${TIMEZONE}" --hostnames="${HOSTNAMES}" --partitions="${PARTITIONS}" --subnets="${SUBNETS}" --adapter_os_pattern="${ADAPTER_OS_PATTERN}" --adapter_name="${ADAPTER_NAME}" --adapter_target_system_pattern="${ADAPTER_TARGET_SYSTEM_PATTERN}" --adapter_flavor_pattern="${ADAPTER_FLAVOR_PATTERN}" --http_proxy="${PROXY}" --https_proxy="${PROXY}" --no_proxy="${IGNORE_PROXY}" --ntp_server="${NTP_SERVER}" --dns_servers="${NAMESERVERS}" --domain="${DOMAIN}" --search_path="${SEARCH_PATH}" --default_gateway="${GATEWAY}" --server_credential="${SERVER_CREDENTIAL}" --local_repo_url="${LOCAL_REPO_URL}" --os_config_json_file="${OS_CONFIG_FILENAME}" --service_credentials="${SERVICE_CREDENTIALS}" --console_credentials="${CONSOLE_CREDENTIALS}" --host_networks="${HOST_NETWORKS}" --network_mapping="${NETWORK_MAPPING}" --package_config_json_file="${PACKAGE_CONFIG_FILENAME}" --host_roles="${HOST_ROLES}" --default_roles="${DEFAULT_ROLES}" --switch_ips="${SWITCH_IPS}" --machines="${machines}" --switch_credential="${SWITCH_CREDENTIAL}" --deployment_timeout="${DEPLOYMENT_TIMEOUT}" --${POLL_SWITCHES_FLAG} --dashboard_url="${DASHBOARD_URL}"
|
||||||
rc=$?
|
rc=$?
|
||||||
deactivate
|
deactivate
|
||||||
# Tear down machines after the test
|
# Tear down machines after the test
|
||||||
|
Loading…
x
Reference in New Issue
Block a user