Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions ci/master.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from buildbot.schedulers.triggerable import Triggerable
from buildbot.changes.filter import ChangeFilter
from buildbot.process.factory import BuildFactory
from buildbot.steps.master import MasterShellCommand
from buildbot.steps.main import MainShellCommand
from buildscripts import steps as buildsteps


Expand Down Expand Up @@ -30,19 +30,19 @@
def push_to_github(__opts__):
cwd = 'sandboxes/{0}/public'.format(project)
return [
MasterShellCommand(
MainShellCommand(
command="""
cd sandboxes/{0}/public
git pull --rebase private master
git push origin master""".format(project),
git pull --rebase private main
git push origin main""".format(project),
description='Pushing commit to GitHub',
descriptionDone='Push commit to GitHub (trunk)'),
]


c['builders'].append(dict(
name='{0} source'.format(project),
slavenames=['ubuntu1204'],
subordinatenames=['ubuntu1204'],
factory=BuildFactory(steps=
#buildsteps.svn(__opts__) +
#buildsteps.bump_version(__opts__, setter='cat > src/scalarizr/version') +
Expand Down
8 changes: 4 additions & 4 deletions scripts/amiscripts-to-scalarizr.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
host_conf = None
farm_conf = None
mysql_conf = None
master_conf = None
main_conf = None
behaviour = None
role_name = None
snmp_community_name = None
Expand Down Expand Up @@ -60,8 +60,8 @@ def main():
snmp_community_name = farm_conf['ACCESS_HASH']

if behaviour == 'mysql':
if host_conf['MYSQL_ROLE'] != 'master':
raise MigrationException('MySQL migration available only for replication master')
if host_conf['MYSQL_ROLE'] != 'main':
raise MigrationException('MySQL migration available only for replication main')
mysql_conf = parse_amiscripts_config('/etc/aws/mysql.conf')
mysql_storage = mysql_conf['MYSQL_STORAGE']
if mysql_storage == 'ebs':
Expand Down Expand Up @@ -282,7 +282,7 @@ def configure_scalarizr_mysql_ebs():
logger.info('Regenerating Scalr mysql system users')
passwds = hdlr._add_mysql_users('scalr', 'scalr_repl', 'scalr_stat')
mysql_hdlr_conf = {'mysql' : {
'replication_master' : '1',
'replication_main' : '1',
'root_password' : passwds[0],
'repl_password' : passwds[1],
'stat_password' : passwds[2]
Expand Down
4 changes: 2 additions & 2 deletions scripts/update_win.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ def SvcDoRun(self):
branch = branch.replace('/','-').replace('.','').strip()
except:
e = sys.exc_info()[1]
logger.debug('Could not obtain userdata: %s. Using master branch' % e)
branch = 'master'
logger.debug('Could not obtain userdata: %s. Using main branch' % e)
branch = 'main'

logger.info('Detecting architecture')
arch = platform.uname()[4]
Expand Down
4 changes: 2 additions & 2 deletions src/scalarizr/adm/commands/queryenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def _display_list_roles(self, out):
'index',
'internal-ip',
'external-ip',
'replication-master']
'replication-main']
table_data = []
for d in out:
behaviour = ', '.join(d.behaviour)
Expand All @@ -132,7 +132,7 @@ def _display_list_roles(self, out):
str(host.index),
host.internal_ip,
host.external_ip,
str(host.replication_master)])
str(host.replication_main)])
print make_table(table_data, headers)

def _display_list_virtual_hosts(self, out):
Expand Down
44 changes: 22 additions & 22 deletions src/scalarizr/api/mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,23 +180,23 @@ def _check_empty(self, param, name):
@rpc.command_method
def reset_password(self, new_password=None):
"""
Reset password for MySQL user 'scalr_master'. Return new password
Reset password for MySQL user 'scalr_main'. Return new password
"""
if not new_password:
new_password = pwgen(20)
mysql_cli = mysql_svc.MySQLClient(__mysql__['root_user'],
__mysql__['root_password'])
master_user = __mysql__['master_user']
main_user = __mysql__['main_user']

if mysql_cli.user_exists(master_user, 'localhost'):
mysql_cli.set_user_password(master_user, 'localhost', new_password)
if mysql_cli.user_exists(main_user, 'localhost'):
mysql_cli.set_user_password(main_user, 'localhost', new_password)
else:
mysql_cli.create_user(master_user, 'localhost', new_password)
mysql_cli.create_user(main_user, 'localhost', new_password)

if mysql_cli.user_exists(master_user, '%'):
mysql_cli.set_user_password(master_user, '%', new_password)
if mysql_cli.user_exists(main_user, '%'):
mysql_cli.set_user_password(main_user, '%', new_password)
else:
mysql_cli.create_user(master_user, '%', new_password)
mysql_cli.create_user(main_user, '%', new_password)

mysql_cli.flush_privileges()

Expand All @@ -212,23 +212,23 @@ def replication_status(self):
"""
mysql_cli = mysql_svc.MySQLClient(__mysql__['root_user'],
__mysql__['root_password'])
if int(__mysql__['replication_master']):
master_status = mysql_cli.master_status()
result = {'master': {'status': 'up',
'log_file': master_status[0],
'log_pos': master_status[1]}}
if int(__mysql__['replication_main']):
main_status = mysql_cli.main_status()
result = {'main': {'status': 'up',
'log_file': main_status[0],
'log_pos': main_status[1]}}
return result
else:
try:
slave_status = mysql_cli.slave_status()
slave_status = dict(zip(map(string.lower, slave_status.keys()),
slave_status.values()))
slave_running = slave_status['slave_io_running'] == 'Yes' and \
slave_status['slave_sql_running'] == 'Yes'
slave_status['status'] = 'up' if slave_running else 'down'
return {'slave': slave_status}
subordinate_status = mysql_cli.subordinate_status()
subordinate_status = dict(zip(map(string.lower, subordinate_status.keys()),
subordinate_status.values()))
subordinate_running = subordinate_status['subordinate_io_running'] == 'Yes' and \
subordinate_status['subordinate_sql_running'] == 'Yes'
subordinate_status['status'] = 'up' if subordinate_running else 'down'
return {'subordinate': subordinate_status}
except ServiceError:
return {'slave': {'status': 'down'}}
return {'subordinate': {'status': 'down'}}


@rpc.command_method
Expand All @@ -240,7 +240,7 @@ def do_backup(op, backup_conf=None):
try:
purpose = '{0}-{1}'.format(
__mysql__.behavior,
'master' if int(__mysql__.replication_master) == 1 else 'slave')
'main' if int(__mysql__.replication_main) == 1 else 'subordinate')
backup = {
'type': 'mysqldump',
'cloudfs_dir': __node__.platform.scalrfs.backups('mysql'),
Expand Down
36 changes: 18 additions & 18 deletions src/scalarizr/api/postgresql.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,20 +136,20 @@ def get_service_status(self):
@rpc.command_method
def reset_password(self, new_password=None):
"""
Resets password for PostgreSQL user 'scalr_master'.
Resets password for PostgreSQL user 'scalr_main'.

:returns: New password
:rtype: str
"""
if not new_password:
new_password = pwgen(10)
pg = postgresql_svc.PostgreSql()
if pg.master_user.exists():
pg.master_user.change_role_password(new_password)
pg.master_user.change_system_password(new_password)
if pg.main_user.exists():
pg.main_user.change_role_password(new_password)
pg.main_user.change_system_password(new_password)
else:
pg.create_linux_user(pg.master_user.name, new_password)
pg.create_pg_role(pg.master_user.name,
pg.create_linux_user(pg.main_user.name, new_password)
pg.create_pg_role(pg.main_user.name,
new_password,
super=True,
force=False)
Expand Down Expand Up @@ -196,17 +196,17 @@ def replication_status(self):

Examples::

On master:
On main:

{'master': {'status': 'up'}}
{'main': {'status': 'up'}}

On broken slave:
On broken subordinate:

{'slave': {'status': 'down','error': <errmsg>}}
{'subordinate': {'status': 'down','error': <errmsg>}}

On normal slave:
On normal subordinate:

{'slave': {'status': 'up', 'xlog_delay': <xlog_delay>}}
{'subordinate': {'status': 'up', 'xlog_delay': <xlog_delay>}}

"""
psql = postgresql_svc.PSQL()
Expand All @@ -219,14 +219,14 @@ def replication_status(self):
raise e
query_result = self._parse_query_out(query_out)

is_master = int(__postgresql__[OPT_REPLICATION_MASTER])
is_main = int(__postgresql__[OPT_REPLICATION_MASTER])

if query_result['xlog_delay'] is None:
if is_master:
return {'master': {'status': 'up'}}
return {'slave': {'status': 'down',
if is_main:
return {'main': {'status': 'up'}}
return {'subordinate': {'status': 'down',
'error': query_result['error']}}
return {'slave': {'status': 'up',
return {'subordinate': {'status': 'up',
'xlog_delay': query_result['xlog_delay']}}


Expand Down Expand Up @@ -321,7 +321,7 @@ def _single_backup(db_name):

cloud_storage_path = __node__.platform.scalrfs.backups(BEHAVIOUR)

suffix = 'master' if int(__postgresql__[OPT_REPLICATION_MASTER]) else 'slave'
suffix = 'main' if int(__postgresql__[OPT_REPLICATION_MASTER]) else 'subordinate'
backup_tags = {'scalr-purpose': 'postgresql-%s' % suffix}

LOG.info("Uploading backup to %s with tags %s" % (cloud_storage_path, backup_tags))
Expand Down
4 changes: 2 additions & 2 deletions src/scalarizr/api/rabbitmq.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def get_service_status(self):
@rpc.command_method
def reset_password(self, new_password=None):
"""
Resets password for RabbitMQ user 'scalr_master'.
Resets password for RabbitMQ user 'scalr_main'.

:param new_password: New password. If not provided, 10-character string will be generated.
:type new_password: str
Expand All @@ -104,7 +104,7 @@ def reset_password(self, new_password=None):
"""
if not new_password:
new_password = pwgen(10)
self.rabbitmq.check_master_user(new_password)
self.rabbitmq.check_main_user(new_password)
return new_password

@classmethod
Expand Down
54 changes: 27 additions & 27 deletions src/scalarizr/api/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ def launch_processes(self, num=None, ports=None, passwords=None, async=False):
raise AssertionError('Number of ports must be equal to number of passwords')
if num and ports and num != len(ports):
raise AssertionError('When ports range is passed its length must be equal to num parameter')
if not __redis__["replication_master"]:
if not __redis__["replication_main"]:
if not passwords or not ports:
raise AssertionError('ports and passwords are required to launch processes on redis slave')
raise AssertionError('ports and passwords are required to launch processes on redis subordinate')
available_ports = self.available_ports
if num > len(available_ports):
raise AssertionError('Cannot launch %s new processes: Ports available: %s' % (num, str(available_ports)))
Expand Down Expand Up @@ -198,7 +198,7 @@ def _launch(self, ports=None, passwords=None, op=None):

for port, password in zip(ports, passwords or [None for port in ports]):
log.info('Launch Redis %s on port %s',
'Master' if __redis__["replication_master"] else 'Slave', port)
'Main' if __redis__["replication_main"] else 'Subordinate', port)

if iptables.enabled():
iptables.FIREWALL.ensure({
Expand All @@ -209,10 +209,10 @@ def _launch(self, ports=None, passwords=None, op=None):
redis_process = redis_service.Redis(port, password)

if not redis_process.service.running:
if __redis__["replication_master"]:
current_password = redis_process.init_master(STORAGE_PATH)
if __redis__["replication_main"]:
current_password = redis_process.init_main(STORAGE_PATH)
else:
current_password = redis_process.init_slave(STORAGE_PATH, primary_ip, port)
current_password = redis_process.init_subordinate(STORAGE_PATH, primary_ip, port)
new_passwords.append(current_password)
new_ports.append(port)
log.debug('Redis process has been launched on port %s with password %s' % (port, current_password))
Expand All @@ -227,7 +227,7 @@ def _shutdown(self, ports, remove_data=False, op=None):
freed_ports = []
for port in ports:
log.info('Shutdown Redis %s on port %s' % (
'Master' if __redis__["replication_master"] else 'Slave', port))
'Main' if __redis__["replication_main"] else 'Subordinate', port))

instance = redis_service.Redis(port=port)
if instance.service.running:
Expand Down Expand Up @@ -303,18 +303,18 @@ def persistence_type(self):
return __redis__["persistence_type"]

def get_primary_ip(self):
master_host = None
LOG.info("Requesting master server")
while not master_host:
main_host = None
LOG.info("Requesting main server")
while not main_host:
try:
master_host = list(
main_host = list(
host for host in self._queryenv.list_roles(behaviour=BEHAVIOUR)[0].hosts
if host.replication_master)[0]
if host.replication_main)[0]
except IndexError:
LOG.debug("QueryEnv responded with no %s master. " % BEHAVIOUR +
LOG.debug("QueryEnv responded with no %s main. " % BEHAVIOUR +
"Waiting %d seconds before the next attempt" % 5)
time.sleep(5)
host = master_host.internal_ip or master_host.external_ip
host = main_host.internal_ip or main_host.external_ip
LOG.debug('primary IP: %s', host)
return host

Expand All @@ -327,14 +327,14 @@ def reset_password(self, port=__redis__['defaults']['port'], new_password=None):
redis_conf = redis_service.RedisConf.find(port=port)
redis_conf.requirepass = new_password

if redis_conf.slaveof:
redis_conf.masterauth = new_password
if redis_conf.subordinateof:
redis_conf.mainauth = new_password

redis_wrapper = redis_service.Redis(port=port, password=new_password)
redis_wrapper.service.reload()

if int(port) == __redis__['defaults']['port']:
__redis__["master_password"] = new_password
__redis__["main_password"] = new_password

return new_password

Expand All @@ -348,23 +348,23 @@ def replication_status(self):
"""
ri = redis_service.RedisInstances()

if __redis__["replication_master"]:
masters = {}
if __redis__["replication_main"]:
mains = {}
for port in ri.ports:
masters[port] = {'status': 'up'}
return {'masters': masters}
mains[port] = {'status': 'up'}
return {'mains': mains}

slaves = {}
subordinates = {}
for redis_process in ri.instances:
repl_data = {}
for key, val in redis_process.redis_cli.info.items():
if key.startswith('master'):
if key.startswith('main'):
repl_data[key] = val
if 'master_link_status' in repl_data:
repl_data['status'] = repl_data['master_link_status']
slaves[redis_process.port] = repl_data
if 'main_link_status' in repl_data:
repl_data['status'] = repl_data['main_link_status']
subordinates[redis_process.port] = repl_data

return {'slaves': slaves}
return {'subordinates': subordinates}

@rpc.command_method
def create_databundle(self, async=True):
Expand Down
Loading