Class: StackMate::CloudStackSecurityGroupAWS
- Inherits:
-
CloudStackResource
- Object
- Ruote::Participant
- CloudStackResource
- StackMate::CloudStackSecurityGroupAWS
- Defined in:
- lib/stackmate/participants/cloudstack.rb
Constant Summary
Constants included from Resolver
Resolver::INTEXP, Resolver::STRINGEXP, Resolver::UUIDEXP
Instance Attribute Summary
Attributes inherited from CloudStackResource
Instance Method Summary collapse
Methods inherited from CloudStackResource
Methods included from Resolver
#get_named_tag, #get_resolved, #resolve_tags, #resolve_to_deviceid, #validate_param
Methods included from Logging
configure_logger_for, #logger, logger_for
Constructor Details
This class inherits a constructor from StackMate::CloudStackResource
Instance Method Details
#create ⇒ Object
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 |
# File 'lib/stackmate/participants/cloudstack.rb', line 240 def create myname = workitem.participant_name workitem[participant_name] = {} logger.debug("Going to create resource #{myname}") @name = myname p myname resolved = workitem['ResolvedNames'] props = workitem['Resources'][myname]['Properties'] name = workitem['StackName'] + '-' + workitem.participant_name; resolved[myname] = name args = { 'name' => name, 'description' => props['GroupDescription'] } sg_resp = make_sync_request('createSecurityGroup', args) logger.debug("created resource #{myname}") props['SecurityGroupIngress'].each do |rule| cidrIp = rule['CidrIp'] if cidrIp.kind_of? Hash #TODO: some sort of validation cidrIpName = cidrIp['Ref'] cidrIp = resolved[cidrIpName] end args = { 'securitygroupname' => name, 'startport' => rule['FromPort'], 'endport' => rule['ToPort'], 'protocol' => rule['IpProtocol'], 'cidrlist' => cidrIp } #TODO handle usersecuritygrouplist make_async_request('authorizeSecurityGroupIngress', args) end workitem[participant_name][:physical_id] = sg_resp['securitygroup']['id'] end |
#delete ⇒ Object
274 275 276 277 278 279 280 281 282 283 |
# File 'lib/stackmate/participants/cloudstack.rb', line 274 def delete logger.info "In delete #{participant_name}" return nil if !workitem[participant_name] logger.info "In delete #{participant_name} #{workitem[participant_name].inspect}" physical_id = workitem[participant_name]['physical_id'] if physical_id args = {'id' => physical_id} del_resp = make_sync_request('deleteSecurityGroup', args) end end |
#on_workitem ⇒ Object
285 286 287 288 289 290 291 292 |
# File 'lib/stackmate/participants/cloudstack.rb', line 285 def on_workitem if workitem['params']['operation'] == 'create' create else delete end reply end |