diff options
-rw-r--r-- | nova/virt/disk/vfs/__init__.py | 19 | ||||
-rw-r--r-- | nova/virt/disk/vfs/api.py | 107 |
2 files changed, 126 insertions, 0 deletions
diff --git a/nova/virt/disk/vfs/__init__.py b/nova/virt/disk/vfs/__init__.py new file mode 100644 index 000000000..880979c48 --- /dev/null +++ b/nova/virt/disk/vfs/__init__.py @@ -0,0 +1,19 @@ +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +# Copyright 2012 Red Hat, 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. +""" +Operations on virtual filesystems + +""" diff --git a/nova/virt/disk/vfs/api.py b/nova/virt/disk/vfs/api.py new file mode 100644 index 000000000..7d7768bb2 --- /dev/null +++ b/nova/virt/disk/vfs/api.py @@ -0,0 +1,107 @@ +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +# Copyright 2012 Red Hat, 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. + +from nova.openstack.common import log as logging + +LOG = logging.getLogger(__name__) + + +class VFS(object): + + """ + The VFS class defines an interface for manipulating files within + a virtual disk image filesystem. This allows file injection code + to avoid the assumption that the virtual disk image can be mounted + in the host filesystem. + + All paths provided to the APIs in this class should be relative + to the root of the virtual disk image filesystem. Subclasses + will translate paths as required by their implementation. + """ + def __init__(self, imgfile, imgfmt, partition): + self.imgfile = imgfile + self.imgfmt = imgfmt + self.partition = partition + + """ + Perform any one-time setup tasks to make the virtual + filesystem available to future API calls + """ + def setup(self): + pass + + """ + Release all resources initialized in the setup method + """ + def teardown(self): + pass + + """ + Create a directory @path, including all intermedia + path components if they do not already exist + """ + def make_path(self, path): + pass + + """ + Append @content to the end of the file identified + by @path, creating the file if it does not already + exist + """ + def append_file(self, path, content): + pass + + """ + Replace the entire contents of the file identified + by @path, wth @content, creating the file if it does + not already exist + """ + def replace_file(self, path, content): + pass + + """ + Return the entire contents of the file identified + by @path + """ + def read_file(self, path): + pass + + """ + Return a True if the file identified by @path + exists + """ + def has_file(self, path): + pass + + """ + Set the permissions on the file identified by + @path to @mode. The file must exist prior to + this call. + """ + def set_permissions(self, path, mode): + pass + + """ + Set the ownership on the file identified by + @path to the username @user and groupname @group. + Either of @user or @group may be None, in which case + the current ownership will be left unchanged. The + ownership must be passed in string form, allowing + subclasses to translate to uid/gid form as required. + The file must exist prior to this call. + """ + def set_ownership(self, path, user, group): + pass |