1
1
/*
2
- Copyright IBM Corp. 2017 All Rights Reserved.
2
+ Copyright IBM Corp. All Rights Reserved.
3
3
4
- Licensed under the Apache License, Version 2.0 (the "License");
5
- you may not use this file except in compliance with the License.
6
- You may obtain a copy of the License at
7
-
8
- http://www.apache.org/licenses/LICENSE-2.0
9
-
10
- Unless required by applicable law or agreed to in writing, software
11
- distributed under the License is distributed on an "AS IS" BASIS,
12
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- See the License for the specific language governing permissions and
14
- limitations under the License.
4
+ SPDX-License-Identifier: Apache-2.0
15
5
*/
16
6
package main
17
7
@@ -75,12 +65,13 @@ type UsersSpec struct {
75
65
}
76
66
77
67
type OrgSpec struct {
78
- Name string `yaml:"Name"`
79
- Domain string `yaml:"Domain"`
80
- CA NodeSpec `yaml:"CA"`
81
- Template NodeTemplate `yaml:"Template"`
82
- Specs []NodeSpec `yaml:"Specs"`
83
- Users UsersSpec `yaml:"Users"`
68
+ Name string `yaml:"Name"`
69
+ Domain string `yaml:"Domain"`
70
+ EnableNodeOUs bool `yaml:"EnableNodeOUs"`
71
+ CA NodeSpec `yaml:"CA"`
72
+ Template NodeTemplate `yaml:"Template"`
73
+ Specs []NodeSpec `yaml:"Specs"`
74
+ Users UsersSpec `yaml:"Users"`
84
75
}
85
76
86
77
type Config struct {
@@ -114,6 +105,7 @@ PeerOrgs:
114
105
# ---------------------------------------------------------------------------
115
106
- Name: Org1
116
107
Domain: org1.example.com
108
+ EnableNodeOUs: false
117
109
118
110
# ---------------------------------------------------------------------------
119
111
# "CA"
@@ -197,6 +189,7 @@ PeerOrgs:
197
189
# ---------------------------------------------------------------------------
198
190
- Name: Org2
199
191
Domain: org2.example.com
192
+ EnableNodeOUs: false
200
193
Template:
201
194
Count: 1
202
195
Users:
@@ -315,7 +308,7 @@ func extendPeerOrg(orgSpec OrgSpec) {
315
308
signCA := getCA (caDir , orgSpec , orgSpec .CA .CommonName )
316
309
tlsCA := getCA (tlscaDir , orgSpec , "tls" + orgSpec .CA .CommonName )
317
310
318
- generateNodes (peersDir , orgSpec .Specs , signCA , tlsCA , msp .PEER )
311
+ generateNodes (peersDir , orgSpec .Specs , signCA , tlsCA , msp .PEER , orgSpec . EnableNodeOUs )
319
312
320
313
adminUser := NodeSpec {
321
314
CommonName : fmt .Sprintf ("%s@%s" , adminBaseName , orgName ),
@@ -341,7 +334,7 @@ func extendPeerOrg(orgSpec OrgSpec) {
341
334
users = append (users , user )
342
335
}
343
336
344
- generateNodes (usersDir , users , signCA , tlsCA , msp .CLIENT )
337
+ generateNodes (usersDir , users , signCA , tlsCA , msp .CLIENT , orgSpec . EnableNodeOUs )
345
338
}
346
339
347
340
func extendOrdererOrg (orgSpec OrgSpec ) {
@@ -360,7 +353,7 @@ func extendOrdererOrg(orgSpec OrgSpec) {
360
353
signCA := getCA (caDir , orgSpec , orgSpec .CA .CommonName )
361
354
tlsCA := getCA (tlscaDir , orgSpec , "tls" + orgSpec .CA .CommonName )
362
355
363
- generateNodes (orderersDir , orgSpec .Specs , signCA , tlsCA , msp .ORDERER )
356
+ generateNodes (orderersDir , orgSpec .Specs , signCA , tlsCA , msp .ORDERER , false )
364
357
365
358
adminUser := NodeSpec {
366
359
CommonName : fmt .Sprintf ("%s@%s" , adminBaseName , orgName ),
@@ -533,13 +526,13 @@ func generatePeerOrg(baseDir string, orgSpec OrgSpec) {
533
526
os .Exit (1 )
534
527
}
535
528
536
- err = msp .GenerateVerifyingMSP (mspDir , signCA , tlsCA )
529
+ err = msp .GenerateVerifyingMSP (mspDir , signCA , tlsCA , orgSpec . EnableNodeOUs )
537
530
if err != nil {
538
531
fmt .Printf ("Error generating MSP for org %s:\n %v\n " , orgName , err )
539
532
os .Exit (1 )
540
533
}
541
534
542
- generateNodes (peersDir , orgSpec .Specs , signCA , tlsCA , msp .PEER )
535
+ generateNodes (peersDir , orgSpec .Specs , signCA , tlsCA , msp .PEER , orgSpec . EnableNodeOUs )
543
536
544
537
// TODO: add ability to specify usernames
545
538
users := []NodeSpec {}
@@ -556,7 +549,7 @@ func generatePeerOrg(baseDir string, orgSpec OrgSpec) {
556
549
}
557
550
558
551
users = append (users , adminUser )
559
- generateNodes (usersDir , users , signCA , tlsCA , msp .CLIENT )
552
+ generateNodes (usersDir , users , signCA , tlsCA , msp .CLIENT , orgSpec . EnableNodeOUs )
560
553
561
554
// copy the admin cert to the org's MSP admincerts
562
555
err = copyAdminCert (usersDir , adminCertsDir , adminUser .CommonName )
@@ -603,12 +596,12 @@ func copyAdminCert(usersDir, adminCertsDir, adminUserName string) error {
603
596
604
597
}
605
598
606
- func generateNodes (baseDir string , nodes []NodeSpec , signCA * ca.CA , tlsCA * ca.CA , nodeType int ) {
599
+ func generateNodes (baseDir string , nodes []NodeSpec , signCA * ca.CA , tlsCA * ca.CA , nodeType int , nodeOUs bool ) {
607
600
608
601
for _ , node := range nodes {
609
602
nodeDir := filepath .Join (baseDir , node .CommonName )
610
603
if _ , err := os .Stat (nodeDir ); os .IsNotExist (err ) {
611
- err := msp .GenerateLocalMSP (nodeDir , node .CommonName , node .SANS , signCA , tlsCA , nodeType )
604
+ err := msp .GenerateLocalMSP (nodeDir , node .CommonName , node .SANS , signCA , tlsCA , nodeType , nodeOUs )
612
605
if err != nil {
613
606
fmt .Printf ("Error generating local MSP for %s:\n %v\n " , node , err )
614
607
os .Exit (1 )
@@ -642,13 +635,13 @@ func generateOrdererOrg(baseDir string, orgSpec OrgSpec) {
642
635
os .Exit (1 )
643
636
}
644
637
645
- err = msp .GenerateVerifyingMSP (mspDir , signCA , tlsCA )
638
+ err = msp .GenerateVerifyingMSP (mspDir , signCA , tlsCA , false )
646
639
if err != nil {
647
640
fmt .Printf ("Error generating MSP for org %s:\n %v\n " , orgName , err )
648
641
os .Exit (1 )
649
642
}
650
643
651
- generateNodes (orderersDir , orgSpec .Specs , signCA , tlsCA , msp .ORDERER )
644
+ generateNodes (orderersDir , orgSpec .Specs , signCA , tlsCA , msp .ORDERER , false )
652
645
653
646
adminUser := NodeSpec {
654
647
CommonName : fmt .Sprintf ("%s@%s" , adminBaseName , orgName ),
@@ -658,7 +651,7 @@ func generateOrdererOrg(baseDir string, orgSpec OrgSpec) {
658
651
users := []NodeSpec {}
659
652
// add an admin user
660
653
users = append (users , adminUser )
661
- generateNodes (usersDir , users , signCA , tlsCA , msp .CLIENT )
654
+ generateNodes (usersDir , users , signCA , tlsCA , msp .CLIENT , false )
662
655
663
656
// copy the admin cert to the org's MSP admincerts
664
657
err = copyAdminCert (usersDir , adminCertsDir , adminUser .CommonName )
0 commit comments