diff options
Diffstat (limited to 'snaps/openstack/openstack_creator.py')
-rw-r--r-- | snaps/openstack/openstack_creator.py | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/snaps/openstack/openstack_creator.py b/snaps/openstack/openstack_creator.py new file mode 100644 index 0000000..de2ae91 --- /dev/null +++ b/snaps/openstack/openstack_creator.py @@ -0,0 +1,110 @@ +# Copyright (c) 2017 Cable Television Laboratories, Inc. ("CableLabs") +# and others. All rights reserved. +# +# 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 snaps.domain.creator import CloudObject +from snaps.openstack.utils import nova_utils, neutron_utils, keystone_utils + +__author__ = 'spisarski' + + +class OpenStackCloudObject(CloudObject): + """ + Abstract class for all OpenStack object creators + """ + + def __init__(self, os_creds): + """ + Constructor + :param os_creds: the OpenStack credentials object + """ + # super(self.__class__, self, os_creds) + self._os_creds = os_creds + + def initialize(self): + raise NotImplementedError('Do not override abstract method') + + def create(self): + raise NotImplementedError('Do not override abstract method') + + def clean(self): + raise NotImplementedError('Do not override abstract method') + + +class OpenStackComputeObject(OpenStackCloudObject): + """ + Abstract class for all OpenStack compute creators + """ + + def __init__(self, os_creds): + """ + Constructor + :param os_creds: the OpenStack credentials object + """ + super(OpenStackComputeObject, self).__init__(os_creds) + self._nova = None + + def initialize(self): + self._nova = nova_utils.nova_client(self._os_creds) + + def create(self): + raise NotImplementedError('Do not override abstract method') + + def clean(self): + raise NotImplementedError('Do not override abstract method') + + +class OpenStackNetworkObject(OpenStackCloudObject): + """ + Abstract class for all OpenStack compute creators + """ + + def __init__(self, os_creds): + """ + Constructor + :param os_creds: the OpenStack credentials object + """ + super(OpenStackNetworkObject, self).__init__(os_creds) + self._neutron = None + + def initialize(self): + self._neutron = neutron_utils.neutron_client(self._os_creds) + + def create(self): + raise NotImplementedError('Do not override abstract method') + + def clean(self): + raise NotImplementedError('Do not override abstract method') + + +class OpenStackIdentityObject(OpenStackCloudObject): + """ + Abstract class for all OpenStack compute creators + """ + + def __init__(self, os_creds): + """ + Constructor + :param os_creds: the OpenStack credentials object + """ + super(OpenStackIdentityObject, self).__init__(os_creds) + self._keystone = None + + def initialize(self): + self._keystone = keystone_utils.keystone_client(self._os_creds) + + def create(self): + raise NotImplementedError('Do not override abstract method') + + def clean(self): + raise NotImplementedError('Do not override abstract method') |