using global properties to configure db - corda

I followed the link How can the Corda node be extended to work with databases other than H2? to connect to pgdb. Is there a way to define global config and reuse, for example maintain global config for "dataSource.user", "dataSource.password", dataSourceClassName and refer them in gradle task deployNodes..? Also, is there a way to encrypt "dataSource.password" and use it?

You can use a Gradle property to provide a global constant that you can use in your Gradle build scripts. For example, suppose you wanted to set the node's RPC password using a constant. You would:
Add a property to the gradle.properties file (e.g. rpc_password=my_test_password)
Use this property inside deployNodes. For example:
task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
directory "./build/nodes"
node {
...
rpcUsers = [[ user: "user1", "password": rpc_password, "permissions": ["ALL"]]]
...
}
}
There is no way to encrypt the database password currently. Only RPC credentials can be encrypted.

Related

Cloud-init should use another yaml file. Not 50-cloud-init.yaml

i would like cloud-init to not use 50-cloud-init.yaml. I have prepared my own file.
Do you know how to do this
You can add
network:
config: disabled
to /etc/cloud/cloud.cfg or a file in /etc/cloud/cloud.cfg.d.
Another option is to add
network-config=disabled
to the kernel command line.
While the network config yaml technically works as userdata, the network configuration will have already been written out before userdata is read.
One other option is to write your netplan configuration into /etc/netplan/99-some-name.yaml. If you have configuration there that overlaps with what is in 50-cloud-init.yaml, your configuration will override what is in the default configuration.
See https://cloudinit.readthedocs.io/en/latest/topics/network-config.html#disabling-network-configuration .

How to add a new node to an existing corda network?

I have a use case where I need to add a new node to an existing Corda network (let's say in existing Corda network 2 nodes are running currently (A, B node) and now need to add node C to this network.
I went through following links as well but no luck:
Adding new node to existing corda network
Couldn't find network parameters file and compatibility zone wasn't configured/isn't reachable
Deploy and run nodes dynamically in CORDA
I tried the following approach:
I Added A and B nodes configurations in deployNodes task inside build.gradle and then run deployNodes tasks so A and B nodes start-up successfully now I create new folder PartyC and inside that added corda.jar and node.conf for node C and then running the command:
java -jar corda.jar
but I am getting the following exception while running this command:
Exception during node startup: Couldn't find network parameters file and compatibility zone wasn't configured/isn't reachable. [errorCode=1917kd6, moreInformationAt=https://errors.corda.net/OS/4.3/1917kd6]
node.conf file for new node (node C) is following:
devMode=true
h2Settings {
address="localhost:12348"
}
myLegalName="O=PartyC,L=London,C=GB"
p2pAddress="partyc:10011"
rpcSettings {
address="partyc:10012"
adminAddress="partyc:10013"
}
security {
authService {
dataSource {
type=INMEMORY
users=[
{
password=test
permissions=[
ALL
]
user=user1
}
]
}
}
}
sshd {
port=2227
}
I am not able to get how should I need to add network parameters or compatibility zone inside this node.conf file.
To add a new node to an existing network, there are 2 possible options.
Use the network bootstrapper (and docs to manually create the required files to allow nodes to interact with each other. This is more for test networks.
Or use a network map service, an OS implementation can be found here. This is more for real networks. There is also the Corda Enterprise Network Manager if you are using Corda Enterprise.
For adding new nodes in a cordapp you need add the partyC code in build.gradle file inside this section of the code
task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
directory "./build/nodes"
node {
as
node {
name "O=PartyC,L=Paris,C=FR"
p2pPort 10013
rpcSettings {
address("localhost:10014")
adminAddress("localhost:10054")
}
rpcUsers = [[user: "user1", "password": "test", "permissions": ["ALL"]]]
}
Yes, You can add new node in existing Corda network using shell script. You just need to configure configuration of new node in main build.gradle and clients/build.gradle file.

Unable to network-bootstrap using enterprise 3.2 version, due to 73 outstanding database changes

I am using enterprise version 3.2 of network bootstrapper to build node configurations with devMode enabled. When i bootstrap with default database backend (h2), it works fine.
But when I am connecting to MSSQL DB backend, it fails to generate the node config with the following error.
"There are 73 outstanding database changes that need to be run. Please use the advanced migration tool. See: https://docs.corda.r3.com/database-management.html"
I do not have any apps placed in the directory during my bootstrapping process.
The database is a new one and there are no tables created yet. Yet, it is complaining about the database changes.
The link mentioned in the error, recommends us to do a database migration, specific to a cordapp. But in my case, i do not even have a cordapp.
How can I overcome this issue?
Here is the config file i used:
myLegalName="O=Branch,L=Bangalore,C=IN"
p2pAddress="192.168.100.104:11121"
devMode=true
rpcSettings {
address="192.168.100.104:10011"
adminAddress="192.168.100.104:11252"
}
rpcUsers=[
{
password=test
permissions=[
ALL
]
user=user1
}
]
dataSourceProperties = {
dataSourceClassName = "com.microsoft.sqlserver.jdbc.SQLServerDataSource"
dataSource.url = "jdbc:sqlserver://192.168.100.116:1433;databaseName=cordadb"
dataSource.user = "adminuser"
dataSource.password = "Password123"
}
database = {
transactionIsolationLevel = READ_COMMITTED
}
jarDirs = ["/root/jdbcdriver/sqljdbc_6.2/enu/"]
Here is the command line that was invoked:
java -jar corda-tools-network-bootstrapper-3.2.jar --dir finance
The "73 outstanding database changes" referenced in the error message are the creation of the new database tables required by every Corda node.
You can run these automatically by adding database.runMigration=true to your node's node.conf file.

Launch RancherOs with Openstack and Terraform

Hi running the latest OpenStack, Terraform and RancherOs.
From the Openstack UI I can get rancher to work and I can pass in my own ssh keys for instance but you need to explicitly click the configuration drive otherwise it will not accept the user data.
I don't think this is possible with terraform is it?
resource "openstack_compute_instance_v2" "terraform-rancher" {
name = "terraform-rancher"
image_name = "RancherOs"
flavor_name = "t2.xlarge"
security_groups = ["default"]
#This is on the same path as my terraform file.
user_data = "${file("test.txt")}"
network {
name = "provider"
}
}
The instance launches and gets created but when I look at the logs Rancher cannot seem to find the config with:
cloud-init: Datasource unavailable, skipping: cloud-drive: /media/config-2 (lastError: no such file or directory)
From Openstack UI it works fine, but as stated you have to click the config drive check box.
cloud-init: Datasource available: cloud-drive: /media/config-2
To get it work like in the UI, the config_drive parameter in the instance configuration needs to be set to true.

Setting Logback Configuration file Programmatically

I'm using the sbt run command to run my project. My project uses the Logback logging mechanism and if I would like to enable logging, then I have to use the following command:
sbt -Dlogback.configurationFile=/path/to/log/file/app-logger.xml run
Is there a way that I could set this programmatically? I mean I would like to just say
sbt run
and it picks up automagically the app-logger.xml by itself via the application.
This is how I do it!
def loadLogger() = Option(System.getProperty("logback.configurationFile")) match {
case Some(logXml) =>
logger.info(s"using logger $logXml")
case None =>
val path = s"${System.getProperty("user.dir")}/conf/app-logger.xml"
System.setProperty("logback.configurationFile", path)
logger.info(s"using logger $path")
}

Resources