ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ababiic...@apache.org
Subject git commit: AMBARI-8157 Create model and mapper for stack versions. (ababiichuk)
Date Thu, 06 Nov 2014 12:48:42 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 4d9685f4f -> f159e40bf


AMBARI-8157 Create model and mapper for stack versions. (ababiichuk)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/f159e40b
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/f159e40b
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/f159e40b

Branch: refs/heads/trunk
Commit: f159e40bf0f344dc1994548bc82aaa9e1480579b
Parents: 4d9685f
Author: aBabiichuk <ababiichuk@cybervisiontech.com>
Authored: Thu Nov 6 14:48:29 2014 +0200
Committer: aBabiichuk <ababiichuk@cybervisiontech.com>
Committed: Thu Nov 6 14:48:29 2014 +0200

----------------------------------------------------------------------
 .../data/stack_versions/stack_version_all.json  |  94 +++++++++++++++++
 ambari-web/app/mappers.js                       |   3 +-
 ambari-web/app/mappers/stack_version_mapper.js  | 101 +++++++++++++++++++
 ambari-web/app/models.js                        |   3 +
 ambari-web/app/models/stack_version/os.js       |  30 ++++++
 .../app/models/stack_version/repository.js      |  30 ++++++
 ambari-web/app/models/stack_version/version.js  |  31 ++++++
 ambari-web/app/utils/ajax/ajax.js               |   4 +
 8 files changed, 295 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/f159e40b/ambari-web/app/assets/data/stack_versions/stack_version_all.json
