コード例 #1
0
 public function list_nodes()
 {
     $success = false;
     $integration = Integration::find($this->db_integration_id);
     $nodes = [];
     try {
         $client = \Aws\Ec2\Ec2Client::factory(array('key' => $integration->authorization_field_1, 'secret' => $integration->authorization_field_2, 'region' => 'us-east-1'));
         $res = $client->DescribeInstances();
         $reservations = $res['Reservations'];
         $success = [];
         foreach ($reservations as $reservation) {
             $instances = $reservation['Instances'];
             foreach ($instances as $instance) {
                 $interfaces = [];
                 foreach ($instance['NetworkInterfaces'] as $network_interface) {
                     array_push($interfaces, $network_interface['MacAddress']);
                 }
                 // Find out if we're part of a cluster
                 $sp_cluster_id = null;
                 try {
                     foreach ($instance['Tags'] as $tag) {
                         if ($tag['Key'] == 'elasticbeanstalk:environment-id') {
                             $sp_cluster_id = $tag['Value'];
                         }
                     }
                 } catch (Exception $e) {
                 }
                 array_push($nodes, array('service_provider_status' => $instance['State']['Name'], 'service_provider_base_image_id' => $instance['ImageId'], 'service_provider_id' => $instance['InstanceId'], 'private_dns_name' => $instance['PrivateDnsName'], 'public_dns_name' => $instance['PublicDnsName'], 'network_interfaces' => $interfaces, 'service_provider_cluster_id' => $sp_cluster_id, 'node_count' => $integration->nodes->count()));
             }
         }
     } catch (Exception $exception) {
         $nodes = false;
     }
     return $nodes;
 }
コード例 #2
0
 /**
  * @return mixed
  */
 public function addIntegration(Integration $integration)
 {
     if (array_key_exists($integration->getName(), $this->integrations)) {
         $this->addIntegration(new Integration($integration->getName() . ' (1)', $integration->getImage(), $integration->getDescription(), $integration->getUrl()));
     } else {
         $this->integrations[$integration->getName()] = $integration;
     }
 }
コード例 #3
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $user_ids = DB::table('users')->lists('id');
     if (!$user_ids) {
         $this->command->info('You must have users. At least one.');
     }
     DB::table('integrations')->delete();
     foreach ($user_ids as $id) {
         $integration = ['name' => 'Integ' . $id, 'service_provider' => 'SeededIntegration', 'user_id' => $id, 'authorization_field_1' => 'something', 'authorization_field_2' => 'something'];
         Integration::firstOrCreate($integration);
     }
 }
コード例 #4
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('nodes')->delete();
     $integrations = Integration::all();
     if (!$integrations) {
         $this->command->info('You must have users and integrations. At least one of each');
     }
     foreach ($integrations as $integration) {
         $node = ['name' => 'Node' . $integration->id, 'description' => 'Seeded Node', 'owner_id' => $integration->user_id, 'integration_id' => $integration->id];
         Node::firstOrCreate($node);
     }
 }
コード例 #5
0
 public function list_nodes($availability_zone_name, $availability_zone_friendly_name)
 {
     #$output = new Symfony\Component\Console\Output\ConsoleOutput();
     #$output->writeln($availability_zone_name);
     $success = false;
     $integration = Integration::find($this->db_integration_id);
     $nodes = [];
     $client = \Aws\Ec2\Ec2Client::factory(array('key' => $integration->authorization_field_1, 'secret' => $integration->authorization_field_2, 'region' => $availability_zone_name));
     $res = $client->DescribeInstances();
     $reservations = $res['Reservations'];
     $success = [];
     #$output->writeln(print_r($reservations));
     foreach ($reservations as $reservation) {
         $instances = $reservation['Instances'];
         foreach ($instances as $instance) {
             $platform = "Linux";
             if (isset($instance['Platform'])) {
                 $platform = ucfirst($instance['Platform']);
             }
             $interfaces = [];
             foreach ($instance['NetworkInterfaces'] as $network_interface) {
                 array_push($interfaces, $network_interface['MacAddress']);
             }
             // Find out if we're part of a cluster. This feature is being deprecated.
             $sp_cluster_id = null;
             try {
                 foreach ($instance['Tags'] as $tag) {
                     if ($tag['Key'] == 'elasticbeanstalk:environment-id') {
                         $sp_cluster_id = $tag['Value'];
                     }
                 }
             } catch (Exception $e) {
             }
             $all_ips = array();
             foreach ($instance['NetworkInterfaces'] as $ni) {
                 foreach ($ni['PrivateIpAddresses'] as $interface) {
                     array_push($all_ips, isset($interface['PrivateIpAddress']) ? $interface['PrivateIpAddress'] : null, isset($interface['Association']['PublicIp']) ? $interface['Association']['PublicIp'] : null);
                 }
             }
             array_push($nodes, array('service_provider_status' => $instance['State']['Name'], 'service_provider_base_image_id' => $instance['ImageId'], 'service_provider_id' => $instance['InstanceId'], 'private_dns_name' => $instance['PrivateDnsName'], 'public_dns_name' => $instance['PublicDnsName'], 'network_interfaces' => $interfaces, 'service_provider_cluster_id' => $sp_cluster_id, 'service_provider_ip_addresses' => $all_ips, 'availability_zone_friendly' => $availability_zone_friendly_name, 'availability_zone_name' => $availability_zone_name, 'platform' => $platform));
         }
     }
     return $nodes;
 }
