Skip to content

Commit

Permalink
yank old flight record data
Browse files Browse the repository at this point in the history
  • Loading branch information
Kapil Thangavelu committed Apr 16, 2016
1 parent 69b3cf5 commit 5199248
Show file tree
Hide file tree
Showing 7 changed files with 132 additions and 15 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Cloud Maid
# Cloud Custodian

Cloud maid is a rules engine that provides for querying, filtering,
Cloud custodian is a rules engine that provides for querying, filtering,
and applying actions to AWS resources.

Goals for the project are to help organizations manage their cloud
Expand All @@ -10,7 +10,7 @@ via offhours resource management.

# Links

- [Docs https://github.kdc.capitalone.com/pages/cloud-maid/cloud-maid/ ]
- [Docs](https://github.com/pages/capitalone/cloud-custodian/)
- [Architecture](docs/architecture.rst)
- [Developer Install](docs/developer.rst)

Expand Down Expand Up @@ -56,10 +56,11 @@ policies:

```

Given that, you can run cloud-maid via
Given that, you can run cloud-custodian via

```
$ cloud-maid run -c policy.yml
$ mkdir out
$ custodian run -c policy.yml -s out
```
By default any run of the maid will output csv of the instances operated on.

Expand All @@ -70,7 +71,7 @@ One is to just query for instances matching and export them as csv or json with
the *identify* subcommand.

```
$ cloud-maid identify -c policy.yml > instances.json
$ custodian identify -c policy.yml > instances.json
```

For additional information please look at the individual
Expand Down
2 changes: 1 addition & 1 deletion tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def load_data(file_name, state=None, **kw):


def instance(state=None, **kw):
return load_data('instance.json', state, **kw)
return load_data('ec2-instance.json', state, **kw)


class Bag(dict):
Expand Down
111 changes: 111 additions & 0 deletions tests/data/ec2-instance.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
{
"Monitoring": {
"State": "disabled"
},
"PublicDnsName": "ec2-52-37-189-36.us-west-2.compute.amazonaws.com",
"State": {
"Code": 16,
"Name": "running"
},
"EbsOptimized": false,
"LaunchTime": "2016-04-14T05:17:29.000Z",
"PublicIpAddress": "52.37.189.36",
"PrivateIpAddress": "172.31.8.154",
"ProductCodes": [],
"VpcId": "vpc-399e3d52",
"StateTransitionReason": "",
"InstanceId": "i-1aebf7c0",
"ImageId": "ami-c229c0a2",
"PrivateDnsName": "ip-172-31-8-154.us-west-2.compute.internal",
"KeyName": "HazmatGreenField",
"SecurityGroups": [
{
"GroupName": "jlxc",
"GroupId": "sg-47b76f22"
},
{
"GroupName": "default",
"GroupId": "sg-0a08e365"
}
],
"ClientToken": "JlRpx1460611049040",
"SubnetId": "subnet-389e3d53",
"InstanceType": "m3.medium",
"NetworkInterfaces": [
{
"Status": "in-use",
"MacAddress": "0a:d4:67:1f:58:03",
"SourceDestCheck": true,
"VpcId": "vpc-399e3d52",
"Description": "",
"Association": {
"PublicIp": "52.37.189.36",
"PublicDnsName": "ec2-52-37-189-36.us-west-2.compute.amazonaws.com",
"IpOwnerId": "amazon"
},
"NetworkInterfaceId": "eni-68d48235",
"PrivateIpAddresses": [
{
"PrivateDnsName": "ip-172-31-8-154.us-west-2.compute.internal",
"Association": {
"PublicIp": "52.37.189.36",
"PublicDnsName": "ec2-52-37-189-36.us-west-2.compute.amazonaws.com",
"IpOwnerId": "amazon"
},
"Primary": true,
"PrivateIpAddress": "172.31.8.154"
}
],
"PrivateDnsName": "ip-172-31-8-154.us-west-2.compute.internal",
"Attachment": {
"Status": "attached",
"DeviceIndex": 0,
"DeleteOnTermination": true,
"AttachmentId": "eni-attach-f1c55f38",
"AttachTime": "2016-04-14T05:17:29.000Z"
},
"Groups": [
{
"GroupName": "jlxc",
"GroupId": "sg-47b76f22"
},
{
"GroupName": "default",
"GroupId": "sg-0a08e365"
}
],
"SubnetId": "subnet-389e3d53",
"OwnerId": "619193117841",
"PrivateIpAddress": "172.31.8.154"
}
],
"SourceDestCheck": true,
"Placement": {
"Tenancy": "default",
"GroupName": "",
"AvailabilityZone": "us-west-2c"
},
"Hypervisor": "xen",
"BlockDeviceMappings": [
{
"DeviceName": "/dev/xvda",
"Ebs": {
"Status": "attached",
"DeleteOnTermination": true,
"VolumeId": "vol-2b047792",
"AttachTime": "2016-04-14T05:17:29.000Z"
}
}
],
"Architecture": "x86_64",
"RootDeviceType": "ebs",
"RootDeviceName": "/dev/xvda",
"VirtualizationType": "hvm",
"Tags": [
{
"Value": "CompileLambda",
"Key": "Name"
}
],
"AmiLaunchIndex": 0
}
3 changes: 2 additions & 1 deletion tests/test_cwe.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@

class CloudWatchEventsFacadeTest(TestCase):

def test_get_ids(self):
# DISABLED / Record flight data
def disabled_xtest_get_ids(self):
self.assertEqual(
CloudWatchEvents.get_ids(
event_data('event-instance-state.json'),
Expand Down
6 changes: 4 additions & 2 deletions tests/test_ebs.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@

class CopyInstanceTagsTest(BaseTest):

def test_copy_instance_tags(self):
# DISABLED / Re-record flight data on public account
def disabled_xtest_copy_instance_tags(self):
# More a functional/coverage test then a unit test.
self.patch(
CopyInstanceTags, 'executor_factory', MainThreadExecutor)
Expand Down Expand Up @@ -57,7 +58,8 @@ def test_copy_instance_tags(self):

class EncryptExtantVolumesTest(BaseTest):

def test_encrypt_volumes(self):
# DISABLED / Re-record flight data on public account
def disabled_xtest_encrypt_volumes(self):
# More a functional/coverage test then a unit test.
self.patch(
EncryptInstanceVolumes, 'executor_factory', MainThreadExecutor)
Expand Down
6 changes: 4 additions & 2 deletions tests/test_ec2.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@

class TestVolumeFilter(BaseTest):

def test_ec2_attached_ebs_filter(self):
# DISABLED / Re-record flight data on public account
def disabled_xtest_ec2_attached_ebs_filter(self):
session_factory = self.replay_flight_data(
'test_ec2_attached_ebs_filter')
policy = self.load_policy({
Expand All @@ -37,7 +38,8 @@ def test_ec2_attached_ebs_filter(self):
resources = policy.run()
self.assertEqual(len(resources), 7)

def test_ec2_attached_volume_skip_block(self):
# DISABLED / Re-record flight data on public account
def disabled_xtest_ec2_attached_volume_skip_block(self):
session_factory = self.replay_flight_data(
'test_ec2_attached_ebs_filter')
policy = self.load_policy({
Expand Down
6 changes: 3 additions & 3 deletions tests/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ def test_filter_tag(self):

def test_jmespath(self):
self.assertFilter(
{'Placement.AvailabilityZone': 'us-east-1b'},
{'Placement.AvailabilityZone': 'us-west-2c'},
instance(),
True)

Expand Down Expand Up @@ -282,7 +282,7 @@ def test_complex_validator(self):

def test_complex_value_filter(self):
self.assertFilter(
{"key": "length(BlockDeviceMappings[?Ebs.DeleteOnTermination == `false`].Ebs.DeleteOnTermination)",
{"key": "length(BlockDeviceMappings[?Ebs.DeleteOnTermination == `true`].Ebs.DeleteOnTermination)",
"value": 0,
"type": "value",
"op": "gt"},
Expand All @@ -291,7 +291,7 @@ def test_complex_value_filter(self):

def test_not_null_filter(self):
self.assertFilter(
{"key": "tag:aws:cloudformation:stack-name",
{"key": "Hypervisor",
"value": "not-null",
"type": "value"},
instance(),
Expand Down

0 comments on commit 5199248

Please sign in to comment.