mirror of
https://github.com/Telecominfraproject/OpenNetworkLinux.git
synced 2025-12-27 02:04:43 +00:00
Merge branch 'master' of github.com:opencomputeproject/OpenNetworkLinux into roth_install_hook
This commit is contained in:
@@ -1,2 +1 @@
|
||||
DIRECTORIES := rootfs swi installer
|
||||
include $(ONL)/make/subdirs.mk
|
||||
include $(ONL)/make/arch-build.mk
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
DIRECTORIES := rootfs swi installer
|
||||
include $(ONL)/make/subdirs.mk
|
||||
include $(ONL)/make/arch-build.mk
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
DIRECTORIES := rootfs swi installer
|
||||
include $(ONL)/make/subdirs.mk
|
||||
include $(ONL)/make/arch-build.mk
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
DIRECTORIES := rootfs swi installer
|
||||
include $(ONL)/make/subdirs.mk
|
||||
include $(ONL)/make/arch-build.mk
|
||||
|
||||
3
make/.gitignore
vendored
3
make/.gitignore
vendored
@@ -1,3 +1,4 @@
|
||||
versions/
|
||||
module-manifest.mk
|
||||
modules/module*
|
||||
|
||||
|
||||
|
||||
9
make/arch-build.mk
Normal file
9
make/arch-build.mk
Normal file
@@ -0,0 +1,9 @@
|
||||
DIRECTORIES := rootfs swi installer
|
||||
include $(ONL)/make/subdirs.mk
|
||||
|
||||
.PHONY: swi
|
||||
|
||||
swi:
|
||||
$(MAKE) -C rootfs
|
||||
$(MAKE) -C swi
|
||||
|
||||
@@ -26,8 +26,11 @@ export ONL_DEBIAN_SUITE_$(ONL_DEBIAN_SUITE)=1
|
||||
|
||||
export BUILD_DIR_BASE=BUILD/$(ONL_DEBIAN_SUITE)
|
||||
|
||||
# Generate manifest if necessary
|
||||
export MODULEMANIFEST := $(shell $(BUILDER)/tools/mmg.py $(ONL)/make/mmg.yml $(ONL) --only-if-missing)
|
||||
|
||||
# Use the new module database tool to resolve dependencies dynamically.
|
||||
export BUILDER_MODULE_DATABASE := $(ONL)/make/modules/modules.json
|
||||
# Regenerate the module manifest if necessary.
|
||||
export MODULEMANIFEST := $(shell $(BUILDER)/tools/modtool.py --db $(BUILDER_MODULE_DATABASE) --dbroot $(ONL) --make-manifest $(ONL)/make/modules/modules.mk)
|
||||
|
||||
# Generate versions if necessary.
|
||||
$(shell $(ONL)/tools/make-versions.py --import-file=$(ONL)/tools/onlvi --class-name=OnlVersionImplementation --output-dir $(ONL)/make/versions)
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
directories:
|
||||
- .
|
||||
|
||||
manifest: make/module-manifest.mk
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
1
make/modules/README
Normal file
1
make/modules/README
Normal file
@@ -0,0 +1 @@
|
||||
This directory contains the module database files generated at build time.
|
||||
4
packages/base/all/vendor-config-onl/src/bin/onl-boot-config
Executable file
4
packages/base/all/vendor-config-onl/src/bin/onl-boot-config
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/python
|
||||
############################################################
|
||||
from onl.bootconfig import OnlBootConfigNet
|
||||
OnlBootConfigNet().main("onl-boot-config")
|
||||
34
packages/base/all/vendor-config-onl/src/bin/onl-onie-boot-mode
Executable file
34
packages/base/all/vendor-config-onl/src/bin/onl-onie-boot-mode
Executable file
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/python
|
||||
############################################################
|
||||
import sys
|
||||
import platform
|
||||
import argparse
|
||||
import onl.grub
|
||||
|
||||
if platform.machine() != 'x86_64':
|
||||
sys.stderr.write("This command can only be used on GRUB-based X86_64 architectures.")
|
||||
sys.exit(1)
|
||||
|
||||
ap = argparse.ArgumentParser("onl-onie-boot-mode")
|
||||
|
||||
ap.add_argument("mode", choices=onl.grub.ONIE_BOOT_MODES)
|
||||
ap.add_argument("--onie-only", action='store_true', help="Do not set ONIE boot menu option.")
|
||||
|
||||
ops = ap.parse_args()
|
||||
|
||||
onl.grub.onie_boot_mode_set(ops.mode)
|
||||
|
||||
if not ops.onie_only:
|
||||
onl.grub.boot_onie()
|
||||
print "The system will boot into ONIE %s mode at the next restart." % ops.mode
|
||||
else:
|
||||
print "Mode %s will be selected the next time the system boots into ONIE." % ops.mode
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
3
packages/base/all/vendor-config-onl/src/bin/onlfs
Executable file
3
packages/base/all/vendor-config-onl/src/bin/onlfs
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/usr/bin/python
|
||||
from onl.mounts import OnlMountManager
|
||||
OnlMountManager.main('onlfs')
|
||||
5
packages/base/all/vendor-config-onl/src/bin/onlswi
Executable file
5
packages/base/all/vendor-config-onl/src/bin/onlswi
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
############################################################
|
||||
onlfs mount images --rw
|
||||
(cd /mnt/onl/images && rm *.swi && wget $1)
|
||||
onlfs mount images
|
||||
217
packages/base/all/vendor-config-onl/src/python/onl/bootconfig/__init__.py
Executable file
217
packages/base/all/vendor-config-onl/src/python/onl/bootconfig/__init__.py
Executable file
@@ -0,0 +1,217 @@
|
||||
#!/usr/bin/python
|
||||
############################################################
|
||||
import os
|
||||
import sys
|
||||
import netaddr
|
||||
|
||||
class OnlBootConfig(object):
|
||||
BOOT_CONFIG_DEFAULT='/mnt/onl/boot/boot-config'
|
||||
|
||||
def __init__(self):
|
||||
self.keys = {}
|
||||
self.__classmethod("init")
|
||||
|
||||
def _readf(self, fname):
|
||||
with open(fname) as f:
|
||||
for line in f.readlines():
|
||||
(k,d,v) = line.partition('=')
|
||||
if d == '=':
|
||||
self.keys[k] = v.strip()
|
||||
self._original = self.keys.copy()
|
||||
|
||||
def read(self, bc=None):
|
||||
if bc is None:
|
||||
bc = self.BOOT_CONFIG_DEFAULT
|
||||
self._readf(bc)
|
||||
|
||||
def set(self, k, v):
|
||||
self.keys[k] = v
|
||||
|
||||
def get(self, k, d=None):
|
||||
return self.keys.get(k, d)
|
||||
|
||||
def delete(self, k):
|
||||
self.keys.pop(k, None)
|
||||
|
||||
def _writeh(self, handle):
|
||||
for (k, v) in self.keys.iteritems():
|
||||
handle.write("%s=%s\n" % (k, v))
|
||||
|
||||
def _writef(self, f):
|
||||
with open(f, "w") as f:
|
||||
self._writeh(f)
|
||||
|
||||
def write(self, dst=None):
|
||||
self.validate()
|
||||
if dst:
|
||||
self._writef(dst)
|
||||
else:
|
||||
from onl.mounts import OnlMountContextReadWrite
|
||||
with OnlMountContextReadWrite("ONL-BOOT", logger=None):
|
||||
self._writef(self.BOOT_CONFIG_DEFAULT)
|
||||
|
||||
|
||||
def __classmethod(self, name, *args):
|
||||
for attr in dir(self):
|
||||
if attr.endswith("__%s" % name):
|
||||
getattr(self, attr)(*args)
|
||||
|
||||
def validate(self):
|
||||
return self.__classmethod("validate")
|
||||
|
||||
def argparse_init(self, ap):
|
||||
ap.add_argument("--read", help="Read the given file instead of the default [ %s ]." % OnlBootConfig.BOOT_CONFIG_DEFAULT)
|
||||
ap.add_argument("--write", help="Write the given file instead of the default [ %s ]." % OnlBootConfig.BOOT_CONFIG_DEFAULT)
|
||||
ap.add_argument("--show", help="Show the configuration.", action='store_true')
|
||||
self.__classmethod("argparse_init", ap)
|
||||
ap.add_argument("--dry", help='Show changes but do not update.', action='store_true')
|
||||
|
||||
def argparse_process(self, ops):
|
||||
self.read(ops.read)
|
||||
if(ops.show):
|
||||
self._writeh(sys.stdout)
|
||||
return self.__classmethod("argparse_process", ops)
|
||||
|
||||
def argparse_write(self, ops):
|
||||
try:
|
||||
if ops.dry:
|
||||
print self.keys
|
||||
self.validate()
|
||||
else:
|
||||
self.write(ops.write)
|
||||
if not ops.write and self.keys != self._original:
|
||||
print "You must reboot the switch before these changes will take affect."
|
||||
|
||||
except Exception, e:
|
||||
print e
|
||||
print "The boot configuration has not been changed."
|
||||
|
||||
|
||||
def main(self, name):
|
||||
import argparse
|
||||
ap = argparse.ArgumentParser("name")
|
||||
self.argparse_init(ap)
|
||||
ops = ap.parse_args()
|
||||
self.argparse_process(ops)
|
||||
self.argparse_write(ops)
|
||||
|
||||
|
||||
class OnlBootConfigNet(OnlBootConfig):
|
||||
|
||||
NET_REQUIRED = False
|
||||
|
||||
def netauto_set(self):
|
||||
self.delete('NETIP')
|
||||
self.delete('NETMASK')
|
||||
self.delete('NETGW')
|
||||
self.set('NETAUTO', 'dhcp')
|
||||
|
||||
def netip_set(self, addr):
|
||||
self.delete('NETAUTO')
|
||||
self.keys['NETIP'] = addr
|
||||
|
||||
def netmask_set(self, mask):
|
||||
self.delete('NETAUTO')
|
||||
self.keys['NETMASK'] = mask
|
||||
|
||||
def netgw_set(self, gw):
|
||||
self.delete('NETAUTO')
|
||||
self.keys['NETGW'] = gw
|
||||
|
||||
def __validate(self):
|
||||
if 'NETAUTO' not in self.keys:
|
||||
|
||||
netip = self.keys.get('NETIP', None)
|
||||
if netip:
|
||||
if not self.is_ip_address(netip):
|
||||
raise ValueError("NETIP=%s is not a valid ip-address" % (netup))
|
||||
elif self.NET_REQUIRED:
|
||||
raise ValueError("No IP configuration set for the management interface.")
|
||||
|
||||
netmask = self.keys.get('NETMASK', None)
|
||||
if netmask:
|
||||
if not self.is_netmask(netmask):
|
||||
raise ValueError("NETMASK=%s is not a valid netmask." % (netmask))
|
||||
elif self.NET_REQUIRED:
|
||||
raise ValueError("No Netmask configured for the management interface.")
|
||||
|
||||
netgw = self.keys.get('NETGW', None)
|
||||
if netgw:
|
||||
if not self.is_ip_address(netgw):
|
||||
raise ValueError("NETGW=%s is not a valid ip-address." % (netgw))
|
||||
elif self.NET_REQUIRED:
|
||||
raise ValueError("No gateway configured for the management interface.")
|
||||
|
||||
if netip and netmask and netgw:
|
||||
net = netaddr.IPNetwork("%s/%s" % (netip, netmask))
|
||||
if netaddr.IPAddress(netgw) not in net:
|
||||
raise ValueError("Gateway provided is not within the management network %s" % net)
|
||||
elif netip or netmask or netgw:
|
||||
raise ValueError("Incomplete static network configuration. NETIP, NETMASK, and NETGW must all be set.")
|
||||
|
||||
elif self.keys['NETAUTO'] not in ['dhcp', 'up']:
|
||||
raise ValueError("The NETAUTO value '%s' is invalid." % self.keys['NETAUTO'])
|
||||
elif self.keys['NETAUTO'] == 'up' && self.NET_REQUIRED:
|
||||
raise ValueError("NETAUTO is 'up' but non-local networking is required.")
|
||||
|
||||
if 'NETDEV' not in self.keys:
|
||||
self.keys['NETDEV'] = 'ma1'
|
||||
|
||||
return True
|
||||
|
||||
@staticmethod
|
||||
def is_ip_address(value):
|
||||
try:
|
||||
netaddr.IPAddress(value)
|
||||
return value
|
||||
except (netaddr.core.AddrFormatError, ValueError):
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
def is_netmask(value):
|
||||
try:
|
||||
if not netaddr.IPAddress(value).is_netmask():
|
||||
return False
|
||||
return value
|
||||
except (netaddr.core.AddrFormatError, ValueError):
|
||||
return False
|
||||
|
||||
@staticmethod
|
||||
def argparse_type_is_ip_address(value):
|
||||
if not OnlBootConfigNet.is_ip_address(value):
|
||||
import argparse
|
||||
raise argparse.ArgumentTypeError("%s is not a valid address." % value)
|
||||
return value
|
||||
|
||||
@staticmethod
|
||||
def argparse_type_is_netmask(value):
|
||||
if not OnlBootConfigNet.is_netmask(value):
|
||||
import argparse
|
||||
raise argparse.ArgumentTypeError("%s is not a valid netmask." % value)
|
||||
return value
|
||||
|
||||
def __argparse_init(self, ap):
|
||||
ap.add_argument("--dhcp", action='store_true', help="Use DHCP on the management interface.")
|
||||
ap.add_argument("--ip", help='Set static IP address for the management interface.', type=OnlBootConfigNet.argparse_type_is_ip_address)
|
||||
ap.add_argument("--netmask", help='Set the static netmask for the management interface.', type=OnlBootConfigNet.argparse_type_is_netmask)
|
||||
ap.add_argument("--gateway", help='Set the gateway address.', type=OnlBootConfigNet.argparse_type_is_ip_address)
|
||||
|
||||
|
||||
def __argparse_process(self, ops):
|
||||
if ops.dhcp:
|
||||
self.netauto_set()
|
||||
|
||||
if ops.ip:
|
||||
self.netip_set(ops.ip)
|
||||
|
||||
if ops.netmask:
|
||||
self.netmask_set(ops.netmask)
|
||||
|
||||
if ops.gateway:
|
||||
self.netgw_set(ops.gateway)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
bc = OnlBootConfigNet()
|
||||
bc.main("onl-boot-config")
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
from onl.mounts import OnlOnieBootContext, OnlMountContextReadWrite
|
||||
import subprocess
|
||||
import os
|
||||
|
||||
ONIE_BOOT_MODES = [ 'install',
|
||||
'rescue',
|
||||
'uninstall',
|
||||
'update',
|
||||
'embed',
|
||||
'diag',
|
||||
'none'
|
||||
]
|
||||
|
||||
def onie_boot_mode_set(mode):
|
||||
if mode not in ONIE_BOOT_MODES:
|
||||
raise ValueError("%s is not a valid onie boot mode." % mode)
|
||||
|
||||
with OnlOnieBootContext() as ob:
|
||||
subprocess.check_call("%s/onie/tools/bin/onie-boot-mode -o %s" % (ob.directory, mode), shell=True)
|
||||
|
||||
def _makedirs(d):
|
||||
if not os.path.exists(d):
|
||||
os.makedirs(d)
|
||||
|
||||
def onie_fwpkg(arguments):
|
||||
with OnlOnieBootContext() as ob:
|
||||
# This is necessary if we've upgraded ONIE but haven't booted into it yet...
|
||||
_makedirs("%s/onie/update/pending" % ob.directory)
|
||||
_makedirs("%s/onie/update/attempts" % ob.directory)
|
||||
subprocess.check_call("%s/onie/tools/bin/onie-fwpkg %s" % (ob.directory, arguments), shell=True)
|
||||
|
||||
def boot_entry_set(index):
|
||||
with OnlMountContextReadWrite("ONL-BOOT", logger=None) as ob:
|
||||
subprocess.check_call("/usr/sbin/grub-set-default --boot-directory=%s %d" % (ob.directory, index), shell=True)
|
||||
|
||||
def boot_onie():
|
||||
return boot_entry_set(1)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -465,8 +465,17 @@ terminal_input serial
|
||||
terminal_output serial
|
||||
set timeout=5
|
||||
|
||||
# Always boot the saved_entry value
|
||||
load_env
|
||||
if [ "${saved_entry}" ] ; then
|
||||
set default="${saved_entry}"
|
||||
fi
|
||||
|
||||
menuentry %(boot_menu_entry)s {
|
||||
search --no-floppy --label --set=root ONL-BOOT
|
||||
# Always return to this entry by default.
|
||||
set saved_entry="0"
|
||||
save_env saved_entry
|
||||
echo 'Loading %(boot_loading_name)s ...'
|
||||
insmod gzio
|
||||
insmod part_msdos
|
||||
@@ -477,6 +486,9 @@ menuentry %(boot_menu_entry)s {
|
||||
# Menu entry to chainload ONIE
|
||||
menuentry ONIE {
|
||||
search --no-floppy --label --set=root ONIE-BOOT
|
||||
# Always return to entry 0 by default.
|
||||
set saved_entry="0"
|
||||
save_env saved_entry
|
||||
echo 'Loading ONIE ...'
|
||||
chainloader +1
|
||||
}
|
||||
|
||||
@@ -355,3 +355,15 @@ class OnlMountContextReadWrite(OnlMountContext):
|
||||
def __init__(self, label, logger):
|
||||
OnlMountContext.__init__(self, label, "rw", logger)
|
||||
|
||||
|
||||
class OnlOnieBootContext(MountContext):
|
||||
def __init__(self, mdir="/mnt/onie-boot", mode="rw", label="ONIE-BOOT", logger=None):
|
||||
try:
|
||||
device = subprocess.check_output("blkid -L %s" % label, shell=True).strip()
|
||||
except subprocess.CalledProcessError:
|
||||
self.logger.debug("Block label %s does not yet exist..." % label)
|
||||
raise
|
||||
if not os.path.exists(mdir):
|
||||
os.makedirs(mdir)
|
||||
MountContext.__init__(self, device, mdir, mode, logger)
|
||||
|
||||
|
||||
@@ -25,8 +25,12 @@ class FirmwareUpgrade(ubase.BaseOnieUpgrade):
|
||||
self.load_manifest(os.path.join(sysconfig.upgrade.firmware.package.dir, "manifest.json"))
|
||||
|
||||
def do_upgrade(self, forced=False):
|
||||
self.install_onie_updater(sysconfig.upgrade.firmware.package.dir,
|
||||
self.manifest['updater'])
|
||||
if self.manifest.get('fwpkg', False):
|
||||
self.onie_fwpkg_add(os.path.join(sysconfig.upgrade.firmware.package.dir,
|
||||
self.manifest['updater']))
|
||||
else:
|
||||
self.install_onie_updater(sysconfig.upgrade.firmware.package.dir,
|
||||
self.manifest['updater'])
|
||||
self.initiate_onie_update()
|
||||
|
||||
|
||||
|
||||
@@ -391,24 +391,23 @@ class BaseOnieUpgrade(BaseUpgrade):
|
||||
dst = os.path.join(self.ONIE_UPDATER_PATH, f)
|
||||
self.copyfile(src, dst)
|
||||
|
||||
def onie_fwpkg_add(self, pkg):
|
||||
import onl.grub
|
||||
onl.grub.onie_fwpkg("add %s" % pkg)
|
||||
onl.grub.onie_fwpkg("show")
|
||||
|
||||
def initiate_onie_update(self):
|
||||
self.logger.info("Initiating %s Update." % self.Name)
|
||||
|
||||
if self.arch == 'ppc':
|
||||
# Initiate update
|
||||
self.fw_setenv('onie_boot_reason', 'update')
|
||||
self.reboot()
|
||||
|
||||
elif self.arch == 'x86_64':
|
||||
OB = "/mnt/onie-boot"
|
||||
self.mount(OB, label="ONIE-BOOT")
|
||||
if os.system("/mnt/onie-boot/onie/tools/bin/onie-boot-mode -o update") != 0:
|
||||
self.abort("Could not set ONIE Boot Mode to Update. Upgrade cannot continue.")
|
||||
self.umount(OB)
|
||||
|
||||
with OnlMountContextReadWrite("ONL-BOOT", logger=None):
|
||||
with open("/mnt/onl/boot/grub/grub.cfg", "a") as f:
|
||||
f.write("set default=ONIE\n")
|
||||
import onl.grub
|
||||
onl.grub.onie_boot_mode_set("update")
|
||||
onl.grub.boot_onie()
|
||||
self.reboot()
|
||||
|
||||
else:
|
||||
|
||||
@@ -3,26 +3,13 @@ set -e
|
||||
|
||||
uninstall_x86_64()
|
||||
{
|
||||
#
|
||||
# Set ONIE boot selection to uninstall
|
||||
#
|
||||
mkdir -p /mnt/onie-boot
|
||||
mount -L ONIE-BOOT /mnt/onie-boot > /dev/null 2>&1
|
||||
|
||||
if [ "$1" = "factory" ]; then
|
||||
/mnt/onie-boot/onie/tools/bin/onie-boot-mode -o uninstall
|
||||
mode=uninstall
|
||||
else
|
||||
/mnt/onie-boot/onie/tools/bin/onie-boot-mode -o install
|
||||
mode=install
|
||||
fi
|
||||
|
||||
umount /mnt/onie-boot
|
||||
|
||||
#
|
||||
# Select ONIE as the boot default
|
||||
#
|
||||
onl-mounts mount boot --rw
|
||||
echo "set default=ONIE" >> /mnt/onl/boot/grub/grub.cfg
|
||||
onl-mounts mount boot
|
||||
onl-onie-boot-mode $mode
|
||||
}
|
||||
|
||||
uninstall_uboot()
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
name: onlplib
|
||||
depends: cjson
|
||||
|
||||
@@ -395,38 +395,53 @@ onlp_onie_show(onlp_onie_info_t* info, aim_pvs_t* pvs)
|
||||
}
|
||||
}
|
||||
|
||||
#include <cjson/cJSON.h>
|
||||
|
||||
void
|
||||
onlp_onie_show_json(onlp_onie_info_t* info, aim_pvs_t* pvs)
|
||||
{
|
||||
aim_printf(pvs, "{\n");
|
||||
cJSON* cj = cJSON_CreateObject();
|
||||
|
||||
#define STROUT(_name, _member) \
|
||||
do { \
|
||||
aim_printf(pvs, " \"%s\" : ", #_name); \
|
||||
if(info-> _member) { \
|
||||
aim_printf(pvs, "\"%s\",\n", info->_member); \
|
||||
} \
|
||||
else { \
|
||||
aim_printf(pvs, "null,\n"); \
|
||||
} \
|
||||
#define _S(_name, _member) \
|
||||
do { \
|
||||
if(info-> _member) { \
|
||||
cJSON_AddStringToObject(cj, #_name, info-> _member); \
|
||||
} else { \
|
||||
cJSON_AddNullToObject(cj, #_name); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
STROUT(Product Name, product_name);
|
||||
STROUT(Part Number, part_number);
|
||||
STROUT(Serial Number, serial_number);
|
||||
aim_printf(pvs, " \"MAC\": \"%{mac}\", ", info->mac);
|
||||
aim_printf(pvs, " \"MAC Range\": %d,\n", info->mac_range);
|
||||
STROUT(Manufacture Date,manufacture_date);
|
||||
STROUT(Vendor,vendor);
|
||||
STROUT(Platform Name,platform_name);
|
||||
aim_printf(pvs, " \"Device Version\": %u,\n", info->device_version);
|
||||
STROUT(Label Revision,label_revision);
|
||||
STROUT(Country Code,country_code);
|
||||
STROUT(Diag Version,diag_version);
|
||||
STROUT(Service Tag,service_tag);
|
||||
STROUT(ONIE Version,onie_version);
|
||||
aim_printf(pvs, " \"CRC\": \"0x%x\"\n", info->crc);
|
||||
aim_printf(pvs, "}\n");
|
||||
#define _N(_name, _member) \
|
||||
do { \
|
||||
cJSON_AddNumberToObject(cj, #_name, info-> _member); \
|
||||
} while(0)
|
||||
|
||||
_S(Product Name, product_name);
|
||||
_S(Part Number, part_number);
|
||||
_S(Serial Number, serial_number);
|
||||
{
|
||||
char* mac = aim_dfstrdup("%{mac}", info->mac);
|
||||
cJSON_AddStringToObject(cj, "MAC", mac);
|
||||
aim_free(mac);
|
||||
}
|
||||
_S(Manufacture Date,manufacture_date);
|
||||
_S(Vendor,vendor);
|
||||
_S(Platform Name,platform_name);
|
||||
_S(Label Revision,label_revision);
|
||||
_S(Country Code,country_code);
|
||||
_S(Diag Version,diag_version);
|
||||
_S(Service Tag,service_tag);
|
||||
_S(ONIE Version,onie_version);
|
||||
_N(Device Version, device_version);
|
||||
{
|
||||
char* crc = aim_fstrdup("0x%x", info->crc);
|
||||
cJSON_AddStringToObject(cj, "CRC", crc);
|
||||
aim_free(crc);
|
||||
}
|
||||
char* out = cJSON_Print(cj);
|
||||
aim_printf(pvs, "%s\n", out);
|
||||
free(out);
|
||||
cJSON_Delete(cj);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Submodule packages/platforms-closed updated: 70859b05b6...7084217321
@@ -52,6 +52,7 @@
|
||||
#define SFP_HWMON_NODE(node) SFP_HWMON_PREFIX#node
|
||||
#define SFP_HWMON_DOM_PREFIX "/sys/bus/i2c/devices/3-0051/"
|
||||
#define SFP_HWMON_DOM_NODE(node) SFP_HWMON_DOM_PREFIX#node
|
||||
#define SFP_BUS 3
|
||||
|
||||
int deviceNodeWriteInt(char *filename, int value, int data_len);
|
||||
int deviceNodeReadBinary(char *filename, char *buffer, int buf_size, int data_len);
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include <onlplib/i2c.h>
|
||||
#include "platform_lib.h"
|
||||
|
||||
static int
|
||||
@@ -333,6 +333,75 @@ onlp_sfpi_dom_read(int port, uint8_t data[256])
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_dev_readb(int port, uint8_t devaddr, uint8_t addr)
|
||||
{
|
||||
int rc;
|
||||
|
||||
if (set_active_port(port+1) != 0) {
|
||||
AIM_LOG_ERROR("Unable to set active port(%d)\r\n", port);
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
rc= onlp_i2c_readb(SFP_BUS, devaddr, addr, ONLP_I2C_F_FORCE);
|
||||
|
||||
set_active_port(0);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_dev_writeb(int port, uint8_t devaddr, uint8_t addr, uint8_t value)
|
||||
{
|
||||
int rc;
|
||||
|
||||
if (set_active_port(port+1) != 0) {
|
||||
AIM_LOG_ERROR("Unable to set active port(%d)\r\n", port);
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
rc = onlp_i2c_writeb(SFP_BUS, devaddr, addr, value, ONLP_I2C_F_FORCE);
|
||||
|
||||
set_active_port(0);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_dev_readw(int port, uint8_t devaddr, uint8_t addr)
|
||||
{
|
||||
int rc;
|
||||
|
||||
if (set_active_port(port+1) != 0) {
|
||||
AIM_LOG_ERROR("Unable to set active port(%d)\r\n", port);
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
rc= onlp_i2c_readw(SFP_BUS, devaddr, addr, ONLP_I2C_F_FORCE);
|
||||
|
||||
set_active_port(0);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_dev_writew(int port, uint8_t devaddr, uint8_t addr, uint16_t value)
|
||||
{
|
||||
int rc;
|
||||
|
||||
if (set_active_port(port+1) != 0) {
|
||||
AIM_LOG_ERROR("Unable to set active port(%d)\r\n", port);
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
rc = onlp_i2c_writew(SFP_BUS, devaddr, addr, value, ONLP_I2C_F_FORCE);
|
||||
|
||||
set_active_port(0);
|
||||
|
||||
return rc;
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value)
|
||||
{
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include <onlplib/i2c.h>
|
||||
#include "platform_lib.h"
|
||||
|
||||
#define MAX_SFP_PATH 64
|
||||
@@ -347,6 +347,34 @@ onlp_sfpi_dom_read(int port, uint8_t data[256])
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_dev_readb(int port, uint8_t devaddr, uint8_t addr)
|
||||
{
|
||||
int bus = front_port_to_cpld_mux_index(port);
|
||||
return onlp_i2c_readb(bus, devaddr, addr, ONLP_I2C_F_FORCE);
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_dev_writeb(int port, uint8_t devaddr, uint8_t addr, uint8_t value)
|
||||
{
|
||||
int bus = front_port_to_cpld_mux_index(port);
|
||||
return onlp_i2c_writeb(bus, devaddr, addr, value, ONLP_I2C_F_FORCE);
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_dev_readw(int port, uint8_t devaddr, uint8_t addr)
|
||||
{
|
||||
int bus = front_port_to_cpld_mux_index(port);
|
||||
return onlp_i2c_readw(bus, devaddr, addr, ONLP_I2C_F_FORCE);
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_dev_writew(int port, uint8_t devaddr, uint8_t addr, uint16_t value)
|
||||
{
|
||||
int bus = front_port_to_cpld_mux_index(port);
|
||||
return onlp_i2c_writew(bus, devaddr, addr, value, ONLP_I2C_F_FORCE);
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value)
|
||||
{
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include <onlplib/i2c.h>
|
||||
#include "platform_lib.h"
|
||||
|
||||
#define MAX_SFP_PATH 64
|
||||
@@ -347,6 +347,34 @@ onlp_sfpi_dom_read(int port, uint8_t data[256])
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_dev_readb(int port, uint8_t devaddr, uint8_t addr)
|
||||
{
|
||||
int bus = front_port_to_cpld_mux_index(port);
|
||||
return onlp_i2c_readb(bus, devaddr, addr, ONLP_I2C_F_FORCE);
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_dev_writeb(int port, uint8_t devaddr, uint8_t addr, uint8_t value)
|
||||
{
|
||||
int bus = front_port_to_cpld_mux_index(port);
|
||||
return onlp_i2c_writeb(bus, devaddr, addr, value, ONLP_I2C_F_FORCE);
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_dev_readw(int port, uint8_t devaddr, uint8_t addr)
|
||||
{
|
||||
int bus = front_port_to_cpld_mux_index(port);
|
||||
return onlp_i2c_readw(bus, devaddr, addr, ONLP_I2C_F_FORCE);
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_dev_writew(int port, uint8_t devaddr, uint8_t addr, uint16_t value)
|
||||
{
|
||||
int bus = front_port_to_cpld_mux_index(port);
|
||||
return onlp_i2c_writew(bus, devaddr, addr, value, ONLP_I2C_F_FORCE);
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value)
|
||||
{
|
||||
|
||||
2
sm/infra
2
sm/infra
Submodule sm/infra updated: b0e02165a7...b7974c19ed
@@ -58,7 +58,7 @@ if __name__ == "__main__":
|
||||
ModuleGenerator.main(globals().copy())
|
||||
|
||||
# Make sure the manifest gets regenerated.
|
||||
os.system("rm -rf %s/make/module-manifest.mk" % ROOT)
|
||||
os.system("rm -rf %s/make/modules/modules*" % ROOT)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,14 +2,11 @@
|
||||
############################################################
|
||||
#
|
||||
# Every time a merge is performed we should invalidate
|
||||
# the module manifest.
|
||||
# the module data.
|
||||
#
|
||||
############################################################
|
||||
mm="$GIT_DIR/../make/module-manifest.mk"
|
||||
|
||||
if [ -f "$mm" ]; then
|
||||
echo "Removing module manifest after merge..."
|
||||
rm "$mm"
|
||||
fi
|
||||
echo "Removing module data after merge..."
|
||||
rm -rf "$GIT_DIR/../make/modules/modules*"
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
############################################################
|
||||
|
||||
# Removing the manifest causes it to be regenerated.
|
||||
rm -rf $ONL/make/module-manifest.mk
|
||||
rm -rf $ONL/make/modules/module*
|
||||
|
||||
# Rebuild pkg cache
|
||||
onlpm.py --rebuild-pkg-cache
|
||||
|
||||
Reference in New Issue
Block a user