Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

is open5gs-dbctl works whit Mongo v6 ? #2061

Open
infercom2 opened this issue Feb 8, 2023 · 6 comments
Open

is open5gs-dbctl works whit Mongo v6 ? #2061

infercom2 opened this issue Feb 8, 2023 · 6 comments
Labels
Help Wanted Maintainers are not working on this issue so community help is wanted. Housekeeping:FR-Toreview Housekeeping: Feature requests to review type:enhancement Enhance performance or improve usability of original features.

Comments

@infercom2
Copy link
Contributor

Hi, I was using open5gs-dbctl with mongo v4 but when open5gs update to use mongo v6, to interact with mongo by the shell now we need to use mongosh, and the architecture of open5gs db subscriber changed.
Mongo4:

mongo --eval "db.subscribers.find({\"imsi\":\"994050700000220612\"}).pretty()" --quiet open5gs
{
  "_id" : ObjectId("6390d6a1b0ddxxxxxxbac45e"),
  "imsi" : "994050700000220612",
  "access_restriction_data" : 32,
  "ambr" : {
    "downlink" : {
      "value" : 55,
      "unit" : 2
    },
    "uplink" : {
      "value" : 240,
      "unit" : 2
    }
  },
  "network_access_mode" : 0,
  "security" : {
    "k" : "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "amf" : "8000",
    "op" : null,
    "opc" : "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "sqn" : NumberLong(5223)
  },
  "slice" : [
    {
      "sst" : 1,
      "default_indicator" : true,
      "session" : [
        {
          "name" : "internet",
          "type" : 1,
          "qos" : {
            "index" : 9,
            "arp" : {
              "priority_level" : 8,
              "pre_emption_capability" : 1,
              "pre_emption_vulnerability" : 2
            }
          },
          "ambr" : {
            "downlink" : {
              "value" : 5000000,
              "unit" : 0
            },
            "uplink" : {
              "value" : 5000000,
              "unit" : 0
            }
          },
          "ue" : {
            "addr" : "192.168.0.92"
          },
          "pcc_rule" : [ ],
          "_id" : ObjectId("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
        }
      ],
      "_id" : ObjectId("xxxxxxxxxxxxxxxxxxxx")
    }
  ],
  "subscribed_rau_tau_timer" : 12,
  "subscriber_status" : 0,
  "imeisv" : "xxxxxxxxxxxxxxx"
}

Mongo6:

mongosh --eval "db.subscribers.find({\"imsi\":\"994050700000220612\"}).pretty()" --quiet open5gs
[
  {
    _id: ObjectId("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"),
    schema_version: 1,
    imsi: '99405070000220612',
    msisdn: [],
    imeisv: [],
    mme_host: [],
    mme_realm: [],
    purge_flag: [],
    security: {
      k: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
      op: null,
      opc: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
      amf: '8000'
    },
    ambr: { downlink: { value: 10, unit: 2 }, uplink: { value: 5, unit: 2 } },
    slice: [
      {
        sst: 1,
        default_indicator: true,
        session: [
          {
            name: 'internet',
            type: 1,
            qos: { index: 9, arp: [Object] },
            ambr: { downlink: [Object], uplink: [Object] },
            pcc_rule: [],
            _id: ObjectId("xxxxxxxxxxxxxxxxxxxxx")
          }
        ],
        _id: ObjectId("xxxxxxxxxxxxxxxxxxxx")
      }
    ],
    access_restriction_data: 32,
    subscriber_status: 0,
    network_access_mode: 0,
    subscribed_rau_tau_timer: 12,
    __v: 0
  }
]

https://github.com/open5gs/open5gs/blob/main/misc/db/open5gs-dbctl

@acetcom acetcom added the Help Wanted Maintainers are not working on this issue so community help is wanted. label Feb 9, 2023
@pobk pobk added the Housekeeping:Discussion Housekeeping: issue should be discussion label Feb 18, 2023
@acetcom acetcom added type:enhancement Enhance performance or improve usability of original features. Housekeeping:FR-Toreview Housekeeping: Feature requests to review and removed Housekeeping:Discussion Housekeeping: issue should be discussion labels Feb 19, 2023
@infercom2
Copy link
Contributor Author

Hi, I' trying to adapt the code to the new version mongo, I attach a script It works to insert if a subscriber doesn't exist.
open5gs-insert-user-example.txt

But if you check the structure of it in mongo :

mongosh --eval "db.subscribers.find({ \"imsi\":\"334070000000894\"})" --quiet open5gs
[
  {
    _id: ObjectId("640902b8fcb0343959e38da0"),
    imsi: '334070000000894',
    __v: 0,
    access_restriction_data: 32,
    ambr: {
      downlink: { value: 1000000000, unit: 0 },
      uplink: { value: 1000000000, unit: 0 }
    },
    imeisv: [],
    mm_realm: [],
    mme_host: [],
    msisdn: [],
    network_access_mode: 0,
    purge_flag: [],
    schema_version: 1,
    security: {
      k: '00001234567891234567222222289A',
      op: null,
      opc: '000012345678912344444444ED12',
      amf: '8000'
    },
    slice: [
      {
        sst: 1,
        default_indicator: true,
        session: [
          {
            name: 'internet',
            type: 1,
            qos: { index: 9, arp: [Object] },
            ambr: { downlink: [Object], uplink: [Object] },
            ue: { addr: '10.45.1.94' },
            pcc_rule: [],
            _id: ObjectId("640902b70c4c812d87bd1954")
          }
        ],
        _id: ObjectId("640902b70c4c812d87bd1955")
      }
    ],
    subscribed_rau_tau_timer: 12,
    subscriber_status: 0
  }
]

If I use insertOne mongo structure looks like when I add a subscriber by the webui:

[
  {
    _id: ObjectId("6409052a36f0a9e98766b262"),
    schema_version: 1,
    imsi: '334070000000895',
    msisdn: [],
    imeisv: [],
    mme_host: [],
    mm_realm: [],
    purge_flag: [],
    security: {
      k: '000012341231412414214211389123456789A',
      op: null,
      opc: '0000123456712312421321312339123456789A',
      amf: '8000'
    },
    ambr: {
      downlink: { value: 1000000000, unit: 0 },
      uplink: { value: 1000000000, unit: 0 }
    },
    slice: [
      {
        sst: 1,
        default_indicator: true,
        session: [
          {
            name: 'internet',
            type: 1,
            qos: { index: 9, arp: [Object] },
            ambr: { downlink: [Object], uplink: [Object] },
            ue: { addr: '10.45.1.95' },
            pcc_rule: [],
            _id: ObjectId("6409052a36f0a9e98766b263")
          }
        ],
        _id: ObjectId("6409052a36f0a9e98766b264")
      }
    ],
    access_restriction_data: 32,
    subscriber_status: 0,
    network_access_mode: 0,
    subscribed_rau_tau_timer: 12,
    __v: 0
  }
]

I have this script with inserOne :

#!/bin/bash		

		mongosh --eval "db.subscribers.insertOne(
			{
				\"_id\" : new ObjectId(),
				\"schema_version\" : NumberInt(1),
				\"imsi\" : \"334070000000895\",
				\"msisdn\": [],
				\"imeisv\": [],
				\"mme_host\": [],
				\"mm_realm\": [],
				\"purge_flag\": [],
				\"security\": {
					\"k\" : \"000012341231412414214211389123456789A\",
					\"op\" : null,
					\"opc\" : \"0000123456712312421321312339123456789A\",
					\"amf\" : \"8000\",
						      },
				\"ambr\" : {
					\"downlink\" : { \"value\": NumberInt(1000000000), \"unit\": NumberInt(0)},
					\"uplink\" : { \"value\": NumberInt(1000000000), \"unit\": NumberInt(0)}
				},
				\"slice\":[{
					\"sst\": NumberInt(1),
					\"default_indicator\": true, 
					\"session\": [{
						\"name\" : \"internet\",
						\"type\" : NumberInt(1),
						\"qos\" : { \"index\": NumberInt(9), 
							\"arp\": {
								\"priority_level\" : NumberInt(8),
								\"pre_emption_capability\": NumberInt(1),
								\"pre_emption_vulnerability\": NumberInt(2)
							}
						},
						\"ambr\": {\"downlink\": {
										\"value\": NumberInt(1000000000),
										\"unit\": NumberInt(0)
												},
									\"uplink\":{
										\"value\": NumberInt(1000000000),
										\"unit\": NumberInt(0)
										}
									},
						\"ue\": { \"addr\": \"10.45.1.95\"},
						\"pcc_rule\": [],
						\"_id\": new ObjectId(),
								}],
					\"_id\": new ObjectId(),
						  }], 

				\"access_restriction_data\": NumberInt(32),
				\"subscriber_status\": NumberInt(0),
				\"network_access_mode\": NumberInt(0),
				\"subscribed_rau_tau_timer\": NumberInt(12),
				\"__v\": NumberInt(0)

						}, upsert=true);" --quiet open5gs

