Ejemplo n.º 1
0
    def _postInstallOsKit(self, kit):
        """
        Enable the OS component that may already be associated with an
        existing software profile.  This is possible when OS media is
        not available during installation/creation of software profiles
        """
        swProfileApi = softwareProfileFactory.getSoftwareProfileApi()

        osComponents = kit.getComponentList()
        kitOsInfo = osComponents[0].getOsComponentList()[0].getOsInfo()

        # Load the newly added kit component from the database
        c = self._component_db_api.getComponent(osComponents[0].getName(),
                                                osComponents[0].getVersion(),
                                                kitOsInfo)

        # Iterate over all software profiles looking for matching OS
        for swProfile in swProfileApi.getSoftwareProfileList():
            if swProfile.getOsInfo() != kitOsInfo:
                continue

            # Ensure OS component is enabled on this software profile
            try:
                self._component_db_api.addComponentToSoftwareProfile(
                    c.getId(), swProfile.getId())
            except SoftwareProfileComponentAlreadyExists:
                # Not an error...
                pass
Ejemplo n.º 2
0
    def action_post_uninstall(self, *args, **kwargs):
        super().action_post_install(*args, **kwargs)

        #
        # Remove symlink to modules
        #
        tortugaSubprocess.executeCommand(
            '/bin/rm -f {}/lib/tortuga/vmwareUtil'.format(self.getRoot()))

        #
        # Delete the hardware and software profiles we created in
        # post_install
        #
        hardware_profile_api = getHardwareProfileApi()
        software_profile_api = getSoftwareProfileApi()

        for hwp_name in DEFAULT_HARDWARE_PROFILE_LIST:
            try:
                hardware_profile_api.deleteHardwareProfile(hwp_name)
            except HardwareProfileNotFound:
                #
                # We can safely ignore this error
                #
                pass

        for swp_name in DEFAULT_SOFTWARE_PROFILE_LIST:
            try:
                software_profile_api.deleteSoftwareProfile(swp_name)
            except SoftwareProfileNotFound:
                #
                # We can safely ignore this error
                #
                pass
# limitations under the License.

import sys
import pprint

from tortuga.softwareprofile import softwareProfileFactory
from tortuga.hardwareprofile import hardwareProfileFactory

import tortuga.resourceAdapter.openstack

hwProfileName = 'hpcloud'
hwProfileName = 'rackspace'

hwProfile = hardwareProfileFactory.getHardwareProfileApi().getHardwareProfile(
    hwProfileName)
swProfile = softwareProfileFactory.getSoftwareProfileApi().getSoftwareProfile(
    'Compute')

openstack = tortuga.resourceAdapter.openstack.Openstack()

session = openstack._Openstack__initSession(hwProfile=hwProfile,
                                            swProfile=swProfile)

# pprint.pprint(openstack._Openstack__openstack_get_flavors(session))

# Get list of available networks

headers = {}
# import pdb; pdb.set_trace()

# networks = openstack._Openstack__openstack_compute_get_request(session, '/os-floating-ips', headers, expected_status=(200,))