Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

OS-1744 add support for zonecfg flags added by OS-1170 to VM.js

  • Loading branch information...
commit c56350ead06122e09227a381c2a5a712a46ccbd8 1 parent 7cfe3ff
@joshwilsdon joshwilsdon authored
Showing with 40 additions and 13 deletions.
  1. +6 −0 src/vm/lib/metadata/agent.js
  2. +34 −13 src/vm/node_modules/VM.js
View
6 src/vm/lib/metadata/agent.js
@@ -75,6 +75,9 @@ MetadataAgent.prototype.createServersOnExistingZones = function (callback) {
if (zone.brand === 'kvm') {
self.startKVMSocketServer(zone.zonename, callback);
}
+ else if (zone.force_metadata_socket) {
+ self.startZoneSocketServer(zone.zonename, false, callback);
+ }
else {
self.startZoneSocketServer(zone.zonename, true, callback);
}
@@ -103,6 +106,9 @@ MetadataAgent.prototype.start = function () {
if (self.zones[msg.zonename].brand === 'kvm') {
self.startKVMSocketServer(msg.zonename);
}
+ else if (self.zones[msg.zonename].force_metadata_socket) {
+ self.startZoneSocketServer(msg.zonename, false);
+ }
else {
self.startZoneSocketServer(msg.zonename, true);
}
View
47 src/vm/node_modules/VM.js
@@ -415,7 +415,9 @@ var XML_PROPERTIES = {
'do-not-inventory': 'do_not_inventory',
'failed': 'failed',
'firewall-enabled': 'firewall_enabled',
+ 'force-metadata-socket': 'force_metadata_socket',
'hostname': 'hostname',
+ 'init-name': 'init_name',
'never-booted': 'never_booted',
'owner-uuid': 'owner_uuid',
'package-name': 'package_name',
@@ -423,6 +425,7 @@ var XML_PROPERTIES = {
'qemu-extra-opts': 'qemu_extra_opts',
'qemu-opts': 'qemu_opts',
'ram': 'ram',
+ 'restart-init': 'restart_init',
'resolvers': 'resolvers',
'spice-opts': 'spice_opts',
'spice-password': 'spice_password',
@@ -513,6 +516,7 @@ var XML_PROPERTY_TRANSFORMS = {
},
'do_not_inventory': fixBoolean,
'firewall_enabled': fixBoolean,
+ 'force_metadata_socket': fixBoolean,
'max_locked_memory': unmangleMem,
'max_lwps': numberify,
'max_physical_memory': unmangleMem,
@@ -532,6 +536,7 @@ var XML_PROPERTY_TRANSFORMS = {
'qemu_extra_opts': unbase64,
'qemu_opts': unbase64,
'ram': numberify,
+ 'restart_init': fixBoolean,
'resolvers': separateCommas,
'spice_password': unbase64,
'spice_port': numberify,
@@ -601,9 +606,11 @@ var PAYLOAD_PROPERTIES = {
'filesystems.*.options': {'type': 'list'},
'firewall': {'type': 'object'},
'firewall_enabled': {'type': 'boolean'},
+ 'force_metadata_socket': {'type': 'boolean'},
'fs_allowed': {'type': 'list'},
'hostname': {'type': 'string'},
'image_uuid': {'type': 'uuid'},
+ 'init_name': {'type': 'string'},
'internal_metadata': {'type': 'flat-object'},
'limit_priv': {'type': 'list'},
'max_locked_memory': {'type': 'integer'},
@@ -644,6 +651,7 @@ var PAYLOAD_PROPERTIES = {
'remove_internal_metadata': {'type': 'list'},
'remove_nics': {'type': 'list'},
'remove_tags': {'type': 'list'},
+ 'restart_init': {'type': 'boolean'},
'resolvers': {'type': 'list'},
'set_tags': {'type': 'flat-object'},
'set_customer_metadata': {'type': 'flat-object'},
@@ -698,9 +706,11 @@ var joyent_allowed = {
'filesystems.*.options': ['add'],
'firewall': ['create'],
'firewall_enabled': ['create', 'receive', 'update'],
+ 'force_metadata_socket': ['create', 'receive', 'update'],
'fs_allowed': ['create', 'receive', 'update'],
'hostname': ['create', 'receive', 'update'],
'image_uuid': ['create', 'receive'],
+ 'init_name': ['create', 'receive', 'update'],
'internal_metadata': ['create', 'receive'],
'limit_priv': ['create', 'receive', 'update'],
'max_locked_memory': ['create', 'receive', 'update'],
@@ -735,6 +745,7 @@ var joyent_allowed = {
'remove_internal_metadata': ['update'],
'remove_nics': ['update'],
'remove_tags': ['update'],
+ 'restart_init': ['create', 'receive', 'update'],
'resolvers': ['create', 'receive', 'update'],
'set_customer_metadata': ['update'],
'set_internal_metadata': ['update'],
@@ -4869,20 +4880,36 @@ function buildZonecfgUpdate(vmobj, payload)
+ (Number(payload.cpu_cap) * 0.01).toString() + '; end\n';
}
- // set to empty string so property is removed when not true
+ // set to empty string so property is removed when not true or when not
+ // false if that's the default for the property.
if (payload.hasOwnProperty('do_not_inventory')) {
- if (payload.do_not_inventory !== 'true') {
+ if (payload.do_not_inventory !== true) {
+ // removing sets false as that's the default.
payload.do_not_inventory = '';
}
}
if (payload.hasOwnProperty('firewall_enabled')) {
- if (payload.firewall_enabled !== 'true'
- && payload.firewall_enabled !== true) {
+ if (payload.firewall_enabled !== true) {
+ // removing sets false as that's the default.
payload.firewall_enabled = '';
}
}
+ if (payload.hasOwnProperty('force_metadata_socket')) {
+ if (payload.force_metadata_socket !== true) {
+ // removing sets false as that's the default.
+ payload.force_metadata_socket = '';
+ }
+ }
+
+ if (payload.hasOwnProperty('restart_init')) {
+ if (payload.restart_init === true) {
+ // removing sets true as that's the default.
+ payload.restart_init = '';
+ }
+ }
+
// Attributes
function setAttr(attr, attr_name, value) {
if (!value) {
@@ -4919,6 +4946,9 @@ function buildZonecfgUpdate(vmobj, payload)
setAttr('default-gateway', 'default_gateway');
setAttr('do-not-inventory', 'do_not_inventory');
setAttr('firewall-enabled', 'firewall_enabled');
+ setAttr('restart-init', 'restart_init');
+ setAttr('init-name', 'init_name');
+ setAttr('force-metadata-socket', 'force_metadata_socket');
if (payload.hasOwnProperty('resolvers')) {
setAttr('resolvers', 'resolvers', payload.resolvers.join(','));
@@ -5855,15 +5885,6 @@ function createZone(payload, callback)
+ 'set value="' + payload.image_uuid + '"; end\n';
}
- // if do_not_inventory is set, we don't don't want there to be a window
- // where the VM might get accidentally imported.
- if (payload.hasOwnProperty('do_not_inventory')
- && payload.do_not_inventory) {
-
- zcfg = zcfg + 'add attr; set name="do-not-inventory"; set type=string; '
- + 'set value="true"; end\n';
- }
-
if (BRAND_OPTIONS[payload.brand].features.use_vm_autoboot) {
// we always set autoboot=false for VM zones, since we want vmadmd to
// boot them and not the zones tools. Use vm-autoboot to control VMs
Please sign in to comment.
Something went wrong with that request. Please try again.