I'm not tested connecting a subscriber, so the question is doesn't matter the mongo structure to connect subscribers? why do you use update instead of insert? I think if somebody try to insert a subscriber but if this isn't exist the script will add, is for that?

@infercom2
Copy link
Contributor Author

I modified the open5gs-dbctl script

infercom2@1147442

@rodrigosanzsanz
Copy link

I have the same issue, any update about this appreciated ::)

@infercom2
Copy link
Contributor Author

I have the same issue, any update about this appreciated ::)

Hi Rodrigo, I fix it and its in the official repositories
#2243

@tariromukute
Copy link

Thanks @infercom2 on the update.

I think it will be helpful to have open5gs-dbctl installed when we install open5gs e.g., when we run apt install open5gs. Can it be included?

@Aniket621
Copy link

Hi, I' trying to adapt the code to the new version mongo, I attach a script It works to insert if a subscriber doesn't exist. open5gs-insert-user-example.txt

But if you check the structure of it in mongo :

mongosh --eval "db.subscribers.find({ \"imsi\":\"334070000000894\"})" --quiet open5gs
[
  {
    _id: ObjectId("640902b8fcb0343959e38da0"),
    imsi: '334070000000894',
    __v: 0,
    access_restriction_data: 32,
    ambr: {
      downlink: { value: 1000000000, unit: 0 },
      uplink: { value: 1000000000, unit: 0 }
    },
    imeisv: [],
    mm_realm: [],
    mme_host: [],
    msisdn: [],
    network_access_mode: 0,
    purge_flag: [],
    schema_version: 1,
    security: {
      k: '00001234567891234567222222289A',
      op: null,
      opc: '000012345678912344444444ED12',
      amf: '8000'
    },
    slice: [
      {
        sst: 1,
        default_indicator: true,
        session: [
          {
            name: 'internet',
            type: 1,
            qos: { index: 9, arp: [Object] },
            ambr: { downlink: [Object], uplink: [Object] },
            ue: { addr: '10.45.1.94' },
            pcc_rule: [],
            _id: ObjectId("640902b70c4c812d87bd1954")
          }
        ],
        _id: ObjectId("640902b70c4c812d87bd1955")
      }
    ],
    subscribed_rau_tau_timer: 12,
    subscriber_status: 0
  }
]

