PDA

View Full Version : Insert MFS Record (subtree)



jasch
05-12-2005, 10:33 AM
I have this MFS record (under State/Network)



NetConfig 554910/10 {
Version = 1
Default = 1
HardwareAddress = 0 18 23 197 74 221
NetworkMedium = 5
IndexPath = /State/Network/005:554910
}


I need to insert a new subtree called IpParams (or object that has several object within itself), so It would look like this: (from another DVR)



NetConfig 126662/10 {
Version = 8
Default = 1
HardwareAddress = 0 9 91 26 195 71
IpParams = 126662/11
NetworkMedium = 4
IndexPath = /State/Network/004:126662
}


IpParams shoud look like this:



NetConfigIpParams 126662/11 {
AutoConfigEnabled = 0
DnsServers = 196.40.43.130
GatewayAddress = 192.168.0.1
HostAddress = 192.168.0.14
SubnetMask = 255.255.255.0
}


This would allow me to change IP configuration through MFS. I already coded a tcl script to change the contents of IpParams succesfully on 2 of my DVR's, but the 3rd one is missing IpParams altogether, and I haven't found a way to create the new mfs records.

Any help?

Thanks in advance.

NutKase
05-12-2005, 10:46 AM
the 3rd one is missing IpParams altogether, and I haven't found a way to create the new mfs records.

Disclaimer: I'm not an expert on tcl.

This sounds close, FindOrCreateObject or FindOrCreateSubObject (http://www.dealdatabase.com/forum/showthread.php?s=&threadid=1961)


NutKase

jasch
05-12-2005, 10:55 AM
It seems those commands are to be typed directly from tivosh, unfortunately they need other parameters not documented on that thread.

I was looking for a way to create the subobject through a TCL script.

Right now I am looking through several tcl script I have collected over the years...

psxboy
05-12-2005, 10:58 AM
Look at the insertion functions in MFS_FTP... it has to create Recording objects, etc. from scratch. You should be able to get a lot of mileage out of that.

EDIT: Or... I could look for you. ;)

This piece appears to illustrate what you want to do:


set showing [db $db createsub Showing $recording]
dbobj $showing set Date $date ; dbobj $showing set Duration 60
dbobj $showing set Station $station ; dbobj $showing set Time $time
dbobj $recording set Showing $showing ; dbobj $recording set StreamFileSize 0

You'll need to munge things to match what you want it to do, but the relevent parts are the "createsub" command (to create a sub-object under another object), "set" your data in that sub-object, and finally "set" the link to the sub-object in the main object. Seems to me that you need to create the sub-object and link to it from the main object all in the same transaction or it'll be rubbished, IIRC.

-psxboy

Jamie
05-12-2005, 11:18 AM
It seems those commands are to be typed directly from tivosh, unfortunately they need other parameters not documented on that thread.

I was looking for a way to create the subobject through a TCL script.You can use them in a script just fine. Look at /tvlib/tcl/tv/mfslib.tcl, where they are defined. Also, if you just try commands from an interactive tivosh, you'll often get usage information:
bash-2.02# tivosh
% FindOrCreateSubObject
wrong # args: should be "FindOrCreateSubObject object subtype field"

Right now I am looking through several tcl script I have collected over the years...Be sure to look at the tivo provided scripts under /tvlib.

jasch
05-12-2005, 12:58 PM
set showing [db $db createsub Showing $recording]
dbobj $showing set Date $date ; dbobj $showing set Duration 60
dbobj $showing set Station $station ; dbobj $showing set Time $time
dbobj $recording set Showing $showing ; dbobj $recording set StreamFileSize 0

Right now I am trying to figure out this code (I looked at it briefly yesterday) Mainly I would like to know "where" is Showing created...

I mean, I need to find out a way to specify that "Showing" (for example) need to be created in /State/Network/xxx:yyyy

Jamie
05-12-2005, 01:33 PM
I mean, I need to find out a way to specify that "Showing" (for example) need to be created in /State/Network/xxx:yyyy
MFS is "magic" that way: When you create objects of a certain type, they automatically link themselves into the MFS hierarchy in the appropriate place.

