Skip to content

Commit

Permalink
Add plugin for adding new mds host
Browse files Browse the repository at this point in the history
Change-Id: Ib69556ae8532c6f52457eb3bd37be0d23ebeb3fd
  • Loading branch information
9seconds committed Apr 27, 2017
1 parent acdf427 commit 529b236
Show file tree
Hide file tree
Showing 12 changed files with 294 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,7 @@ nfs:
protocols: "3,4"
access_type: RW
user: cephnfs

mds:
multi: true
max: 3
2 changes: 2 additions & 0 deletions backend/common/decapod_common/playbook_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,8 @@ def get_ceph_ansible_common_settings(cls, cluster, servers, *,
"max_open_files": config["max_open_files"],
"nfs_file_gw": False,
"nfs_obj_gw": False,
"mds_max_mds": config["mds"]["max"],
"mds_allow_multimds": config["mds"]["multi"],
"os_tuning_params": [],
"public_network": str(networkutils.get_public_network(servers)),
"radosgw_civetweb_num_threads": config["radosgw"]["num_threads"],
Expand Down
76 changes: 76 additions & 0 deletions backend/common/decapod_common/playbooks/plays/deploy_mds.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---
# Copyright (c) 2017 Mirantis Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.


- include: "{{ decapod_common_playbooks }}/plays/add_ceph_ansible_role.yaml"

- hosts: mons
become: true
tasks:
- block:
- name: get default pg_num
command: >
ceph --cluster {{ cluster | quote }} daemon
mon.{{ ansible_hostname }} config get osd_pool_default_pg_num
register: default_pg_num

- name: create filesystem pools
command: >
ceph --cluster {{ cluster | quote }} osd pool create
{{ item | quote }}
{{ (default_pg_num.stdout | from_json).osd_pool_default_pg_num }}
with_items:
- cephfs_data
- cephfs_metadata
changed_when: false

- name: check if ceph filesystem already exists
command: ceph --cluster {{ cluster | quote }} fs get cephfs
register: check_existing_cephfs
changed_when: false
failed_when: false

- name: create ceph filesystem
command: >
ceph --cluster {{ cluster | quote }} fs new
cephfs cephfs_metadata cephfs_data
changed_when: false
when: check_existing_cephfs.rc != 0

- name: allow multimds
command: >
ceph --cluster {{ cluster | quote }} fs set cephfs
allow_multimds true --yes-i-really-mean-it
changed_when: false
when: mds_allow_multimds

- name: set max mds
command: >
ceph --cluster {{ cluster | quote }} fs set cephfs max_mds
{{ mds_max_mds }}
changed_when: false
when:
- mds_allow_multimds
- mds_max_mds
when:
- "{{ (groups.mdss | length) > 0 }}"
- "{{ inventory_hostname == (groups.mons | last) }}"

- hosts: mdss
become: true
roles:
- ceph-client
- ceph-mds
3 changes: 3 additions & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ services:
- ./backend/monitoring/decapod_monitoring:/usr/local/lib/python2.7/dist-packages/decapod_monitoring:ro
- ./plugins/alerts/emails/decapod_plugin_alerts_emails:/usr/local/lib/python3.5/dist-packages/decapod_plugin_alerts_emails:ro
- ./plugins/playbook/add_client/decapod_plugin_playbook_add_client:/usr/local/lib/python3.5/dist-packages/decapod_plugin_playbook_add_client:ro
- ./plugins/playbook/add_mds/decapod_plugin_playbook_add_mds:/usr/local/lib/python3.5/dist-packages/decapod_plugin_playbook_add_mds:ro
- ./plugins/playbook/add_mon/decapod_plugin_playbook_add_mon:/usr/local/lib/python3.5/dist-packages/decapod_plugin_playbook_add_mon:ro
- ./plugins/playbook/add_nfs/decapod_plugin_playbook_add_nfs:/usr/local/lib/python3.5/dist-packages/decapod_plugin_playbook_add_nfs:ro
- ./plugins/playbook/add_osd/decapod_plugin_playbook_add_osd:/usr/local/lib/python3.5/dist-packages/decapod_plugin_playbook_add_osd:ro
Expand Down Expand Up @@ -63,6 +64,7 @@ services:
- ./backend/docker/decapod_docker:/usr/local/lib/python3.5/dist-packages/decapod_docker:ro
- ./plugins/alerts/emails/decapod_plugin_alerts_emails:/usr/local/lib/python3.5/dist-packages/decapod_plugin_alerts_emails:ro
- ./plugins/playbook/add_client/decapod_plugin_playbook_add_client:/usr/local/lib/python3.5/dist-packages/decapod_plugin_playbook_add_client:ro
- ./plugins/playbook/add_mds/decapod_plugin_playbook_add_mds:/usr/local/lib/python3.5/dist-packages/decapod_plugin_playbook_add_mds:ro
- ./plugins/playbook/add_mon/decapod_plugin_playbook_add_mon:/usr/local/lib/python3.5/dist-packages/decapod_plugin_playbook_add_mon:ro
- ./plugins/playbook/add_nfs/decapod_plugin_playbook_add_nfs:/usr/local/lib/python3.5/dist-packages/decapod_plugin_playbook_add_nfs:ro
- ./plugins/playbook/add_osd/decapod_plugin_playbook_add_osd:/usr/local/lib/python3.5/dist-packages/decapod_plugin_playbook_add_osd:ro
Expand Down Expand Up @@ -94,6 +96,7 @@ services:
- ./backend/docker/decapod_docker:/usr/local/lib/python3.5/dist-packages/decapod_docker:ro
- ./plugins/alerts/emails/decapod_plugin_alerts_emails:/usr/local/lib/python3.5/dist-packages/decapod_plugin_alerts_emails:ro
- ./plugins/playbook/add_client/decapod_plugin_playbook_add_client:/usr/local/lib/python3.5/dist-packages/decapod_plugin_playbook_add_client:ro
- ./plugins/playbook/add_mds/decapod_plugin_playbook_add_mds:/usr/local/lib/python3.5/dist-packages/decapod_plugin_playbook_add_mds:ro
- ./plugins/playbook/add_mon/decapod_plugin_playbook_add_mon:/usr/local/lib/python3.5/dist-packages/decapod_plugin_playbook_add_mon:ro
- ./plugins/playbook/add_nfs/decapod_plugin_playbook_add_nfs:/usr/local/lib/python3.5/dist-packages/decapod_plugin_playbook_add_nfs:ro
- ./plugins/playbook/add_osd/decapod_plugin_playbook_add_osd:/usr/local/lib/python3.5/dist-packages/decapod_plugin_playbook_add_osd:ro
Expand Down
2 changes: 2 additions & 0 deletions plugins/playbook/add_mds/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include decapod_plugin_playbook_add_mds/config.yaml
include decapod_plugin_playbook_add_mds/playbook.yaml
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
# Copyright (c) 2016 Mirantis Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
# Copyright (c) 2016 Mirantis Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.


- include: "{{ decapod_common_playbooks }}/plays/deploy_mds.yaml"
114 changes: 114 additions & 0 deletions plugins/playbook/add_mds/decapod_plugin_playbook_add_mds/plugin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2016 Mirantis Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Playbook plugin for Add metadata server host."""


from decapod_common import log
from decapod_common import playbook_plugin
from decapod_common import playbook_plugin_hints
from decapod_common.models import cluster_data
from decapod_common.models import server


DESCRIPTION = "Add metadata server host"
"""Plugin description."""

HINTS_SCHEMA = {
"ceph_version_verify": {
"description": "Verify Ceph version consistency on install",
"typename": "boolean",
"type": "boolean",
"default_value": True
}
}
"""Schema for playbook hints."""

LOG = log.getLogger(__name__)
"""Logger."""


class AddMds(playbook_plugin.CephAnsiblePlaybook):

NAME = "Add metadata server host"
DESCRIPTION = DESCRIPTION
PUBLIC = True
REQUIRED_SERVER_LIST = True
SERVER_LIST_POLICY = playbook_plugin.ServerListPolicy.not_in_other_cluster

HINTS = playbook_plugin_hints.Hints(HINTS_SCHEMA)

def on_pre_execute(self, task):
super().on_pre_execute(task)

playbook_config = self.get_playbook_configuration(task)
config = playbook_config.configuration["inventory"]
cluster = playbook_config.cluster
servers = playbook_config.servers
servers = {srv.ip: srv for srv in servers}

for name, group_vars in config.items():
if name != "mdss" or not group_vars:
continue
group_servers = [servers[ip] for ip in group_vars]
cluster.add_servers(group_servers, name)

if cluster.configuration.changed:
cluster.save()

def make_playbook_configuration(self, cluster, servers, hints):
data = cluster_data.ClusterData.find_one(cluster.model_id)
global_vars = self.make_global_vars(cluster, data, servers, hints)
inventory = self.make_inventory(cluster, data, servers, hints)

return global_vars, inventory

def make_global_vars(self, cluster, data, servers, hints):
result = super().make_global_vars(cluster, servers, hints)
result.update(data.global_vars)

result["ceph_version_verify"] = bool(hints["ceph_version_verify"])

return result

def make_inventory(self, cluster, data, servers, hints):
groups = self.get_inventory_groups(cluster, servers, hints)
inventory = {"_meta": {"hostvars": {}}}

for name, group_servers in groups.items():
for srv in group_servers:
inventory.setdefault(name, []).append(srv.ip)

hostvars = inventory["_meta"]["hostvars"].setdefault(
srv.ip, {})
hostvars.update(data.get_host_vars(srv.ip))
hostvars["ansible_user"] = srv.username

return inventory

def get_inventory_groups(self, cluster, servers, hints):
cluster_servers = server.ServerModel.cluster_servers(cluster.model_id)
cluster_servers = {item._id: item for item in cluster_servers}

mons = [
cluster_servers[item["server_id"]]
for item in cluster.configuration.state if item["role"] == "mons"
]

return {
"mons": mons,
"mdss": servers,
"already_deployed": list(cluster_servers.values())
}
9 changes: 9 additions & 0 deletions plugins/playbook/add_mds/setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[bdist_wheel]
python-tag = py3

[flake8]
exclude = build,dist,docs/conf.py,*.egg-info,.eggs,.cache,.tox
inline-quotes = "
application-import-names = decapod_api,decapod_common,decapod_controller,decapodlib
import-order-style = smarkets
48 changes: 48 additions & 0 deletions plugins/playbook/add_mds/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2016 Mirantis Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Setup script for decapod_plugin_playbook_add_mds plugin."""


import setuptools


setuptools.setup(
name="decapod-plugin-playbook-add-mds",
description="Add metadata server host",
version="1.1.0.dev1",
author="Sergey Arkhipov",
author_email="sarkhipov@mirantis.com",
url="https://github.com/Mirantis/ceph-lcm",
packages=setuptools.find_packages(),
entry_points={
"decapod.playbooks": [
"add_mds = decapod_plugin_playbook_add_mds.plugin:AddMds"
]
},
python_requires=">= 3.4",
include_package_data=True,
package_data={
"decapod_plugin_playbook_add_mds": [
"config.yaml",
"playbook.yaml"
]
},
install_requires=[
"decapod-common~=1.1.dev1"
],
zip_safe=False
)
3 changes: 3 additions & 0 deletions plugins/playbook/add_mds/stdeb.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[DEFAULT]
X-Python3-Version: >= 3.4
Depends3: python3-decapod-common (>= 1.1), python3-decapod-common (<< 1.2)

0 comments on commit 529b236

Please sign in to comment.