def test_launchActive():
    hwProfileName = 'gce'
    swProfileName = 'BasicCompute'

    hwProfile = HardwareProfileDbApi().getHardwareProfile(hwProfileName)
    swProfile = SoftwareProfileDbApi().getSoftwareProfile(swProfileName)

    gceAdapter = tortuga.resourceAdapter.gce.Gce()

    resourceAdapterConfig = {}

    session = gceAdapter._Gce__initSession(resourceAdapterConfig,
                                           swProfile=swProfile,
                                           hwProfile=hwProfile)

    nodeCreateDict = {
        'nodeCount': 5,
        'hardwareProfile': hwProfile,
        'softwareProfile': swProfile,
        'nodeDetails': [],
        'deviceName': None,
        'rackNumber': 1,
        'resourceUnits': 1,
        'supportedUnits': 1,
    }

    gceAdapter._Gce__launchActive(session, nodeCreateDict)
Beispiel #2
0
    def __init__(self):
        super(NodeManager, self).__init__()

        self._nodeDbApi = NodeDbApi()
        self._hardwareProfileDbApi = HardwareProfileDbApi()
        self._cm = ConfigManager()
        self._san = san.San()
    def __init__(self):
        super(HardwareProfileManager, self).__init__()

        self._hpDbApi = HardwareProfileDbApi()
        self._spDbApi = SoftwareProfileDbApi()
        self._networkDbApi = NetworkDbApi()
        self._globalParameterDbApi = GlobalParameterDbApi()
        self._nodeDbApi = NodeDbApi()
Beispiel #4
0
    def __init__(self):
        super(NodeManager, self).__init__()

        self._nodeDbApi = NodeDbApi()
        self._hardwareProfileDbApi = HardwareProfileDbApi()
        self._cm = ConfigManager()
        self._san = san.San()
        self._bhm = osUtility.getOsObjectFactory().getOsBootHostManager()
Beispiel #5
0
    def __init__(self):
        super(HardwareProfileManager, self).__init__()

        self._hpDbApi = HardwareProfileDbApi()
        self._spDbApi = SoftwareProfileDbApi()
        self._networkDbApi = NetworkDbApi()
        self._globalParameterDbApi = GlobalParameterDbApi()
        self._nodeDbApi = NodeDbApi()
        self._logger = logging.getLogger(HARDWARE_PROFILE_NAMESPACE)
def test_getConfig():
    hwProfileName = 'gce'
    swProfileName = 'BasicCompute'

    hwProfile = HardwareProfileDbApi().getHardwareProfile(hwProfileName)
    swProfile = SoftwareProfileDbApi().getSoftwareProfile(swProfileName)

    gceAdapter = tortuga.resourceAdapter.gce.Gce()

    configDict = gceAdapter._Gce__getConfig(resourceAdapterConfig={},
                                            swProfile=swProfile,
                                            hwProfile=hwProfile)

    pprint.pprint(configDict)
Beispiel #7
0
    def __init__(self):
        OsObjectManager.__init__(self)

        # Cache this for later
        try:
            self.passdata = pwd.getpwnam('apache')
        except KeyError:
            self.passdata = pwd.getpwnam(os.getenv('USER'))

        self.hardwareProfileDbApi = HardwareProfileDbApi()
        self.softwareProfileDbApi = SoftwareProfileDbApi()

        self._nodeApi = nodeApi.NodeApi()

        self._cm = ConfigManager()
def test_initSession():
    hwProfileName = 'gce'
    swProfileName = 'BasicCompute'

    hwProfile = HardwareProfileDbApi().getHardwareProfile(hwProfileName)
    swProfile = SoftwareProfileDbApi().getSoftwareProfile(swProfileName)

    gceAdapter = tortuga.resourceAdapter.gce.Gce()

    resourceAdapterConfig = {}

    session = gceAdapter._Gce__initSession(resourceAdapterConfig,
                                           swProfile=swProfile,
                                           hwProfile=hwProfile)

    return session
def main():
    swProfileName = 'BasicCompute'
    hwProfileName = 'rackspace'

    hwProfile = HardwareProfileDbApi().getHardwareProfile(hwProfileName)

    swProfile = SoftwareProfileDbApi().getSoftwareProfile(swProfileName)

    osAdapter = Openstack()

    # import pdb; pdb.set_trace()

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

    instance = osAdapter._Openstack__getInstance(
        session, '9d232b72-d50b-4018-8b76-febf503b722f')