If I use insertOne mongo structure looks like when I add a subscriber by the webui:

[
  {
    _id: ObjectId("6409052a36f0a9e98766b262"),
    schema_version: 1,
    imsi: '334070000000895',
    msisdn: [],
    imeisv: [],
    mme_host: [],
    mm_realm: [],
    purge_flag: [],
    security: {
      k: '000012341231412414214211389123456789A',
      op: null,
      opc: '0000123456712312421321312339123456789A',
      amf: '8000'
    },
    ambr: {
      downlink: { value: 1000000000, unit: 0 },
      uplink: { value: 1000000000, unit: 0 }
    },
    slice: [
      {
        sst: 1,
        default_indicator: true,
        session: [
          {
            name: 'internet',
            type: 1,
            qos: { index: 9, arp: [Object] },
            ambr: { downlink: [Object], uplink: [Object] },
            ue: { addr: '10.45.1.95' },
            pcc_rule: [],
            _id: ObjectId("6409052a36f0a9e98766b263")
          }
        ],
        _id: ObjectId("6409052a36f0a9e98766b264")
      }
    ],
    access_restriction_data: 32,
    subscriber_status: 0,
    network_access_mode: 0,
    subscribed_rau_tau_timer: 12,
    __v: 0
  }
]

I have this script with inserOne :

#!/bin/bash		

		mongosh --eval "db.subscribers.insertOne(
			{
				\"_id\" : new ObjectId(),
				\"schema_version\" : NumberInt(1),
				\"imsi\" : \"334070000000895\",
				\"msisdn\": [],
				\"imeisv\": [],
				\"mme_host\": [],
				\"mm_realm\": [],
				\"purge_flag\": [],
				\"security\": {
					\"k\" : \"000012341231412414214211389123456789A\",
					\"op\" : null,
					\"opc\" : \"0000123456712312421321312339123456789A\",
					\"amf\" : \"8000\",
						      },
				\"ambr\" : {
					\"downlink\" : { \"value\": NumberInt(1000000000), \"unit\": NumberInt(0)},
					\"uplink\" : { \"value\": NumberInt(1000000000), \"unit\": NumberInt(0)}
				},
				\"slice\":[{
					\"sst\": NumberInt(1),
					\"default_indicator\": true, 
					\"session\": [{
						\"name\" : \"internet\",
						\"type\" : NumberInt(1),
						\"qos\" : { \"index\": NumberInt(9), 
							\"arp\": {
								\"priority_level\" : NumberInt(8),
								\"pre_emption_capability\": NumberInt(1),
								\"pre_emption_vulnerability\": NumberInt(2)
							}
						},
						\"ambr\": {\"downlink\": {
										\"value\": NumberInt(1000000000),
										\"unit\": NumberInt(0)
												},
									\"uplink\":{
										\"value\": NumberInt(1000000000),
										\"unit\": NumberInt(0)
										}
									},
						\"ue\": { \"addr\": \"10.45.1.95\"},
						\"pcc_rule\": [],
						\"_id\": new ObjectId(),
								}],
					\"_id\": new ObjectId(),
						  }], 

				\"access_restriction_data\": NumberInt(32),
				\"subscriber_status\": NumberInt(0),
				\"network_access_mode\": NumberInt(0),
				\"subscribed_rau_tau_timer\": NumberInt(12),
				\"__v\": NumberInt(0)

						}, upsert=true);" --quiet open5gs

I'm not tested connecting a subscriber, so the question is doesn't matter the mongo structure to connect subscribers? why do you use update instead of insert? I think if somebody try to insert a subscriber but if this isn't exist the script will add, is for that?

@infercom2 can we use this script for insert the multi subsciber in open5gs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Help Wanted Maintainers are not working on this issue so community help is wanted. Housekeeping:FR-Toreview Housekeeping: Feature requests to review type:enhancement Enhance performance or improve usability of original features.
Projects
None yet
Development

No branches or pull requests

6 participants