예제 #1
0
def get_flavor_os_metadata(
    flavor_id, os_id,
    user=None, session=None, **kwargs
):
    """Get metadata by flavor and os."""
    flavor = adapter_holder_api.get_flavor(
        flavor_id, user=user, session=session
    )
    adapter_id = flavor['adapter_id']
    adapter = adapter_holder_api.get_adapter(
        adapter_id, user=user, session=session
    )
    os_ids = [os['id'] for os in adapter['supported_oses']]
    if os_id not in os_ids:
        raise exception.InvalidParameter(
            'os %s is not in the supported os list of adapter %s' % (
                os_id, adapter_id
            )
        )
    metadatas = {}
    metadatas['os_config'] = _get_os_metadata(
        session, os_id
    )
    metadatas['package_config'] = _get_flavor_metadata(
        session, flavor_id
    )
    return metadatas
예제 #2
0
 def test_get_adapter(self):
     get_adapter = adapter.get_adapter(
         self.adapter_id,
         user=self.user_object,
     )
     name = None
     for k, v in get_adapter.items():
         if k == 'name':
             name = v
     self.assertIsNotNone(get_adapter)
     self.assertEqual(name, 'openstack_icehouse')
예제 #3
0
 def test_get_adapter(self):
     get_adapter = adapter.get_adapter(
         self.adapter_id,
         user=self.user_object,
     )
     name = None
     for k, v in get_adapter.items():
         if k == 'name':
             name = v
     self.assertIsNotNone(get_adapter)
     self.assertEqual(name, 'openstack_icehouse')
예제 #4
0
def get_package_os_metadata(adapter_id,
                            os_id,
                            user=None,
                            session=None,
                            **kwargs):
    """Get metadata by adapter and os."""
    adapter = adapter_holder_api.get_adapter(adapter_id,
                                             user=user,
                                             session=session)
    os_ids = [os['id'] for os in adapter['supported_oses']]
    if os_id not in os_ids:
        raise exception.InvalidParameter(
            'os %s is not in the supported os list of adapter %s' %
            (os_id, adapter_id))
    metadatas = {}
    metadatas['os_config'] = _get_os_metadata(os_id)
    metadatas['package_config'] = _get_package_metadata(adapter_id)
    return metadatas
예제 #5
0
    def get_adapter_info(adapter_id, cluster_id, user):
        """Get adapter information. Return a dictionary as below,

           {
              "id": 1,
              "name": "xxx",
              "flavors": [
                  {
                      "flavor_name": "xxx",
                      "roles": ['xxx', 'yyy', ...],
                      "template": "xxx.tmpl"
                  },
                  ...
              ],
              "metadata": {
                  "os_config": {
                      ...
                  },
                  "package_config": {
                      ...
                  }
              },
              "os_installer": {
                  "name": "cobbler",
                  "settings": {....}
              },
              "pk_installer": {
                  "name": "chef",
                  "settings": {....}
              },
              ...
           }
           To view a complete output, please refer to backend doc.
        """

        adapter_info = adapter_db.get_adapter(adapter_id, user=user)
        metadata = cluster_db.get_cluster_metadata(cluster_id, user=user)
        adapter_info.update({const.METADATA: metadata})

        for flavor_info in adapter_info[const.FLAVORS]:
            roles = flavor_info[const.ROLES]
            flavor_info[const.ROLES] = ActionHelper._get_role_names(roles)

        return adapter_info
예제 #6
0
    def get_adapter_info(adapter_id, cluster_id, user):
        """Get adapter information. Return a dictionary as below,

           {
              "id": 1,
              "name": "xxx",
              "flavors": [
                  {
                      "flavor_name": "xxx",
                      "roles": ['xxx', 'yyy', ...],
                      "template": "xxx.tmpl"
                  },
                  ...
              ],
              "metadata": {
                  "os_config": {
                      ...
                  },
                  "package_config": {
                      ...
                  }
              },
              "os_installer": {
                  "name": "cobbler",
                  "settings": {....}
              },
              "pk_installer": {
                  "name": "chef",
                  "settings": {....}
              },
              ...
           }
           To view a complete output, please refer to backend doc.
        """

        adapter_info = adapter_db.get_adapter(adapter_id, user=user)
        metadata = cluster_db.get_cluster_metadata(cluster_id, user=user)
        adapter_info.update({const.METADATA: metadata})

        for flavor_info in adapter_info[const.FLAVORS]:
            roles = flavor_info[const.ROLES]
            flavor_info[const.ROLES] = ActionHelper._get_role_names(roles)

        return adapter_info