def test_getHardwareProfile(dbm):
    """
    Get hardware profile with default resource adapter configuration
    defined.
    """

    name = 'aws'

    with dbm.session() as session:
        result = HardwareProfileDbApi().getHardwareProfile(session, name)

    assert isinstance(result, HardwareProfile)

    assert result.getName() == name

    assert result.getDefaultResourceAdapterConfig() is None

    assert result.getResourceAdapter()
    def runCommand(self):
        self.parseArgs(
            _("""
Display list of nodes able to use the specified software profile,
ordered by cost.
"""))
        softwareProfileName = self.getArgs().softwareProfile

        nodeApi = NodeApi()
        softwareUsesHardwareDbApi = SoftwareUsesHardwareDbApi()
        hardwareProfileDbApi = HardwareProfileDbApi()

        load_kits()

        with DbManager().session() as session:
            hwPList = hardwareProfileDbApi.getHardwareProfileList(session)

            hardwareProfileIdList = softwareUsesHardwareDbApi.\
                getAllowedHardwareProfilesBySoftwareProfileName(
                    session, softwareProfileName)

            nodeList = nodeApi.getNodeList(session)
            usableNodes = []
            for node in nodeList:
                if (node.getHardwareProfile().getId() in hardwareProfileIdList) \
                        and node.getIsIdle():
                    usableNodes.append(node)

            costNameList = []
            for node in usableNodes:
                nodeHwP = node.getHardwareProfile().getId()
                for hwP in hwPList:
                    if hwP.getId() == nodeHwP:
                        costNameList.append(
                            [int(hwP.getCost()),
                             node.getName()])
                        break

            costNameList.sort()

            for node in costNameList:
                print('%s' % (node[1]))
def test_getHardwareProfile_alt(dbm):
    """
    Get hardware profile with default resource adapter configuration
    defined.
    """

    name = 'aws2'

    with dbm.session() as session:
        result = HardwareProfileDbApi().getHardwareProfile(session, name)

    assert isinstance(result, HardwareProfile)

    assert result.getName() == name

    # 'nondefault' is the known default resource adapter configuration
    # profile for the hardware profile 'aws2'
    assert result.getDefaultResourceAdapterConfig() == 'nondefault'

    assert result.getResourceAdapter()
def test_updateHardwareProfileTags(dbm):
    api = HardwareProfileDbApi()
    tags = {'tag1': 'tag1 value', 'tag2': 'tag2 value'}

    with dbm.session() as session:
        hwprofile = api.getHardwareProfile(session, 'notags')

        #
        # Set tags
        #
        hwprofile.setTags({'tag1': 'tag1 value', 'tag2': 'tag2 value'})
        api.updateHardwareProfile(session, hwprofile)
        session.commit()
        hwprofile = api.getHardwareProfile(session, 'notags')
        assert hwprofile.getTags() == tags

        #
        # Remove tags
        #
        hwprofile.setTags({})
        api.updateHardwareProfile(session, hwprofile)
        session.commit()
        hwprofile = api.getHardwareProfile(session, 'notags')
        assert hwprofile.getTags() == {}
Beispiel #14
0
 def __init__(self, *args, **kwargs):
     self._hwp_api = HardwareProfileDbApi()
     self._node_api = NodeDbApi()
     self._swp_api = SoftwareProfileDbApi()
     super().__init__(*args, **kwargs)
#    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 pytest

from tortuga.db.hardwareProfileDbApi import HardwareProfileDbApi
from tortuga.exceptions.hardwareProfileNotFound import HardwareProfileNotFound
from tortuga.exceptions.invalidArgument import InvalidArgument
from tortuga.objects.hardwareProfile import HardwareProfile

hardwareProfileDbApi = HardwareProfileDbApi()


def test_getHardwareProfile(dbm):
    """
    Get hardware profile with default resource adapter configuration
    defined.
    """

    name = 'aws'

    with dbm.session() as session:
        result = HardwareProfileDbApi().getHardwareProfile(session, name)

    assert isinstance(result, HardwareProfile)
Beispiel #16
0
        'hardwareProfile': hwProfile,
        'softwareProfile': swProfile,
        'nodeDetails': [],
        'deviceName': None,
        'rackNumber': 1,
        'resourceUnits': 1,
        'supportedUnits': 1,
    }

    gceAdapter._Gce__launchActive(session, nodeCreateDict)


hwProfileName = 'gce'
swProfileName = 'BasicCompute'

hwProfile = HardwareProfileDbApi().getHardwareProfile(hwProfileName)
swProfile = SoftwareProfileDbApi().getSoftwareProfile(swProfileName)

gceAdapter = tortuga.resourceAdapter.gce.Gce()

session = gceAdapter._Gce__initSession(swProfile=swProfile,
                                       hwProfile=hwProfile)

# instance = gceAdapter._Gce__getInstance(session, instance_name='gce-02-local')

# for intfc in instance [u'networkInterfaces']:
#     for access_cfg in intfc[u'accessConfigs']:
#         print access_cfg[u'natIP']

# gceAdapter._Gce__deleteInstance(session, instance_name='gce-01-local')
# gceAdapter._Gce__deleteInstance(session, instance_name='gce-02-local')
def test_getHardwareProfile_failed(dbm):
    with dbm.session() as session:
        with pytest.raises(HardwareProfileNotFound):
            HardwareProfileDbApi().getHardwareProfile(session,
                                                      'doesnotexistEXAMPLE')