Skip to content

Commit

Permalink
support rgw
Browse files Browse the repository at this point in the history
  • Loading branch information
zhubx007 committed Apr 12, 2016
1 parent 9f7257b commit a36d4e3
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 36 deletions.
21 changes: 13 additions & 8 deletions source/vsm/vsm/agent/cephconfigparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,24 +106,26 @@ def read(self, file_path):
content = f.readlines()
self.init(content)

def write(self, file_path):
content = self.as_str()
def write(self, file_path, rgw=False):
content = self.as_str(rgw)
with open(FLAGS.ceph_conf, 'w') as f:
f.write(content)
f.write('\n')

def as_dict(self):
return self._sections

def as_str(self):
def as_str(self, rgw=False):
lines = ""
d = self._sections.copy()
def _sec_as_str(sec_name):
return Section(sec_name, d[sec_name]).as_str() + '\n'

def _secs_as_str(sec_type):
strs = _sec_as_str(sec_type)
d.pop(sec_type)
strs = ''
if sec_type != "client.radosgw":
strs = _sec_as_str(sec_type)
d.pop(sec_type)
drop_list = []
for sec in d:
if sec.find(sec_type+'.') != -1:
Expand All @@ -150,6 +152,9 @@ def _secs_as_str(sec_type):
if self.has_section('osd'):
lines = lines + _secs_as_str('osd')

if rgw:
lines = lines + _secs_as_str("client.radosgw")

lines = lines.strip()

return lines
Expand Down Expand Up @@ -370,15 +375,15 @@ def _update_ceph_conf_into_db(self, content):
for ser in server_list:
self._agent_rpcapi.update_ceph_conf(self.context, ser['host'])

def save_conf(self, file_path=FLAGS.ceph_conf):
def save_conf(self, file_path=FLAGS.ceph_conf, rgw=False):
utils.execute('chown',
'-R',
'vsm:vsm',
'/etc/ceph/',
run_as_root=True)

self._parser.write(file_path)
self._update_ceph_conf_into_db(self._parser.as_str())
self._parser.write(file_path, rgw)
self._update_ceph_conf_into_db(self._parser.as_str(rgw))

