Permalink
Browse files

Merge branch 'master' of github.com:StackIQ/stacki

  • Loading branch information...
2 parents 02fb3d5 + 8c118f0 commit dbd5a7d388c4a9740a97fdbf257a0683c13afde8 @masonkatz masonkatz committed Jan 10, 2017
View
@@ -46,6 +46,9 @@ else:
<package>vim</package>
<package>pciutils</package>
+<package>ipmitool</package>
+<package>OpenIPMI</package>
+
<post>
/sbin/chkconfig stack-pre on
View
@@ -24,10 +24,6 @@ All rights reserved. Rocks(r) v5.4 www.rocksclusters.org
</main>
-<package>ipmitool</package>
-<package>OpenIPMI</package>
-
-
<pre>
<!-- start lighttpd for the Avalanche Installer -->
@@ -464,6 +464,7 @@ CREATE TABLE storage_partition (
Mountpoint varchar(128) NOT NULL default '',
Size int(11) NOT NULL,
FsType varchar(128) NOT NULL default '',
+ PartID int(11) NOT NULL,
Options varchar(512) NOT NULL default ''
);
@@ -100,7 +100,7 @@ DEPENDS.FILES = mariadb-$(VERSION).tar.gz
include $(STACKBUILD)/etc/CCRules.mk
bootstrap: install-rpm
- co $(PKGROOT)/etc/my.cnf
+ co -f $(PKGROOT)/etc/my.cnf
build:
gunzip -c mariadb-$(VERSION).tar.gz | $(TAR) -xf -
@@ -98,7 +98,7 @@ DEPENDS.DIRS = patch-files
include $(STACKBUILD)/etc/CCRules.mk
bootstrap:
- yum install -y libxml2-devel
+ yum install -y libxml2-devel curses-devel
$(MAKE) install-rpm
build:
@@ -73,6 +73,11 @@ class Command(stack.commands.HostArgumentProcessor,
<param type='string' name='options' optional='0'>
Options that need to be supplied while adding partitions.
</param>
+
+ <param type='string' name='partid' optional='1'>
+ The relative partition id for this partition. Partitions will be
+ created in ascending partition id order.
+ </param>
<example cmd='add storage partition compute-0-0 device=sda mountpoint=/var
size=50 type=ext4'>
@@ -156,18 +161,18 @@ def run(self, params, args):
else:
name = args[0]
- device, size, fstype, mountpt, options = self.fillParams([
- ('device', None, True),
- ('size', None),
- ('type', None),
- ('mountpoint', None, True),
- ('options', None)
- ])
+ device, size, fstype, mountpt, options, partid = \
+ self.fillParams([
+ ('device', None, True),
+ ('size', None),
+ ('type', None),
+ ('mountpoint', None),
+ ('options', None),
+ ('partid', None),
+ ])
if not device:
raise ParamRequired(self, 'device')
- if not mountpt:
- raise ParamRequired(self, 'mountpoint')
# Validate size
if size:
@@ -184,6 +189,18 @@ def run(self, params, args):
if s < 0:
raise ParamValue(self, 'size', '>= 0')
+ # Validate partid
+ if partid:
+ try:
+ p = int(partid)
+ except:
+ partid = None
+
+ if p < 1:
+ raise ParamValue(self, 'partid', '>= 0')
+
+ partid = p
+
#
# look up the id in the appropriate 'scope' table
#
@@ -202,16 +219,22 @@ def run(self, params, args):
#
# make sure the specification for mountpt doesn't already exist
#
- self.checkIt(device, scope, tableid, mountpt)
+ if mountpt:
+ self.checkIt(device, scope, tableid, mountpt)
if not options:
options = ""
#
# now add the specifications to the database
#
+ sqlvars = "Scope, TableID, device, Mountpoint, Size, FsType, Options"
+ sqldata = "'%s', %s, '%s', '%s', %s, '%s', '%s'" % \
+ (scope, tableid, device, mountpt, size, fstype, options)
+
+ if partid:
+ sqlvars += ", PartID"
+ sqldata += ", %s" % partid
+
self.db.execute("""insert into storage_partition
- (Scope, TableID, device, Mountpoint,
- Size, FsType, Options) values ('%s', %s, '%s', '%s',
- %s, '%s', '%s') """ % (scope, tableid, device,
- mountpt, size, fstype, options))
+ (%s) values (%s) """ % (sqlvars, sqldata))
@@ -185,82 +185,39 @@ def run(self, params, args):
discovered_macs.append(a)
+ pre_config=self.command('list.host.interface',[host])
#
- # make sure all the MACs are in the database
+ # First, assign the correct names to the mac addresses
#
for (mac, interface, module, ks) in discovered_macs:
rows = self.db.execute("""select mac from networks
where mac = '%s' """ % (mac))
- if rows == 0:
- #
- # the mac is not in the database. but check
- # if the interface is already in the database.
- # if so, then we just need to set the MAC
- # for the interface.
- #
- rows = self.db.execute("""select * from
- networks where device = '%s' and
- node = (select id from nodes where
- name = '%s')""" % (interface, host))
-
- if rows == 1:
- self.command('set.host.interface.mac',
- (host, 'interface=%s' % interface,
- 'mac=%s' % mac))
- #
- # since the MAC changed, we are not
- # guaranteed that the module will be
- # correct. we need to clear out the
- # module field
- #
- self.command(
- 'set.host.interface.module',
- (host, 'interface=%s' % interface,
- 'module=NULL'))
- else:
- self.command('add.host.interface',
- (host, 'interface=%s' % interface,
- 'mac=%s' % mac))
+ if rows:
+ self.command('set.host.interface.interface',
+ [host, 'interface=%s' % interface, 'mac=%s' % mac])
+ else:
+ continue
- sync_config = 1
+ if module:
+ self.command('set.host.interface.module',
+ [host, 'interface=%s' % interface, 'module=%s' % module])
#
- # update the interface-to-mac mapping
+ # Add any missing/new interfaces to the database
#
for (mac, interface, module, ks) in discovered_macs:
- self.command('set.host.interface.interface',
- (host, 'interface=%s' % interface,
- 'mac=%s' % mac))
-
- #
- # let's see if the private interface moved
- #
- for (mac, interface, module, ks) in discovered_macs:
- if ks != 'ks':
- continue
-
- rows = self.db.execute("""select mac,device from
- networks where subnet = (select id from
- subnets where name = 'private') and node =
- (select id from nodes where name = '%s') """
- % (host))
-
- if rows == 1:
- (old_mac, old_interface) = self.db.fetchone()
+ rows = self.db.execute("""select mac from networks
+ where mac = '%s' """ % (mac))
+ if not rows:
+ self.command('add.host.interface',
+ [host, 'interface=%s' % interface, 'mac=%s' % mac, ])
+ if module:
+ self.command('set.host.interface.module',
+ [host, 'interface=%s' % interface, 'module=%s' % module])
- if old_mac != mac:
- #
- # the private network moved. swap the
- # networking info for these two
- # interfaces
- #
- self.command('swap.host.interface',
- (host, 'sync-config=no',
- 'interfaces=%s,%s' %
- (old_interface, interface)))
- sync_config = 1
+ post_config=self.command('list.host.interface',[host])
- if sync_config:
+ if pre_config != post_config:
self.command('sync.config')
@@ -125,21 +125,21 @@ def run(self, params, args):
query = None
if scope == 'global':
if globalOnlyFlag:
- query = """select scope, device, mountpoint, size, fstype, options
+ query = """select scope, device, mountpoint, size, fstype, options, partid
from storage_partition
where scope = 'global'
order by fstype, size"""
else:
- query = """(select scope, device, mountpoint, size, fstype, options
+ query = """(select scope, device, mountpoint, size, fstype, options, partid
from storage_partition
where scope = 'global'
order by fstype, size) UNION ALL
(select a.name, p.device, p.mountpoint, p.size,
- p.fstype, p.options from storage_partition as p inner join
+ p.fstype, p.options, p.partid from storage_partition as p inner join
nodes as a on p.tableid=a.id where p.scope='host'
order by p.fstype, p.size) UNION ALL
(select a.name, p.device, p.mountpoint, p.size,
- p.fstype, p.options from storage_partition as p inner join
+ p.fstype, p.options, p.partid from storage_partition as p inner join
appliances as a on p.tableid=a.id where
p.scope='appliance' order by p.fstype, p.size)"""
elif scope == 'os':
@@ -148,13 +148,13 @@ def run(self, params, args):
#
return
elif scope == 'appliance':
- query = """select scope, device, mountpoint, size, fstype,
- options from storage_partition where scope = "appliance"
+ query = """select scope, device, mountpoint, size, fstype, options, partid
+ from storage_partition where scope = "appliance"
and tableid = (select id from appliances
where name = '%s') order by fstype, size""" % args[0]
elif scope == 'host':
- query = """select scope, device, mountpoint, size, fstype,
- options from storage_partition where scope="host" and
+ query = """select scope, device, mountpoint, size, fstype, options, partid
+ from storage_partition where scope="host" and
tableid = (select id from nodes
where name = '%s') order by fstype, size""" % args[0]
@@ -167,16 +167,27 @@ def run(self, params, args):
i = 0
for row in self.db.fetchall():
- name, device, mountpoint, size, fstype, options = row
+ name, device, mountpoint, size, fstype, options, partid = row
if size == -1:
size = "recommended"
elif size == -2:
size = "hibernation"
+
if name == "host" or name == "appliance":
name = args[0]
- self.addOutput(name, [ device, mountpoint,
- size, fstype, options])
+
+ if mountpoint == 'None':
+ mountpoint = None
+
+ if fstype == 'None':
+ fstype = None
+
+ if partid == 0:
+ partid = None
+
+ self.addOutput(name, [device, partid, mountpoint,
+ size, fstype, options, partid])
i += 1
- self.endOutput(header=['scope', 'device', 'mountpoint', 'size',
- 'fstype', 'options'], trimOwner = 0)
+
+ self.endOutput(header=['scope', 'device', 'partid', 'mountpoint', 'size', 'fstype', 'options'], trimOwner = 0)
@@ -149,8 +149,10 @@ def run(self, args):
params = []
for host in hosts:
params.append(host)
- params.append('all=true')
- self.owner.call('remove.host.interface', params)
+ # only remove all interfaces from hosts if hostnames were actually specified *cough*
+ if params:
+ params.append('all=true')
+ self.owner.call('remove.host.interface', params)
for host in hosts:
Oops, something went wrong.

0 comments on commit dbd5a7d

Please sign in to comment.