<commit_before>/*
 * instances.js: Rackspace Cloud Database Instance
 *
 * (C) 2011 Nodejitsu Inc.
 *
 */

var utile = require('utile'),
    model = require('../../core/base/model');

var Instance = exports.Instance = function Instance (client, details) {
  model.Model.call(this, client, details);
};

utile.inherits(Instance, model.Model);

Instance.prototype.refresh = function (callback) {
  this.client.getInstance(this, callback);
};

Instance.prototype._setProperties = function (details) {
  this.id = details.id;
  this.name = details.name;
  this.links = details.links;

  // Fix for name in rackspace
  details.state = (details.status) ? details.status : details.state

  if (details.state) {
    switch (details.state.toUpperCase()) {
      case 'PROVISIONING':
      case 'BUILD':
        this.status = "PROVISIONING";
        break;
      case 'RUNNING':
      case 'ACTIVE': // Change for keep consistency
        this.status = "RUNNING";
        break;
      case 'STOPPING':
      case 'STOPPED':
        this.status = "STOPPED";
        break;
      case 'FAILED':
        this.status = 'FAILED';
        break;
      default:
        this.status = "UNKNOWN";
        break;
    }
  }

  // Seems Rackspace not will provide this fields so I comment it.
  //this.created  = details.created  || this.created;
  //this.updated  = details.updated  || this.updated;
  this.flavor   = details.flavor   || {};
  this.hostname = details.hostname || this.hostname;
  this.volume   = details.volume   || this.volume;
  this.original = this.rackspace = details;
};<commit_msg>[databases] added reboot and resize status to instance<commit_after>/*
 * instances.js: Rackspace Cloud Database Instance
 *
 * (C) 2011 Nodejitsu Inc.
 *
 */

var utile = require('utile'),
    model = require('../../core/base/model');

var Instance = exports.Instance = function Instance (client, details) {
  model.Model.call(this, client, details);
};

utile.inherits(Instance, model.Model);

Instance.prototype.refresh = function (callback) {
  this.client.getInstance(this, callback);
};

Instance.prototype._setProperties = function (details) {
  this.id = details.id;
  this.name = details.name;
  this.links = details.links;

  // Fix for name in rackspace
  details.state = (details.status) ? details.status : details.state

  if (details.state) {
    switch (details.state.toUpperCase()) {
      case 'PROVISIONING':
      case 'BUILD':
      case 'REBOOT':
      case 'RESIZE':
        this.status = "PROVISIONING";
        break;
      case 'RUNNING':
      case 'ACTIVE': // Change for keep consistency
        this.status = "RUNNING";
        break;
      case 'STOPPING':
      case 'STOPPED':
        this.status = "STOPPED";
        break;
      case 'FAILED':
        this.status = 'FAILED';
        break;
      default:
        this.status = "UNKNOWN";
        break;
    }
  }

  // Seems Rackspace not will provide this fields so I comment it.
  //this.created  = details.created  || this.created;
  //this.updated  = details.updated  || this.updated;
  this.flavor   = details.flavor   || {};
  this.hostname = details.hostname || this.hostname;
  this.volume   = details.volume   || this.volume;
  this.original = this.rackspace = details;
};
{'fraction_non_alphanumeric': 0.13665743305632502, 'fraction_numerical': 0.0024622960911049553, 'mean_word_length': 2.6931818181818183, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6976310', 'n_tokens_mistral': 1002, 'n_tokens_neox': 996, 'n_words': 243}