def do_rabbit_addusers(cname): self = facility.get_component(cname) pwd = cmd_quote(util.get_keymgr()(self.name, 'openstack')) localsh.run("""rabbitmqctl add_user openstack {passwd} || rabbitmqctl change_password openstack {passwd} && rabbitmqctl set_permissions -p / openstack ".*" ".*" ".*" """.format(passwd=pwd))
def do_fetch_image(cname): self = facility.get_component(cname) tempest_git_dir = gitutils.component_git_dir(self) self.have_content() image_file = tempest_git_dir + '/etc/cirros.img' fetch.download_origin_or_mirror(img_url, image_file) um = _file_md5_sum(image_file) assert um == img_md5 # TODO: raise real
def do_swift_service_start(cname): self = facility.get_component(cname) tasks.local_os_service_start_by_component(self) # NOTE: other service will be started implictly selected_services = set(self.get_enabled_services_from_component()) if selected_services.intersection(s_store): localsh.run('systemctl start rsyncd')
def do_proxy(cname, cfg): self = facility.get_component(cname) self.have_content() self.file_path('/etc/systemd/system/haproxy.service.d') self.file_ini('/etc/systemd/system/haproxy.service.d/limits.conf', self.etc_systemd_system_haproxy_service_d_limits_conf()) self.file_haproxy('/etc/haproxy/haproxy.cfg', cfg) localsh.run( 'systemctl daemon-reload && systemctl reload-or-restart haproxy')
def do_fernet_init(cname): self = facility.get_component(cname) self.have_content() localsh.run(""" mkdir -p /etc/keystone/fernet-keys # replace with install chown keystone:keystone /etc/keystone/fernet-keys chmod 770 /etc/keystone/fernet-keys keystone-manage fernet_setup --keystone-user keystone --keystone-group keystone """)
def hosts_with_component(component): if component in HOST_WITH_COMPONENT_CACHE: return HOST_WITH_COMPONENT_CACHE[component] related = set() for n, node in INVENTORY.items(): if 'extra_components' in node and component in node['extra_components']: related.add(n) c = facility.get_component(component) if hasattr(c, 'services') and c.services: related.update(hosts_with_any_service(list(c['services'].keys()))) HOST_WITH_COMPONENT_CACHE[component] = related return related
def pre_flight(): args = conf.get_args() state_dir = args.state_dir cfgfile.content_file(state_dir + '/admin-openrc.sh', util.userrc_script('admin'), owner=os.getuid(), group=os.getgid()) keystone = facility.get_component('keystone') keystone.register_project_in_domain('Default', 'demo', 'demo project') keystone.register_user_in_domain('Default', 'demo', password=util.get_keymgr()('keystone', 'demo@default'), email='*****@*****.**', project_roles={('Default', 'demo'): ['user']}) cfgfile.content_file(state_dir + '/demo-openrc.sh', util.userrc_script('demo'), owner=os.getuid(), group=os.getgid())
def do_ensure_test_images(cname): # TODO: Do not duplicate images self = facility.get_component(cname) self.have_content() tempest_git_dir = gitutils.component_git_dir(self) image_file = tempest_git_dir + '/etc/cirros.img' admin_snippet = util.userrc_script('admin') image_uuid = localsh.ret( admin_snippet + "openstack image create cirros --public --file {image_file} --disk-format qcow2 | awk '/\\| id/{{print $4}}'" .format(image_file=image_file)) image_alt_uuid = localsh.ret( admin_snippet + "openstack image create cirros_alt --public --file {image_file} --disk-format qcow2 | awk '/\\| id/{{print $4}}'" .format(image_file=image_file)) return (image_uuid.strip(), image_alt_uuid.strip())
def do_keystone_endpoint_sync(cname, enp): self = facility.get_component(cname) from keystoneauth1.identity import v3 import slos.ossync auth = v3.Password(auth_url='http://*****:*****@default'), project_name='admin', user_domain_name='Default', project_domain_name='Default') # session object is not thread safe, using auth ;((( # TODO: wipe python client usage, looks like, # I cannot use the same token in all threads endpoint_override = 'http://localhost:5000/v3' slos.ossync.endpoint_sync(auth, enp, endpoint_override=endpoint_override)
def do_create_clustr_user(cname): self = facility.get_component(cname) passwd = util.get_keymgr()(self.name, 'clustercheckuser') pwd = passwd.replace('\\', '\\\\').replace("'", r"\'").replace('$', r'\$') sql = "GRANT PROCESS ON *.* TO 'clustercheckuser'@'localhost' IDENTIFIED BY '{pwd}'".format(pwd=pwd) # $ for shell, the others for mysql retry = 1024 # wating for mariadb become ready while True: try: script = 'mysql -u root <<EOF\n{sql}\nEOF\n'.format(sql=sql) localsh.run(script) break except util.NonZeroExitCode: if retry: time.sleep(0.2) retry -= 1 else: raise
def do_tempest_cfg(cname, image_ref, image_ref_alt, public_network_id, min_compute_nodes=1): self = facility.get_component(cname) tempest_git_dir = gitutils.component_git_dir(self) self.file_path(tempest_git_dir, owner='stack', group='stack', mode=0o775) cfg = self.gen_tempest_conf(image_ref, image_ref_alt, public_network_id, min_compute_nodes) self.file_ini('/'.join((tempest_git_dir, 'etc', 'tempest.conf')), cfg, mode=0o755, owner='stack', group='stack')
def do_rabbit_start(cname): self = facility.get_component(cname) self.have_content() retry = 128 # TODO: use state file, or vallet/key_mgr self.file_plain('/var/lib/rabbitmq/.erlang.cookie', 'NETTIQETJNDTXLRUSANA', owner='rabbitmq', mode=0o600) while True: try: if self.changed: # TODO: rolling bounce action = 'reload-or-restart' else: action = 'start' localsh.run("systemctl {} rabbitmq-server".format(action)) break except util.NonZeroExitCode: LOG.warn('Check the RABBIT systemd deps!') time.sleep(0.5) if not retry: raise retry -= 1
def do_swift_deploy_demo_local(cname): self = facility.get_component(cname) # prepare swift # this is from the all in script, it needs to be completly rewritten object_ip = self.get_addr_for(self.get_this_inv(), 'backing_object', net_attr='swift_object_network') # replica_ip = self.get_addr_for(self.get_this_inv(), 'replication', # net_attr='swift_object_replica_network') self.have_content() script = """ INSTALLER_DATA_DIR="%s" BACKING_IP="%s" mkdir $INSTALLER_DATA_DIR/swift cd $INSTALLER_DATA_DIR/swift # old demo only script! for ring in account container object; do swift-ring-builder "$ring.builder" create 10 1 1 # 2^10 partiotions, 1 replicas (no replication), 1 hour move limit done # device is the name of directory in the /srv/node , normally it is a mounted xfs swift-ring-builder account.builder add --region 1 --zone 1 --ip "$BACKING_IP" --port 6202 --device disk1 --weight 100 swift-ring-builder container.builder add --region 1 --zone 1 --ip "$BACKING_IP" --port 6201 --device disk1 --weight 100 swift-ring-builder object.builder add --region 1 --zone 1 --ip "$BACKING_IP" --port 6200 --device disk1 --weight 100 # update the ring file and copy to ALL SWIFT STORAGE SERVERS # it should be rsync-d or scp -ed not cp -d, (or remote copied by the script itself) for ring in account container object; do swift-ring-builder $ring.builder rebalance cp "$ring.ring.gz" /etc/swift/ # TODO: use install done """ % ('/tmp', object_ip) # we would need to use the inventory ips, and iterate over the full map localsh.run(script)
def do_memcached_service_start(cname): self = facility.get_component(cname) self.have_content() localsh.run('systemctl start memcached')
def etccfg_content(self): super(Swift, self).etccfg_content() usrgrp.group('swift', 160) usrgrp.user('swift', 'swift') self.file_path('/etc/swift', owner='swift', group='swift') self.file_ini('/etc/swift/swift.conf', self.etc_swift_swift_conf(), owner='swift', group='swift') comp = facility.get_component('swift') if comp.deploy_source == 'src': util.unit_file( self.services['swift-account']['unit_name']['src'], '/usr/local/bin/swift-account-server /etc/swift/account-server.conf', 'swift') util.unit_file( self.services['swift-object']['unit_name']['src'], '/usr/local/bin/swift-object-server /etc/swift/object-server.conf', 'swift') util.unit_file( self.services['swift-container']['unit_name']['src'], '/usr/local/bin/swift-container-server /etc/swift/container-server.conf', 'swift') util.unit_file( self.services['swift-container-sync']['unit_name']['src'], '/usr/local/bin/swift-container-sync /etc/swift/container-server.conf', 'swift') util.unit_file( self.services['swift-proxy']['unit_name']['src'], '/usr/local/bin/swift-proxy-server /etc/swift/proxy-server.conf', 'swift') services = self.filter_node_enabled_services(self.services.keys()) if 'swift-proxy' in services: self.file_ini('/etc/swift/proxy-server.conf', self.etc_swift_proxy_server_conf(), owner='swift', group='swift') if 'swift-container' in services or 'swift-demo' in services: self.file_ini('/etc/swift/container-server.conf', self.etc_swift_container_server_conf(), owner='swift', group='swift') if 'swift-proxy' in services or 'swift-container' in services: self.file_ini('/etc/swift/container-sync-realms.conf', self.etc_swift_container_sync_realms_conf(), owner='swift', group='swift') if 'swift-object' in services or 'swift-demo' in services: self.file_ini('/etc/swift/object-server.conf', self.etc_swift_object_server_conf(), owner='swift', group='swift') if 'swift-account' in services or 'swift-demo' in services: self.file_ini('/etc/swift/account-server.conf', self.etc_swift_account_server_conf(), owner='swift', group='swift') if set(services).intersection(s_store): self.file_path('/srv/node', owner='swift', group='swift') # TODO use node config self.file_path('/srv/node/disk1', owner='swift', group='swift') self.file_path('/var/lock/rsyncd', owner='swift', group='swift')
def do_mariadb_cfg(cname, nodes, seed=False): self = facility.get_component(cname) self.have_content() self.file_plain(self.get_etcconf_d() + '/80-mariadb_openstack.cnf', self.etc_my_cnf_d_mariadb_openstack_cnf(seed), mode=0o644)
def do_handle_schemas(cname, schemas): self = facility.get_component(cname) for s in schemas: self.handle_schema(*s)
def do_httpd_restart(cname): self = facility.get_component(cname) self.have_content() srv_name = 'httpd' if util.get_distro( )['family'] == 'redhat' else 'apache2' localsh.run("systemctl reload-or-restart " + srv_name)
def do_keystone_init(cname): self = facility.get_component(cname) self.have_content() localsh.run("keystone-manage bootstrap --bootstrap-password %s" % cmd_quote(util.get_keymgr()(self.name, 'admin@default')))
def do_libvirt(cname): self = facility.get_component(cname) self.have_content() localsh.run('systemctl start libvirtd')
def do_local_glance_service_start(cname): self = facility.get_component(cname) tasks.local_os_service_start_by_component(self)
def do_have_content(cname): self = facility.get_component(cname) self.have_content()