コード例 #6
0
 /**
  * Statement execution supports fallthrough retry policy (read exception).
  *
  * This test will ensure that the PHP driver supports the ability to
  * provide any exception that occurs  when executing statements. This test
  * will ensure that a ReadTimeoutException occurs when a consistency level
  * cannot be achieved.
  *
  * @test
  * @ticket PHP-60
  *
  * @cassandra-version-2.0
  *
  * @expectedException \Cassandra\Exception\UnavailableException
  * @expectedExceptionMessageRegExp |Cannot achieve consistency level .*|
  */
 public function testFallThroughPolicyRead()
 {
     // Create the retry policy (RF = 3 with 1 node)
     $policy = new RetryPolicy\Fallthrough();
     // Iterate over each statement type
     foreach (range(1, 3) as $statementType) {
         // Determine if the statement type should be skipped
         if ($statementType == self::BATCH_STATEMENT && version_compare(\Cassandra::CPP_DRIVER_VERSION, "2.2.3") < 0) {
             if (Integration::isDebug()) {
                 fprintf(STDOUT, "Skipping Batch Statements in %s: Issue fixed in DataStax C/C++ v2.2.3" . PHP_EOL, $this->getName());
             }
         } else {
             // Create an exception during read
             $this->insert($statementType, $policy, 0, self::NUMBER_OF_INSERTS, \Cassandra::CONSISTENCY_ONE);
             $this->assert($policy, 0, self::NUMBER_OF_INSERTS, \Cassandra::CONSISTENCY_ALL);
         }
     }
 }
コード例 #7
0
ファイル: list.blade.php プロジェクト: crudbug/Dashboard
    ?>