You have to be a little careful about this. I know in this (http://www.dealdatabase.com/forum/showthread.php?t=40179&highlight=DiskConfiguration) thread we found that DiskConfiguration objects created from scripts would mysteriously disappear after a few days if they weren't also linked under /Server with a ServerId. Our solution there was to 'hijack' an existing DiskConfiguration object rather than creating a new one.

psxboy
05-12-2005, 01:47 PM
Right now I am trying to figure out this code (I looked at it briefly yesterday) Mainly I would like to know "where" is Showing created...

I mean, I need to find out a way to specify that "Showing" (for example) need to be created in /State/Network/xxx:yyyy
That is only a snippet of a full transaction. But you'll notice that Showing is created as a subobject of $recording, which is defined earlier in the script (not in the snippet).

Here's how you would do it in a transaction:


set db [dbopen]

RetryTransaction {

set netcfg [db $db openid 554910]
set ipparam [db $db createsub NetConfigIpParams $netcfg]
dbobj $ipparam set AutoConfigEnabled 1
dbobj $ipparam set DnsServers 196.40.43.130
dbobj $ipparam set GatewayAddress 192.168.0.1
dbobj $ipparam set HostAddress 192.168.0.14
dbobj $ipparam set SubnetMask 255.255.255.0
dbobj $netcfg set IpParams $ipparam
}

In this case, I had to use the explicit FSID for your NetConfig object since on my system the NetConfig object was named weird in State/Network/. But otherwise, you can refer to the object by its name & use [db $db open <object_name>] on the first line.

-psxboy

jasch
05-12-2005, 01:59 PM
In this case, I had to use the explicit FSID for your NetConfig object since on my system the NetConfig object was named weird in State/Network/. But otherwise, you can refer to the object by its name & use [db $db open <object_name>] on the first line.

No sweat, I already created the routine that grabs the current FSID for the specific TiVo.

I got this error running your code



can't open object (0x70003)

while executing
"db $db open $ipparam"
("uplevel" body line 9)
invoked from within
"uplevel $body"
invoked from within
"transaction {uplevel $body}"
(procedure "RetryTransaction" line 5)
invoked from within
"RetryTransaction {
set netcfg [db $db openid 554910]
set ipparam [db $db createsub NetConfigIpParams $netcfg]
dbobj $ipparam s..."
(file "./set_ip.tcl" line 20)

psxboy
05-12-2005, 02:18 PM
I got this error running your code



can't open object (0x70003)

while executing
"db $db open $ipparam"
("uplevel" body line 9)
...

Hrm... probably need to use something other than "open" in the last transaction line. Try with "openobj" or "openid" instead. (Don't have my Tivo tcl references handy.)

EDIT: Duh! Try changing the last transaction line to this instead:


dbobj $netcfg set IpParams $ipparam

-psxboy

jasch
05-12-2005, 02:24 PM
Hrm... probably need to use something other than "open" in the last transaction line. Try with "openobj" or "openid" instead. (Don't have my Tivo tcl references handy.)

openobj says:
no such db command: openobj
while executing
"db $db openobj $ipparam"

openid says:
expected integer but got "dbobj4"
while executing
"db $db openid $ipparam"

I'll give a try later tonight...

psxboy
05-12-2005, 03:55 PM
Did you notice the edit on my previous post? Try the line as I provided in the edit at the bottom:


dbobj $netcfg set IpParams $ipparam

($ipparam is already a handle to an open object, so no need to "open" it again.)

-psxboy

tyke
05-12-2005, 04:25 PM
psxboy-

I tried your edited code (setting my proper FSID) and renamed dhclient.
rebooted
I did not get an IP address.

So, I modified the 'dbobj $ipparam set AutoConfigEnabled 1' by changing the 1 to 0

Rebooted and it worked!

Thanks!

jasch
05-12-2005, 04:26 PM
Since I am not expecting to get an IP (not using DHCP), I guess I can let it at 0?

jasch
05-12-2005, 04:31 PM
Rebooted and it worked!

I got it working now. Only one to find out if it works right? <grin>

BTW. How would I delete the entire IpParams object? (to start again, or revert to original defaults).

Thanks

psxboy
05-12-2005, 04:32 PM
Since I am not expecting to get an IP (not using DHCP), I guess I can let it at 0?
That'd be my guess.

Disclaimer: I'm not vouching for the functionality of the newly created sub-object; I only provided a way to create the sub-object containing the data you provided.

-psxboy

jasch
05-12-2005, 04:35 PM
BTW, did you check out this script:

http://www.dealdatabase.com/forum/showthread.php?t=43375&goto=newpost

It seems to do the same I was trying to acomplish :-)

psxboy
05-12-2005, 04:38 PM
BTW. How would I delete the entire IpParams object? (to start again, or revert to original defaults).
You'd use one of the "rubbish" commands in a transaction similar to the one you used to create the object. Offhand, I remember "rubbishobj" & "rubbishbyid" or something similar to those. I don't have any readily available samples, nor do I have my tcl reference handy, but I can give you a definitive answer later tonight. (If you don't figure it out on your own by then.) :)

-psxboy

psxboy
05-12-2005, 04:48 PM
BTW, did you check out this script:

http://www.dealdatabase.com/forum/showthread.php?t=43375&goto=newpost

It seems to do the same I was trying to acomplish :-)
hehe... Yeah, I actually posted to that thread shortly after I wrote the transaction for this one basically giving him the same info. Then someone else fixed up his script with those suggestions & posted it.

Things sure do move fast around here, huh? :)

-psxboy

psxboy
05-12-2005, 08:10 PM
Ok... here's the deletion transaction. It will mark your IpParams sub-object as rubbish, causing it to be removed at the next garbage collection cycle:


set db [dbopen]

RetryTransaction {

set netcfg [db $db openid 554910]
set ipparam [dbobj $netcfg get IpParams]
dbobj $ipparam markasrubbish
dbobj $netcfg remove IpParams
}

Disclaimer: BE VERY CAREFUL DELETING THINGS FROM MFS! In the example above, I used a hard-coded FSID that was provided by the original poster. If you plan on using this example yourself, verify/change the FSID (or generate it some other way) before blindly rubbishing db objects!!! You've been warned.

-psxboy