----------------------------------------------------------------------
diff --git a/ambari-web/app/assets/data/stack_versions/stack_version_all.json b/ambari-web/app/assets/data/stack_versions/stack_version_all.json
new file mode 100644
index 0000000..ff8ece0
--- /dev/null
+++ b/ambari-web/app/assets/data/stack_versions/stack_version_all.json
@@ -0,0 +1,94 @@
+{
+  "items": [
+    {
+      "StackVersion": {
+        "name": "HDP 2.2.0.0",
+        "version": "2.2.0.0",
+        "installed_hosts": 0,
+        "current_hosts": 0,
+        "repositories": [
+          {
+            "os": "redhat6",
+            "baseurls": [
+              {
+                "id": "HDP-2.2.0.1-885",
+                "type": "HDP",
+                "baseurl": "http://host1/hdp"
+              },
+              {
+                "id": "HDP-UTILS-1.0.0.20",
+                "type": "HDP-UTILS",
+                "baseurl": "http://host1/hdp-utils"
+              }
+            ]
+          },
+          {
+            "os": "ubuntu12",
+            "baseurls": [
+              {
+                "id": "HDP-2.2.0.1-885",
+                "type": "HDP",
+                "baseurl": "http://host1/hdp"
+              },
+              {
+                "id": "HDP-UTILS-1.0.0.20",
+                "type": "HDP-UTILS",
+                "baseurl": "http://host1/hdp-utils"
+              }
+            ]
+          }
+        ]
+      }
+    },
+    {
+      "StackVersion": {
+        "name": "HDP 2.2.0.1",
+        "version": "2.2.0.1",
+        "installed_hosts": 2,
+        "current_hosts": 3,
+        "repositories": [
+          {
+            "os": "redhat6",
+            "baseurls": [
+              {
+                "id": "HDP-2.2.0.1-885",
+                "type": "HDP",
+                "baseurl": "http://host1/hdp"
+              },
+              {
+                "id": "HDP-UTILS-1.0.0.20",
+                "type": "HDP-UTILS",
+                "baseurl": "http://host1/hdp-utils"
+              }
+            ]
+          }
+        ]
+      }
+    },
+    {
+      "StackVersion": {
+        "name": "HDP 2.2.0.2",
+        "version": "2.2.0.2",
+        "installed_hosts": 5,
+        "current_hosts": 5,
+        "repositories": [
+          {
+            "os": "redhat6",
+            "baseurls": [
+              {
+                "id": "HDP-2.2.0.1-885",
+                "type": "HDP",
+                "baseurl": "http://host1/hdp"
+              },
+              {
+                "id": "HDP-UTILS-1.0.0.20",
+                "type": "HDP-UTILS",
+                "baseurl": "http://host1/hdp-utils"
+              }
+            ]
+          }
+        ]
+      }
+    }
+  ]
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/f159e40b/ambari-web/app/mappers.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers.js b/ambari-web/app/mappers.js
index 88c7328..9b72e09 100644
--- a/ambari-web/app/mappers.js
+++ b/ambari-web/app/mappers.js
@@ -20,6 +20,7 @@
 require('mappers/server_data_mapper');
 require('mappers/stack_service_mapper');
 require('mappers/stack_mapper');
+require('mappers/stack_version_mapper');
 require('mappers/hosts_mapper');
 require('mappers/jobs_mapper');
 require('mappers/cluster_mapper');
@@ -33,4 +34,4 @@ require('mappers/dataset_mapper');
 require('mappers/component_config_mapper');
 require('mappers/components_state_mapper');
 require('mappers/service_config_version_mapper');
-require('mappers/alert_definitions_mapper');
\ No newline at end of file
+require('mappers/alert_definitions_mapper');

http://git-wip-us.apache.org/repos/asf/ambari/blob/f159e40b/ambari-web/app/mappers/stack_version_mapper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers/stack_version_mapper.js b/ambari-web/app/mappers/stack_version_mapper.js
new file mode 100644
index 0000000..856bccb
--- /dev/null
+++ b/ambari-web/app/mappers/stack_version_mapper.js
@@ -0,0 +1,101 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+var App = require('app');
+
+App.stackVersionMapper = App.QuickDataMapper.create({
+  modelStackVerion: App.StackVersion,
+  modelRepositories: App.Repositories,
+  modelOperatingSystems: App.OS,
+
+  modelStack: {
+    id: 'id',
+    name: 'name',
+    version: 'version',
+    operating_systems_key: 'operating_systems',
+    operating_systems_type: 'array',
+    operating_systems: {
+      item: 'id'
+    },
+    installed_hosts_count: 'installed_hosts',
+    current_hosts_count: 'current_hosts'
+  },
+
+  modelOS: {
+    id: 'id',
+    name: 'os',
+    stack_version_id: 'stack_version_id',
+    repositories_key: 'repositories',
+    repositories_type: 'array',
+    repositories: {
+      item: 'id'
+    }
+  },
+
+  modelRepository: {
+    id: 'id',
+    type: 'type',
+    baseurl: 'baseurl',
+    os_id: 'os_id'
+  },
+
+  map: function (json) {
+    var modelStackVerion = this.get('modelStackVerion');
+    var modelOperatingSystems = this.get('modelOperatingSystems');
+    var modelRepositories = this.get('modelRepositories');
+
+    var resultStack = [];
+    var resultOS = [];
+    var resultRepo = [];
+
+    if (json && json.items) {
+      json.items.forEach(function (item) {
+        var stack = item.StackVersion;
+        stack.id = item.StackVersion.name + item.StackVersion.version;
+        var osArray = [];
+
+        if (Em.get(item, 'StackVersion.repositories')) {
+          item.StackVersion.repositories.forEach(function (os) {
+            os.id = item.StackVersion.version + os.os;
+            os.stack_version_id = stack.id;
+            os.name = os.os;
+            var repoArray = [];
+
+            if (Em.get(os, 'baseurls')) {
+              os.baseurls.forEach(function (repo) {
+                repo.os_id = os.id;
+                resultRepo.push(this.parseIt(repo, this.get('modelRepository')));
+                repoArray.pushObject(repo);
+              }, this);
+            }
+
+            os.repositories = repoArray;
+            resultOS.push(this.parseIt(os, this.get('modelOS')));
+            osArray.pushObject(os);
+          }, this);
+        }
+
+        stack.operating_systems = osArray;
+        resultStack.push(this.parseIt(stack, this.get('modelStack')));
+      }, this);
+    }
+    App.store.commit();
+    App.store.loadMany(modelRepositories, resultRepo);
+    App.store.loadMany(modelOperatingSystems, resultOS);
+    App.store.loadMany(modelStackVerion, resultStack);
+  }
+});

http://git-wip-us.apache.org/repos/asf/ambari/blob/f159e40b/ambari-web/app/models.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models.js b/ambari-web/app/models.js
index cf8af7e..5aa3bd6 100644
--- a/ambari-web/app/models.js
+++ b/ambari-web/app/models.js
@@ -25,6 +25,9 @@ require('models/cluster');
 require('models/cluster_states');
 require('models/hosts');
 require('models/stack');
+require('models/stack_version/version');
+require('models/stack_version/os');
+require('models/stack_version/repository');
 require('models/operating_system');
 require('models/repository');
 require('models/stack_service');

http://git-wip-us.apache.org/repos/asf/ambari/blob/f159e40b/ambari-web/app/models/stack_version/os.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/stack_version/os.js b/ambari-web/app/models/stack_version/os.js
new file mode 100644
index 0000000..19d9eac
--- /dev/null
+++ b/ambari-web/app/models/stack_version/os.js
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+var App = require('app');
+
+App.OS = DS.Model.extend({
+  id: DS.attr('string'),
+  name: DS.attr('string'),
+  stackVersion: DS.belongsTo('App.StackVersion'),
+  repositories: DS.hasMany('App.Repositories')
+});
+
+App.OS.FIXTURES = [];
+
+

http://git-wip-us.apache.org/repos/asf/ambari/blob/f159e40b/ambari-web/app/models/stack_version/repository.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/stack_version/repository.js b/ambari-web/app/models/stack_version/repository.js
new file mode 100644
index 0000000..c0ad88b
--- /dev/null
+++ b/ambari-web/app/models/stack_version/repository.js
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+var App = require('app');
+
+App.Repositories = DS.Model.extend({
+  id: DS.attr('string'),
+  type: DS.attr('string'),
+  baseurl: DS.attr('string'),
+  os: DS.belongsTo('App.OS')
+});
+
+App.Repositories.FIXTURES = [];
+
+

http://git-wip-us.apache.org/repos/asf/ambari/blob/f159e40b/ambari-web/app/models/stack_version/version.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/stack_version/version.js b/ambari-web/app/models/stack_version/version.js
new file mode 100644
index 0000000..b7ede22
--- /dev/null
+++ b/ambari-web/app/models/stack_version/version.js
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+var App = require('app');
+
+App.StackVersion = DS.Model.extend({
+  id: DS.attr('string'),
+  name: DS.attr('string'),
+  version: DS.attr('string'),
+  installedHostsCount: DS.attr('number'),
+  currentHostsCount: DS.attr('number'),
+  operatingSystems: DS.hasMany('App.OS')
+});
+
+App.StackVersion.FIXTURES = [];
+

http://git-wip-us.apache.org/repos/asf/ambari/blob/f159e40b/ambari-web/app/utils/ajax/ajax.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/ajax/ajax.js b/ambari-web/app/utils/ajax/ajax.js
index 275f3d9..5929152 100644
--- a/ambari-web/app/utils/ajax/ajax.js
+++ b/ambari-web/app/utils/ajax/ajax.js
@@ -1149,6 +1149,10 @@ var urls = {
     'real': '/clusters/{cluster}/requests/{requestId}?fields=tasks/*',
     'mock': '/data/wizard/{mock}'
   },
+  'admin.stack_versions.all': {
+    'real': '/clusters/{clusterName}/stack_versions',
+    'mock': '/data/stack_versions/stack_version_all.json'
+  },
   'wizard.advanced_repositories.valid_url': {
     'real': '/stacks/{stackName}/versions/{stackVersion}/operating_systems/{osType}/repositories/{repoId}',
     'mock': '',


Mime
View raw message