">
		<div class="uk-grid uk-grid-collapse nos-title-row">
	    <div class="uk-width-1-6">Patch Risk</div>
	    <div class="uk-width-1-6">Provider &amp; Platform</div>
			<div class="uk-width-1-6">Physical Location</div>
			<div class="uk-width-1-6">Base Image</div>
			<div class="uk-width-1-6">Host Name</div>
			<div class="uk-width-1-6">Classifications</div>
		</div>
	
	<?php 
    foreach ($page_data['managed_nodes'] as $node) {
        ?>
		<?php 
        $integration = Integration::find($node->integration_id);
        ?>
		<?php 
        $service_provider_cluster_id = empty($node->service_provider_cluster_id) ? 'None' : $node->service_provider_cluster_id;
        ?>
		<?php 
        $service_provider_description = $node->description == " " ? 'None' : $node->description;
        ?>
		<div class="uk-grid uk-grid-collapse nos-row nos-activatable" rel="<?php 
        echo $node->id;
        ?>
" class="<?php 
        echo $service_provider_cluster_id;
        ?>
">
			<div class="uk-width-1-6 node_status activatable">
コード例 #8
0
 public function fire($job, $data)
 {
     $output = new Symfony\Component\Console\Output\ConsoleOutput();
     $json_array = json_decode($data['message']);
     $service_provider = new $json_array->service_provider();
     # Ensure the integration still exists. If not, delete all the nodes and remove the job from the queue forever.
     try {
         $integration = Integration::findOrFail($json_array->db_integration_id);
     } catch (Exception $e) {
         try {
             Node::where('integration_id', '=', $json_array->db_integration_id)->delete();
             return $job->delete();
         } catch (Exception $e) {
         }
     }
     $user_id = $integration->user_id;
     $service_provider->db_integration_id = $integration->id;
     $nodes = null;
     $service_provider_nodes = array();
     foreach ($service_provider->availability_zones as $availability_zone_name => $availability_zone_friendly_name) {
         // I think this could be done with a recursive array merge
         foreach ($service_provider->list_nodes($availability_zone_name, $availability_zone_friendly_name) as $availability_zone_node_list) {
             array_push($service_provider_nodes, $availability_zone_node_list);
         }
     }
     $current_nodes = $integration->nodes;
     $all_service_provider_ids = [];
     if ($service_provider_nodes && sizeof($service_provider_nodes) > 0) {
         $integration->status = "Confirmed";
         $integration->save();
         foreach ($service_provider_nodes as $service_provider_node) {
             array_push($all_service_provider_ids, $service_provider_node['service_provider_id']);
             $node = Node::firstOrNew(array('service_provider_uuid' => $service_provider_node['service_provider_id'], 'integration_id' => $integration->id));
             // Delete the node if it's been terminated
             if ($node->service_provider_status == "terminated") {
                 $node->delete();
                 continue;
             }
             $node->service_provider_status = $service_provider_node['service_provider_status'];
             $node->service_provider_uuid = $service_provider_node['service_provider_id'];
             $node->service_provider_base_image_id = $service_provider_node['service_provider_base_image_id'];
             $node->description = $service_provider_node['private_dns_name'] . " " . $service_provider_node['public_dns_name'];
             $node->owner_id = $integration->user_id;
             $node->public_dns_name = $service_provider_node['public_dns_name'];
             $node->platform = $service_provider_node['platform'];
             $node->name = "";
             try {
                 $node->service_provider_availability_zone = $service_provider_node['availability_zone_name'];
                 $node->friendly_availability_zone = $service_provider_node['availability_zone_friendly'];
             } catch (Exception $e) {
                 $node->service_provider_availability_zone = "San Francisco!";
                 $node->friendly_availability_zone = "San Francisco!";
             }
             // This should be handled in the DB schema. Default val of false.
             if ($node->managed == null) {
                 $node->managed = false;
             }
             $base_image = BaseImage::firstOrNew(array('integration_id' => $integration->id, 'service_provider_id' => $service_provider_node['service_provider_base_image_id'], 'integration_id' => $integration->id, 'service_provider_label' => $service_provider_node['service_provider_base_image_id']));
             $base_image->rollback_index = 0;
             // Should be handled by schema or just removed. Stupid.
             $base_image->save();
             $node->base_image_id = $base_image->id;
             if (!is_null($service_provider_node['service_provider_cluster_id'])) {
                 $node->service_provider_cluster_id = $service_provider_node['service_provider_cluster_id'];
             }
             $node->save();
             foreach ($service_provider_node['service_provider_ip_addresses'] as $service_provider_ip) {
                 $db_ip = IpAddress::firstOrNew(array('address' => $service_provider_ip, 'node_id' => $node->id));
                 $db_ip->save();
             }
             // Delete ips from the database that don't appear in client report
             IpAddress::where('address', '=', $integration->id)->where('node_id', '=', $node->id)->whereNotIn('address', $service_provider_node['service_provider_ip_addresses'])->delete();
         }
         // This is where we delete Nodes that no longer exist on the service provider side.
         Node::where('integration_id', '=', $integration->id)->where('owner_id', '=', $user_id)->whereNotIn('service_provider_uuid', $all_service_provider_ids)->delete();
     } else {
         if (sizeof($service_provider_nodes) == 0) {
         }
         $integration->status = "Bad";
         $integration->save();
     }
     // Do this job again in 30 seconds.
     $job->release(900);
 }
コード例 #9
0
 public function list_nodes($availability_zone_name, $availability_zone_friendly_name)
 {
     $output = new Symfony\Component\Console\Output\ConsoleOutput();
     $success = false;
     $integration = Integration::find($this->db_integration_id);
     $nodes = [];
     // We need to measure how often this actually matters. I wonder if UK_IDENTITY_ENDPOINT is only
     // for UK-based companies, or if it's needed to connect to Hong Kong.
     try {
         $client = new Rackspace(Rackspace::US_IDENTITY_ENDPOINT, array('username' => $integration->authorization_field_1, 'apiKey' => $integration->authorization_field_2));
     } catch (Exception $e) {
         $client = new Rackspace(Rackspace::UK_IDENTITY_ENDPOINT, array('username' => $integration->authorization_field_1, 'apiKey' => $integration->authorization_field_2));
     }
     $computeService = $client->computeService(null, $availability_zone_name, 'publicURL');
     $serverList = $computeService->serverList();
     foreach ($serverList as $server) {
         $server_ips = [];
         $private_dns = "";
         $public_dns = "";
         $server_status = "";
         if (strtolower($server->status) == "active") {
             foreach ($server->addresses->public as $ip) {
                 array_push($server_ips, $ip->addr);
             }
             foreach ($server->addresses->private as $ip) {
                 array_push($server_ips, $ip->addr);
             }
             $public_dns = null;
             foreach ($server->addresses->public as $pubdns) {
                 if (strlen($pubdns->addr) < 16) {
                     $public_dns = $pubdns->addr;
                 }
             }
             $private_dns = null;
             foreach ($server->addresses->private as $pdns) {
                 if (strlen($pubdns->addr) < 16) {
                     $private_dns = $pdns->addr;
                 }
             }
             $server_status = 'running';
         } else {
             switch (strtolower($server->status)) {
                 case "active":
                     $server_status = 'running';
                     break;
                 case "build":
                     $server_status = 'starting';
                     break;
                 default:
                     continue;
             }
         }
         // Get image info so we can get platform info
         $imageService = $client->imageService("cloudImages", $availability_zone_name);
         $imageInfo = $imageService->getImage($server->image->id);
         $platform = $imageInfo['os_type'];
         array_push($nodes, array('service_provider_status' => $server_status, 'service_provider_base_image_id' => $server->image->id, 'service_provider_id' => $server->id, 'private_dns_name' => $private_dns, 'public_dns_name' => $public_dns, 'network_interfaces' => [], 'service_provider_cluster_id' => null, 'service_provider_ip_addresses' => $server_ips, 'availability_zone_friendly' => $availability_zone_friendly_name, 'availability_zone_name' => $availability_zone_name, 'platform' => ucfirst($platform)));
     }
     // If nodes is empty, make attempt to list them through the legacy api.
     if (empty($nodes)) {
         $output->writeln("robby's account");
     }
     return $nodes;
 }
コード例 #10
0
 /**
  * Page through the results while validating no memory leaks exists
  *
  * @param $start Starting memory value
  * @return int Number of rows visited
  */
 private function validatePageResults($rows)
 {
     // Get the starting memory usage
     $start = memory_get_usage() / 1024;
     if (Integration::isDebug() && Integration::isVerbose()) {
         fprintf(STDOUT, "Start Usage: %dkb" . PHP_EOL, $start);
     }
     // Page over each result set and count the number of rows visited
     $count = $rows->count();
     while ($rows = $rows->nextPage()) {
         if ($rows->count() != 0) {
             $count += $rows->count();
             if (Integration::isDebug() && Integration::isVerbose()) {
                 fprintf(STDOUT, "Page %d: Current memory usage is %dkb" . PHP_EOL, $count / 2, memory_get_usage() / 1024 - $start);
             }
         }
     }
     // Get the final memory usage (and apply a tolerance to compensate for GC)
     $end = memory_get_usage() / 1024;
     if (Integration::isDebug() && Integration::isVerbose()) {
         fprintf(STDOUT, "End Usage: %dkb [%dkb]" . PHP_EOL, $end, $end - $start);
     }
     $difference = $end - $start - 20;
     // 20KB tolerance
     $this->assertLessThanOrEqual(0, $difference);
     // Return the number of rows visited
     return $count;
 }
コード例 #11
0
 public function deleteIntegration($id)
 {
     Integration::destroy($id);
     return Redirect::to('/integrations');
 }
コード例 #12
0
 /**
  * Add an integration to the project.
  *
  * @param string $type
  * @param array $data
  *
  * @return Integration
  */
 public function addIntegration($type, array $data = [])
 {
     $body = ['type' => $type] + $data;
     return Integration::create($body, $this->getLink('integrations'), $this->client);
 }
コード例 #13
0
ファイル: config.php プロジェクト: albertoneto/localhost
$guestsMode = setConfigValue('guestsMode', '0');
$guestnamePrefix = setConfigValue('guestnamePrefix', 'Guest');
$guestsList = setConfigValue('guestsList', '3');
$guestsUsersList = setConfigValue('guestsUsersList', '3');
/* CCAUTH END */
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/* GOOGLE ANALYTICS START */
$gatrackerid = setConfigValue('gatrackerid', '');
/* GOOGLE ANALYTICS END */
global $integration;
if (USE_CCAUTH == '1') {
    include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'ccauth.php';
    $integration = new CCAuth();
    $guestsMode = '0';
} else {
    $integration = new Integration();
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/* BASE URL START */
define('BASE_URL', setConfigValue('BASE_URL', '/cometchat/'));
/* BASE URL END */
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/* LANGUAGE START */
$lang = setConfigValue('lang', 'en');
/* LANGUAGE END */
if (!empty($_COOKIE[$cookiePrefix . "lang"])) {
    $lang = preg_replace("/[^A-Za-z0-9\\-]/", '', $_COOKIE[$cookiePrefix . "lang"]);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
$trayicon = array();
$trayicon['home'] = array('home', 'Home', '/', '', '', '', '', '', '');