Add actions to set,get and remove quotas
This commit is contained in:
parent
1829282205
commit
746780d0ea
@ -6,22 +6,30 @@ Ceph is a distributed storage and network file system designed to provide
|
||||
excellent performance, reliability, and scalability.
|
||||
|
||||
This charm deploys a Ceph MDS cluster.
|
||||
juju
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
Boot things up by using::
|
||||
|
||||
Boot things up by using:
|
||||
|
||||
juju deploy -n 3 --config ceph.yaml ceph-mon
|
||||
juju deploy -n 3 --config ceph.yaml ceph-osd
|
||||
|
||||
You can then deploy this charm by simply doing::
|
||||
In my example deployments on EC2 the following ceph.yaml will work:
|
||||
```
|
||||
ceph-mon:
|
||||
source: cloud:trusty-mitaka
|
||||
ceph-osd:
|
||||
osd-devices: /dev/xvdb
|
||||
ephemeral-unmount: "/mnt"
|
||||
source: cloud:trusty-mitaka
|
||||
```
|
||||
You can then deploy this charm by simply doing:
|
||||
|
||||
juju deploy -n 3 --config ceph.yaml ceph-fs
|
||||
juju deploy --config ceph.yaml ceph-fs
|
||||
juju add-relation ceph-fs ceph-mon
|
||||
|
||||
Once the ceph-mon and osd charms have bootstrapped the cluster, it will notify the ceph-fs charm.
|
||||
|
||||
Once the ceph-mon and osd charms have bootstrapped the cluster, the ceph-mon
|
||||
charm will notify the ceph-fs charm.
|
||||
|
||||
Contact Information
|
||||
===================
|
||||
@ -30,4 +38,4 @@ Contact Information
|
||||
|
||||
- [Ceph website](http://ceph.com)
|
||||
- [Ceph mailing lists](http://ceph.com/resources/mailing-list-irc/)
|
||||
- [Ceph bug tracker](http://tracker.ceph.com/projects/ceph)
|
||||
- [Ceph bug tracker](http://tracker.ceph.com/projects/ceph)
|
||||
|
@ -5,12 +5,14 @@ get-quota:
|
||||
type: boolean
|
||||
description: |
|
||||
The limit of how many files can be written. Use either this or
|
||||
max-bytes but not both.
|
||||
max-bytes but not both. The action tries max-files first and then
|
||||
falls back on max-bytes if both are set
|
||||
max-bytes:
|
||||
type: integer
|
||||
description: |
|
||||
The maximum number of bytes that are allowed to be written. Use
|
||||
either this or max-files but not both.
|
||||
either this or max-files but not both. The action tries max-files
|
||||
first and then falls back on max-bytes if both are set
|
||||
directory:
|
||||
type: string
|
||||
description: |
|
||||
@ -24,12 +26,14 @@ remove-quota:
|
||||
type: boolean
|
||||
description: |
|
||||
The limit of how many files can be written. Use either this or
|
||||
max-bytes but not both.
|
||||
max-bytes but not both. The action tries max-files first and then
|
||||
falls back on max-bytes if both are set
|
||||
max-bytes:
|
||||
type: integer
|
||||
description: |
|
||||
The maximum number of bytes that are allowed to be written. Use
|
||||
either this or max-files but not both.
|
||||
either this or max-files but not both. The action tries max-files
|
||||
first and then falls back on max-bytes if both are set
|
||||
directory:
|
||||
type: string
|
||||
description: |
|
||||
@ -43,12 +47,14 @@ set-quota:
|
||||
type: integer
|
||||
description: |
|
||||
The limit of how many files can be written. Use either this or
|
||||
max-bytes but not both.
|
||||
max-bytes but not both. The action tries max-files
|
||||
first and then falls back on max-bytes if both are set
|
||||
max-bytes:
|
||||
type: integer
|
||||
description: |
|
||||
The maximum number of bytes that are allowed to be written. Use
|
||||
either this or max-files but not both.
|
||||
either this or max-files but not both. The action tries max-files
|
||||
first and then falls back on max-bytes if both are set
|
||||
directory:
|
||||
type: string
|
||||
description: |
|
||||
|
1
src/actions/get-quota
Symbolic link
1
src/actions/get-quota
Symbolic link
@ -0,0 +1 @@
|
||||
get-quota.py
|
45
src/actions/get-quota.py
Executable file
45
src/actions/get-quota.py
Executable file
@ -0,0 +1,45 @@
|
||||
#!/usr/bin/python3
|
||||
#
|
||||
# Copyright 2016 Canonical Ltd
|
||||
#
|
||||
# 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.
|
||||
import os
|
||||
from charmhelpers.core.hookenv import action_get, action_fail, action_set
|
||||
import xattr
|
||||
|
||||
__author__ = 'Chris Holcombe <chris.holcombe@canonical.com>'
|
||||
|
||||
|
||||
def get_quota():
|
||||
max_files = action_get('max-files')
|
||||
max_bytes = action_get('max-bytes')
|
||||
directory = action_get('directory')
|
||||
|
||||
if not os.path.exists(directory):
|
||||
action_fail("Directory must exist before setting quota")
|
||||
attr = "ceph.quota.{}"
|
||||
if max_files:
|
||||
attr.format("max_files")
|
||||
elif max_bytes:
|
||||
attr.format("max_bytes")
|
||||
|
||||
try:
|
||||
quota_value = xattr.getxattr(directory, attr)
|
||||
action_set({'{} quota'.format(directory): quota_value})
|
||||
except IOError as err:
|
||||
action_fail(
|
||||
"Unable to get xattr on {}. Error: {}".format(directory, err))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
get_quota()
|
1
src/actions/remove-quota
Symbolic link
1
src/actions/remove-quota
Symbolic link
@ -0,0 +1 @@
|
||||
remove-quota.py
|
44
src/actions/remove-quota.py
Executable file
44
src/actions/remove-quota.py
Executable file
@ -0,0 +1,44 @@
|
||||
#!/usr/bin/python3
|
||||
#
|
||||
# Copyright 2016 Canonical Ltd
|
||||
#
|
||||
# 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.
|
||||
import os
|
||||
from charmhelpers.core.hookenv import action_get, action_fail, action_set
|
||||
import xattr
|
||||
|
||||
__author__ = 'Chris Holcombe <chris.holcombe@canonical.com>'
|
||||
|
||||
|
||||
def remove_quota():
|
||||
max_files = action_get('max-files')
|
||||
max_bytes = action_get('max-bytes')
|
||||
directory = action_get('directory')
|
||||
|
||||
if not os.path.exists(directory):
|
||||
action_fail("Directory must exist before setting quota")
|
||||
attr = "ceph.quota.{}"
|
||||
if max_files:
|
||||
attr.format("max_files")
|
||||
elif max_bytes:
|
||||
attr.format("max_bytes")
|
||||
|
||||
try:
|
||||
xattr.setxattr(directory, attr, str(0))
|
||||
except IOError as err:
|
||||
action_fail(
|
||||
"Unable to set xattr on {}. Error: {}".format(directory, err))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
remove_quota()
|
1
src/actions/set-quota
Symbolic link
1
src/actions/set-quota
Symbolic link
@ -0,0 +1 @@
|
||||
set-quota.py
|
47
src/actions/set-quota.py
Executable file
47
src/actions/set-quota.py
Executable file
@ -0,0 +1,47 @@
|
||||
#!/usr/bin/python3
|
||||
#
|
||||
# Copyright 2016 Canonical Ltd
|
||||
#
|
||||
# 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.
|
||||
|
||||
__author__ = 'Chris Holcombe <chris.holcombe@canonical.com>'
|
||||
import os
|
||||
from charmhelpers.core.hookenv import action_get, action_fail
|
||||
import xattr
|
||||
|
||||
|
||||
def set_quota():
|
||||
max_files = action_get('max-files')
|
||||
max_bytes = action_get('max-bytes')
|
||||
directory = action_get('directory')
|
||||
|
||||
if not os.path.exists(directory):
|
||||
action_fail("Directory must exist before setting quota")
|
||||
attr = "ceph.quota.{}"
|
||||
value = None
|
||||
if max_files:
|
||||
attr.format("max_files")
|
||||
value = str(max_files)
|
||||
elif max_bytes:
|
||||
attr.format("max_bytes")
|
||||
value = str(max_bytes)
|
||||
|
||||
try:
|
||||
xattr.setxattr(directory, attr, value)
|
||||
except IOError as err:
|
||||
action_fail(
|
||||
"Unable to set xattr on {}. Error: {}".format(directory, err))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
set_quota()
|
@ -1,4 +1,7 @@
|
||||
options:
|
||||
apt:
|
||||
packages:
|
||||
- python3-pyxattr
|
||||
ceph-public-network:
|
||||
type: string
|
||||
default:
|
||||
@ -8,15 +11,6 @@ options:
|
||||
.
|
||||
If multiple networks are to be used, a space-delimited list of a.b.c.d/x
|
||||
can be provided.
|
||||
ceph-cluster-network:
|
||||
type: string
|
||||
default:
|
||||
description: |
|
||||
The IP address and netmask of the cluster (back-side) network (e.g.,
|
||||
192.168.0.0/24)
|
||||
.
|
||||
If multiple networks are to be used, a space-delimited list of a.b.c.d/x
|
||||
can be provided.
|
||||
loglevel:
|
||||
default: 1
|
||||
type: int
|
||||
|
@ -1,2 +1,2 @@
|
||||
includes: ['layer:ceph-base', 'interface:/home/chris/repos/juju-interface-ceph-mds'] # if you use any interfaces, add them here
|
||||
includes: ['layer:apt', 'layer:ceph-base', 'interface:/home/chris/repos/juju-interface-ceph-mds'] # if you use any interfaces, add them here
|
||||
repo: git@github.com:cholcombe973/charm-ceph-fs.git
|
||||
|
@ -1 +1 @@
|
||||
ceph_api
|
||||
ceph_api
|
||||
|
Loading…
Reference in New Issue
Block a user