Browse Source

Venu and Kashyap | moved the aws keys from our config file to nova.conf and importing those values using cfg

changes/85/139985/1
Kashyap Kopparam 4 years ago
parent
commit
e060e1464a
3 changed files with 19 additions and 10 deletions
  1. 12
    4
      README.md
  2. 7
    4
      ec2driver.py
  3. 0
    2
      ec2driver_standard_config.py

+ 12
- 4
README.md View File

@@ -21,14 +21,22 @@ Using the native OpenStack Dashboard or APIs you would be able to manage the EC2
21 21
 - VirtualBox
22 22
 - Vagrant
23 23
 
24
-###Instructions
24
+###Instructions for Developer environment
25 25
 1. Clone this repository: `git clone https://github.com/ThoughtWorksInc/OpenStack-EC2-Driver.git`
26 26
 2. Run`vagrant up` from within the repository to create an Ubuntu virtualbox that will install devstack. This will take a couple minutes.
27 27
 3. `vagrant ssh` to ssh into the new machine
28 28
 4. Use `vim /etc/nova/nova.conf` to edit the nova configuration so that 
29
-    - the compute_driver is set to ec2.EC2Driver
30
-    - under the [conductor] section, add the following line
31
-        use_local = True
29
+
30
+        [DEFAULT]
31
+        compute_driver=ec2.EC2Driver
32
+
33
+        [conductor]
34
+        use_local=True
35
+
36
+        [ec2driver]
37
+        ec2_secret_access_key = <your_aws_secret_access_key>
38
+        ec2_access_key_id = <your_aws_access_key_id>
39
+
32 40
 5. Restart nova
33 41
   - `~/devstack/rejoin-stack.sh`
34 42
   - go to the nova-cpu screen (`ctrl+a`, `6`)

+ 7
- 4
ec2driver.py View File

@@ -67,6 +67,10 @@ ec2driver_opts = [
67 67
     cfg.BoolOpt('use_linked_clone',
68 68
                 default=True,
69 69
                 help='Whether to use linked clone'),
70
+    cfg.StrOpt('ec2_secret_access_key',
71
+               help='The secret access key of the Amazon Web Services account'),
72
+    cfg.StrOpt('ec2_access_key_id',
73
+               help='The access key ID of the Amazon Web Services account'),
70 74
 ]
71 75
 
72 76
 CONF = cfg.CONF
@@ -140,17 +144,16 @@ class EC2Driver(driver.ComputeDriver):
140 144
 
141 145
         self.creds = get_nova_creds()
142 146
         self.nova = client.Client(**self.creds)
143
-
144 147
         region = RegionInfo(name=aws_region, endpoint=aws_endpoint)
145
-        self.ec2_conn = ec2.EC2Connection(aws_access_key_id=aws_access_key_id,
146
-                                          aws_secret_access_key=aws_secret_access_key,
148
+        self.ec2_conn = ec2.EC2Connection(aws_access_key_id=CONF.ec2driver.ec2_access_key_id,
149
+                                          aws_secret_access_key=CONF.ec2driver.ec2_secret_access_key,
147 150
                                           host=host,
148 151
                                           port=port,
149 152
                                           region=region,
150 153
                                           is_secure=secure)
151 154
 
152 155
         self.cloudwatch_conn = ec2.cloudwatch.connect_to_region(
153
-            aws_region, aws_access_key_id=aws_access_key_id, aws_secret_access_key=aws_secret_access_key)
156
+            aws_region, aws_access_key_id=CONF.ec2driver.ec2_access_key_id, aws_secret_access_key=CONF.ec2driver.ec2_secret_access_key)
154 157
 
155 158
         self.security_group_lock = Lock()
156 159
         self.rule_comparator = rule_comparator.RuleComparator(self.ec2_conn)

+ 0
- 2
ec2driver_standard_config.py View File

@@ -18,8 +18,6 @@ from collections import defaultdict
18 18
 
19 19
 aws_region = 'us-east-1'
20 20
 aws_endpoint = 'ec2.us-east-1.amazonaws.com'
21
-aws_access_key_id = 'AKIAIZJDDRNNJUWZ3LXA'
22
-aws_secret_access_key = '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'
23 21
 port = 443
24 22
 host = str(port) + ":" + aws_endpoint
25 23
 secure = True

Loading…
Cancel
Save