def add_mon(self, hostname, ip, mon_id):
sec = 'mon.%s' % mon_id
Expand Down
11 changes: 7 additions & 4 deletions source/vsm/vsm/agent/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -3077,7 +3077,10 @@ def revoke_storage_pool_from_cinder_conf(self, context, auth_host,
def create_keyring_and_key_for_rgw(self, context, rgw_instance_name,
rgw_keyring_path="/etc/ceph"):
rgw_keyring = rgw_keyring_path + "/keyring.radosgw." + rgw_instance_name
utils.execute("rm", rgw_keyring, run_as_root=True)
try:
utils.execute("rm", rgw_keyring, run_as_root=True)
except:
pass
utils.execute("ceph-authtool", "--create-keyring", rgw_keyring,
run_as_root=True)
utils.execute("chmod", "+r", rgw_keyring, run_as_root=True)
Expand All @@ -3097,13 +3100,13 @@ def create_keyring_and_key_for_rgw(self, context, rgw_instance_name,

def add_rgw_conf_into_ceph_conf(self, context, server_name, rgw_instance_name):
config = cephconfigparser.CephConfigParser(FLAGS.ceph_conf)
rgw_section = "client.radosgw." + rgw_instance_name
rgw_section = "client.radosgw." + str(rgw_instance_name)
host = server_name
keyring = "/etc/ceph/" + rgw_instance_name
keyring = "/etc/ceph/keyring.radosgw." + str(rgw_instance_name)
rsp = "/var/run/ceph/radosgw.sock"
log_file = "/var/log/ceph/radosgw.log"
config.add_rgw(rgw_section, host, keyring, rsp, log_file)
config.save_conf()
config.save_conf(rgw=True)
LOG.info("+++++++++++++++end add_rgw_conf_into_ceph_conf")

def create_default_pools_for_rgw(self, context):
Expand Down
15 changes: 3 additions & 12 deletions source/vsm/vsm/agent/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -2330,15 +2330,6 @@ def get_default_pg_num_by_storage_group(self,context,body):
def rgw_create(self, context, server_name, rgw_instance_name, is_ssl,
uid, display_name, email, sub_user, access, key_type):
LOG.info("++++++++++++++++++++++++++rgw_create")
LOG.info("==========server_name: %s" % str(server_name))
LOG.info("==========rgw_instance_name: %s" % str(rgw_instance_name))
LOG.info("==========is_ssl: %s" % str(is_ssl))
LOG.info("==========uid: %s" % str(uid))
LOG.info("==========display_name: %s" % str(display_name))
LOG.info("==========email: %s" % str(email))
LOG.info("==========sub_user: %s" % str(sub_user))
LOG.info("==========access: %s" % str(access))
LOG.info("==========key_type: %s" % str(key_type))
self.ceph_driver.create_keyring_and_key_for_rgw(context, rgw_instance_name)
self.ceph_driver.add_rgw_conf_into_ceph_conf(context, server_name,
rgw_instance_name)
Expand All @@ -2349,8 +2340,8 @@ def rgw_create(self, context, server_name, rgw_instance_name, is_ssl,
utils.execute("service", "ceph", "restart", run_as_root=True)
try:
utils.execute("service", "apache2", "restart", run_as_root=True)
LOG.info("==========service apache2 restart")
LOG.info("==========sudo service apache2 restart")
except:
utils.execute("service", "httpd", "restart", run_as_root=True)
utils.execute("/etc/init.d/radosgw", "start", run_as_root=True)
LOG.info("=======/etc/init.d/radosgr start")
utils.execute("radosgw", "restart", run_as_root=True)
LOG.info("=======sudo /etc/init.d/radosgr restart")
10 changes: 0 additions & 10 deletions source/vsm/vsm/api/v1/rgw.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ def create(self, req, body):
}
:return:
"""
LOG.info("===========================rgw")
context = req.environ['vsm.context']

rgw = body['rgw']
Expand All @@ -91,15 +90,6 @@ def create(self, req, body):
access = user_info.get('access') if user_info.get('access', '') else "full"
key_type = user_info.get('key_type') if user_info.get('key_type', '') else "swift"

LOG.info("==========server_name: %s" % str(server_name))
LOG.info("==========rgw_instance_name: %s" % str(rgw_instance_name))
LOG.info("==========is_ssl: %s" % str(is_ssl))
LOG.info("==========uid: %s" % str(uid))
LOG.info("==========display_name: %s" % str(display_name))
LOG.info("==========email: %s" % str(email))
LOG.info("==========sub_user: %s" % str(sub_user))
LOG.info("==========access: %s" % str(access))
LOG.info("==========key_type: %s" % str(key_type))
self.scheduler_api.rgw_create(context, server_name, rgw_instance_name, is_ssl,
uid, display_name, email, sub_user, access, key_type)

Expand Down
2 changes: 1 addition & 1 deletion ubuntu14/vsm-deploy/tools/etc/vsm/rootwrap.d/vsm.filters
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ start_osd: CommandFilter, /usr/local/bin/start_osd, root
mkfs: CommandFilter, /sbin/mkfs, root
mount: CommandFilter, /bin/mount, root
umount: CommandFilter, /bin/umount, root
/etc/init.d/radosgw: CommandFilter, /etc/init.d/radosgw, root
radosgw: CommandFilter, /etc/init.d/radosgw, root

#common
ssh: CommandFilter, /usr/bin/ssh, root
Expand Down
2 changes: 1 addition & 1 deletion ubuntu14/vsm/etc/vsm/rootwrap.d/vsm.filters
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ start_osd: CommandFilter, /usr/local/bin/start_osd, root
mkfs: CommandFilter, /sbin/mkfs, root
mount: CommandFilter, /bin/mount, root
umount: CommandFilter, /bin/umount, root
/etc/init.d/radosgw: CommandFilter, /etc/init.d/radosgw, root
radosgw: CommandFilter, /etc/init.d/radosgw, root

#common
su: CommandFilter, /bin/su, root
Expand Down

0 comments on commit a36d4e3

Please sign in to comment.