Merge "update code" into dev/experimental
This commit is contained in:
commit
5150166d82
@ -30,6 +30,7 @@ SUPPORTED_FIELDS = [
|
||||
RESP_FIELDS = [
|
||||
'id', 'name', 'roles',
|
||||
'os_installer', 'package_installer',
|
||||
'distributed_system_id',
|
||||
'distributed_system_name',
|
||||
'supported_oses', 'display_name'
|
||||
]
|
||||
|
@ -33,7 +33,7 @@ SUPPORTED_FIELDS = [
|
||||
SUPPORTED_CLUSTERHOST_FIELDS = []
|
||||
RESP_FIELDS = [
|
||||
'id', 'name', 'os_name', 'os_id', 'distributed_system_id',
|
||||
'reinstall_distributed_system',
|
||||
'reinstall_distributed_system', 'flavor',
|
||||
'distributed_system_name', 'distributed_system_installed',
|
||||
'owner', 'adapter_id',
|
||||
'created_at', 'updated_at'
|
||||
@ -95,9 +95,9 @@ RESP_REVIEW_FIELDS = [
|
||||
RESP_DEPLOY_FIELDS = [
|
||||
'status', 'cluster', 'clusterhosts'
|
||||
]
|
||||
ADDED_FIELDS = ['name', 'adapter_id']
|
||||
OPTIONAL_ADDED_FIELDS = ['os_id']
|
||||
UPDATED_FIELDS = ['name', 'reinstall_distributed_system']
|
||||
ADDED_FIELDS = ['name', 'adapter_id', 'os_id']
|
||||
OPTIONAL_ADDED_FIELDS = ['flavor']
|
||||
UPDATED_FIELDS = ['name', 'reinstall_distributed_system', 'flavor']
|
||||
ADDED_HOST_FIELDS = ['machine_id']
|
||||
UPDATED_HOST_FIELDS = ['name', 'reinstall_os']
|
||||
UPDATED_CONFIG_FIELDS = [
|
||||
|
@ -74,6 +74,7 @@ def _filter_metadata(metadata):
|
||||
filtered_metadata[key] = {
|
||||
'name': value['name'],
|
||||
'description': value.get('description', None),
|
||||
'default_value': value.get('default_value', None),
|
||||
'is_required': value['is_required'],
|
||||
'required_in_whole_config': value['required_in_whole_config'],
|
||||
'js_validator': value.get('js_validator', None),
|
||||
|
@ -302,9 +302,7 @@ def filter_output(filter_callbacks, filters, obj, missing_ok=False):
|
||||
if missing_ok:
|
||||
continue
|
||||
else:
|
||||
raise exception.InvalidResponse(
|
||||
'%s is not in %s' % (callback_key, obj)
|
||||
)
|
||||
return False
|
||||
if not callback_value(
|
||||
filters[callback_key], obj[callback_key]
|
||||
):
|
||||
|
@ -394,7 +394,7 @@ class ClusterHostState(BASE, StateMixin):
|
||||
)
|
||||
|
||||
def update(self):
|
||||
host_state = self.host.state
|
||||
host_state = self.clusterhost.host.state
|
||||
if self.state == 'INITIALIZED':
|
||||
if host_state.state in ['UNINITIALIZED']:
|
||||
host_state.state = 'INITIALIZED'
|
||||
@ -403,6 +403,10 @@ class ClusterHostState(BASE, StateMixin):
|
||||
if host_state.state in ['UNINITIALIZED', 'INITIALIZED']:
|
||||
host_state.state = 'INSTALLING'
|
||||
host_state.update()
|
||||
elif self.state == 'SUCCESSFUL':
|
||||
if host_state.state != 'SUCCESSFUL':
|
||||
host_state.state = 'SUCCESSFUL'
|
||||
host_state.update()
|
||||
super(ClusterHostState, self).update()
|
||||
|
||||
|
||||
@ -433,7 +437,7 @@ class ClusterHost(BASE, TimestampMixin, HelperMixin):
|
||||
uselist=False,
|
||||
passive_deletes=True, passive_updates=True,
|
||||
cascade='all, delete-orphan',
|
||||
backref=backref('host')
|
||||
backref=backref('clusterhost')
|
||||
)
|
||||
|
||||
def __init__(self, cluster_id, host_id, **kwargs):
|
||||
@ -834,7 +838,7 @@ class ClusterState(BASE, StateMixin):
|
||||
host = clusterhost.host
|
||||
host_state = host.state.state
|
||||
if host_state == 'INSTALLING':
|
||||
self.intsalling_hosts += 1
|
||||
self.installing_hosts += 1
|
||||
elif host_state == 'ERROR':
|
||||
self.failed_hosts += 1
|
||||
elif host_state == 'SUCCESSFUL':
|
||||
@ -843,7 +847,7 @@ class ClusterState(BASE, StateMixin):
|
||||
for clusterhost in clusterhosts:
|
||||
clusterhost_state = clusterhost.state.state
|
||||
if clusterhost_state == 'INSTALLING':
|
||||
self.intsalling_hosts += 1
|
||||
self.installing_hosts += 1
|
||||
elif clusterhost_state == 'ERROR':
|
||||
self.failed_hosts += 1
|
||||
elif clusterhost_state == 'SUCCESSFUL':
|
||||
@ -855,10 +859,10 @@ class ClusterState(BASE, StateMixin):
|
||||
float(self.total_hosts)
|
||||
)
|
||||
self.message = (
|
||||
'toal %s, installing %s, complted: %s, error $s'
|
||||
'total %s, installing %s, completed: %s, error %s'
|
||||
) % (
|
||||
self.total_hosts, self.completed_hosts,
|
||||
self.intsalling_hosts, self.failed_hosts
|
||||
self.installing_hosts, self.failed_hosts
|
||||
)
|
||||
if self.failed_hosts:
|
||||
self.severity = 'ERROR'
|
||||
@ -875,6 +879,7 @@ class Cluster(BASE, TimestampMixin, HelperMixin):
|
||||
config_step = Column(String(80), default='')
|
||||
os_id = Column(Integer, ForeignKey('os.id'), nullable=True)
|
||||
os_name = Column(String(80), nullable=True)
|
||||
flavor = Column(String(80), nullable=True)
|
||||
distributed_system_id = Column(
|
||||
Integer, ForeignKey('distributed_system.id'),
|
||||
nullable=True
|
||||
@ -1872,8 +1877,9 @@ class Adapter(BASE, HelperMixin):
|
||||
for adapter_os in self.adapter_supported_oses
|
||||
],
|
||||
})
|
||||
distributed_system = self.distributed_system
|
||||
distributed_system = self.adapter_distributed_system
|
||||
if distributed_system:
|
||||
dict_info['distributed_system_id'] = distributed_system.id
|
||||
dict_info['distributed_system_name'] = distributed_system.name
|
||||
os_installer = self.adapter_os_installer
|
||||
if os_installer:
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
.. moduleauthor:: Xiaodong Wang <xiaodongwang@huawei.com>
|
||||
"""
|
||||
import datetime
|
||||
import logging
|
||||
import re
|
||||
|
||||
@ -29,8 +30,7 @@ from compass.db.models import ClusterHost
|
||||
from compass.db.models import Host
|
||||
|
||||
from compass.log_analyzor.line_matcher import Progress
|
||||
|
||||
import datetime
|
||||
from compass.utils import setting_wrapper as setting
|
||||
|
||||
|
||||
class AdapterItemMatcher(object):
|
||||
@ -436,9 +436,7 @@ class AdapterMatcher(object):
|
||||
host_progresses = {}
|
||||
clusterhost_progresses = {}
|
||||
updater = user_api.get_user_object(
|
||||
'admin@abc.com',
|
||||
expire_timestamp=datetime.datetime.now() +
|
||||
datetime.timedelta(seconds=10000)
|
||||
setting.COMPASS_ADMIN_EMAIL
|
||||
)
|
||||
with database.session():
|
||||
for hostid in hostids:
|
||||
|
@ -17,6 +17,14 @@ import logging
|
||||
import os
|
||||
import unittest2
|
||||
|
||||
|
||||
os.environ['COMPASS_IGNORE_SETTING'] = 'true'
|
||||
|
||||
|
||||
from compass.utils import setting_wrapper as setting
|
||||
reload(setting)
|
||||
|
||||
|
||||
from compass.db.api import database
|
||||
from compass.db.api import permission
|
||||
from compass.db.api import user as user_api
|
||||
@ -24,8 +32,6 @@ from compass.db import exception
|
||||
from compass.utils import flags
|
||||
from compass.utils import logsetting
|
||||
|
||||
os.environ['COMPASS_IGNORE_SETTING'] = 'true'
|
||||
|
||||
|
||||
class BaseTest(unittest2.TestCase):
|
||||
"""Base Class for unit test."""
|
||||
@ -36,7 +42,7 @@ class BaseTest(unittest2.TestCase):
|
||||
database.create_db()
|
||||
self.user_object = (
|
||||
user_api.get_user_object(
|
||||
'admin@abc.com'
|
||||
setting.COMPASS_ADMIN_EMAIL
|
||||
)
|
||||
)
|
||||
|
||||
@ -76,5 +82,8 @@ class TestGetPermission(BaseTest):
|
||||
get_permission = permission.get_permission(self.user_object, 1)
|
||||
self.assertIsNotNone(get_permission)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
flags.init()
|
||||
logsetting.init()
|
||||
unittest2.main()
|
||||
|
@ -17,14 +17,20 @@ import logging
|
||||
import os
|
||||
import unittest2
|
||||
|
||||
|
||||
os.environ['COMPASS_IGNORE_SETTING'] = 'true'
|
||||
|
||||
|
||||
from compass.utils import setting_wrapper as setting
|
||||
reload(setting)
|
||||
|
||||
|
||||
from compass.db.api import database
|
||||
from compass.db.api import user as user_api
|
||||
from compass.db import exception
|
||||
from compass.utils import flags
|
||||
from compass.utils import logsetting
|
||||
|
||||
os.environ['COMPASS_IGNORE_SETTING'] = 'true'
|
||||
|
||||
|
||||
class BaseTest(unittest2.TestCase):
|
||||
"""Base Class for unit test."""
|
||||
@ -35,7 +41,7 @@ class BaseTest(unittest2.TestCase):
|
||||
database.create_db()
|
||||
self.user_object = (
|
||||
user_api.get_user_object(
|
||||
'admin@abc.com'
|
||||
setting.COMPASS_ADMIN_EMAIL
|
||||
)
|
||||
)
|
||||
|
||||
@ -58,7 +64,7 @@ class TestGetUserObject(unittest2.TestCase):
|
||||
super(TestGetUserObject, self).tearDown()
|
||||
|
||||
def test_get_user_object(self):
|
||||
user_object = user_api.get_user_object('admin@abc.com')
|
||||
user_object = user_api.get_user_object(setting.COMPASS_ADMIN_EMAIL)
|
||||
self.assertIsNotNone(user_object)
|
||||
|
||||
def test_get_user_object_unauthorized(self):
|
||||
@ -194,14 +200,14 @@ class TestUpdateUser(BaseTest):
|
||||
user_objs = user_api.update_user(
|
||||
self.user_object,
|
||||
self.user_object.id,
|
||||
email='admin@abc.com',
|
||||
email=setting.COMPASS_ADMIN_EMAIL,
|
||||
firstname='a',
|
||||
lastname='b',
|
||||
password='ab',
|
||||
is_admin=True,
|
||||
active=True
|
||||
)
|
||||
self.assertEqual('admin@abc.com', user_objs['email'])
|
||||
self.assertEqual(setting.COMPASS_ADMIN_EMAIL, user_objs['email'])
|
||||
|
||||
def test_user_id(self):
|
||||
user_api.add_user(
|
||||
@ -325,5 +331,8 @@ class TestUpdatePermissions(BaseTest):
|
||||
item in add_permission[0].items() for item in expected.items()
|
||||
)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
flags.init()
|
||||
logsetting.init()
|
||||
unittest2.main()
|
||||
|
@ -17,6 +17,13 @@ import logging
|
||||
import os
|
||||
import unittest2
|
||||
|
||||
os.environ['COMPASS_IGNORE_SETTING'] = 'true'
|
||||
|
||||
|
||||
from compass.utils import setting_wrapper as setting
|
||||
reload(setting)
|
||||
|
||||
|
||||
from compass.db.api import database
|
||||
from compass.db.api import user as user_api
|
||||
from compass.db.api import user_log
|
||||
@ -24,8 +31,6 @@ from compass.db import exception
|
||||
from compass.utils import flags
|
||||
from compass.utils import logsetting
|
||||
|
||||
os.environ['COMPASS_IGNORE_SETTING'] = 'true'
|
||||
|
||||
|
||||
class BaseTest(unittest2.TestCase):
|
||||
"""Base Class for unit test."""
|
||||
@ -36,7 +41,7 @@ class BaseTest(unittest2.TestCase):
|
||||
database.create_db()
|
||||
self.user_object = (
|
||||
user_api.get_user_object(
|
||||
'admin@abc.com',
|
||||
setting.COMPASS_ADMIN_EMAIL,
|
||||
)
|
||||
)
|
||||
|
||||
@ -153,5 +158,8 @@ class TestDelActions(BaseTest):
|
||||
)
|
||||
self.assertEqual([], del_action)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
flags.init()
|
||||
logsetting.init()
|
||||
unittest2.main()
|
||||
|
@ -21,6 +21,8 @@ os.environ['COMPASS_IGNORE_SETTING'] = 'true'
|
||||
|
||||
|
||||
from compass.utils import setting_wrapper as setting
|
||||
reload(setting)
|
||||
|
||||
|
||||
from compass.db.api import database
|
||||
from compass.db.api import utils
|
||||
@ -30,8 +32,6 @@ from compass.db import models
|
||||
from compass.utils import flags
|
||||
from compass.utils import logsetting
|
||||
|
||||
reload(setting)
|
||||
|
||||
|
||||
class TestModelQuery(unittest2.TestCase):
|
||||
"""Test model query."""
|
||||
|
@ -51,7 +51,7 @@ SWITCHES = [
|
||||
USER_SECRET_KEY = datetime.datetime.now().isoformat()
|
||||
USER_AUTH_HEADER_NAME = 'X-Auth-Token'
|
||||
USER_TOKEN_DURATION = '2h'
|
||||
COMPASS_ADMIN_EMAIL = 'admin@abc.com'
|
||||
COMPASS_ADMIN_EMAIL = 'admin@huawei.com'
|
||||
COMPASS_ADMIN_PASSWORD = 'admin'
|
||||
COMPASS_DEFAULT_PERMISSIONS = [
|
||||
'list_permissions',
|
||||
|
@ -30,9 +30,9 @@ METADATA = {
|
||||
'http_proxy': {
|
||||
'_self': {
|
||||
'field': 'general',
|
||||
'default_value': 'http://10.145.88.211:3128',
|
||||
'default_value': 'http://$ipaddr:3128',
|
||||
'options': [
|
||||
'http://10.145.88.211:3128'
|
||||
'http://$ipaddr:3128'
|
||||
],
|
||||
'mapping_to': 'http_proxy'
|
||||
}
|
||||
@ -40,9 +40,9 @@ METADATA = {
|
||||
'https_proxy': {
|
||||
'_self': {
|
||||
'field': 'general',
|
||||
'default_value': 'http://10.145.88.211:3128',
|
||||
'default_value': 'http://$ipaddr:3128',
|
||||
'options': [
|
||||
'http://10.145.88.211:3128'
|
||||
'http://$ipaddr:3128'
|
||||
],
|
||||
'mapping_to': 'https_proxy'
|
||||
}
|
||||
@ -52,13 +52,13 @@ METADATA = {
|
||||
'field': 'general_list',
|
||||
'default_value': [
|
||||
'127.0.0.1',
|
||||
'compass',
|
||||
'10.145.88.211'
|
||||
'$hostname',
|
||||
'$ipaddr'
|
||||
],
|
||||
'options': [
|
||||
'127.0.0.1',
|
||||
'compass',
|
||||
'10.145.88.211'
|
||||
'$hostname',
|
||||
'$ipaddr'
|
||||
],
|
||||
'mapping_to': 'no_proxy'
|
||||
}
|
||||
@ -67,9 +67,9 @@ METADATA = {
|
||||
'_self': {
|
||||
'is_required': True,
|
||||
'field': 'general',
|
||||
'default_value': '10.145.88.211',
|
||||
'default_value': '$ipaddr',
|
||||
'options': [
|
||||
'10.145.88.211'
|
||||
'$ipaddr'
|
||||
],
|
||||
'mapping_to': 'ntp_server'
|
||||
}
|
||||
@ -79,10 +79,10 @@ METADATA = {
|
||||
'is_required': True,
|
||||
'field': 'general_list',
|
||||
'default_value': [
|
||||
'10.145.88.211',
|
||||
'$ipaddr',
|
||||
],
|
||||
'options': [
|
||||
'10.145.88.211'
|
||||
'$ipaddr'
|
||||
],
|
||||
'mapping_to': 'nameservers'
|
||||
}
|
||||
@ -91,17 +91,17 @@ METADATA = {
|
||||
'_self': {
|
||||
'field': 'general',
|
||||
'is_required' : True,
|
||||
'default_value': 'ods.com',
|
||||
'options': ['ods.com'],
|
||||
'default_value': ['$domain'][0],
|
||||
'options': ['$domain'],
|
||||
}
|
||||
},
|
||||
'search_path': {
|
||||
'_self': {
|
||||
'field': 'general_list',
|
||||
'default_value': [
|
||||
'ods.com'
|
||||
'$domain'
|
||||
],
|
||||
'options': ['ods.com'],
|
||||
'options': ['$domain'],
|
||||
'mapping_to': 'search_path'
|
||||
}
|
||||
},
|
||||
@ -109,7 +109,7 @@ METADATA = {
|
||||
'_self': {
|
||||
'is_required': True,
|
||||
'field': 'ip',
|
||||
'default_value': '10.145.88.1',
|
||||
'default_value': '$gateway',
|
||||
'mapping_to': 'gateway'
|
||||
}
|
||||
}
|
||||
@ -122,6 +122,7 @@ METADATA = {
|
||||
'username': {
|
||||
'_self': {
|
||||
'is_required': True,
|
||||
'default_value': 'root',
|
||||
'field': 'username',
|
||||
'mapping_to': 'username'
|
||||
}
|
||||
@ -129,6 +130,7 @@ METADATA = {
|
||||
'password': {
|
||||
'_self': {
|
||||
'is_required': True,
|
||||
'default_value': 'root',
|
||||
'field': 'password',
|
||||
'mapping_to': 'password'
|
||||
}
|
||||
@ -153,12 +155,14 @@ METADATA = {
|
||||
'percentage': {
|
||||
'_self': {
|
||||
'field': 'percentage',
|
||||
'default_value': 10,
|
||||
'mapping_to': 'vol_percentage'
|
||||
}
|
||||
},
|
||||
'size': {
|
||||
'_self': {
|
||||
'field': 'size',
|
||||
'default_value': '1G',
|
||||
'mapping_to': 'vol_size'
|
||||
},
|
||||
}
|
||||
|
@ -54,6 +54,11 @@ sudo sed -e 's|$PythonHome|'$VIRTUAL_ENV'|' -i /var/www/compass/compass.wsgi
|
||||
sudo sed -e 's|$Python|'$VIRTUAL_ENV/bin/python'|' -i /etc/init.d/compass-progress-updated
|
||||
sudo sed -e 's|$CeleryPath|'$VIRTUAL_ENV/bin/celeryd'|' -i /etc/init.d/compass-celeryd
|
||||
sudo sed -e 's|$Python|'$VIRTUAL_ENV/bin/python'|' -i /usr/bin/compassd
|
||||
sudo sed -i "s/\$ipaddr/$ipaddr/g" /etc/compass/os_metadata/general.conf
|
||||
sudo sed -i "s/\$hostname/$HOSTNAME/g" /etc/compass/os_metadata/general.conf
|
||||
sed -i "s/\$gateway/$OPTION_ROUTER/g" /etc/compass/os_metadata/general.conf
|
||||
domains=$(echo $NAMESERVER_DOMAINS | sed "s/,/','/g")
|
||||
sudo sed -i "s/\$domain/$domains/g" /etc/compass/os_metadata/general.conf
|
||||
|
||||
# add cookbooks, databags and roles
|
||||
sudo chmod +x /opt/compass/bin/addcookbooks.py
|
||||
|
Loading…
Reference in New Issue
Block a user